-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1165 from bcgov/test
UAT Release - IS23
- Loading branch information
Showing
363 changed files
with
86,619 additions
and
1,606 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
backend/api/Areas/Admin/Mapping/AccessRequest/AccessRequestMap.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
backend/api/Areas/Keycloak/Mapping/AccessRequest/AccessRequestMap.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Pims.Api.Policies; | ||
using Pims.Api.Services; | ||
using Pims.Dal.Security; | ||
using Swashbuckle.AspNetCore.Annotations; | ||
|
||
namespace Pims.Api.Controllers | ||
{ | ||
/// <summary> | ||
/// DocumentController class, provides endpoints to handle document requests. | ||
/// </summary> | ||
[Authorize] | ||
[ApiController] | ||
[ApiVersion("1.0")] | ||
[Route("v{version:apiVersion}/documents/")] | ||
[Route("/documents")] | ||
public class DocumentController : ControllerBase | ||
{ | ||
#region Variables | ||
private readonly IDocumentService _documentService; | ||
#endregion | ||
|
||
#region Constructors | ||
/// <summary> | ||
/// Creates a new instance of a ErrorController class. | ||
/// </summary> | ||
/// <param name="documentService"></param> | ||
public DocumentController(IDocumentService documentService) | ||
{ | ||
_documentService = documentService; | ||
} | ||
#endregion | ||
|
||
#region Endpoints | ||
/// <summary> | ||
/// Retrieves a list of documents. | ||
/// </summary> | ||
[HttpGet] | ||
[HasPermission(Permissions.PropertyAdd)] | ||
[Produces("application/json")] | ||
[ProducesResponseType(typeof(string), 200)] | ||
[SwaggerOperation(Tags = new[] { "documents" })] | ||
public IActionResult GetDocumentList() | ||
{ | ||
var ast = _documentService.GetDocumentList(); | ||
return new JsonResult(ast); | ||
} | ||
|
||
/// <summary> | ||
/// Downloads the file for the correspoding file and document id. | ||
/// </summary> | ||
[HttpGet("{documentId}/files/{fileId}/download")] | ||
[HasPermission(Permissions.PropertyAdd)] | ||
[ProducesResponseType(typeof(string), 200)] | ||
[SwaggerOperation(Tags = new[] { "documents" })] | ||
public IActionResult DownloadFile(int documentId, int fileId) | ||
{ | ||
var ast = _documentService.DownloadFile(documentId, fileId); | ||
return new JsonResult(ast); | ||
} | ||
|
||
/// <summary> | ||
/// Uploads the passed document. | ||
/// </summary> | ||
[HttpPost] | ||
[HasPermission(Permissions.PropertyAdd)] | ||
[ProducesResponseType(typeof(string), 200)] | ||
[SwaggerOperation(Tags = new[] { "documents" })] | ||
public IActionResult UploadDocument([FromForm] IFormFile file) | ||
{ | ||
var ast = _documentService.UploadDocument(1, file); | ||
return new JsonResult(ast); | ||
} | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System.Net.Http; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Pims.Api.Handlers | ||
{ | ||
public class LoggingHandler : DelegatingHandler | ||
{ | ||
private readonly ILogger _logger; | ||
|
||
public LoggingHandler(ILogger<LoggingHandler> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) | ||
{ | ||
_logger.LogTrace("Request:"); | ||
_logger.LogTrace("{request}", request.ToString()); | ||
if (request.Content != null) | ||
{ | ||
_logger.LogTrace("{cancellationToken}", await request.Content.ReadAsStringAsync(cancellationToken)); | ||
} | ||
|
||
HttpResponseMessage response = await base.SendAsync(request, cancellationToken); | ||
|
||
_logger.LogTrace("Response:"); | ||
_logger.LogTrace("{response}", response.ToString()); | ||
if (response.Content != null) | ||
{ | ||
_logger.LogTrace("{cancellationToken}", await response.Content.ReadAsStringAsync(cancellationToken)); | ||
} | ||
|
||
return response; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
|
||
namespace Pims.Api.Models.Config | ||
{ | ||
public class MayanConfig | ||
{ | ||
public Uri BaseUri { get; set; } | ||
public string ConnectionUser { get; set; } | ||
public string ConnectionPassword { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace Pims.Api.Models | ||
{ | ||
/// <summary> | ||
/// Defines the results comming back from an external resource. | ||
/// </summary> | ||
public class ExternalResult<T> | ||
{ | ||
/// <summary> | ||
/// get/set - Result status. | ||
/// </summary> | ||
public ExternalResultStatus Status { get; set; } | ||
|
||
/// <summary> | ||
/// get/set - Additional message for the result. | ||
/// </summary> | ||
public string Message { get; set; } | ||
|
||
/// <summary> | ||
/// get/set - A description of the type. | ||
/// </summary> | ||
public T Payload { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.Runtime.Serialization; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Pims.Api.Models | ||
{ | ||
/// <summary> | ||
/// Status of an external call. | ||
/// </summary> | ||
[JsonConverter(typeof(JsonStringEnumMemberConverter))] | ||
public enum ExternalResultStatus | ||
{ | ||
/// <summary> | ||
/// The call was successfull. | ||
/// </summary> | ||
[EnumMember(Value = "success")] | ||
Success, | ||
|
||
/// <summary> | ||
/// Error occured. | ||
/// </summary> | ||
[EnumMember(Value = "error")] | ||
Error, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Pims.Api.Models.Mayan.Document | ||
{ | ||
/// <summary> | ||
/// Represents the document result information. Note, this does not contain the stored document. | ||
/// </summary> | ||
public class DocumentDetail | ||
{ | ||
/// <summary> | ||
/// get/set - The document id. | ||
/// </summary> | ||
[JsonPropertyName("id")] | ||
public int Id { get; set; } | ||
|
||
/// <summary> | ||
/// get/set - Document label. | ||
/// </summary> | ||
[JsonPropertyName("label")] | ||
public string Label { get; set; } | ||
|
||
/// <summary> | ||
/// get/set - Total number of results. | ||
/// </summary> | ||
[JsonPropertyName("datetime_created")] | ||
public DateTime DatetimeCreated { get; set; } | ||
|
||
/// <summary> | ||
/// get/set - The results of the query. | ||
/// </summary> | ||
[JsonPropertyName("description")] | ||
public string Description { get; set; } | ||
|
||
/// <summary> | ||
/// get/set - The results of the query. | ||
/// </summary> | ||
[JsonPropertyName("file_latest")] | ||
public FileLatest FileLatest { get; set; } | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
namespace Pims.Api.Models.Mayan.Document | ||
{ | ||
/// <summary> | ||
/// Represents a file download result. | ||
/// </summary> | ||
public class FileDownload | ||
{ | ||
/// <summary> | ||
/// get/set - The file contents. Could be encoded. | ||
/// </summary> | ||
public byte[] FilePayload { get; set; } | ||
|
||
/// <summary> | ||
/// get/set - The file size | ||
/// </summary> | ||
public int Size { get; set; } | ||
|
||
/// <summary> | ||
/// get/set - Name of the file. | ||
/// </summary> | ||
public string FileName { get; set; } | ||
|
||
/// <summary> | ||
/// get/set - THe Mime-Type that the file uses. | ||
/// </summary> | ||
public string Mimetype { get; set; } | ||
} | ||
} |
Oops, something went wrong.