[OLINGO-663] Minor code clean up
This commit is contained in:
parent
53881c2acf
commit
a4913636dc
|
@ -220,7 +220,7 @@ public class ODataDispatcher {
|
||||||
.processActionVoid(request, response, uriInfo, requestFormat);
|
.processActionVoid(request, response, uriInfo, requestFormat);
|
||||||
} else {
|
} else {
|
||||||
final boolean isCollection = returnType.isCollection();
|
final boolean isCollection = returnType.isCollection();
|
||||||
ContentType responseFormat = null;
|
ContentType responseFormat;
|
||||||
switch (returnType.getType().getKind()) {
|
switch (returnType.getType().getKind()) {
|
||||||
case ENTITY:
|
case ENTITY:
|
||||||
responseFormat = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(),
|
responseFormat = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(),
|
||||||
|
@ -534,8 +534,9 @@ public class ODataDispatcher {
|
||||||
private void validatePreconditions(ODataRequest request, boolean isMediaValue) throws PreconditionRequiredException {
|
private void validatePreconditions(ODataRequest request, boolean isMediaValue) throws PreconditionRequiredException {
|
||||||
// If needed perform preconditions validation
|
// If needed perform preconditions validation
|
||||||
if (handler.getCustomETagSupport() != null) {
|
if (handler.getCustomETagSupport() != null) {
|
||||||
new PreconditionsValidator(handler.getCustomETagSupport(), uriInfo, request.getHeader("if-match"), request
|
new PreconditionsValidator(handler.getCustomETagSupport(), uriInfo,
|
||||||
.getHeader("if-none-match")).validatePreconditions(isMediaValue);
|
request.getHeader(HttpHeader.IF_MATCH),
|
||||||
|
request.getHeader(HttpHeader.IF_NONE_MATCH)).validatePreconditions(isMediaValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,6 @@ import org.apache.olingo.server.api.uri.UriResourceSingleton;
|
||||||
|
|
||||||
public class PreconditionsValidator {
|
public class PreconditionsValidator {
|
||||||
|
|
||||||
;
|
|
||||||
private final CustomETagSupport customETagSupport;
|
private final CustomETagSupport customETagSupport;
|
||||||
private final UriInfo uriInfo;
|
private final UriInfo uriInfo;
|
||||||
private final String ifMatch;
|
private final String ifMatch;
|
||||||
|
@ -68,16 +67,17 @@ public class PreconditionsValidator {
|
||||||
for (UriResource uriResourcePart : uriInfo.getUriResourceParts()) {
|
for (UriResource uriResourcePart : uriInfo.getUriResourceParts()) {
|
||||||
switch (uriResourcePart.getKind()) {
|
switch (uriResourcePart.getKind()) {
|
||||||
case function:
|
case function:
|
||||||
lastFoundEntitySetOrSingleton = getEnitySetFromFunctionImport(uriResourcePart);
|
lastFoundEntitySetOrSingleton = getEntitySetFromFunctionImport((UriResourceFunction) uriResourcePart);
|
||||||
break;
|
break;
|
||||||
case singleton:
|
case singleton:
|
||||||
lastFoundEntitySetOrSingleton = ((UriResourceSingleton) uriResourcePart).getSingleton();
|
lastFoundEntitySetOrSingleton = ((UriResourceSingleton) uriResourcePart).getSingleton();
|
||||||
break;
|
break;
|
||||||
case entitySet:
|
case entitySet:
|
||||||
lastFoundEntitySetOrSingleton = getEntitySet(uriResourcePart);
|
lastFoundEntitySetOrSingleton = getEntitySet((UriResourceEntitySet) uriResourcePart);
|
||||||
break;
|
break;
|
||||||
case navigationProperty:
|
case navigationProperty:
|
||||||
lastFoundEntitySetOrSingleton = getEntitySetFromNavigation(lastFoundEntitySetOrSingleton, uriResourcePart);
|
lastFoundEntitySetOrSingleton = getEntitySetFromNavigation(lastFoundEntitySetOrSingleton,
|
||||||
|
(UriResourceNavigation) uriResourcePart);
|
||||||
break;
|
break;
|
||||||
case value:
|
case value:
|
||||||
case action:
|
case action:
|
||||||
|
@ -100,8 +100,7 @@ public class PreconditionsValidator {
|
||||||
return lastFoundEntitySetOrSingleton;
|
return lastFoundEntitySetOrSingleton;
|
||||||
}
|
}
|
||||||
|
|
||||||
private EdmBindingTarget getEnitySetFromFunctionImport(UriResource uriResourcePart) {
|
private EdmBindingTarget getEntitySetFromFunctionImport(UriResourceFunction uriResourceFunction) {
|
||||||
UriResourceFunction uriResourceFunction = (UriResourceFunction) uriResourcePart;
|
|
||||||
EdmFunctionImport functionImport = uriResourceFunction.getFunctionImport();
|
EdmFunctionImport functionImport = uriResourceFunction.getFunctionImport();
|
||||||
if (functionImport != null && functionImport.getReturnedEntitySet() != null
|
if (functionImport != null && functionImport.getReturnedEntitySet() != null
|
||||||
&& !uriResourceFunction.isCollection()) {
|
&& !uriResourceFunction.isCollection()) {
|
||||||
|
@ -110,8 +109,7 @@ public class PreconditionsValidator {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private EdmBindingTarget getEntitySet(UriResource uriResourcePart) {
|
private EdmBindingTarget getEntitySet(UriResourceEntitySet uriResourceEntitySet) {
|
||||||
UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) uriResourcePart;
|
|
||||||
if (!uriResourceEntitySet.isCollection()) {
|
if (!uriResourceEntitySet.isCollection()) {
|
||||||
return uriResourceEntitySet.getEntitySet();
|
return uriResourceEntitySet.getEntitySet();
|
||||||
}
|
}
|
||||||
|
@ -119,8 +117,7 @@ public class PreconditionsValidator {
|
||||||
}
|
}
|
||||||
|
|
||||||
private EdmBindingTarget getEntitySetFromNavigation(EdmBindingTarget lastFoundEntitySetOrSingleton,
|
private EdmBindingTarget getEntitySetFromNavigation(EdmBindingTarget lastFoundEntitySetOrSingleton,
|
||||||
UriResource uriResourcePart) {
|
UriResourceNavigation uriResourceNavigation) {
|
||||||
UriResourceNavigation uriResourceNavigation = (UriResourceNavigation) uriResourcePart;
|
|
||||||
if (lastFoundEntitySetOrSingleton != null && !uriResourceNavigation.isCollection()) {
|
if (lastFoundEntitySetOrSingleton != null && !uriResourceNavigation.isCollection()) {
|
||||||
EdmNavigationProperty navProp = uriResourceNavigation.getProperty();
|
EdmNavigationProperty navProp = uriResourceNavigation.getProperty();
|
||||||
return lastFoundEntitySetOrSingleton.getRelatedBindingTarget(navProp.getName());
|
return lastFoundEntitySetOrSingleton.getRelatedBindingTarget(navProp.getName());
|
||||||
|
|
Loading…
Reference in New Issue