Repository: olingo-odata2 Updated Branches: refs/heads/Olingo-298_Fix [created] 82f2fbc7b
[OLINGO-298] Fixed response status and removed NotAllowedException Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/82f2fbc7 Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/82f2fbc7 Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/82f2fbc7 Branch: refs/heads/Olingo-298_Fix Commit: 82f2fbc7b59f48edb01a6fde2fa06884e18a248b Parents: 402ad9a Author: Michael Bolz <[email protected]> Authored: Wed May 28 15:02:23 2014 +0200 Committer: Michael Bolz <[email protected]> Committed: Wed May 28 15:02:23 2014 +0200 ---------------------------------------------------------------------- .../olingo/odata2/core/rest/ODataExceptionMapperImpl.java | 5 +++-- .../java/org/apache/olingo/odata2/fit/basic/BasicHttpTest.java | 4 ++-- .../java/org/apache/olingo/odata2/fit/basic/UrlRewriteTest.java | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/82f2fbc7/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataExceptionMapperImpl.java ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataExceptionMapperImpl.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataExceptionMapperImpl.java index 5f7d059..93bd18e 100644 --- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataExceptionMapperImpl.java +++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataExceptionMapperImpl.java @@ -132,8 +132,9 @@ public class ODataExceptionMapperImpl implements ExceptionMapper<Exception> { context.setErrorCode(null); context.setMessage(exception.getMessage()); context.setLocale(DEFAULT_RESPONSE_LOCALE); - context.setHttpStatus(HttpStatusCodes.fromStatusCode(exception.getResponse().getStatus())); - if (exception instanceof NotAllowedException) { + HttpStatusCodes statusCode = HttpStatusCodes.fromStatusCode(exception.getResponse().getStatus()); + context.setHttpStatus(statusCode); + if (statusCode == HttpStatusCodes.METHOD_NOT_ALLOWED) { // RFC 2616, 5.1.1: " An origin server SHOULD return the status code // 405 (Method Not Allowed) if the method is known by the origin server // but not allowed for the requested resource, and 501 (Not Implemented) http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/82f2fbc7/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/basic/BasicHttpTest.java ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/basic/BasicHttpTest.java b/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/basic/BasicHttpTest.java index b8d5939..408373c 100644 --- a/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/basic/BasicHttpTest.java +++ b/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/basic/BasicHttpTest.java @@ -207,7 +207,7 @@ public class BasicHttpTest extends AbstractBasicTest { public void unknownMethod() throws Exception { HttpSomethingUnsupported request = new HttpSomethingUnsupported(getEndpoint() + "aaa/bbb/ccc"); final HttpResponse response = getHttpClient().execute(request); - assertEquals(HttpStatusCodes.METHOD_NOT_ALLOWED.getStatusCode(), response.getStatusLine().getStatusCode()); + assertEquals(HttpStatusCodes.NOT_IMPLEMENTED.getStatusCode(), response.getStatusLine().getStatusCode()); } @Test @@ -269,6 +269,6 @@ public class BasicHttpTest extends AbstractBasicTest { @Test public void tunneledUnknownMethodOverride() throws Exception { - tunnelPost("X-HTTP-Method-Override", "xxx", HttpStatusCodes.METHOD_NOT_ALLOWED); + tunnelPost("X-HTTP-Method-Override", "xxx", HttpStatusCodes.NOT_IMPLEMENTED); } } http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/82f2fbc7/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/basic/UrlRewriteTest.java ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/basic/UrlRewriteTest.java b/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/basic/UrlRewriteTest.java index 348e715..37d8ba7 100644 --- a/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/basic/UrlRewriteTest.java +++ b/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/basic/UrlRewriteTest.java @@ -130,7 +130,7 @@ public class UrlRewriteTest extends AbstractBasicTest { public void testSomethingUnsupportedServiceDocumentRedirect() throws Exception { final HttpRequestBase httpMethod = createRedirectRequest(HttpSomethingUnsupported.class); final HttpResponse response = getHttpClient().execute(httpMethod); - assertEquals(HttpStatusCodes.METHOD_NOT_ALLOWED.getStatusCode(), response.getStatusLine().getStatusCode()); + assertEquals(HttpStatusCodes.NOT_IMPLEMENTED.getStatusCode(), response.getStatusLine().getStatusCode()); } private HttpRequestBase createRedirectRequest(final Class<? extends HttpRequestBase> clazz) throws Exception {
