diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataDispatcher.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataDispatcher.java index da4ee2d99..2984ede37 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataDispatcher.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataDispatcher.java @@ -220,7 +220,7 @@ public class ODataDispatcher { .processActionVoid(request, response, uriInfo, requestFormat); } else { final boolean isCollection = returnType.isCollection(); - ContentType responseFormat = null; + ContentType responseFormat; switch (returnType.getType().getKind()) { case ENTITY: responseFormat = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(), @@ -534,8 +534,9 @@ public class ODataDispatcher { private void validatePreconditions(ODataRequest request, boolean isMediaValue) throws PreconditionRequiredException { // If needed perform preconditions validation if (handler.getCustomETagSupport() != null) { - new PreconditionsValidator(handler.getCustomETagSupport(), uriInfo, request.getHeader("if-match"), request - .getHeader("if-none-match")).validatePreconditions(isMediaValue); + new PreconditionsValidator(handler.getCustomETagSupport(), uriInfo, + request.getHeader(HttpHeader.IF_MATCH), + request.getHeader(HttpHeader.IF_NONE_MATCH)).validatePreconditions(isMediaValue); } } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/PreconditionsValidator.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/PreconditionsValidator.java index 1ca899358..490acc1ec 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/PreconditionsValidator.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/PreconditionsValidator.java @@ -31,7 +31,6 @@ import org.apache.olingo.server.api.uri.UriResourceSingleton; public class PreconditionsValidator { - ; private final CustomETagSupport customETagSupport; private final UriInfo uriInfo; private final String ifMatch; @@ -68,16 +67,17 @@ public class PreconditionsValidator { for (UriResource uriResourcePart : uriInfo.getUriResourceParts()) { switch (uriResourcePart.getKind()) { case function: - lastFoundEntitySetOrSingleton = getEnitySetFromFunctionImport(uriResourcePart); + lastFoundEntitySetOrSingleton = getEntitySetFromFunctionImport((UriResourceFunction) uriResourcePart); break; case singleton: lastFoundEntitySetOrSingleton = ((UriResourceSingleton) uriResourcePart).getSingleton(); break; case entitySet: - lastFoundEntitySetOrSingleton = getEntitySet(uriResourcePart); + lastFoundEntitySetOrSingleton = getEntitySet((UriResourceEntitySet) uriResourcePart); break; case navigationProperty: - lastFoundEntitySetOrSingleton = getEntitySetFromNavigation(lastFoundEntitySetOrSingleton, uriResourcePart); + lastFoundEntitySetOrSingleton = getEntitySetFromNavigation(lastFoundEntitySetOrSingleton, + (UriResourceNavigation) uriResourcePart); break; case value: case action: @@ -100,8 +100,7 @@ public class PreconditionsValidator { return lastFoundEntitySetOrSingleton; } - private EdmBindingTarget getEnitySetFromFunctionImport(UriResource uriResourcePart) { - UriResourceFunction uriResourceFunction = (UriResourceFunction) uriResourcePart; + private EdmBindingTarget getEntitySetFromFunctionImport(UriResourceFunction uriResourceFunction) { EdmFunctionImport functionImport = uriResourceFunction.getFunctionImport(); if (functionImport != null && functionImport.getReturnedEntitySet() != null && !uriResourceFunction.isCollection()) { @@ -110,8 +109,7 @@ public class PreconditionsValidator { return null; } - private EdmBindingTarget getEntitySet(UriResource uriResourcePart) { - UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) uriResourcePart; + private EdmBindingTarget getEntitySet(UriResourceEntitySet uriResourceEntitySet) { if (!uriResourceEntitySet.isCollection()) { return uriResourceEntitySet.getEntitySet(); } @@ -119,8 +117,7 @@ public class PreconditionsValidator { } private EdmBindingTarget getEntitySetFromNavigation(EdmBindingTarget lastFoundEntitySetOrSingleton, - UriResource uriResourcePart) { - UriResourceNavigation uriResourceNavigation = (UriResourceNavigation) uriResourcePart; + UriResourceNavigation uriResourceNavigation) { if (lastFoundEntitySetOrSingleton != null && !uriResourceNavigation.isCollection()) { EdmNavigationProperty navProp = uriResourceNavigation.getProperty(); return lastFoundEntitySetOrSingleton.getRelatedBindingTarget(navProp.getName());