Merge pull request #540 from CarthageKing/feature-resource_not_supported-fix
return 404 instead of 400 when the FHIR resource/endpoint is not recognized/not supported
This commit is contained in:
commit
4e2e54a929
|
@ -75,6 +75,7 @@ import ca.uhn.fhir.rest.server.exceptions.AuthenticationException;
|
|||
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.NotModifiedException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.rest.server.interceptor.ExceptionHandlingInterceptor;
|
||||
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor;
|
||||
import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor;
|
||||
|
@ -253,7 +254,7 @@ public class RestfulServer extends HttpServlet implements IRestfulServer<Servlet
|
|||
} else {
|
||||
resourceBinding = myResourceNameToBinding.get(resourceName);
|
||||
if (resourceBinding == null) {
|
||||
throw new InvalidRequestException("Unknown resource type '" + resourceName + "' - Server knows how to handle: " + myResourceNameToBinding.keySet());
|
||||
throw new ResourceNotFoundException("Unknown resource type '" + resourceName + "' - Server knows how to handle: " + myResourceNameToBinding.keySet());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -527,7 +527,7 @@ public class RestfulServerMethodTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidResourceTriggers400() throws Exception {
|
||||
public void testInvalidResourceTriggers404() throws Exception {
|
||||
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/FooResource?blah=bar");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
|
@ -537,7 +537,7 @@ public class RestfulServerMethodTest {
|
|||
|
||||
ourLog.info("Response was:\n{}", responseContent);
|
||||
|
||||
assertEquals(400, status.getStatusLine().getStatusCode());
|
||||
assertEquals(404, status.getStatusLine().getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -82,7 +82,7 @@ public class ServerFeaturesDstu2Test {
|
|||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
ourLog.info(responseContent);
|
||||
assertEquals(400, status.getStatusLine().getStatusCode());
|
||||
assertEquals(404, status.getStatusLine().getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -171,7 +171,7 @@ public class ResponseHighlightingInterceptorTest {
|
|||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
ourLog.info("Resp: {}", responseContent);
|
||||
assertEquals(400, status.getStatusLine().getStatusCode());
|
||||
assertEquals(404, status.getStatusLine().getStatusCode());
|
||||
|
||||
assertThat(responseContent, not(stringContainsInOrder("<span class='hlTagName'>OperationOutcome</span>", "Unknown resource type 'Foobar' - Server knows how to handle")));
|
||||
assertThat(responseContent, (stringContainsInOrder("Unknown resource type 'Foobar'")));
|
||||
|
|
Loading…
Reference in New Issue