private void populateDetails(FhirContext theCtx, Throwable theException, IBaseOperationOutcome theOo) { if (myReturnStackTracesForExceptionTypes != null) { for (Class<?> next : myReturnStackTracesForExceptionTypes) { if (next.isAssignableFrom(theException.getClass())) { String detailsValue = theException.getMessage() + "\n\n" + ExceptionUtils.getStackTrace(theException); OperationOutcomeUtil.addIssue(theCtx, theOo, "error", detailsValue, null, PROCESSING); return; } } } OperationOutcomeUtil.addIssue(theCtx, theOo, "error", theException.getMessage(), null, PROCESSING); }
/** * Constructor which accepts an {@link IBaseOperationOutcome} resource which will be supplied in the response */ public UnprocessableEntityException(FhirContext theCtx, IBaseOperationOutcome theOperationOutcome) { super(STATUS_CODE, OperationOutcomeUtil.getFirstIssueDetails(theCtx, theOperationOutcome), theOperationOutcome); }
/** * Add an issue to an OperationOutcome * * @param theCtx * The fhir context * @param theOperationOutcome * The OO resource to add to * @param theSeverity * The severity (fatal | error | warning | information) * @param theDetails * The details string * @param theCode */ public static void addIssue(FhirContext theCtx, IBaseOperationOutcome theOperationOutcome, String theSeverity, String theDetails, String theLocation, String theCode) { IBase issue = createIssue(theCtx, theOperationOutcome); populateDetails(theCtx, issue, theSeverity, theDetails, theLocation, theCode); }
public void validateDeleteConflictsEmptyOrThrowException(List<DeleteConflict> theDeleteConflicts) { if (theDeleteConflicts.isEmpty()) { return; } IBaseOperationOutcome oo = OperationOutcomeUtil.newInstance(getContext()); String firstMsg = null; for (DeleteConflict next : theDeleteConflicts) { StringBuilder b = new StringBuilder(); b.append("Unable to delete "); b.append(next.getTargetId().toUnqualifiedVersionless().getValue()); b.append(" because at least one resource has a reference to this resource. First reference found was resource "); b.append(next.getTargetId().toUnqualifiedVersionless().getValue()); b.append(" in path "); b.append(next.getSourcePath()); String msg = b.toString(); if (firstMsg == null) { firstMsg = msg; } OperationOutcomeUtil.addIssue(getContext(), oo, OO_SEVERITY_ERROR, msg, null, "processing"); } throw new ResourceVersionConflictException(firstMsg, oo); }
public static String getFirstIssueDetails(FhirContext theCtx, IBaseOperationOutcome theOutcome) { return getFirstIssueStringPart(theCtx, theOutcome, "diagnostics"); }
oo = OperationOutcomeUtil.newInstance(ctx); if (baseServerResponseException.getAdditionalMessages() != null) { for (String next : baseServerResponseException.getAdditionalMessages()) { OperationOutcomeUtil.addIssue(ctx, oo, "error", next, null, PROCESSING);
public static String getFirstIssueLocation(FhirContext theCtx, IBaseOperationOutcome theOutcome) { return getFirstIssueStringPart(theCtx, theOutcome, "location"); }
oo = OperationOutcomeUtil.newInstance(getContext()); String message = getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "unableToDeleteNotFound", theUrl); String severity = "warning"; String code = "not-found"; OperationOutcomeUtil.addIssue(getContext(), oo, severity, message, null, code); } else { oo = OperationOutcomeUtil.newInstance(getContext()); String message = getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "successfulDeletes", deletedResources.size(), w.getMillis()); String severity = "information"; String code = "informational"; OperationOutcomeUtil.addIssue(getContext(), oo, severity, message, null, code);
/** * Populate an operation outcome with the results of the validation */ public void populateOperationOutcome(IBaseOperationOutcome theOperationOutcome) { for (SingleValidationMessage next : myMessages) { String location; if (isNotBlank(next.getLocationString())) { location = next.getLocationString(); } else if (next.getLocationLine() != null || next.getLocationCol() != null) { location = "Line[" + next.getLocationLine() + "] Col[" + next.getLocationCol() + "]"; } else { location = null; } String severity = next.getSeverity() != null ? next.getSeverity().getCode() : null; OperationOutcomeUtil.addIssue(myCtx, theOperationOutcome, severity, next.getMessage(), location, Constants.OO_INFOSTATUS_PROCESSING); } if (myMessages.isEmpty()) { String message = myCtx.getLocalizer().getMessage(ValidationResult.class, "noIssuesDetected"); OperationOutcomeUtil.addIssue(myCtx, theOperationOutcome, "information", message, null, "informational"); } }
private static String toDescription(FhirContext theCtx, IBaseOperationOutcome theOo) { StringBuilder b = new StringBuilder(); b.append(OperationOutcomeUtil.getFirstIssueDetails(theCtx, theOo)); // b.append(" - "); // b.append(theOo.getIssueFirstRep().getLocationFirstRep().getValue()); return b.toString(); }
/** * Add an issue to an OperationOutcome * * @param theCtx * The fhir context * @param theOperationOutcome * The OO resource to add to * @param theSeverity * The severity (fatal | error | warning | information) * @param theDetails * The details string * @param theCode */ public static void addIssue(FhirContext theCtx, IBaseOperationOutcome theOperationOutcome, String theSeverity, String theDetails, String theLocation, String theCode) { IBase issue = createIssue(theCtx, theOperationOutcome); populateDetails(theCtx, issue, theSeverity, theDetails, theLocation, theCode); }
public static String getFirstIssueLocation(FhirContext theCtx, IBaseOperationOutcome theOutcome) { return getFirstIssueStringPart(theCtx, theOutcome, "location"); }
outcome = OperationOutcomeUtil.newInstance(ctx); OperationOutcomeUtil.addIssue(ctx, outcome, "information", "No issues detected", "", "informational");
private void populateDetails(FhirContext theCtx, Throwable theException, IBaseOperationOutcome theOo) { if (myReturnStackTracesForExceptionTypes != null) { for (Class<?> next : myReturnStackTracesForExceptionTypes) { if (next.isAssignableFrom(theException.getClass())) { String detailsValue = theException.getMessage() + "\n\n" + ExceptionUtils.getStackTrace(theException); OperationOutcomeUtil.addIssue(theCtx, theOo, "error", detailsValue, null, PROCESSING); return; } } } OperationOutcomeUtil.addIssue(theCtx, theOo, "error", theException.getMessage(), null, PROCESSING); }
/** * Constructor which accepts an {@link IBaseOperationOutcome} resource which will be supplied in the response */ public UnprocessableEntityException(FhirContext theCtx, IBaseOperationOutcome theOperationOutcome) { super(STATUS_CODE, OperationOutcomeUtil.getFirstIssueDetails(theCtx, theOperationOutcome), theOperationOutcome); }
public static String getFirstIssueDetails(FhirContext theCtx, IBaseOperationOutcome theOutcome) { return getFirstIssueStringPart(theCtx, theOutcome, "diagnostics"); }
outcome.setId(id); IBaseOperationOutcome oo = OperationOutcomeUtil.newInstance(getContext()); String message = getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "successfulDeletes", 1, 0); String severity = "information"; String code = "informational"; OperationOutcomeUtil.addIssue(getContext(), oo, severity, message, null, code); outcome.setOperationOutcome(oo); IBaseOperationOutcome oo = OperationOutcomeUtil.newInstance(getContext()); String message = getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "successfulDeletes", 1, w.getMillis()); String severity = "information"; String code = "informational"; OperationOutcomeUtil.addIssue(getContext(), oo, severity, message, null, code); outcome.setOperationOutcome(oo);
/** * Populate an operation outcome with the results of the validation */ public void populateOperationOutcome(IBaseOperationOutcome theOperationOutcome) { for (SingleValidationMessage next : myMessages) { String location; if (isNotBlank(next.getLocationString())) { location = next.getLocationString(); } else if (next.getLocationLine() != null || next.getLocationCol() != null) { location = "Line[" + next.getLocationLine() + "] Col[" + next.getLocationCol() + "]"; } else { location = null; } String severity = next.getSeverity() != null ? next.getSeverity().getCode() : null; OperationOutcomeUtil.addIssue(myCtx, theOperationOutcome, severity, next.getMessage(), location, Constants.OO_INFOSTATUS_PROCESSING); } if (myMessages.isEmpty()) { String message = myCtx.getLocalizer().getMessage(ValidationResult.class, "noIssuesDetected"); OperationOutcomeUtil.addIssue(myCtx, theOperationOutcome, "information", message, null, "informational"); } }
String details = OperationOutcomeUtil.getFirstIssueDetails(getFhirContext(), oo); if (isNotBlank(details)) { message = message + ": " + details;
public void validateDeleteConflictsEmptyOrThrowException(List<DeleteConflict> theDeleteConflicts) { if (theDeleteConflicts.isEmpty()) { return; } IBaseOperationOutcome oo = OperationOutcomeUtil.newInstance(getContext()); String firstMsg = null; for (DeleteConflict next : theDeleteConflicts) { StringBuilder b = new StringBuilder(); b.append("Unable to delete "); b.append(next.getTargetId().toUnqualifiedVersionless().getValue()); b.append(" because at least one resource has a reference to this resource. First reference found was resource "); b.append(next.getTargetId().toUnqualifiedVersionless().getValue()); b.append(" in path "); b.append(next.getSourcePath()); String msg = b.toString(); if (firstMsg == null) { firstMsg = msg; } OperationOutcomeUtil.addIssue(getContext(), oo, OO_SEVERITY_ERROR, msg, null, "processing"); } throw new ResourceVersionConflictException(firstMsg, oo); }