Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Bundle notification to Core #2478

Merged
merged 1 commit into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static ICapabilityStatementBuilder Create(IModelInfoProvider modelInfoPro
FileVersionInfo version = ProductVersionInfo.Version;
var versionString = $"{version.FileMajorPart}.{version.FileMinorPart}.{version.FileBuildPart}";

statement.Name = string.Format(Resources.CapabilityStatementNameFormat, statement.Publisher, configuration.Value.SoftwareName, versionString);
statement.Name = string.Format(Core.Resources.CapabilityStatementNameFormat, statement.Publisher, configuration.Value.SoftwareName, versionString);
statement.Software = new SoftwareComponent
{
Name = configuration.Value.SoftwareName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s
// When a list is specified, check that the default is an option
if (objects.Any() && !objects.Any(x => Equals(defaultOption, x)))
{
throw new UnsupportedConfigurationException(string.Format(Resources.InvalidConfigSetting, defaultOption, string.Join(", ", objects.ToArray())));
throw new UnsupportedConfigurationException(string.Format(Core.Resources.InvalidConfigSetting, defaultOption, string.Join(", ", objects.ToArray())));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,12 @@ private static SearchParameterInfo GetOrCreateSearchParameterInfo(SearchParamete
}
catch (FormatException)
{
AddIssue(Resources.SearchParameterDefinitionInvalidDefinitionUri, entryIndex);
AddIssue(Core.Resources.SearchParameterDefinitionInvalidDefinitionUri, entryIndex);
continue;
}
catch (ArgumentException)
{
AddIssue(Resources.SearchParameterDefinitionDuplicatedEntry, searchParameter.Url);
AddIssue(Core.Resources.SearchParameterDefinitionDuplicatedEntry, searchParameter.Url);
continue;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public void DeleteSearchParameter(string url, bool calculateHash = true)

if (!UrlLookup.TryRemove(url, out searchParameterInfo))
{
throw new ResourceNotFoundException(string.Format(Resources.CustomSearchParameterNotfound, url));
throw new ResourceNotFoundException(string.Format(Core.Resources.CustomSearchParameterNotfound, url));
}

// for search parameters with a base resource type we need to delete the search parameter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,22 @@ async Task<string> TokenEntryFactory(ICacheEntry entry)
_cache.Remove(GetCacheKey(request.RegistryServer));

_logger.LogWarning(authEx, "Failed to access container registry.");
throw new ContainerRegistryNotAuthorizedException(string.Format(Resources.ContainerRegistryNotAuthorized, request.RegistryServer), authEx);
throw new ContainerRegistryNotAuthorizedException(string.Format(Core.Resources.ContainerRegistryNotAuthorized, request.RegistryServer), authEx);
}
catch (ImageFetchException fetchEx)
{
_logger.LogWarning(fetchEx, "Failed to fetch template image.");
throw new FetchTemplateCollectionFailedException(string.Format(Resources.FetchTemplateCollectionFailed, fetchEx.Message), fetchEx);
throw new FetchTemplateCollectionFailedException(string.Format(Core.Resources.FetchTemplateCollectionFailed, fetchEx.Message), fetchEx);
}
catch (TemplateManagementException templateEx)
{
_logger.LogWarning(templateEx, "Template collection is invalid.");
throw new TemplateCollectionErrorException(string.Format(Resources.FetchTemplateCollectionFailed, templateEx.Message), templateEx);
throw new TemplateCollectionErrorException(string.Format(Core.Resources.FetchTemplateCollectionFailed, templateEx.Message), templateEx);
}
catch (Exception unhandledEx)
{
_logger.LogError(unhandledEx, "Unhandled exception: failed to get template collection.");
throw new FetchTemplateCollectionFailedException(string.Format(Resources.FetchTemplateCollectionFailed, unhandledEx.Message), unhandledEx);
throw new FetchTemplateCollectionFailedException(string.Format(Core.Resources.FetchTemplateCollectionFailed, unhandledEx.Message), unhandledEx);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,16 @@ private string GetConvertDataResult(ConvertDataRequest convertRequest, ITemplate
if (convertException.FhirConverterErrorCode == FhirConverterErrorCode.TimeoutError)
{
_logger.LogError(convertException.InnerException, "Convert data operation timed out.");
throw new ConvertDataTimeoutException(Resources.ConvertDataOperationTimeout, convertException.InnerException);
throw new ConvertDataTimeoutException(Core.Resources.ConvertDataOperationTimeout, convertException.InnerException);
}

_logger.LogInformation(convertException, "Convert data failed.");
throw new ConvertDataFailedException(string.Format(Resources.ConvertDataFailed, convertException.Message), convertException);
throw new ConvertDataFailedException(string.Format(Core.Resources.ConvertDataFailed, convertException.Message), convertException);
}
catch (Exception ex)
{
_logger.LogError(ex, "Unhandled exception: convert data process failed.");
throw new ConvertDataUnhandledException(string.Format(Resources.ConvertDataFailed, ex.Message), ex);
throw new ConvertDataUnhandledException(string.Format(Core.Resources.ConvertDataFailed, ex.Message), ex);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public async Task<CancelExportResponse> Handle(CancelExportRequest request, Canc
outcome.JobRecord.Status = OperationStatus.Canceled;
outcome.JobRecord.CanceledTime = Clock.UtcNow;

outcome.JobRecord.FailureDetails = new JobFailureDetails(Resources.UserRequestedCancellation, HttpStatusCode.NoContent);
outcome.JobRecord.FailureDetails = new JobFailureDetails(Core.Resources.UserRequestedCancellation, HttpStatusCode.NoContent);

_logger.LogInformation($"Attempting to cancel export job {request.JobId}");
await _fhirOperationDataStore.UpdateExportJobAsync(outcome.JobRecord, outcome.ETag, cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private static IList<ExportJobFilter> ParseFilter(string filterString)

if (parameterIndex < 0 || parameterIndex == filter.Length - 1)
{
throw new BadRequestException(string.Format(Resources.TypeFilterUnparseable, filter));
throw new BadRequestException(string.Format(Core.Resources.TypeFilterUnparseable, filter));
}

var filterType = filter.Substring(0, parameterIndex);
Expand All @@ -143,7 +143,7 @@ private static IList<ExportJobFilter> ParseFilter(string filterString)

if (keyValue.Length != 2)
{
throw new BadRequestException(string.Format(Resources.TypeFilterUnparseable, filter));
throw new BadRequestException(string.Format(Core.Resources.TypeFilterUnparseable, filter));
}

parameterTupleList.Add(new Tuple<string, string>(keyValue[0], keyValue[1]));
Expand All @@ -167,7 +167,7 @@ private ExportJobFormatConfiguration ParseFormat(string formatName, bool useCont

if (formatConfiguration == null)
{
throw new BadRequestException(string.Format(Resources.ExportFormatNotFound, formatName));
throw new BadRequestException(string.Format(Core.Resources.ExportFormatNotFound, formatName));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public async Task ExecuteAsync(ExportJobRecord exportJobRecord, WeakETag weakETa
_exportJobRecord.Filters.Count > 0 &&
string.IsNullOrEmpty(_exportJobRecord.ResourceType))
{
throw new BadRequestException(Resources.TypeFilterWithoutTypeIsUnsupported);
throw new BadRequestException(Core.Resources.TypeFilterWithoutTypeIsUnsupported);
}

// Connect to export destination using appropriate client.
Expand Down Expand Up @@ -207,7 +207,7 @@ public async Task ExecuteAsync(ExportJobRecord exportJobRecord, WeakETag weakETa
{
_logger.LogError(ex, "Failed to anonymize resource. The job will be marked as failed.");

_exportJobRecord.FailureDetails = new JobFailureDetails(string.Format(Resources.FailedToAnonymizeResource, ex.Message), HttpStatusCode.BadRequest);
_exportJobRecord.FailureDetails = new JobFailureDetails(string.Format(Core.Resources.FailedToAnonymizeResource, ex.Message), HttpStatusCode.BadRequest);
await CompleteJobAsync(OperationStatus.Failed, cancellationToken);
}
catch (AnonymizationConfigurationNotFoundException ex)
Expand All @@ -230,7 +230,7 @@ public async Task ExecuteAsync(ExportJobRecord exportJobRecord, WeakETag weakETa
// Try to update the job to failed state.
_logger.LogError(ex, "Encountered an unhandled exception. The job will be marked as failed.");

_exportJobRecord.FailureDetails = new JobFailureDetails(Resources.UnknownError, HttpStatusCode.InternalServerError);
_exportJobRecord.FailureDetails = new JobFailureDetails(Core.Resources.UnknownError, HttpStatusCode.InternalServerError);
await CompleteJobAsync(OperationStatus.Failed, cancellationToken);
}
finally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ public async Task<GetExportResponse> Handle(GetExportRequest request, Cancellati
}
else if (outcome.JobRecord.Status == OperationStatus.Failed || outcome.JobRecord.Status == OperationStatus.Canceled)
{
string failureReason = outcome.JobRecord.FailureDetails != null ? outcome.JobRecord.FailureDetails.FailureReason : Resources.UnknownError;
string failureReason = outcome.JobRecord.FailureDetails != null ? outcome.JobRecord.FailureDetails.FailureReason : Core.Resources.UnknownError;
HttpStatusCode failureStatusCode = outcome.JobRecord.FailureDetails != null ? outcome.JobRecord.FailureDetails.FailureStatusCode : HttpStatusCode.InternalServerError;

throw new OperationFailedException(
string.Format(Resources.OperationFailed, OperationsConstants.Export, failureReason), failureStatusCode);
string.Format(Core.Resources.OperationFailed, OperationsConstants.Export, failureReason), failureStatusCode);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public async Task<CancelImportResponse> Handle(CancelImportRequest request, Canc

if (taskInfo.Status == TaskManagement.TaskStatus.Completed)
{
throw new OperationFailedException(Resources.ImportOperationCompleted, HttpStatusCode.Conflict);
throw new OperationFailedException(Core.Resources.ImportOperationCompleted, HttpStatusCode.Conflict);
}
else
{
Expand All @@ -58,7 +58,7 @@ public async Task<CancelImportResponse> Handle(CancelImportRequest request, Canc
}
catch (TaskNotExistException)
{
throw new ResourceNotFoundException(string.Format(Resources.ImportTaskNotFound, request.TaskId));
throw new ResourceNotFoundException(string.Format(Core.Resources.ImportTaskNotFound, request.TaskId));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public async Task<CreateImportResponse> Handle(CreateImportRequest request, Canc
catch (TaskConflictException)
{
_logger.LogInformation("Already a running import task.");
throw new OperationFailedException(Resources.ImportTaskIsRunning, HttpStatusCode.Conflict);
throw new OperationFailedException(Core.Resources.ImportTaskIsRunning, HttpStatusCode.Conflict);
}

return new CreateImportResponse(taskId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ public async Task<GetImportResponse> Handle(GetImportRequest request, Cancellati

if (taskInfo == null)
{
throw new ResourceNotFoundException(string.Format(Resources.ImportTaskNotFound, request.TaskId));
throw new ResourceNotFoundException(string.Format(Core.Resources.ImportTaskNotFound, request.TaskId));
}

if (taskInfo.Status != TaskManagement.TaskStatus.Completed)
{
if (taskInfo.IsCanceled)
{
throw new OperationFailedException(Resources.UserRequestedCancellation, HttpStatusCode.BadRequest);
throw new OperationFailedException(Core.Resources.UserRequestedCancellation, HttpStatusCode.BadRequest);
}

return new GetImportResponse(HttpStatusCode.Accepted);
Expand All @@ -72,11 +72,11 @@ public async Task<GetImportResponse> Handle(GetImportRequest request, Cancellati
HttpStatusCode failureStatusCode = errorResult.HttpStatusCode;

throw new OperationFailedException(
string.Format(Resources.OperationFailed, OperationsConstants.Import, failureReason), failureStatusCode);
string.Format(Core.Resources.OperationFailed, OperationsConstants.Import, failureReason), failureStatusCode);
}
else
{
throw new OperationFailedException(Resources.UserRequestedCancellation, HttpStatusCode.BadRequest);
throw new OperationFailedException(Core.Resources.UserRequestedCancellation, HttpStatusCode.BadRequest);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public async Task<CancelReindexResponse> Handle(CancelReindexRequest request, Ca
if (outcome.JobRecord.Status.IsFinished())
{
throw new RequestNotValidException(
string.Format(Resources.ReindexJobInCompletedState, outcome.JobRecord.Id, outcome.JobRecord.Status));
string.Format(Core.Resources.ReindexJobInCompletedState, outcome.JobRecord.Id, outcome.JobRecord.Status));
}

// Try to cancel the job.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public async Task<CreateReindexResponse> Handle(CreateReindexRequest request, Ca
(var activeReindexJobs, var reindexJobId) = await _fhirOperationDataStore.CheckActiveReindexJobsAsync(cancellationToken);
if (activeReindexJobs)
{
throw new JobConflictException(string.Format(Resources.OnlyOneResourceJobAllowed, reindexJobId));
throw new JobConflictException(string.Format(Core.Resources.OnlyOneResourceJobAllowed, reindexJobId));
}

// We need to pull in latest search parameter updates from the data store before creating a reindex job.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ private async Task<bool> TryPopulateNewJobFields()
_reindexJobRecord.Error.Add(new OperationOutcomeIssue(
OperationOutcomeConstants.IssueSeverity.Information,
OperationOutcomeConstants.IssueType.Informational,
Resources.NoSearchParametersNeededToBeIndexed));
Core.Resources.NoSearchParametersNeededToBeIndexed));
_reindexJobRecord.CanceledTime = Clock.UtcNow;
await MoveToFinalStatusAsync(OperationStatus.Canceled);
return false;
Expand All @@ -251,7 +251,7 @@ private async Task<bool> TryPopulateNewJobFields()
_reindexJobRecord.Error.Add(new OperationOutcomeIssue(
OperationOutcomeConstants.IssueSeverity.Information,
OperationOutcomeConstants.IssueType.Informational,
Resources.NoResourcesNeedToBeReindexed));
Core.Resources.NoResourcesNeedToBeReindexed));
await UpdateParametersAndCompleteJob();
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class ValidateOperationHandler : IRequestHandler<ValidateOperationRequest
public static readonly OperationOutcomeIssue ValidationPassed = new OperationOutcomeIssue(
OperationOutcomeConstants.IssueSeverity.Information,
OperationOutcomeConstants.IssueType.Informational,
Resources.ValidationPassed);
Core.Resources.ValidationPassed);

private readonly IAuthorizationService<DataActions> _authorizationService;
private readonly IProfileValidator _profileValidator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@
using System.Collections.Generic;
using Microsoft.Health.Fhir.Core.Features.Metrics;
using Microsoft.Health.Fhir.Core.Models;
using Microsoft.Health.Fhir.ValueSets;
using static Hl7.Fhir.Model.Bundle;

namespace Microsoft.Health.Fhir.Api.Features.Resources.Bundle
namespace Microsoft.Health.Fhir.Core.Features.Resources.Bundle
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To document my learnings: BundleMetricsNotification now lives in a new namespace, which requires us to explicitly indicate that resources are being referenced from Core.Resource and not Core.Features.Resource. No string resources have been moved - this PR clears up the ambiguity that comes with this namespace change.

{
public class BundleMetricsNotification : IMetricsNotification
{
public BundleMetricsNotification(IDictionary<string, int> apiCallResults, BundleType bundleType)
public BundleMetricsNotification(IDictionary<string, int> apiCallResults, string bundleType)
rotodd marked this conversation as resolved.
Show resolved Hide resolved
{
FhirOperation = bundleType == BundleType.Batch ? AuditEventSubType.Batch : AuditEventSubType.Transaction;
FhirOperation = bundleType;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, this logic has been moved to BundleHandler.cs since the Hl7.Fhir.Model package is version dependent.

ResourceType = KnownResourceTypes.Bundle;
ApiCallResults = apiCallResults;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static string Decode(string encodedContinuationToken)
}
catch (FormatException)
{
throw new BadRequestException(Resources.InvalidContinuationToken);
throw new BadRequestException(Core.Resources.InvalidContinuationToken);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ public IncludeExpression ParseInclude(string[] resourceTypes, string includeValu
var valueSpan = includeValue.AsSpan();
if (!TrySplit(SearchSplitChar, ref valueSpan, out ReadOnlySpan<char> originalType))
{
throw new InvalidSearchOperationException(isReversed ? Resources.RevIncludeMissingType : Resources.IncludeMissingType);
throw new InvalidSearchOperationException(isReversed ? Core.Resources.RevIncludeMissingType : Core.Resources.IncludeMissingType);
}

if (resourceTypes.Length == 1 && resourceTypes[0].Equals(KnownResourceTypes.DomainResource, StringComparison.OrdinalIgnoreCase))
{
throw new InvalidSearchOperationException(Resources.IncludeCannotBeAgainstBase);
throw new InvalidSearchOperationException(Core.Resources.IncludeCannotBeAgainstBase);
}

SearchParameterInfo refSearchParameter;
Expand Down
Loading