[OLINGO-663] Minor code clean up

This commit is contained in:
Michael Bolz 2015-06-02 08:50:06 +02:00
parent 53881c2acf
commit a4913636dc
2 changed files with 11 additions and 13 deletions

View File

@ -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);
}
}

View File

@ -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());