Made unknown operation exception return an OperationOutcome with issue code "not-supported" (#2384)
This commit is contained in:
parent
1d054054c7
commit
348198e7af
|
@ -59,6 +59,7 @@ import ca.uhn.fhir.rest.server.method.MethodMatchEnum;
|
||||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||||
import ca.uhn.fhir.rest.server.tenant.ITenantIdentificationStrategy;
|
import ca.uhn.fhir.rest.server.tenant.ITenantIdentificationStrategy;
|
||||||
import ca.uhn.fhir.util.CoverageIgnore;
|
import ca.uhn.fhir.util.CoverageIgnore;
|
||||||
|
import ca.uhn.fhir.util.OperationOutcomeUtil;
|
||||||
import ca.uhn.fhir.util.ReflectionUtil;
|
import ca.uhn.fhir.util.ReflectionUtil;
|
||||||
import ca.uhn.fhir.util.UrlPathTokenizer;
|
import ca.uhn.fhir.util.UrlPathTokenizer;
|
||||||
import ca.uhn.fhir.util.UrlUtil;
|
import ca.uhn.fhir.util.UrlUtil;
|
||||||
|
@ -68,6 +69,7 @@ import org.apache.commons.lang3.RandomStringUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseConformance;
|
import org.hl7.fhir.instance.model.api.IBaseConformance;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
import org.hl7.fhir.instance.model.api.IIdType;
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -2035,7 +2037,12 @@ public class RestfulServer extends HttpServlet implements IRestfulServer<Servlet
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void throwUnknownFhirOperationException(RequestDetails requestDetails, String requestPath, RequestTypeEnum theRequestType, FhirContext theFhirContext) {
|
public static void throwUnknownFhirOperationException(RequestDetails requestDetails, String requestPath, RequestTypeEnum theRequestType, FhirContext theFhirContext) {
|
||||||
throw new InvalidRequestException(theFhirContext.getLocalizer().getMessage(RestfulServer.class, "unknownMethod", theRequestType.name(), requestPath, requestDetails.getParameters().keySet()));
|
String message = theFhirContext.getLocalizer().getMessage(RestfulServer.class, "unknownMethod", theRequestType.name(), requestPath, requestDetails.getParameters().keySet());
|
||||||
|
|
||||||
|
IBaseOperationOutcome oo = OperationOutcomeUtil.newInstance(theFhirContext);
|
||||||
|
OperationOutcomeUtil.addIssue(theFhirContext, oo, "error", message, null, "not-supported");
|
||||||
|
|
||||||
|
throw new InvalidRequestException(message, oo);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean partIsOperation(String nextString) {
|
private static boolean partIsOperation(String nextString) {
|
||||||
|
|
Loading…
Reference in New Issue