[OLINGO-841] CleanUp ServerCore

This commit is contained in:
Christian Amend 2015-12-18 13:44:20 +01:00
parent d4902f725b
commit 371bf9a55c
172 changed files with 1546 additions and 1514 deletions

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -65,10 +65,10 @@ public final class ContentNegotiator {
private static List<ContentType> getSupportedContentTypes(
final CustomContentTypeSupport customContentTypeSupport, final RepresentationType representationType)
throws ContentNegotiatorException {
throws ContentNegotiatorException {
final List<ContentType> defaultSupportedContentTypes = getDefaultSupportedContentTypes(representationType);
final List<ContentType> result = customContentTypeSupport == null ? defaultSupportedContentTypes :
customContentTypeSupport.modifySupportedContentTypes(defaultSupportedContentTypes, representationType);
customContentTypeSupport.modifySupportedContentTypes(defaultSupportedContentTypes, representationType);
if (result == null || result.isEmpty()) {
throw new ContentNegotiatorException("No content type has been specified as supported.",
ContentNegotiatorException.MessageKeys.NO_CONTENT_TYPE_SUPPORTED);
@ -79,7 +79,7 @@ public final class ContentNegotiator {
public static ContentType doContentNegotiation(final FormatOption formatOption, final ODataRequest request,
final CustomContentTypeSupport customContentTypeSupport, final RepresentationType representationType)
throws ContentNegotiatorException {
throws ContentNegotiatorException {
final List<ContentType> supportedContentTypes =
getSupportedContentTypes(customContentTypeSupport, representationType);
final String acceptHeaderValue = request.getHeader(HttpHeader.ACCEPT);
@ -93,7 +93,7 @@ public final class ContentNegotiator {
result = getAcceptedType(
AcceptType.fromContentType(contentType == null ?
ContentType.create(formatOption.getFormat()) : contentType),
supportedContentTypes);
supportedContentTypes);
} catch (final IllegalArgumentException e) {
// Exception results in result = null for next check.
}
@ -127,8 +127,8 @@ public final class ContentNegotiator {
private static ContentType mapContentType(final String formatString) {
return JSON.equalsIgnoreCase(formatString) ? ContentType.JSON :
XML.equalsIgnoreCase(formatString) ? ContentType.APPLICATION_XML :
ATOM.equalsIgnoreCase(formatString) ? ContentType.APPLICATION_ATOM_XML : null;
XML.equalsIgnoreCase(formatString) ? ContentType.APPLICATION_XML :
ATOM.equalsIgnoreCase(formatString) ? ContentType.APPLICATION_ATOM_XML : null;
}
private static ContentType getAcceptedType(final List<AcceptType> acceptedContentTypes,
@ -164,7 +164,7 @@ public final class ContentNegotiator {
public static void checkSupport(final ContentType contentType,
final CustomContentTypeSupport customContentTypeSupport, final RepresentationType representationType)
throws ContentNegotiatorException {
throws ContentNegotiatorException {
for (ContentType supportedContentType : getSupportedContentTypes(customContentTypeSupport, representationType)) {
if (AcceptType.fromContentType(supportedContentType).get(0).matches(contentType)) {
return;

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -77,32 +77,32 @@ public class ODataDispatcher {
private final UriInfo uriInfo;
private final ODataHandler handler;
public ODataDispatcher(UriInfo uriInfo, ODataHandler handler) {
public ODataDispatcher(final UriInfo uriInfo, final ODataHandler handler) {
this.uriInfo = uriInfo;
this.handler = handler;
}
public void dispatch(ODataRequest request, ODataResponse response) throws ODataApplicationException,
ODataLibraryException {
public void dispatch(final ODataRequest request, final ODataResponse response) throws ODataApplicationException,
ODataLibraryException {
switch (uriInfo.getKind()) {
case metadata:
checkMethod(request.getMethod(), HttpMethod.GET);
final ContentType requestedContentType = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(),
request, handler.getCustomContentTypeSupport(), RepresentationType.METADATA);
handler.selectProcessor(MetadataProcessor.class)
.readMetadata(request, response, uriInfo, requestedContentType);
.readMetadata(request, response, uriInfo, requestedContentType);
break;
case service:
checkMethod(request.getMethod(), HttpMethod.GET);
if ("".equals(request.getRawODataPath())) {
handler.selectProcessor(RedirectProcessor.class)
.redirect(request, response);
.redirect(request, response);
} else {
final ContentType serviceContentType = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(),
request, handler.getCustomContentTypeSupport(), RepresentationType.SERVICE);
handler.selectProcessor(ServiceDocumentProcessor.class)
.readServiceDocument(request, response, uriInfo, serviceContentType);
.readServiceDocument(request, response, uriInfo, serviceContentType);
}
break;
@ -113,7 +113,7 @@ public class ODataDispatcher {
case batch:
checkMethod(request.getMethod(), HttpMethod.POST);
new BatchHandler(handler, handler.selectProcessor(BatchProcessor.class))
.process(request, response, true);
.process(request, response, true);
break;
default:
@ -211,7 +211,7 @@ public class ODataDispatcher {
final EdmReturnType returnType = action.getReturnType();
if (returnType == null) {
handler.selectProcessor(ActionVoidProcessor.class)
.processActionVoid(request, response, uriInfo, requestFormat);
.processActionVoid(request, response, uriInfo, requestFormat);
} else {
final boolean isCollection = returnType.isCollection();
ContentType responseFormat;
@ -222,10 +222,10 @@ public class ODataDispatcher {
isCollection ? RepresentationType.COLLECTION_ENTITY : RepresentationType.ENTITY);
if (isCollection) {
handler.selectProcessor(ActionEntityCollectionProcessor.class)
.processActionEntityCollection(request, response, uriInfo, requestFormat, responseFormat);
.processActionEntityCollection(request, response, uriInfo, requestFormat, responseFormat);
} else {
handler.selectProcessor(ActionEntityProcessor.class)
.processActionEntity(request, response, uriInfo, requestFormat, responseFormat);
.processActionEntity(request, response, uriInfo, requestFormat, responseFormat);
}
break;
@ -235,10 +235,10 @@ public class ODataDispatcher {
isCollection ? RepresentationType.COLLECTION_PRIMITIVE : RepresentationType.PRIMITIVE);
if (isCollection) {
handler.selectProcessor(ActionPrimitiveCollectionProcessor.class)
.processActionPrimitiveCollection(request, response, uriInfo, requestFormat, responseFormat);
.processActionPrimitiveCollection(request, response, uriInfo, requestFormat, responseFormat);
} else {
handler.selectProcessor(ActionPrimitiveProcessor.class)
.processActionPrimitive(request, response, uriInfo, requestFormat, responseFormat);
.processActionPrimitive(request, response, uriInfo, requestFormat, responseFormat);
}
break;
@ -248,10 +248,10 @@ public class ODataDispatcher {
isCollection ? RepresentationType.COLLECTION_COMPLEX : RepresentationType.COMPLEX);
if (isCollection) {
handler.selectProcessor(ActionComplexCollectionProcessor.class)
.processActionComplexCollection(request, response, uriInfo, requestFormat, responseFormat);
.processActionComplexCollection(request, response, uriInfo, requestFormat, responseFormat);
} else {
handler.selectProcessor(ActionComplexProcessor.class)
.processActionComplex(request, response, uriInfo, requestFormat, responseFormat);
.processActionComplex(request, response, uriInfo, requestFormat, responseFormat);
}
break;
@ -273,13 +273,13 @@ public class ODataDispatcher {
final ContentType responseFormat = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(),
request, handler.getCustomContentTypeSupport(), RepresentationType.COLLECTION_REFERENCE);
handler.selectProcessor(ReferenceCollectionProcessor.class)
.readReferenceCollection(request, response, uriInfo, responseFormat);
.readReferenceCollection(request, response, uriInfo, responseFormat);
} else if (isCollection && httpMethod == HttpMethod.POST) {
final ContentType requestFormat = getSupportedContentType(request.getHeader(HttpHeader.CONTENT_TYPE),
RepresentationType.REFERENCE, true);
handler.selectProcessor(ReferenceProcessor.class)
.createReference(request, response, uriInfo, requestFormat);
.createReference(request, response, uriInfo, requestFormat);
} else if (!isCollection && httpMethod == HttpMethod.GET) {
final ContentType responseFormat = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(),
@ -290,11 +290,11 @@ public class ODataDispatcher {
final ContentType requestFormat = getSupportedContentType(request.getHeader(HttpHeader.CONTENT_TYPE),
RepresentationType.REFERENCE, true);
handler.selectProcessor(ReferenceProcessor.class)
.updateReference(request, response, uriInfo, requestFormat);
.updateReference(request, response, uriInfo, requestFormat);
} else if (httpMethod == HttpMethod.DELETE) {
handler.selectProcessor(ReferenceProcessor.class)
.deleteReference(request, response, uriInfo);
.deleteReference(request, response, uriInfo);
} else {
throwMethodNotAllowed(httpMethod);
@ -310,47 +310,47 @@ public class ODataDispatcher {
&& ((UriResourceFunction) resource).getType().getKind() == EdmTypeKind.PRIMITIVE) {
final EdmType type = resource instanceof UriResourceProperty ?
((UriResourceProperty) resource).getType() : ((UriResourceFunction) resource).getType();
final RepresentationType valueRepresentationType =
type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Binary) ?
RepresentationType.BINARY : RepresentationType.VALUE;
if (method == HttpMethod.GET) {
final ContentType requestedContentType = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(),
request, handler.getCustomContentTypeSupport(), valueRepresentationType);
final RepresentationType valueRepresentationType =
type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Binary) ?
RepresentationType.BINARY : RepresentationType.VALUE;
if (method == HttpMethod.GET) {
final ContentType requestedContentType = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(),
request, handler.getCustomContentTypeSupport(), valueRepresentationType);
handler.selectProcessor(PrimitiveValueProcessor.class)
handler.selectProcessor(PrimitiveValueProcessor.class)
.readPrimitiveValue(request, response, uriInfo, requestedContentType);
} else if (method == HttpMethod.PUT && resource instanceof UriResourceProperty) {
validatePreconditions(request, false);
final ContentType requestFormat = getSupportedContentType(request.getHeader(HttpHeader.CONTENT_TYPE),
valueRepresentationType, true);
final ContentType responseFormat = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(),
request, handler.getCustomContentTypeSupport(), valueRepresentationType);
handler.selectProcessor(PrimitiveValueProcessor.class)
} else if (method == HttpMethod.PUT && resource instanceof UriResourceProperty) {
validatePreconditions(request, false);
final ContentType requestFormat = getSupportedContentType(request.getHeader(HttpHeader.CONTENT_TYPE),
valueRepresentationType, true);
final ContentType responseFormat = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(),
request, handler.getCustomContentTypeSupport(), valueRepresentationType);
handler.selectProcessor(PrimitiveValueProcessor.class)
.updatePrimitiveValue(request, response, uriInfo, requestFormat, responseFormat);
} else if (method == HttpMethod.DELETE && resource instanceof UriResourceProperty) {
validatePreconditions(request, false);
handler.selectProcessor(PrimitiveValueProcessor.class)
} else if (method == HttpMethod.DELETE && resource instanceof UriResourceProperty) {
validatePreconditions(request, false);
handler.selectProcessor(PrimitiveValueProcessor.class)
.deletePrimitiveValue(request, response, uriInfo);
} else {
throwMethodNotAllowed(method);
}
} else {
throwMethodNotAllowed(method);
}
} else {
if (method == HttpMethod.GET) {
final ContentType requestedContentType = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(),
request, handler.getCustomContentTypeSupport(), RepresentationType.MEDIA);
handler.selectProcessor(MediaEntityProcessor.class)
.readMediaEntity(request, response, uriInfo, requestedContentType);
.readMediaEntity(request, response, uriInfo, requestedContentType);
} else if (method == HttpMethod.PUT && resource instanceof UriResourceEntitySet) {
validatePreconditions(request, true);
final ContentType requestFormat = ContentType.parse(request.getHeader(HttpHeader.CONTENT_TYPE));
final ContentType responseFormat = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(),
request, handler.getCustomContentTypeSupport(), RepresentationType.ENTITY);
handler.selectProcessor(MediaEntityProcessor.class)
.updateMediaEntity(request, response, uriInfo, requestFormat, responseFormat);
.updateMediaEntity(request, response, uriInfo, requestFormat, responseFormat);
} else if (method == HttpMethod.DELETE && resource instanceof UriResourceEntitySet) {
validatePreconditions(request, true);
handler.selectProcessor(MediaEntityProcessor.class)
.deleteMediaEntity(request, response, uriInfo);
.deleteMediaEntity(request, response, uriInfo);
} else {
throwMethodNotAllowed(method);
}
@ -367,10 +367,10 @@ public class ODataDispatcher {
request, handler.getCustomContentTypeSupport(), complexRepresentationType);
if (isCollection) {
handler.selectProcessor(ComplexCollectionProcessor.class)
.readComplexCollection(request, response, uriInfo, requestedContentType);
.readComplexCollection(request, response, uriInfo, requestedContentType);
} else {
handler.selectProcessor(ComplexProcessor.class)
.readComplex(request, response, uriInfo, requestedContentType);
.readComplex(request, response, uriInfo, requestedContentType);
}
} else if (method == HttpMethod.PUT || method == HttpMethod.PATCH) {
validatePreconditions(request, false);
@ -380,19 +380,19 @@ public class ODataDispatcher {
request, handler.getCustomContentTypeSupport(), complexRepresentationType);
if (isCollection) {
handler.selectProcessor(ComplexCollectionProcessor.class)
.updateComplexCollection(request, response, uriInfo, requestFormat, responseFormat);
.updateComplexCollection(request, response, uriInfo, requestFormat, responseFormat);
} else {
handler.selectProcessor(ComplexProcessor.class)
.updateComplex(request, response, uriInfo, requestFormat, responseFormat);
.updateComplex(request, response, uriInfo, requestFormat, responseFormat);
}
} else if (method == HttpMethod.DELETE) {
validatePreconditions(request, false);
if (isCollection) {
handler.selectProcessor(ComplexCollectionProcessor.class)
.deleteComplexCollection(request, response, uriInfo);
.deleteComplexCollection(request, response, uriInfo);
} else {
handler.selectProcessor(ComplexProcessor.class)
.deleteComplex(request, response, uriInfo);
.deleteComplex(request, response, uriInfo);
}
} else {
throwMethodNotAllowed(method);
@ -409,10 +409,10 @@ public class ODataDispatcher {
request, handler.getCustomContentTypeSupport(), representationType);
if (isCollection) {
handler.selectProcessor(PrimitiveCollectionProcessor.class)
.readPrimitiveCollection(request, response, uriInfo, requestedContentType);
.readPrimitiveCollection(request, response, uriInfo, requestedContentType);
} else {
handler.selectProcessor(PrimitiveProcessor.class)
.readPrimitive(request, response, uriInfo, requestedContentType);
.readPrimitive(request, response, uriInfo, requestedContentType);
}
} else if (method == HttpMethod.PUT || method == HttpMethod.PATCH) {
validatePreconditions(request, false);
@ -422,19 +422,19 @@ public class ODataDispatcher {
request, handler.getCustomContentTypeSupport(), representationType);
if (isCollection) {
handler.selectProcessor(PrimitiveCollectionProcessor.class)
.updatePrimitiveCollection(request, response, uriInfo, requestFormat, responseFormat);
.updatePrimitiveCollection(request, response, uriInfo, requestFormat, responseFormat);
} else {
handler.selectProcessor(PrimitiveProcessor.class)
.updatePrimitive(request, response, uriInfo, requestFormat, responseFormat);
.updatePrimitive(request, response, uriInfo, requestFormat, responseFormat);
}
} else if (method == HttpMethod.DELETE) {
validatePreconditions(request, false);
if (isCollection) {
handler.selectProcessor(PrimitiveCollectionProcessor.class)
.deletePrimitiveCollection(request, response, uriInfo);
.deletePrimitiveCollection(request, response, uriInfo);
} else {
handler.selectProcessor(PrimitiveProcessor.class)
.deletePrimitive(request, response, uriInfo);
.deletePrimitive(request, response, uriInfo);
}
} else {
throwMethodNotAllowed(method);
@ -449,15 +449,15 @@ public class ODataDispatcher {
|| resource instanceof UriResourceFunction
&& ((UriResourceFunction) resource).getType().getKind() == EdmTypeKind.ENTITY) {
handler.selectProcessor(CountEntityCollectionProcessor.class)
.countEntityCollection(request, response, uriInfo);
.countEntityCollection(request, response, uriInfo);
} else if (resource instanceof UriResourcePrimitiveProperty
|| resource instanceof UriResourceFunction
&& ((UriResourceFunction) resource).getType().getKind() == EdmTypeKind.PRIMITIVE) {
handler.selectProcessor(CountPrimitiveCollectionProcessor.class)
.countPrimitiveCollection(request, response, uriInfo);
.countPrimitiveCollection(request, response, uriInfo);
} else {
handler.selectProcessor(CountComplexCollectionProcessor.class)
.countComplexCollection(request, response, uriInfo);
.countComplexCollection(request, response, uriInfo);
}
}
@ -469,19 +469,19 @@ public class ODataDispatcher {
final ContentType requestedContentType = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(),
request, handler.getCustomContentTypeSupport(), RepresentationType.COLLECTION_ENTITY);
handler.selectProcessor(EntityCollectionProcessor.class)
.readEntityCollection(request, response, uriInfo, requestedContentType);
.readEntityCollection(request, response, uriInfo, requestedContentType);
} else if (method == HttpMethod.POST) {
final ContentType responseFormat = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(),
request, handler.getCustomContentTypeSupport(), RepresentationType.ENTITY);
if (isMedia) {
final ContentType requestFormat = ContentType.parse(request.getHeader(HttpHeader.CONTENT_TYPE));
handler.selectProcessor(MediaEntityProcessor.class)
.createMediaEntity(request, response, uriInfo, requestFormat, responseFormat);
.createMediaEntity(request, response, uriInfo, requestFormat, responseFormat);
} else {
final ContentType requestFormat = getSupportedContentType(request.getHeader(HttpHeader.CONTENT_TYPE),
RepresentationType.ENTITY, true);
handler.selectProcessor(EntityProcessor.class)
.createEntity(request, response, uriInfo, requestFormat, responseFormat);
.createEntity(request, response, uriInfo, requestFormat, responseFormat);
}
} else {
throwMethodNotAllowed(method);
@ -491,7 +491,7 @@ public class ODataDispatcher {
final ContentType requestedContentType = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(),
request, handler.getCustomContentTypeSupport(), RepresentationType.ENTITY);
handler.selectProcessor(EntityProcessor.class)
.readEntity(request, response, uriInfo, requestedContentType);
.readEntity(request, response, uriInfo, requestedContentType);
} else if (method == HttpMethod.PUT || method == HttpMethod.PATCH) {
validatePreconditions(request, false);
final ContentType requestFormat = getSupportedContentType(request.getHeader(HttpHeader.CONTENT_TYPE),
@ -499,11 +499,11 @@ public class ODataDispatcher {
final ContentType responseFormat = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(),
request, handler.getCustomContentTypeSupport(), RepresentationType.ENTITY);
handler.selectProcessor(EntityProcessor.class)
.updateEntity(request, response, uriInfo, requestFormat, responseFormat);
.updateEntity(request, response, uriInfo, requestFormat, responseFormat);
} else if (method == HttpMethod.DELETE) {
validatePreconditions(request, false);
handler.selectProcessor(isMedia ? MediaEntityProcessor.class : EntityProcessor.class)
.deleteEntity(request, response, uriInfo);
.deleteEntity(request, response, uriInfo);
} else {
throwMethodNotAllowed(method);
}
@ -537,7 +537,7 @@ public class ODataDispatcher {
private ContentType getSupportedContentType(final String contentTypeHeader,
final RepresentationType representationType, final boolean mustNotBeNull)
throws ODataHandlerException, ContentNegotiatorException {
throws ODataHandlerException, ContentNegotiatorException {
if (contentTypeHeader == null) {
if (mustNotBeNull) {
throw new ODataHandlerException(contentTypeHeader, ODataHandlerException.MessageKeys.MISSING_CONTENT_TYPE);

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -21,10 +21,10 @@ package org.apache.olingo.server.core;
import java.util.Locale;
import org.apache.olingo.commons.api.http.HttpStatusCode;
import org.apache.olingo.server.api.ODataServerError;
import org.apache.olingo.server.api.ODataApplicationException;
import org.apache.olingo.server.api.ODataLibraryException;
import org.apache.olingo.server.api.ODataLibraryException.ODataErrorMessage;
import org.apache.olingo.server.api.ODataServerError;
import org.apache.olingo.server.api.deserializer.DeserializerException;
import org.apache.olingo.server.api.etag.PreconditionException;
import org.apache.olingo.server.api.serializer.SerializerException;
@ -34,9 +34,9 @@ import org.apache.olingo.server.core.uri.parser.UriParserSyntaxException;
import org.apache.olingo.server.core.uri.validator.UriValidationException;
public class ODataExceptionHelper {
private ODataExceptionHelper() {
//Private Constructor
// Private Constructor
}
public static ODataServerError createServerErrorObject(final UriValidationException e,
@ -52,7 +52,7 @@ public class ODataExceptionHelper {
if (UriParserSemanticException.MessageKeys.RESOURCE_NOT_FOUND.equals(e.getMessageKey())
|| UriParserSemanticException.MessageKeys.PROPERTY_NOT_IN_TYPE.equals(e.getMessageKey())) {
serverError.setStatusCode(HttpStatusCode.NOT_FOUND.getStatusCode());
} else if(UriParserSemanticException.MessageKeys.NOT_IMPLEMENTED.equals(e.getMessageKey())) {
} else if (UriParserSemanticException.MessageKeys.NOT_IMPLEMENTED.equals(e.getMessageKey())) {
serverError.setStatusCode(HttpStatusCode.NOT_IMPLEMENTED.getStatusCode());
} else {
serverError.setStatusCode(HttpStatusCode.BAD_REQUEST.getStatusCode());
@ -66,7 +66,7 @@ public class ODataExceptionHelper {
serverError.setStatusCode(
UriParserSyntaxException.MessageKeys.WRONG_VALUE_FOR_SYSTEM_QUERY_OPTION_FORMAT.equals(e.getMessageKey()) ?
HttpStatusCode.NOT_ACCEPTABLE.getStatusCode() :
HttpStatusCode.BAD_REQUEST.getStatusCode());
HttpStatusCode.BAD_REQUEST.getStatusCode());
return serverError;
}

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -63,7 +63,7 @@ public class ODataHandler {
private UriInfo uriInfo;
private Exception lastThrownException;
public ODataHandler(final OData server, final ServiceMetadata serviceMetadata, ServerCoreDebugger debugger) {
public ODataHandler(final OData server, final ServiceMetadata serviceMetadata, final ServerCoreDebugger debugger) {
odata = server;
this.serviceMetadata = serviceMetadata;
this.debugger = debugger;
@ -159,8 +159,8 @@ public class ODataHandler {
}
public void handleException(final ODataRequest request, final ODataResponse response,
final ODataServerError serverError, Exception exception) {
this.lastThrownException = exception;
final ODataServerError serverError, final Exception exception) {
lastThrownException = exception;
ErrorProcessor exceptionProcessor;
try {
exceptionProcessor = selectProcessor(ErrorProcessor.class);
@ -172,7 +172,7 @@ public class ODataHandler {
try {
requestedContentType = ContentNegotiator.doContentNegotiation(
uriInfo == null ? null : uriInfo.getFormatOption(), request, getCustomContentTypeSupport(),
RepresentationType.ERROR);
RepresentationType.ERROR);
} catch (final ContentNegotiatorException e) {
requestedContentType = ContentType.JSON;
}
@ -184,8 +184,8 @@ public class ODataHandler {
private void validateODataVersion(final ODataRequest request) throws ODataHandlerException {
final String maxVersion = request.getHeader(HttpHeader.ODATA_MAX_VERSION);
if (maxVersion != null && ODataServiceVersion.isBiggerThan(ODataServiceVersion.V40.toString(), maxVersion)) {
throw new ODataHandlerException("ODataVersion not supported: " + maxVersion,
ODataHandlerException.MessageKeys.ODATA_VERSION_NOT_SUPPORTED, maxVersion);
throw new ODataHandlerException("ODataVersion not supported: " + maxVersion,
ODataHandlerException.MessageKeys.ODATA_VERSION_NOT_SUPPORTED, maxVersion);
}
}
@ -212,7 +212,7 @@ public class ODataHandler {
return customContentTypeSupport;
}
public void register(CustomETagSupport customETagSupport) {
public void register(final CustomETagSupport customETagSupport) {
this.customETagSupport = customETagSupport;
}

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -59,7 +59,7 @@ public class ODataHandlerException extends ODataLibraryException {
final String... parameters) {
super(developmentMessage, cause, messageKey, parameters);
}
@Override
protected String getBundleName() {
return DEFAULT_SERVER_BUNDLE_NAME;

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -98,7 +98,7 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
convertToHttp(response, odResponse);
}
private Map<String, String> createEnvironmentVariablesMap(HttpServletRequest request) {
private Map<String, String> createEnvironmentVariablesMap(final HttpServletRequest request) {
Map<String, String> environment = new LinkedHashMap<String, String>();
environment.put("authType", request.getAuthType());
environment.put("localAddr", request.getLocalAddr());
@ -184,7 +184,7 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
}
}
private ODataRequest fillODataRequest(ODataRequest odRequest, final HttpServletRequest httpRequest,
private ODataRequest fillODataRequest(final ODataRequest odRequest, final HttpServletRequest httpRequest,
final int split) throws ODataLibraryException {
final int requestHandle = debugger.startRuntimeMeasurement("ODataHttpHandlerImpl", "fillODataRequest");
try {

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -139,9 +139,9 @@ public class ODataImpl extends OData {
}
@Override
public DebugResponseHelper createDebugResponseHelper(String debugFormat) {
//TODO: What should we do with invalid formats?
//TODO: Support more debug formats
public DebugResponseHelper createDebugResponseHelper(final String debugFormat) {
// TODO: What should we do with invalid formats?
// TODO: Support more debug formats
return new DebugResponseHelperImpl(debugFormat);
}

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -38,8 +38,8 @@ public class ServiceMetadataImpl implements ServiceMetadata {
private final List<EdmxReference> references;
private final ServiceMetadataETagSupport serviceMetadataETagSupport;
public ServiceMetadataImpl(CsdlEdmProvider edmProvider, List<EdmxReference> references,
ServiceMetadataETagSupport serviceMetadataETagSupport) {
public ServiceMetadataImpl(final CsdlEdmProvider edmProvider, final List<EdmxReference> references,
final ServiceMetadataETagSupport serviceMetadataETagSupport) {
edm = new EdmProviderImpl(edmProvider);
this.references = new ArrayList<EdmxReference>();
this.references.addAll(references);

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -40,13 +40,13 @@ public class BatchFacadeImpl implements BatchFacade {
@Override
public ODataResponse handleODataRequest(final ODataRequest request) throws ODataApplicationException,
ODataLibraryException {
ODataLibraryException {
return partHandler.handleODataRequest(request);
}
@Override
public ODataResponsePart handleBatchRequest(final BatchRequestPart request) throws ODataApplicationException,
ODataLibraryException {
ODataLibraryException {
return partHandler.handleBatchRequest(request);
}

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -84,7 +84,7 @@ public class BatchPartHandler {
}
private ODataResponsePart handleChangeSet(final BatchRequestPart request) throws ODataApplicationException,
ODataLibraryException {
ODataLibraryException {
return batchProcessor.processChangeSet(batchFacade, request.getRequests());
}

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -52,7 +52,7 @@ public class DebugResponseHelperImpl implements DebugResponseHelper {
private final DebugFormat requestedFormat;
public DebugResponseHelperImpl(String debugFormat) {
public DebugResponseHelperImpl(final String debugFormat) {
if (DebugSupport.ODATA_DEBUG_HTML.equals(debugFormat)) {
requestedFormat = DebugFormat.HTML;
} else if (DebugSupport.ODATA_DEBUG_DOWNLOAD.equals(debugFormat)) {
@ -181,7 +181,7 @@ public class DebugResponseHelperImpl implements DebugResponseHelper {
}
/**
* Gets version field information for response. Result is never null.
* Gets version field information for response. Result is never null.
* @return version field information
*/
protected static String getVersion() {
@ -196,61 +196,61 @@ public class DebugResponseHelperImpl implements DebugResponseHelper {
StringWriter writer = new StringWriter();
writer.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"\n")
.append(" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n")
.append("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n")
.append("<head>\n")
.append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n")
.append("<title>")
.append(escapeHtml(title))
.append("</title>\n")
.append("<style type=\"text/css\">\n")
.append("body { font-family: Arial, sans-serif; font-size: 13px;\n")
.append(" line-height: 16px; margin: 0;\n")
.append(" background-color: #eeeeee; color: #333333; }\n")
.append(".header { float: left; }\n")
.append(".header a { line-height: 22px; padding: 10px 18px;\n")
.append(" text-decoration: none; color: #333333; }\n")
.append(":target, .header:nth-last-child(2) { background-color: #cccccc; }\n")
.append(":target ~ .header:nth-last-child(2) { background-color: inherit; }\n")
.append(".header:focus, .header:hover,\n")
.append(" .header:nth-last-child(2):focus, .header:nth-last-child(2):hover\n")
.append(" { background-color: #999999; }\n")
.append(".section { position: absolute; top: 42px; min-width: 100%;\n")
.append(" padding-top: 18px; border-top: 1px solid #dddddd; }\n")
.append(".section > * { margin-left: 18px; }\n")
.append(":target + .section, .section:last-child { display: block; }\n")
.append(".section, :target + .section ~ .section { display: none; }\n")
.append("h1 { font-size: 18px; font-weight: normal; margin: 10px 0; }\n")
.append("h2 { font-size: 15px; }\n")
.append("h2:not(:first-child) { margin-top: 2em; }\n")
.append("table { border-collapse: collapse; border-spacing: 0;\n")
.append(" margin-top: 1.5em; }\n")
.append("table, thead { border-width: 1px 0; border-style: solid;\n")
.append(" border-color: #dddddd; text-align: left; }\n")
.append("th.name, td.name { padding: 1ex 2em 1ex 0; }\n")
.append("tbody > tr:hover { background-color: #cccccc; }\n")
.append(".code { font-family: \"Courier New\", monospace; }\n")
.append(".code, .tree li { line-height: 15px; }\n")
.append("ul, .tree { padding-left: 0; list-style-type: none; }\n")
.append(".null, .numeric { padding-left: 1.5em; }\n")
.append(".json { white-space: pre-wrap; }\n")
.append("</style>\n")
.append("</head>\n")
.append("<body>\n");
.append(" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n")
.append("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n")
.append("<head>\n")
.append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n")
.append("<title>")
.append(escapeHtml(title))
.append("</title>\n")
.append("<style type=\"text/css\">\n")
.append("body { font-family: Arial, sans-serif; font-size: 13px;\n")
.append(" line-height: 16px; margin: 0;\n")
.append(" background-color: #eeeeee; color: #333333; }\n")
.append(".header { float: left; }\n")
.append(".header a { line-height: 22px; padding: 10px 18px;\n")
.append(" text-decoration: none; color: #333333; }\n")
.append(":target, .header:nth-last-child(2) { background-color: #cccccc; }\n")
.append(":target ~ .header:nth-last-child(2) { background-color: inherit; }\n")
.append(".header:focus, .header:hover,\n")
.append(" .header:nth-last-child(2):focus, .header:nth-last-child(2):hover\n")
.append(" { background-color: #999999; }\n")
.append(".section { position: absolute; top: 42px; min-width: 100%;\n")
.append(" padding-top: 18px; border-top: 1px solid #dddddd; }\n")
.append(".section > * { margin-left: 18px; }\n")
.append(":target + .section, .section:last-child { display: block; }\n")
.append(".section, :target + .section ~ .section { display: none; }\n")
.append("h1 { font-size: 18px; font-weight: normal; margin: 10px 0; }\n")
.append("h2 { font-size: 15px; }\n")
.append("h2:not(:first-child) { margin-top: 2em; }\n")
.append("table { border-collapse: collapse; border-spacing: 0;\n")
.append(" margin-top: 1.5em; }\n")
.append("table, thead { border-width: 1px 0; border-style: solid;\n")
.append(" border-color: #dddddd; text-align: left; }\n")
.append("th.name, td.name { padding: 1ex 2em 1ex 0; }\n")
.append("tbody > tr:hover { background-color: #cccccc; }\n")
.append(".code { font-family: \"Courier New\", monospace; }\n")
.append(".code, .tree li { line-height: 15px; }\n")
.append("ul, .tree { padding-left: 0; list-style-type: none; }\n")
.append(".null, .numeric { padding-left: 1.5em; }\n")
.append(".json { white-space: pre-wrap; }\n")
.append("</style>\n")
.append("</head>\n")
.append("<body>\n");
char count = '0';
for (final DebugTab part : parts) {
writer.append("<div class=\"header\" id=\"sec").append(++count).append("\">\n")
.append("<h1><a href=\"#sec").append(count).append("\">")
.append(part.getName())
.append("</a></h1>\n")
.append("</div>\n")
.append("<div class=\"section\">\n");
.append("<h1><a href=\"#sec").append(count).append("\">")
.append(part.getName())
.append("</a></h1>\n")
.append("</div>\n")
.append("<div class=\"section\">\n");
part.appendHtml(writer);
writer.append("</div>\n");
}
writer.append("</body>\n")
.append("</html>\n")
.close();
.append("</html>\n")
.close();
byte[] bytes = writer.toString().getBytes("UTF-8");
return new ByteArrayInputStream(bytes);
}
@ -259,7 +259,7 @@ public class DebugResponseHelperImpl implements DebugResponseHelper {
return value == null ? null : value.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;");
}
protected static void appendJsonTable(JsonGenerator gen, final Map<String, String> entries)
protected static void appendJsonTable(final JsonGenerator gen, final Map<String, String> entries)
throws IOException {
if (entries == null || entries.isEmpty()) {
gen.writeNull();
@ -277,16 +277,16 @@ public class DebugResponseHelperImpl implements DebugResponseHelper {
}
}
protected static void appendHtmlTable(Writer writer, final Map<String, String> entries) throws IOException {
protected static void appendHtmlTable(final Writer writer, final Map<String, String> entries) throws IOException {
writer.append("<table>\n<thead>\n")
.append("<tr><th class=\"name\">Name</th><th class=\"value\">Value</th></tr>\n")
.append("</thead>\n<tbody>\n");
.append("<tr><th class=\"name\">Name</th><th class=\"value\">Value</th></tr>\n")
.append("</thead>\n<tbody>\n");
if (entries != null && !entries.isEmpty()) {
for (final String name : entries.keySet()) {
writer.append("<tr><td class=\"name\">").append(name).append("</td>")
.append("<td class=\"value\">")
.append(escapeHtml(entries.get(name)))
.append("</td></tr>\n");
.append("<td class=\"value\">")
.append(escapeHtml(entries.get(name)))
.append("</td></tr>\n");
}
}
writer.append("</tbody>\n</table>\n");

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -23,7 +23,6 @@ import java.io.Writer;
import com.fasterxml.jackson.core.JsonGenerator;
/**
* Debug information.
*/

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -70,7 +70,7 @@ public class DebugTabBody implements DebugTab {
return "Body";
}
//
//
@Override
public void appendJson(final JsonGenerator gen) throws IOException {
if (response == null || response.getContent() == null) {
@ -118,8 +118,8 @@ public class DebugTabBody implements DebugTab {
break;
case IMAGE:
writer.append("<img src=\"data:").append(response.getHeader(HttpHeader.CONTENT_TYPE)).append(";base64,")
.append(body)
.append("\" />\n");
.append(body)
.append("\" />\n");
break;
case TEXT:
default:
@ -130,7 +130,7 @@ public class DebugTabBody implements DebugTab {
}
}
private byte[] streamToBytes(InputStream input) {
private byte[] streamToBytes(final InputStream input) {
if (input != null) {
try {
return new FixedFormatDeserializerImpl().binary(input);

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -39,7 +39,7 @@ public class DebugTabRequest implements DebugTab {
private final String protocol;
private final Map<String, List<String>> headers;
public DebugTabRequest(ODataRequest request) {
public DebugTabRequest(final ODataRequest request) {
if (request != null) {
method = request.getMethod() == null ? UNKOWN_MSG : request.getMethod().toString();
uri = request.getRawRequestUri() == null ? UNKOWN_MSG : request.getRawRequestUri();
@ -56,24 +56,24 @@ public class DebugTabRequest implements DebugTab {
@Override
public void appendHtml(final Writer writer) throws IOException {
writer.append("<h2>Request Method</h2>\n")
.append("<p>").append(method).append("</p>\n")
.append("<h2>Request URI</h2>\n")
.append("<p>").append(DebugResponseHelperImpl.escapeHtml(uri)).append("</p>\n")
.append("<h2>Request Protocol</h2>\n")
.append("<p>").append(DebugResponseHelperImpl.escapeHtml(protocol)).append("</p>\n");
.append("<p>").append(method).append("</p>\n")
.append("<h2>Request URI</h2>\n")
.append("<p>").append(DebugResponseHelperImpl.escapeHtml(uri)).append("</p>\n")
.append("<h2>Request Protocol</h2>\n")
.append("<p>").append(DebugResponseHelperImpl.escapeHtml(protocol)).append("</p>\n");
writer.append("<h2>Request Headers</h2>\n");
writer.append("<table>\n<thead>\n")
.append("<tr><th class=\"name\">Name</th><th class=\"value\">Value</th></tr>\n")
.append("</thead>\n<tbody>\n");
.append("<tr><th class=\"name\">Name</th><th class=\"value\">Value</th></tr>\n")
.append("</thead>\n<tbody>\n");
for (final Map.Entry<String, List<String>> entry : headers.entrySet()) {
List<String> headersList = entry.getValue();
if (headersList != null && !headersList.isEmpty()) {
for (String headerValue : headersList) {
writer.append("<tr><td class=\"name\">").append(entry.getKey()).append("</td>")
.append("<td class=\"value\">")
.append(DebugResponseHelperImpl.escapeHtml(headerValue))
.append("</td></tr>\n");
.append("<td class=\"value\">")
.append(DebugResponseHelperImpl.escapeHtml(headerValue))
.append("</td></tr>\n");
}
}
}
@ -86,7 +86,7 @@ public class DebugTabRequest implements DebugTab {
}
@Override
public void appendJson(JsonGenerator gen) throws IOException {
public void appendJson(final JsonGenerator gen) throws IOException {
gen.writeStartObject();
gen.writeStringField("method", method);

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -40,7 +40,7 @@ public class DebugTabResponse implements DebugTab {
private final Map<String, List<String>> headers;
public DebugTabResponse(final ODataResponse applicationResponse) {
this.response = applicationResponse;
response = applicationResponse;
if (response != null) {
status = HttpStatusCode.fromStatusCode(response.getStatusCode());
headers = response.getAllHeaders();
@ -82,7 +82,7 @@ public class DebugTabResponse implements DebugTab {
gen.writeEndObject();
}
private Map<String, String> map(Map<String, List<String>> headers) {
private Map<String, String> map(final Map<String, List<String>> headers) {
Map<String, String> result = new HashMap<String, String>();
for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
if (entry.getValue().size() == 1) {
@ -97,9 +97,9 @@ public class DebugTabResponse implements DebugTab {
@Override
public void appendHtml(final Writer writer) throws IOException {
writer.append("<h2>Status Code</h2>\n")
.append("<p>").append(Integer.toString(status.getStatusCode())).append(' ')
.append(status.getInfo()).append("</p>\n")
.append("<h2>Response Headers</h2>\n");
.append("<p>").append(Integer.toString(status.getStatusCode())).append(' ')
.append(status.getInfo()).append("</p>\n")
.append("<h2>Response Headers</h2>\n");
DebugResponseHelperImpl.appendHtmlTable(writer, map(headers));
writer.append("<h2>Response Body</h2>\n");
if (response != null && response.getContent() != null) {

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -35,7 +35,7 @@ public class DebugTabRuntime implements DebugTab {
private final RuntimeNode rootNode;
public DebugTabRuntime(List<RuntimeMeasurement> runtimeInformation) {
public DebugTabRuntime(final List<RuntimeMeasurement> runtimeInformation) {
rootNode = new RuntimeNode();
for (final RuntimeMeasurement runtimeMeasurement : runtimeInformation) {
rootNode.add(runtimeMeasurement);
@ -49,11 +49,11 @@ public class DebugTabRuntime implements DebugTab {
}
@Override
public void appendJson(JsonGenerator gen) throws IOException {
public void appendJson(final JsonGenerator gen) throws IOException {
appendJsonChildren(gen, rootNode);
}
private void appendJsonChildren(JsonGenerator gen, RuntimeNode node) throws IOException {
private void appendJsonChildren(final JsonGenerator gen, final RuntimeNode node) throws IOException {
gen.writeStartArray();
for (RuntimeNode child : node.children) {
appendJsonNode(gen, child);
@ -61,7 +61,7 @@ public class DebugTabRuntime implements DebugTab {
gen.writeEndArray();
}
private void appendJsonNode(JsonGenerator gen, RuntimeNode node) throws IOException {
private void appendJsonNode(final JsonGenerator gen, final RuntimeNode node) throws IOException {
gen.writeStartObject();
gen.writeStringField("class", node.className);
gen.writeStringField("method ", node.methodName);
@ -90,25 +90,25 @@ public class DebugTabRuntime implements DebugTab {
throws IOException {
if (node.className != null) {
writer.append("<li>\n")
.append("<span class=\"code\">")
.append("<span class=\"draw\">").append(draw)
.append(isLast ? "&#x2514;" : "&#x251C;").append("&#x2500;&nbsp;</span>")
.append("<span class=\"class\">").append(node.className).append("</span>.")
.append("<span class=\"method\">").append(node.methodName).append("(&hellip;)")
.append("</span></span>");
.append("<span class=\"code\">")
.append("<span class=\"draw\">").append(draw)
.append(isLast ? "&#x2514;" : "&#x251C;").append("&#x2500;&nbsp;</span>")
.append("<span class=\"class\">").append(node.className).append("</span>.")
.append("<span class=\"method\">").append(node.methodName).append("(&hellip;)")
.append("</span></span>");
long time = node.timeStopped == 0 ? 0 : (node.timeStopped - node.timeStarted) / 1000;
writer.append("<span class=\"").append(time == 0 ? "null" : "numeric")
.append("\" title=\"").append(time == 0 ? "Stop time missing" : "Gross duration")
.append("\">").append(time == 0 ? "unfinished" : Long.toString(time) + "&nbsp;&micro;s")
.append("</span>\n");
.append("\" title=\"").append(time == 0 ? "Stop time missing" : "Gross duration")
.append("\">").append(time == 0 ? "unfinished" : Long.toString(time) + "&nbsp;&micro;s")
.append("</span>\n");
}
if (!node.children.isEmpty()) {
writer.append("<ol class=\"tree\">\n");
for (final RuntimeNode childNode : node.children) {
appendRuntimeNode(childNode,
node.className == null ? draw : draw + (isLast ? "&nbsp;" : "&#x2502;") + "&nbsp;&nbsp;",
node.children.indexOf(childNode) == node.children.size() - 1,
writer);
node.children.indexOf(childNode) == node.children.size() - 1,
writer);
}
writer.append("</ol>\n");
}

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -31,7 +31,7 @@ public class DebugTabServer implements DebugTab {
private final Map<String, String> serverEnvironmentVariables;
public DebugTabServer(Map<String, String> serverEnvironmentVariables) {
public DebugTabServer(final Map<String, String> serverEnvironmentVariables) {
this.serverEnvironmentVariables = serverEnvironmentVariables;
}
@ -41,15 +41,15 @@ public class DebugTabServer implements DebugTab {
}
@Override
public void appendJson(JsonGenerator gen) throws IOException {
public void appendJson(final JsonGenerator gen) throws IOException {
DebugResponseHelperImpl.appendJsonTable(gen, serverEnvironmentVariables);
}
@Override
public void appendHtml(Writer writer) throws IOException {
public void appendHtml(final Writer writer) throws IOException {
writer.append("<h2>Library Version</h2>\n")
.append("<p>").append(DebugResponseHelperImpl.getVersion()).append("</p>\n")
.append("<h2>Server Environment</h2>\n");
.append("<p>").append(DebugResponseHelperImpl.getVersion()).append("</p>\n")
.append("<h2>Server Environment</h2>\n");
DebugResponseHelperImpl.appendHtmlTable(writer, serverEnvironmentVariables);
}
}

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -110,9 +110,9 @@ public class DebugTabStacktrace implements DebugTab {
}
final StackTraceElement details = throwable.getStackTrace()[0];
writer.append("<h2>").append(throwable.getClass().getCanonicalName()).append("</h2>\n")
.append("<p>")
.append(DebugResponseHelperImpl.escapeHtml(getMessageText(throwable)))
.append("</p>\n");
.append("<p>")
.append(DebugResponseHelperImpl.escapeHtml(getMessageText(throwable)))
.append("</p>\n");
appendStackTraceElement(details, true, true, writer);
}
@ -120,15 +120,15 @@ public class DebugTabStacktrace implements DebugTab {
final boolean isFirst, final boolean isLast, final Writer writer) throws IOException {
if (isFirst) {
writer.append("<table>\n<thead>\n")
.append("<tr>\n<th class=\"name\">Class</th>\n")
.append("<th class=\"name\">Method</th>\n")
.append("<th class=\"value\">Line number in class</th>\n</tr>\n")
.append("</thead>\n<tbody>\n");
.append("<tr>\n<th class=\"name\">Class</th>\n")
.append("<th class=\"name\">Method</th>\n")
.append("<th class=\"value\">Line number in class</th>\n</tr>\n")
.append("</thead>\n<tbody>\n");
}
writer.append("<tr>\n<td class=\"name\">").append(stackTraceElement.getClassName()).append("</td>\n")
.append("<td class=\"name\">").append(stackTraceElement.getMethodName()).append("</td>\n")
.append("<td class=\"value\">").append(Integer.toString(stackTraceElement.getLineNumber()))
.append("</td>\n</tr>\n");
.append("<td class=\"name\">").append(stackTraceElement.getMethodName()).append("</td>\n")
.append("<td class=\"value\">").append(Integer.toString(stackTraceElement.getLineNumber()))
.append("</td>\n</tr>\n");
if (isLast) {
writer.append("</tbody>\n</table>\n");
}

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -59,7 +59,7 @@ public class DebugTabUri implements DebugTab {
private final UriInfo uriInfo;
public DebugTabUri(UriInfo uriInfo) {
public DebugTabUri(final UriInfo uriInfo) {
this.uriInfo = uriInfo;
}
@ -69,7 +69,7 @@ public class DebugTabUri implements DebugTab {
}
@Override
public void appendJson(JsonGenerator gen) throws IOException {
public void appendJson(final JsonGenerator gen) throws IOException {
gen.writeStartObject();
if (!uriInfo.getUriResourceParts().isEmpty()) {
@ -106,10 +106,12 @@ public class DebugTabUri implements DebugTab {
gen.writeEndObject();
}
private void appendCommonJsonObjects(JsonGenerator gen, CountOption countOption, SkipOption skipOption,
TopOption topOption, FilterOption filterOption, OrderByOption orderByOption, SelectOption selectOption,
ExpandOption expandOption, SearchOption searchOption)
throws IOException {
private void appendCommonJsonObjects(final JsonGenerator gen, final CountOption countOption,
final SkipOption skipOption,
final TopOption topOption, final FilterOption filterOption, final OrderByOption orderByOption,
final SelectOption selectOption,
final ExpandOption expandOption, final SearchOption searchOption)
throws IOException {
if (countOption != null) {
gen.writeBooleanField("isCount", countOption.getValue());
}
@ -152,7 +154,8 @@ public class DebugTabUri implements DebugTab {
}
}
private void appendURIResourceParts(JsonGenerator gen, List<UriResource> uriResourceParts) throws IOException {
private void appendURIResourceParts(final JsonGenerator gen, final List<UriResource> uriResourceParts)
throws IOException {
gen.writeStartArray();
for (UriResource resource : uriResourceParts) {
gen.writeStartObject();
@ -171,7 +174,7 @@ public class DebugTabUri implements DebugTab {
gen.writeEndArray();
}
private void appendParameters(JsonGenerator gen, final String name, final List<UriParameter> parameters)
private void appendParameters(final JsonGenerator gen, final String name, final List<UriParameter> parameters)
throws IOException {
if (!parameters.isEmpty()) {
Map<String, String> parameterMap = new LinkedHashMap<String, String>();
@ -184,7 +187,7 @@ public class DebugTabUri implements DebugTab {
}
}
private void appendOrderByItemsJson(JsonGenerator gen, final List<OrderByItem> orders) throws IOException {
private void appendOrderByItemsJson(final JsonGenerator gen, final List<OrderByItem> orders) throws IOException {
gen.writeStartArray();
for (final OrderByItem item : orders) {
gen.writeStartObject();
@ -197,7 +200,8 @@ public class DebugTabUri implements DebugTab {
gen.writeEndArray();
}
private void appendExpandedPropertiesJson(JsonGenerator gen, List<ExpandItem> expandItems) throws IOException {
private void appendExpandedPropertiesJson(final JsonGenerator gen, final List<ExpandItem> expandItems)
throws IOException {
gen.writeStartArray();
for (ExpandItem item : expandItems) {
appendExpandItemJson(gen, item);
@ -205,7 +209,7 @@ public class DebugTabUri implements DebugTab {
gen.writeEndArray();
}
private void appendExpandItemJson(JsonGenerator gen, ExpandItem item) throws IOException {
private void appendExpandItemJson(final JsonGenerator gen, final ExpandItem item) throws IOException {
gen.writeStartObject();
if (item.isStar()) {
@ -237,7 +241,7 @@ public class DebugTabUri implements DebugTab {
gen.writeEndObject();
}
private void appendExpressionJson(JsonGenerator gen, final Expression expression) throws IOException {
private void appendExpressionJson(final JsonGenerator gen, final Expression expression) throws IOException {
if (expression == null) {
gen.writeNull();
} else {
@ -250,7 +254,8 @@ public class DebugTabUri implements DebugTab {
}
}
private void appendSelectedPropertiesJson(JsonGenerator gen, List<SelectItem> selectItems) throws IOException {
private void appendSelectedPropertiesJson(final JsonGenerator gen, final List<SelectItem> selectItems)
throws IOException {
gen.writeStartArray();
for (SelectItem selectItem : selectItems) {
gen.writeString(getSelectString(selectItem));
@ -279,7 +284,7 @@ public class DebugTabUri implements DebugTab {
return selectedProperty;
}
private void appendSearchJson(JsonGenerator json, final SearchExpression searchExpression) throws IOException {
private void appendSearchJson(final JsonGenerator json, final SearchExpression searchExpression) throws IOException {
json.writeStartObject();
if (searchExpression.isSearchTerm()) {
json.writeStringField("nodeType", "searchTerm");
@ -306,7 +311,7 @@ public class DebugTabUri implements DebugTab {
final JsonFactory jsonFactory = new ObjectMapper().getFactory();
writer.append("<h2>Resource Path</h2>\n")
.append("<ul>\n<li class=\"json\">");
.append("<ul>\n<li class=\"json\">");
JsonGenerator json = jsonFactory.createGenerator(writer).useDefaultPrettyPrinter();
appendURIResourceParts(json, uriInfo.getUriResourceParts());
json.close();
@ -314,7 +319,7 @@ public class DebugTabUri implements DebugTab {
if (uriInfo.getSearchOption() != null) {
writer.append("<h2>Search Option</h2>\n")
.append("<ul>\n<li class=\"json\">");
.append("<ul>\n<li class=\"json\">");
json = jsonFactory.createGenerator(writer).useDefaultPrettyPrinter();
appendSearchJson(json, uriInfo.getSearchOption().getSearchExpression());
json.close();
@ -323,7 +328,7 @@ public class DebugTabUri implements DebugTab {
if (uriInfo.getFilterOption() != null) {
writer.append("<h2>Filter Option</h2>\n")
.append("<ul>\n<li class=\"json\">");
.append("<ul>\n<li class=\"json\">");
json = jsonFactory.createGenerator(writer).useDefaultPrettyPrinter();
appendExpressionJson(json, uriInfo.getFilterOption().getExpression());
json.close();
@ -332,7 +337,7 @@ public class DebugTabUri implements DebugTab {
if (uriInfo.getOrderByOption() != null) {
writer.append("<h2>OrderBy Option</h2>\n")
.append("<ul>\n<li class=\"json\">");
.append("<ul>\n<li class=\"json\">");
json = jsonFactory.createGenerator(writer).useDefaultPrettyPrinter();
appendOrderByItemsJson(json, uriInfo.getOrderByOption().getOrders());
json.close();
@ -341,7 +346,7 @@ public class DebugTabUri implements DebugTab {
if (uriInfo.getExpandOption() != null) {
writer.append("<h2>Expand Option</h2>\n")
.append("<ul>\n<li class=\"json\">");
.append("<ul>\n<li class=\"json\">");
json = jsonFactory.createGenerator(writer).useDefaultPrettyPrinter();
appendExpandedPropertiesJson(json, uriInfo.getExpandOption().getExpandItems());
json.close();
@ -350,7 +355,7 @@ public class DebugTabUri implements DebugTab {
if (uriInfo.getSelectOption() != null) {
writer.append("<h2>Selected Properties</h2>\n")
.append("<ul>\n");
.append("<ul>\n");
for (final SelectItem selectItem : uriInfo.getSelectOption().getSelectItems()) {
writer.append("<li>").append(getSelectString(selectItem)).append("</li>\n");
}

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -191,7 +191,7 @@ public class ExpressionJsonVisitor implements ExpressionVisitor<JsonNode> {
@Override
public JsonNode visitEnum(final EdmEnumType type, final List<String> enumValues) throws ExpressionVisitException,
ODataApplicationException {
ODataApplicationException {
ObjectNode result = nodeFactory.objectNode()
.put(NODE_TYPE_NAME, ENUM_NAME)
.put(TYPE_NAME, getTypeString(type));
@ -266,7 +266,7 @@ public class ExpressionJsonVisitor implements ExpressionVisitor<JsonNode> {
}
}
private String getType(BinaryOperatorKind operator) {
private String getType(final BinaryOperatorKind operator) {
switch (operator) {
case MUL:
case DIV:
@ -302,8 +302,8 @@ public class ExpressionJsonVisitor implements ExpressionVisitor<JsonNode> {
final UriResource lastSegment = uriResourceParts.get(uriResourceParts.size() - 1);
final EdmType type = lastSegment instanceof UriResourcePartTyped ?
((UriResourcePartTyped) lastSegment).getType() :
null;
return type == null ? UNKNOWN_NAME : type.getFullQualifiedName().getFullQualifiedNameAsString();
null;
return type == null ? UNKNOWN_NAME : type.getFullQualifiedName().getFullQualifiedNameAsString();
}
}

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -46,11 +46,11 @@ public class ServerCoreDebugger {
private DebugSupport debugSupport;
private String debugFormat;
public ServerCoreDebugger(OData odata) {
public ServerCoreDebugger(final OData odata) {
this.odata = odata;
}
public void resolveDebugMode(HttpServletRequest request) {
public void resolveDebugMode(final HttpServletRequest request) {
if (debugSupport != null) {
// Should we read the parameter from the servlet here and ignore multiple parameters?
debugFormat = request.getParameter(DebugSupport.ODATA_DEBUG_QUERY_PARAMETER);
@ -63,7 +63,7 @@ public class ServerCoreDebugger {
public ODataResponse createDebugResponse(final ODataRequest request, final ODataResponse response,
final Exception exception, final UriInfo uriInfo, final Map<String, String> serverEnvironmentVariables) {
//Failsafe so we do not generate unauthorized debug messages
// Failsafe so we do not generate unauthorized debug messages
if (!isDebugMode) {
return response;
}
@ -129,7 +129,7 @@ public class ServerCoreDebugger {
}
}
public void setDebugSupportProcessor(DebugSupport debugSupport) {
public void setDebugSupportProcessor(final DebugSupport debugSupport) {
this.debugSupport = debugSupport;
}

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -62,7 +62,7 @@ public class FixedFormatDeserializerImpl implements FixedFormatDeserializer {
}
@Override
public Object primitiveValue(InputStream content, final EdmProperty property) throws DeserializerException {
public Object primitiveValue(final InputStream content, final EdmProperty property) throws DeserializerException {
if (property == null || !property.isPrimitive()) {
throw new DeserializerException("Wrong property.", DeserializerException.MessageKeys.NOT_IMPLEMENTED);
}
@ -103,7 +103,7 @@ public class FixedFormatDeserializerImpl implements FixedFormatDeserializer {
parameter.isNullable(), parameter.getMaxLength(), parameter.getPrecision(), parameter.getScale(), true,
parameter.getMapping() == null ?
primitiveType.getDefaultType() :
parameter.getMapping().getMappedJavaClass()));
parameter.getMapping().getMappedJavaClass()));
} catch (final EdmPrimitiveTypeException e) {
throw new DeserializerException(
"Invalid value '" + content + "' for parameter " + parameter.getName(), e,
@ -119,7 +119,7 @@ public class FixedFormatDeserializerImpl implements FixedFormatDeserializer {
@Override
public List<BatchRequestPart> parseBatchRequest(final InputStream content, final String boundary,
final BatchOptions options)
throws BatchDeserializerException {
throws BatchDeserializerException {
final BatchParser parser = new BatchParser();
return parser.parseBatchRequest(content, boundary, options);

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -72,7 +72,7 @@ public class BatchBodyPart implements BatchPart {
return isChangeSet ? consumeChangeSet(remainingMessage) : consumeQueryOperation(remainingMessage);
}
private List<BatchQueryOperation> consumeChangeSet(List<Line> remainingMessage)
private List<BatchQueryOperation> consumeChangeSet(final List<Line> remainingMessage)
throws BatchDeserializerException {
final List<List<Line>> changeRequests = splitChangeSet(remainingMessage);
final List<BatchQueryOperation> requestList = new LinkedList<BatchQueryOperation>();
@ -84,7 +84,7 @@ public class BatchBodyPart implements BatchPart {
return requestList;
}
private List<List<Line>> splitChangeSet(List<Line> remainingMessage) throws BatchDeserializerException {
private List<List<Line>> splitChangeSet(final List<Line> remainingMessage) throws BatchDeserializerException {
final HeaderField contentTypeField = headers.getHeaderField(HttpHeader.CONTENT_TYPE);
final String changeSetBoundary = BatchParserCommon.getBoundary(contentTypeField.getValue(),

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -18,9 +18,6 @@
*/
package org.apache.olingo.server.core.deserializer.batch;
import org.apache.olingo.commons.api.format.ContentType;
import org.apache.olingo.commons.api.http.HttpHeader;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
@ -28,6 +25,9 @@ import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import org.apache.olingo.commons.api.format.ContentType;
import org.apache.olingo.commons.api.http.HttpHeader;
public class BatchLineReader {
private static final byte CR = '\r';
private static final byte LF = '\n';
@ -66,7 +66,7 @@ public class BatchLineReader {
public List<String> toList() throws IOException {
final List<String> result = new ArrayList<String>();
String currentLine = readLine();
if(currentLine != null) {
if (currentLine != null) {
currentBoundary = currentLine.trim();
result.add(currentLine);
@ -80,7 +80,7 @@ public class BatchLineReader {
public List<Line> toLineList() throws IOException {
final List<Line> result = new ArrayList<Line>();
String currentLine = readLine();
if(currentLine != null) {
if (currentLine != null) {
currentBoundary = currentLine.trim();
int counter = 1;
result.add(new Line(currentLine, counter++));
@ -93,9 +93,9 @@ public class BatchLineReader {
return result;
}
private void updateCurrentCharset(String currentLine) {
if(currentLine != null) {
if(currentLine.startsWith(HttpHeader.CONTENT_TYPE)) {
private void updateCurrentCharset(final String currentLine) {
if (currentLine != null) {
if (currentLine.startsWith(HttpHeader.CONTENT_TYPE)) {
String clValue = currentLine.substring(13, currentLine.length() - 2).trim();
ContentType ct = ContentType.parse(clValue);
if (ct != null) {
@ -111,18 +111,18 @@ public class BatchLineReader {
currentBoundary = DOUBLE_DASH + boundary;
}
}
} else if(CRLF.equals(currentLine)) {
} else if (CRLF.equals(currentLine)) {
readState.foundLinebreak();
} else if(isBoundary(currentLine)) {
} else if (isBoundary(currentLine)) {
readState.foundBoundary();
}
}
}
private boolean isBoundary(String currentLine) {
if((currentBoundary + CRLF).equals(currentLine)) {
private boolean isBoundary(final String currentLine) {
if ((currentBoundary + CRLF).equals(currentLine)) {
return true;
} else if((currentBoundary + DOUBLE_DASH + CRLF).equals(currentLine)) {
} else if ((currentBoundary + DOUBLE_DASH + CRLF).equals(currentLine)) {
return true;
}
return false;
@ -145,10 +145,10 @@ public class BatchLineReader {
}
if (!foundLineEnd) {
byte currentChar = this.buffer[offset++];
if(!innerBuffer.hasRemaining()) {
byte currentChar = buffer[offset++];
if (!innerBuffer.hasRemaining()) {
innerBuffer.flip();
ByteBuffer tmp = ByteBuffer.allocate(innerBuffer.limit() *2);
ByteBuffer tmp = ByteBuffer.allocate(innerBuffer.limit() * 2);
tmp.put(innerBuffer);
innerBuffer = tmp;
}
@ -166,7 +166,7 @@ public class BatchLineReader {
}
// Check if there is at least one character
if (limit != EOF && this.buffer[offset] == LF) {
if (limit != EOF && buffer[offset] == LF) {
innerBuffer.put(LF);
offset++;
}
@ -174,11 +174,11 @@ public class BatchLineReader {
}
}
if(innerBuffer.position() == 0) {
if (innerBuffer.position() == 0) {
return null;
} else {
String currentLine;
if(readState.isReadBody()) {
if (readState.isReadBody()) {
currentLine = new String(innerBuffer.array(), 0, innerBuffer.position(), getCurrentCharset());
} else {
currentLine = new String(innerBuffer.array(), 0, innerBuffer.position(), CS_ISO_8859_1);
@ -208,9 +208,11 @@ public class BatchLineReader {
public void foundLinebreak() {
state++;
}
public void foundBoundary() {
state = 0;
}
public boolean isReadBody() {
return state >= 2;
}

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -34,7 +34,7 @@ public class BatchParser {
public List<BatchRequestPart> parseBatchRequest(final InputStream content, final String boundary,
final BatchOptions options)
throws BatchDeserializerException {
throws BatchDeserializerException {
this.options = options;
BatchRequestTransformator transformator = new BatchRequestTransformator(options.getRawBaseUri(),
@ -44,7 +44,7 @@ public class BatchParser {
private List<BatchRequestPart> parse(final InputStream in, final String boundary,
final BatchRequestTransformator transformator)
throws BatchDeserializerException {
throws BatchDeserializerException {
try {
return parseBatch(in, boundary, transformator);
} catch (IOException e) {
@ -72,7 +72,7 @@ public class BatchParser {
}
private List<List<Line>> splitBodyParts(final InputStream in, final String boundary) throws IOException,
BatchDeserializerException {
BatchDeserializerException {
final BatchLineReader reader = new BatchLineReader(in);
final List<Line> message = reader.toLineList();
reader.close();

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -35,7 +35,7 @@ public class BatchParserCommon {
private static final String PATTERN_BOUNDARY =
"([a-zA-Z0-9_\\-\\.'\\+]{1,70})|"
+ "\"([a-zA-Z0-9_\\-\\.'\\+\\s\\(\\),/:=\\?]{1,69}[a-zA-Z0-9_\\-\\.'\\+\\(\\),/:=\\?])\"";
+ "\"([a-zA-Z0-9_\\-\\.'\\+\\s\\(\\),/:=\\?]{1,69}[a-zA-Z0-9_\\-\\.'\\+\\(\\),/:=\\?])\"";
private static final Pattern PATTERN_LAST_CRLF = Pattern.compile("(.*)\\r\\n\\s*", Pattern.DOTALL);
private static final Pattern PATTERN_HEADER_LINE = Pattern.compile("([a-zA-Z\\-]+):\\s?(.*)\\s*");
@ -147,7 +147,7 @@ public class BatchParserCommon {
return messageParts;
}
private static void removeEndingCRLFFromList(List<Line> list) {
private static void removeEndingCRLFFromList(final List<Line> list) {
if (list.size() > 0) {
Line lastLine = list.remove(list.size() - 1);
list.add(removeEndingCRLF(lastLine));
@ -163,7 +163,7 @@ public class BatchParserCommon {
}
}
public static Header consumeHeaders(List<Line> remainingMessage) {
public static Header consumeHeaders(final List<Line> remainingMessage) {
final int headerLineNumber = remainingMessage.size() != 0 ? remainingMessage.get(0).getLineNumber() : 0;
final Header headers = new Header(headerLineNumber);
final Iterator<Line> iter = remainingMessage.iterator();
@ -189,7 +189,7 @@ public class BatchParserCommon {
return headers;
}
public static void consumeBlankLine(List<Line> remainingMessage, final boolean isStrict)
public static void consumeBlankLine(final List<Line> remainingMessage, final boolean isStrict)
throws BatchDeserializerException {
if (remainingMessage.size() > 0 && remainingMessage.get(0).toString().matches("\\s*\r?\n\\s*")) {
remainingMessage.remove(0);
@ -226,7 +226,7 @@ public class BatchParserCommon {
}
public static InputStream convertLineListToInputStream(final List<Line> list, final Charset charset,
final int length) {
final int length) {
final String message = trimLineListToLength(list, length);
return new ByteArrayInputStream(message.getBytes(charset));

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -30,8 +30,8 @@ import org.apache.olingo.commons.api.http.HttpHeader;
import org.apache.olingo.commons.api.http.HttpMethod;
import org.apache.olingo.server.api.ODataRequest;
import org.apache.olingo.server.api.deserializer.batch.BatchDeserializerException;
import org.apache.olingo.server.api.deserializer.batch.BatchRequestPart;
import org.apache.olingo.server.api.deserializer.batch.BatchDeserializerException.MessageKeys;
import org.apache.olingo.server.api.deserializer.batch.BatchRequestPart;
public class BatchRequestTransformator {
private static final Charset DEFAULT_CHARSET = Charset.forName("utf-8");
@ -100,7 +100,7 @@ public class BatchRequestTransformator {
private ODataRequest createRequest(final BatchQueryOperation operation, final String baseUri,
final boolean isChangeSet)
throws BatchDeserializerException {
throws BatchDeserializerException {
final HttpRequestStatusLine statusLine =
new HttpRequestStatusLine(operation.getHttpStatusLine(), baseUri, rawServiceResolutionUri);
statusLine.validateHttpMethod(isChangeSet);
@ -127,13 +127,13 @@ public class BatchRequestTransformator {
return request;
}
private Charset getCharset(BatchQueryOperation operation) {
private Charset getCharset(final BatchQueryOperation operation) {
String ct = operation.getHeaders().getHeader(HttpHeader.CONTENT_TYPE);
if(ct != null) {
if (ct != null) {
ContentType contentType = ContentType.parse(ct);
if(contentType != null) {
if (contentType != null) {
String charsetValue = contentType.getParameter(ContentType.PARAMETER_CHARSET);
if(charsetValue != null) {
if (charsetValue != null) {
return Charset.forName(charsetValue);
}
}
@ -153,8 +153,8 @@ public class BatchRequestTransformator {
}
private InputStream getBodyStream(final BatchQueryOperation operation, final HttpRequestStatusLine statusLine,
final Charset charset)
throws BatchDeserializerException {
final Charset charset)
throws BatchDeserializerException {
if (statusLine.getMethod().equals(HttpMethod.GET)) {
return new ByteArrayInputStream(new byte[0]);
} else {

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -26,9 +26,9 @@ import org.apache.olingo.server.api.deserializer.batch.BatchDeserializerExceptio
import org.apache.olingo.server.api.deserializer.batch.BatchDeserializerException.MessageKeys;
public class BatchTransformatorCommon {
private BatchTransformatorCommon() {
//Private Utility Constructor
// Private Utility Constructor
}
public static void validateContentType(final Header headers, final ContentType expected)

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -143,7 +143,7 @@ public class HttpRequestStatusLine {
}
public void validateHttpMethod(final boolean isChangeSet) throws BatchDeserializerException {
if(isChangeSet && !HTTP_CHANGE_SET_METHODS.contains(getMethod().toString())) {
if (isChangeSet && !HTTP_CHANGE_SET_METHODS.contains(getMethod().toString())) {
throw new BatchDeserializerException("Invalid change set method", MessageKeys.INVALID_CHANGESET_METHOD,
Integer.toString(statusLine.getLineNumber()));
}

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -93,7 +93,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
}
}
private EntityCollection consumeEntityCollectionNode(final EdmEntityType edmEntityType, ObjectNode tree,
private EntityCollection consumeEntityCollectionNode(final EdmEntityType edmEntityType, final ObjectNode tree,
final ExpandTreeBuilder expandBuilder) throws DeserializerException {
EntityCollection entitySet = new EntityCollection();
@ -185,7 +185,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
}
}
private ObjectNode parseJsonTree(InputStream stream) throws IOException, DeserializerException {
private ObjectNode parseJsonTree(final InputStream stream) throws IOException, DeserializerException {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationFeature.FAIL_ON_READING_DUP_TREE_KEY, true);
JsonParser parser = new JsonFactory(objectMapper).createParser(stream);
@ -227,7 +227,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
return parameters;
}
private Parameter createParameter(JsonNode node, final String paramName, final EdmParameter edmParameter)
private Parameter createParameter(final JsonNode node, final String paramName, final EdmParameter edmParameter)
throws DeserializerException {
Parameter parameter = new Parameter();
parameter.setName(paramName);
@ -265,8 +265,8 @@ public class ODataJsonDeserializer implements ODataDeserializer {
public Parameter parameter(final String content, final EdmParameter parameter) throws DeserializerException {
try {
JsonParser parser = new JsonFactory(new ObjectMapper()
.configure(DeserializationFeature.FAIL_ON_READING_DUP_TREE_KEY, true))
.createParser(content);
.configure(DeserializationFeature.FAIL_ON_READING_DUP_TREE_KEY, true))
.createParser(content);
JsonNode node = parser.getCodec().readTree(parser);
if (node == null) {
throw new DeserializerException("Invalid JSON syntax.",
@ -356,8 +356,8 @@ public class ODataJsonDeserializer implements ODataDeserializer {
* @param edmNavigationProperty related navigation property
* @throws DeserializerException if jsonNode is not null or if null but nullable or collection navigationProperty
*/
private void checkNotNullOrValidNull(JsonNode jsonNode,
EdmNavigationProperty edmNavigationProperty) throws DeserializerException {
private void checkNotNullOrValidNull(final JsonNode jsonNode,
final EdmNavigationProperty edmNavigationProperty) throws DeserializerException {
boolean isNullable = edmNavigationProperty.isNullable();
if ((jsonNode.isNull() && !isNullable) || (jsonNode.isNull() && edmNavigationProperty.isCollection())) {
throw new DeserializerException("Property: " + edmNavigationProperty.getName() + " must not be null.",
@ -365,32 +365,33 @@ public class ODataJsonDeserializer implements ODataDeserializer {
}
}
private Link createLink(ExpandTreeBuilder expandBuilder, String navigationPropertyName, JsonNode jsonNode,
EdmNavigationProperty edmNavigationProperty) throws DeserializerException {
private Link createLink(final ExpandTreeBuilder expandBuilder, final String navigationPropertyName,
final JsonNode jsonNode,
final EdmNavigationProperty edmNavigationProperty) throws DeserializerException {
Link link = new Link();
link.setTitle(navigationPropertyName);
final ExpandTreeBuilder childExpandBuilder = (expandBuilder != null) ?
expandBuilder.expand(edmNavigationProperty) : null;
if (jsonNode.isArray() && edmNavigationProperty.isCollection()) {
link.setType(Constants.ENTITY_SET_NAVIGATION_LINK_TYPE);
EntityCollection inlineEntitySet = new EntityCollection();
inlineEntitySet.getEntities().addAll(
consumeEntitySetArray(edmNavigationProperty.getType(), jsonNode, childExpandBuilder));
link.setInlineEntitySet(inlineEntitySet);
} else if (!jsonNode.isArray() && (!jsonNode.isValueNode() || jsonNode.isNull())
&& !edmNavigationProperty.isCollection()) {
link.setType(Constants.ENTITY_NAVIGATION_LINK_TYPE);
if (!jsonNode.isNull()) {
Entity inlineEntity = consumeEntityNode(edmNavigationProperty.getType(), (ObjectNode) jsonNode,
childExpandBuilder);
link.setInlineEntity(inlineEntity);
}
} else {
throw new DeserializerException("Invalid value: " + jsonNode.getNodeType()
+ " for expanded navigation property: " + navigationPropertyName,
MessageKeys.INVALID_VALUE_FOR_NAVIGATION_PROPERTY, navigationPropertyName);
}
return link;
if (jsonNode.isArray() && edmNavigationProperty.isCollection()) {
link.setType(Constants.ENTITY_SET_NAVIGATION_LINK_TYPE);
EntityCollection inlineEntitySet = new EntityCollection();
inlineEntitySet.getEntities().addAll(
consumeEntitySetArray(edmNavigationProperty.getType(), jsonNode, childExpandBuilder));
link.setInlineEntitySet(inlineEntitySet);
} else if (!jsonNode.isArray() && (!jsonNode.isValueNode() || jsonNode.isNull())
&& !edmNavigationProperty.isCollection()) {
link.setType(Constants.ENTITY_NAVIGATION_LINK_TYPE);
if (!jsonNode.isNull()) {
Entity inlineEntity = consumeEntityNode(edmNavigationProperty.getType(), (ObjectNode) jsonNode,
childExpandBuilder);
link.setInlineEntity(inlineEntity);
}
} else {
throw new DeserializerException("Invalid value: " + jsonNode.getNodeType()
+ " for expanded navigation property: " + navigationPropertyName,
MessageKeys.INVALID_VALUE_FOR_NAVIGATION_PROPERTY, navigationPropertyName);
}
return link;
}
private Link consumeBindingLink(final String key, final JsonNode jsonNode, final EdmEntityType edmEntityType)
@ -460,7 +461,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
private void consumePropertySingleNode(final String name, final EdmType type,
final boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale,
final boolean isUnicode, final EdmMapping mapping, final JsonNode jsonNode, final Property property)
throws DeserializerException {
throws DeserializerException {
switch (type.getKind()) {
case PRIMITIVE:
case DEFINITION:
@ -482,7 +483,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
private Object readComplexNode(final String name, final EdmType type, final boolean isNullable,
final JsonNode jsonNode)
throws DeserializerException {
throws DeserializerException {
// read and add all complex properties
ComplexValue value = readComplexValue(name, type, isNullable, jsonNode);
@ -498,7 +499,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
private void consumePropertyCollectionNode(final String name, final EdmType type,
final boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale,
final boolean isUnicode, final EdmMapping mapping, final JsonNode jsonNode, final Property property)
throws DeserializerException {
throws DeserializerException {
if (!jsonNode.isArray()) {
throw new DeserializerException("Value for property: " + name + " must be an array but is not.",
DeserializerException.MessageKeys.INVALID_JSON_TYPE_FOR_PROPERTY, name);
@ -516,9 +517,9 @@ public class ODataJsonDeserializer implements ODataDeserializer {
valueArray.add(value);
}
property.setValue(type.getKind() == EdmTypeKind.ENUM ?
ValueType.COLLECTION_ENUM :
ValueType.COLLECTION_PRIMITIVE,
valueArray);
ValueType.COLLECTION_ENUM :
ValueType.COLLECTION_PRIMITIVE,
valueArray);
break;
case COMPLEX:
while (iterator.hasNext()) {
@ -611,12 +612,12 @@ public class ODataJsonDeserializer implements ODataDeserializer {
final EdmPrimitiveType edmPrimitiveType =
type.getKind() == EdmTypeKind.ENUM ?
((EdmEnumType) type).getUnderlyingType() :
type.getKind() == EdmTypeKind.DEFINITION ?
((EdmTypeDefinition) type).getUnderlyingType() :
type;
return mapping == null || mapping.getMappedJavaClass() == null ?
edmPrimitiveType.getDefaultType() :
mapping.getMappedJavaClass();
type.getKind() == EdmTypeKind.DEFINITION ?
((EdmTypeDefinition) type).getUnderlyingType() :
type;
return mapping == null || mapping.getMappedJavaClass() == null ?
edmPrimitiveType.getDefaultType() :
mapping.getMappedJavaClass();
}
/**
@ -633,7 +634,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
}
}
private void removeAnnotations(ObjectNode tree) throws DeserializerException {
private void removeAnnotations(final ObjectNode tree) throws DeserializerException {
List<String> toRemove = new ArrayList<String>();
Iterator<Entry<String, JsonNode>> fieldsIterator = tree.fields();
while (fieldsIterator.hasNext()) {
@ -705,23 +706,23 @@ public class ODataJsonDeserializer implements ODataDeserializer {
private boolean matchNumberCase(final JsonNode node, final EdmPrimitiveTypeKind primKind) {
return node.isNumber() &&
(primKind == EdmPrimitiveTypeKind.Int16
|| primKind == EdmPrimitiveTypeKind.Int32
|| primKind == EdmPrimitiveTypeKind.Byte
|| primKind == EdmPrimitiveTypeKind.SByte
|| primKind == EdmPrimitiveTypeKind.Single
|| primKind == EdmPrimitiveTypeKind.Double);
(primKind == EdmPrimitiveTypeKind.Int16
|| primKind == EdmPrimitiveTypeKind.Int32
|| primKind == EdmPrimitiveTypeKind.Byte
|| primKind == EdmPrimitiveTypeKind.SByte
|| primKind == EdmPrimitiveTypeKind.Single
|| primKind == EdmPrimitiveTypeKind.Double);
}
private boolean matchTextualCase(final JsonNode node, final EdmPrimitiveTypeKind primKind) {
return node.isTextual() &&
(primKind == EdmPrimitiveTypeKind.String
|| primKind == EdmPrimitiveTypeKind.Binary
|| primKind == EdmPrimitiveTypeKind.Date
|| primKind == EdmPrimitiveTypeKind.DateTimeOffset
|| primKind == EdmPrimitiveTypeKind.Duration
|| primKind == EdmPrimitiveTypeKind.Guid
|| primKind == EdmPrimitiveTypeKind.TimeOfDay);
|| primKind == EdmPrimitiveTypeKind.Binary
|| primKind == EdmPrimitiveTypeKind.Date
|| primKind == EdmPrimitiveTypeKind.DateTimeOffset
|| primKind == EdmPrimitiveTypeKind.Duration
|| primKind == EdmPrimitiveTypeKind.Guid
|| primKind == EdmPrimitiveTypeKind.TimeOfDay);
}
@Override

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -115,7 +115,7 @@ public class ODataXmlDeserializer implements ODataDeserializer {
return value;
}
private Object complex(final XMLEventReader reader, final StartElement start, EdmComplexType edmComplex)
private Object complex(final XMLEventReader reader, final StartElement start, final EdmComplexType edmComplex)
throws XMLStreamException, EdmPrimitiveTypeException, DeserializerException {
ComplexValue value = new ComplexValue();
boolean foundEndProperty = false;
@ -165,7 +165,7 @@ public class ODataXmlDeserializer implements ODataDeserializer {
private Property property(final XMLEventReader reader, final StartElement start, final EdmType edmType,
final boolean isNullable, final Integer maxLength, final Integer precision,
final Integer scale, final boolean isUnicode, final boolean isCollection)
throws XMLStreamException, EdmPrimitiveTypeException, DeserializerException {
throws XMLStreamException, EdmPrimitiveTypeException, DeserializerException {
final Property property = new Property();
@ -182,7 +182,7 @@ public class ODataXmlDeserializer implements ODataDeserializer {
return property;
}
private ValueType getValueType(EdmType edmType, boolean isCollection) {
private ValueType getValueType(final EdmType edmType, final boolean isCollection) {
if (edmType instanceof EdmPrimitiveType) {
if (edmType instanceof EdmEnumType) {
return isCollection ? ValueType.COLLECTION_ENUM : ValueType.ENUM;
@ -231,7 +231,7 @@ public class ODataXmlDeserializer implements ODataDeserializer {
}
@Override
public DeserializerResult property(InputStream input, EdmProperty edmProperty)
public DeserializerResult property(final InputStream input, final EdmProperty edmProperty)
throws DeserializerException {
try {
final XMLEventReader reader = getReader(input);
@ -342,7 +342,7 @@ public class ODataXmlDeserializer implements ODataDeserializer {
}
}
private List<String> entityRefCollection(XMLEventReader reader, StartElement start)
private List<String> entityRefCollection(final XMLEventReader reader, final StartElement start)
throws XMLStreamException {
boolean foundEndElement = false;
ArrayList<String> references = new ArrayList<String>();
@ -360,7 +360,7 @@ public class ODataXmlDeserializer implements ODataDeserializer {
return references;
}
private String entityRef(XMLEventReader reader, StartElement start) throws XMLStreamException {
private String entityRef(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
boolean foundEndElement = false;
final Attribute entityRefId = start.getAttributeByName(Constants.QNAME_ATOM_ATTR_ID);
while (reader.hasNext() && !foundEndElement) {
@ -388,7 +388,7 @@ public class ODataXmlDeserializer implements ODataDeserializer {
private void properties(final XMLEventReader reader, final StartElement start, final Entity entity,
final EdmEntityType edmEntityType)
throws XMLStreamException, EdmPrimitiveTypeException, DeserializerException {
throws XMLStreamException, EdmPrimitiveTypeException, DeserializerException {
boolean foundEndProperties = false;
while (reader.hasNext() && !foundEndProperties) {
@ -547,7 +547,7 @@ public class ODataXmlDeserializer implements ODataDeserializer {
}
@Override
public DeserializerResult entity(InputStream input, EdmEntityType edmEntityType)
public DeserializerResult entity(final InputStream input, final EdmEntityType edmEntityType)
throws DeserializerException {
try {
final XMLEventReader reader = getReader(input);
@ -633,7 +633,7 @@ public class ODataXmlDeserializer implements ODataDeserializer {
}
@Override
public DeserializerResult entityCollection(InputStream input, EdmEntityType edmEntityType)
public DeserializerResult entityCollection(final InputStream input, final EdmEntityType edmEntityType)
throws DeserializerException {
try {
final XMLEventReader reader = getReader(input);
@ -654,7 +654,7 @@ public class ODataXmlDeserializer implements ODataDeserializer {
}
@Override
public DeserializerResult entityReferences(InputStream stream) throws DeserializerException {
public DeserializerResult entityReferences(final InputStream stream) throws DeserializerException {
try {
XMLEventReader reader = getReader(stream);
ArrayList<URI> references = new ArrayList<URI>();
@ -677,7 +677,7 @@ public class ODataXmlDeserializer implements ODataDeserializer {
}
@Override
public DeserializerResult actionParameters(InputStream stream, EdmAction edmAction)
public DeserializerResult actionParameters(final InputStream stream, final EdmAction edmAction)
throws DeserializerException {
Map<String, Parameter> parameters = new LinkedHashMap<String, Parameter>();
if (edmAction.getParameterNames() == null || edmAction.getParameterNames().isEmpty()
@ -724,8 +724,8 @@ public class ODataXmlDeserializer implements ODataDeserializer {
}
}
private void consumeParameters(EdmAction edmAction, XMLEventReader reader,
StartElement start, Map<String, Parameter> parameters) throws DeserializerException,
private void consumeParameters(final EdmAction edmAction, final XMLEventReader reader,
final StartElement start, final Map<String, Parameter> parameters) throws DeserializerException,
EdmPrimitiveTypeException, XMLStreamException {
List<String> parameterNames = edmAction.getParameterNames();
@ -763,8 +763,8 @@ public class ODataXmlDeserializer implements ODataDeserializer {
}
}
private Parameter createParameter(XMLEventReader reader, StartElement start, String paramName,
EdmParameter edmParameter) throws DeserializerException, EdmPrimitiveTypeException, XMLStreamException {
private Parameter createParameter(final XMLEventReader reader, final StartElement start, final String paramName,
final EdmParameter edmParameter) throws DeserializerException, EdmPrimitiveTypeException, XMLStreamException {
Parameter parameter = new Parameter();
parameter.setName(paramName);

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -29,7 +29,7 @@ public class ETagHelperImpl implements ETagHelper {
@Override
public boolean checkReadPreconditions(final String eTag,
final Collection<String> ifMatchHeaders, final Collection<String> ifNoneMatchHeaders)
throws PreconditionException {
throws PreconditionException {
if (eTag != null) {
final ETagInformation ifMatch = createETagInformation(ifMatchHeaders);
if (!ifMatch.isMatchedBy(eTag) && !ifMatch.getETags().isEmpty()) {
@ -44,7 +44,7 @@ public class ETagHelperImpl implements ETagHelper {
@Override
public void checkChangePreconditions(final String eTag,
final Collection<String> ifMatchHeaders, final Collection<String> ifNoneMatchHeaders)
throws PreconditionException {
throws PreconditionException {
if (eTag != null) {
final ETagInformation ifMatch = createETagInformation(ifMatchHeaders);
final ETagInformation ifNoneMatch = createETagInformation(ifNoneMatchHeaders);

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -31,21 +31,21 @@ import java.util.regex.Pattern;
* <p>See <a href="https://www.ietf.org/rfc/rfc7232.txt">RFC 7232</a> for details;
* there the following grammar is defined:</p>
* <pre>
* If-Match = "*" / 1#entity-tag
* If-None-Match = "*" / 1#entity-tag
* entity-tag = [ weak ] opaque-tag
* weak = %x57.2F ; "W/", case-sensitive
* opaque-tag = DQUOTE *etagc DQUOTE
* etagc = %x21 / %x23-7E / %x80-FF
* If-Match = "*" / 1#entity-tag
* If-None-Match = "*" / 1#entity-tag
* entity-tag = [ weak ] opaque-tag
* weak = %x57.2F ; "W/", case-sensitive
* opaque-tag = DQUOTE *etagc DQUOTE
* etagc = %x21 / %x23-7E / %x80-FF
* </pre>
* <p>Values with illegal syntax do not contribute to the result but no exception is thrown.</p>
*/
public class ETagParser {
private static final Pattern ETAG = Pattern.compile("\\s*(,\\s*)+|((?:W/)?\"[!#-~\\x80-\\xFF]*\")");
private ETagParser (){
//Private constructor for utility classes
private ETagParser() {
// Private constructor for utility classes
}
protected static Collection<String> parse(final Collection<String> values) {

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -42,7 +42,7 @@ public class PreconditionsValidator {
return affectedEntitySetOrSingleton != null
&& (isMediaValue ?
customETagSupport.hasMediaETag(affectedEntitySetOrSingleton) :
customETagSupport.hasETag(affectedEntitySetOrSingleton));
customETagSupport.hasETag(affectedEntitySetOrSingleton));
}
private EdmBindingTarget extractInformation(final UriInfo uriInfo) throws PreconditionException {
@ -87,7 +87,7 @@ public class PreconditionsValidator {
return lastFoundEntitySetOrSingleton;
}
private EdmBindingTarget getEntitySetFromFunctionImport(UriResourceFunction uriResourceFunction) {
private EdmBindingTarget getEntitySetFromFunctionImport(final UriResourceFunction uriResourceFunction) {
EdmFunctionImport functionImport = uriResourceFunction.getFunctionImport();
if (functionImport != null && functionImport.getReturnedEntitySet() != null
&& !uriResourceFunction.isCollection()) {
@ -96,12 +96,12 @@ public class PreconditionsValidator {
return null;
}
private EdmBindingTarget getEntitySet(UriResourceEntitySet uriResourceEntitySet) {
private EdmBindingTarget getEntitySet(final UriResourceEntitySet uriResourceEntitySet) {
return uriResourceEntitySet.isCollection() ? null : uriResourceEntitySet.getEntitySet();
}
private EdmBindingTarget getEntitySetFromNavigation(EdmBindingTarget lastFoundEntitySetOrSingleton,
UriResourceNavigation uriResourceNavigation) {
private EdmBindingTarget getEntitySetFromNavigation(final EdmBindingTarget lastFoundEntitySetOrSingleton,
final UriResourceNavigation uriResourceNavigation) {
if (lastFoundEntitySetOrSingleton != null && !uriResourceNavigation.isCollection()) {
EdmNavigationProperty navProp = uriResourceNavigation.getProperty();
return lastFoundEntitySetOrSingleton.getRelatedBindingTarget(navProp.getName());

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -33,18 +33,18 @@ import org.apache.olingo.server.api.prefer.Preferences.Preference;
* <p>See <a href="https://www.ietf.org/rfc/rfc7240.txt">RFC 7240</a> for details;
* there the following grammar is defined:</p>
* <pre>
* Prefer = "Prefer" ":" 1#preference
* preference = token [ BWS "=" BWS word ] *( OWS ";" [ OWS parameter ] )
* parameter = token [ BWS "=" BWS word ]
* token = 1*tchar
* tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*"
/ "+" / "-" / "." / "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA
* word = token / quoted-string
* quoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE
* qdtext = HTAB / SP / %x21 / %x23-5B / %x5D-7E / %x80-FF
* quoted-pair = "\" ( HTAB / SP / %x21-7E / %x80-FF )
* OWS = *( SP / HTAB ) ; optional whitespace
* BWS = OWS ; "bad" whitespace
* Prefer = "Prefer" ":" 1#preference
* preference = token [ BWS "=" BWS word ] *( OWS ";" [ OWS parameter ] )
* parameter = token [ BWS "=" BWS word ]
* token = 1*tchar
* tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*"
* / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA
* word = token / quoted-string
* quoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE
* qdtext = HTAB / SP / %x21 / %x23-5B / %x5D-7E / %x80-FF
* quoted-pair = "\" ( HTAB / SP / %x21-7E / %x80-FF )
* OWS = *( SP / HTAB ) ; optional whitespace
* BWS = OWS ; "bad" whitespace
* </pre>
* <p>Values with illegal syntax do not contribute to the result but no exception is thrown.</p>
*/
@ -58,9 +58,9 @@ public class PreferParser {
private static final Pattern PREFERENCE = Pattern.compile("\\s*(,\\s*)+|"
+ "(?:" + namedValue + "((?:\\s*;\\s*(?:" + namedValue + ")?)*))");
private static final Pattern PARAMETER = Pattern.compile("\\s*(;\\s*)+|(?:" + namedValue + ")");
private PreferParser (){
//Private constructor for utility classes
private PreferParser() {
// Private constructor for utility classes
}
protected static Map<String, Preference> parse(final Collection<String> values) {
@ -77,7 +77,7 @@ public class PreferParser {
return result;
}
private static void parse(final String value, Map<String, Preference> result) {
private static void parse(final String value, final Map<String, Preference> result) {
Map<String, Preference> partResult = new HashMap<String, Preference>();
String separator = "";
int start = 0;
@ -90,13 +90,13 @@ public class PreferParser {
final String name = matcher.group(2).toLowerCase(Locale.ROOT);
// RFC 7240:
// If any preference is specified more than once, only the first instance is to be
// considered. All subsequent occurrences SHOULD be ignored without signaling
// considered. All subsequent occurrences SHOULD be ignored without signaling
// an error or otherwise altering the processing of the request.
if (!partResult.containsKey(name)) {
final String preferenceValue = getValue(matcher.group(3));
final Map<String, String> parameters =
matcher.group(4) == null || matcher.group(4).isEmpty() ? null :
parseParameters(matcher.group(4));
parseParameters(matcher.group(4));
partResult.put(name, new Preference(preferenceValue, parameters));
}
separator = null;

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -41,14 +41,17 @@ public class PreferencesImpl implements Preferences {
preferences = PreferParser.parse(preferHeaders);
}
@Override
public Preference getPreference(final String name) {
return preferences.get(name.toLowerCase(Locale.ROOT));
}
@Override
public boolean hasAllowEntityReferences() {
return preferences.containsKey(PreferenceName.ALLOW_ENTITY_REFERENCES.getName());
}
@Override
public URI getCallback() {
if (preferences.containsKey(PreferenceName.CALLBACK.getName())
&& preferences.get(PreferenceName.CALLBACK.getName()).getParameters() != null
@ -62,18 +65,22 @@ public class PreferencesImpl implements Preferences {
return null;
}
@Override
public boolean hasContinueOnError() {
return preferences.containsKey(PreferenceName.CONTINUE_ON_ERROR.getName());
}
@Override
public Integer getMaxPageSize() {
return getNonNegativeIntegerPreference(PreferenceName.MAX_PAGE_SIZE.getName());
}
@Override
public boolean hasTrackChanges() {
return preferences.containsKey(PreferenceName.TRACK_CHANGES.getName());
}
@Override
public Return getReturn() {
if (preferences.containsKey(PreferenceName.RETURN.getName())) {
final String value = preferences.get(PreferenceName.RETURN.getName()).getValue();
@ -86,10 +93,12 @@ public class PreferencesImpl implements Preferences {
return null;
}
@Override
public boolean hasRespondAsync() {
return preferences.containsKey(PreferenceName.RESPOND_ASYNC.getName());
}
@Override
public Integer getWait() {
return getNonNegativeIntegerPreference(PreferenceName.WAIT.getName());
}

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -28,7 +28,8 @@ public abstract class AbstractODataSerializer implements ODataSerializer {
protected static final String IO_EXCEPTION_TEXT = "An I/O exception occurred.";
protected void closeCircleStreamBufferOutput(OutputStream outputStream, SerializerException cachedException)
protected void closeCircleStreamBufferOutput(final OutputStream outputStream,
final SerializerException cachedException)
throws SerializerException {
if (outputStream != null) {
try {

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -18,10 +18,6 @@
*/
package org.apache.olingo.server.core.serializer;
import org.apache.olingo.commons.api.http.HttpStatusCode;
import org.apache.olingo.server.api.ODataResponse;
import org.apache.olingo.server.api.serializer.SerializerException;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@ -34,6 +30,10 @@ import java.nio.channels.WritableByteChannel;
import java.util.List;
import java.util.Map;
import org.apache.olingo.commons.api.http.HttpStatusCode;
import org.apache.olingo.server.api.ODataResponse;
import org.apache.olingo.server.api.serializer.SerializerException;
public class AsyncResponseSerializer {
private static final int BUFFER_SIZE = 8192;
private static final String COLON = ":";
@ -59,10 +59,10 @@ public class AsyncResponseSerializer {
}
private void appendResponseHeader(final ODataResponse response,
final ByteArrayOutputStream buffer) throws IOException {
final ByteArrayOutputStream buffer) throws IOException {
final Map<String, List<String>> header = response.getAllHeaders();
for (final Map.Entry<String, List<String>> entry: header.entrySet()) {
for (final Map.Entry<String, List<String>> entry : header.entrySet()) {
appendHeader(entry.getKey(), entry.getValue(), buffer);
}
}
@ -80,7 +80,7 @@ public class AsyncResponseSerializer {
append(HTTP_VERSION + SP + response.getStatusCode() + SP + status + CRLF, buffer);
}
private void appendBody(ODataResponse response, ByteArrayOutputStream buffer) throws IOException {
private void appendBody(final ODataResponse response, final ByteArrayOutputStream buffer) throws IOException {
InputStream input = response.getContent();
if (input != null) {
ByteBuffer inBuffer = ByteBuffer.allocate(BUFFER_SIZE);

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -110,24 +110,24 @@ public class BatchResponseSerializer {
private void appendHeader(final String name, final String value, final BodyBuilder builder) {
builder.append(name)
.append(COLON)
.append(SP)
.append(value)
.append(CRLF);
.append(COLON)
.append(SP)
.append(value)
.append(CRLF);
}
private void appendStatusLine(final ODataResponse response, final BodyBuilder builder) {
builder.append("HTTP/1.1")
.append(SP)
.append(response.getStatusCode())
.append(SP)
.append(getStatusCodeInfo(response))
.append(CRLF);
.append(SP)
.append(response.getStatusCode())
.append(SP)
.append(getStatusCodeInfo(response))
.append(CRLF);
}
private String getStatusCodeInfo(ODataResponse response) {
private String getStatusCodeInfo(final ODataResponse response) {
HttpStatusCode status = HttpStatusCode.fromStatusCode(response.getStatusCode());
if(status == null) {
if (status == null) {
throw new ODataRuntimeException("Invalid status code in response '" + response.getStatusCode() + "'");
}
return status.getInfo();
@ -189,17 +189,17 @@ public class BatchResponseSerializer {
return tmp;
}
public BodyBuilder append(String string) {
byte [] b = string.getBytes(CHARSET_ISO_8859_1);
public BodyBuilder append(final String string) {
byte[] b = string.getBytes(CHARSET_ISO_8859_1);
put(b);
return this;
}
private void put(byte[] b) {
if(isClosed) {
private void put(final byte[] b) {
if (isClosed) {
throw new RuntimeException("BodyBuilder is closed.");
}
if(buffer.remaining() < b.length) {
if (buffer.remaining() < b.length) {
buffer.flip();
int newSize = (buffer.limit() * 2) + b.length;
ByteBuffer tmp = ByteBuffer.allocate(newSize);
@ -209,15 +209,16 @@ public class BatchResponseSerializer {
buffer.put(b);
}
public BodyBuilder append(int statusCode) {
public BodyBuilder append(final int statusCode) {
return append(String.valueOf(statusCode));
}
public BodyBuilder append(Body body) {
public BodyBuilder append(final Body body) {
put(body.getContent());
return this;
}
@Override
public String toString() {
return new String(buffer.array(), 0, buffer.position(), CHARSET_ISO_8859_1);
}
@ -229,8 +230,8 @@ public class BatchResponseSerializer {
private class Body {
private final byte[] content;
public Body(ODataResponse response) {
this.content = getBody(response);
public Body(final ODataResponse response) {
content = getBody(response);
}
public int getLength() {

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -67,7 +67,7 @@ public class FixedFormatSerializerImpl implements FixedFormatSerializer {
}
@Override
public InputStream asyncResponse(ODataResponse odataResponse) throws SerializerException {
public InputStream asyncResponse(final ODataResponse odataResponse) throws SerializerException {
AsyncResponseSerializer serializer = new AsyncResponseSerializer();
return serializer.serialize(odataResponse);
}

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -78,8 +78,8 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
private final boolean isODataMetadataNone;
public ODataJsonSerializer(final ContentType contentType) {
this.isIEEE754Compatible = isODataIEEE754Compatible(contentType);
this.isODataMetadataNone = ContentTypeHelper.isODataMetadataNone(contentType);
isIEEE754Compatible = isODataIEEE754Compatible(contentType);
isODataMetadataNone = ContentTypeHelper.isODataMetadataNone(contentType);
}
@Override
@ -187,9 +187,9 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
JsonGenerator json = new JsonFactory().createGenerator(outputStream);
writeEntity(metadata, entityType, entity, contextURL,
options == null ? null : options.getExpand(),
options == null ? null : options.getSelect(),
options == null ? false : options.getWriteOnlyReferences(),
json);
options == null ? null : options.getSelect(),
options == null ? false : options.getWriteOnlyReferences(),
json);
json.close();
outputStream.close();
@ -232,7 +232,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
protected void writeEntity(final ServiceMetadata metadata, final EdmEntityType entityType,
final Entity entity, final ContextURL contextURL, final ExpandOption expand,
final SelectOption select, final boolean onlyReference, final JsonGenerator json)
throws IOException, SerializerException {
throws IOException, SerializerException {
json.writeStartObject();
if (!isODataMetadataNone) {
if (contextURL != null) { // top-level entity
@ -291,7 +291,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
}
throw new SerializerException("Wrong base type",
SerializerException.MessageKeys.WRONG_BASE_TYPE, derivedTypeName, baseType
.getFullQualifiedName().getFullQualifiedNameAsString());
.getFullQualifiedName().getFullQualifiedNameAsString());
}
protected EdmComplexType resolveComplexType(final ServiceMetadata metadata, final EdmComplexType baseType,
@ -315,21 +315,21 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
}
throw new SerializerException("Wrong base type",
SerializerException.MessageKeys.WRONG_BASE_TYPE, derivedTypeName, baseType
.getFullQualifiedName().getFullQualifiedNameAsString());
.getFullQualifiedName().getFullQualifiedNameAsString());
}
protected void writeProperties(final EdmStructuredType type, final List<Property> properties,
final SelectOption select, final JsonGenerator json)
throws IOException, SerializerException {
throws IOException, SerializerException {
final boolean all = ExpandSelectHelper.isAll(select);
final Set<String> selected = all ? new HashSet<String>() :
ExpandSelectHelper.getSelectedPropertyNames(select.getSelectItems());
ExpandSelectHelper.getSelectedPropertyNames(select.getSelectItems());
for (final String propertyName : type.getPropertyNames()) {
if (all || selected.contains(propertyName)) {
final EdmProperty edmProperty = type.getStructuralProperty(propertyName);
final Property property = findProperty(propertyName, properties);
final Set<List<String>> selectedPaths = all || edmProperty.isPrimitive() ? null :
ExpandSelectHelper.getSelectedPaths(select.getSelectItems(), propertyName);
ExpandSelectHelper.getSelectedPaths(select.getSelectItems(), propertyName);
writeProperty(edmProperty, property, selectedPaths, json);
}
}
@ -341,20 +341,20 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
if (ExpandSelectHelper.hasExpand(expand)) {
final boolean expandAll = ExpandSelectHelper.isExpandAll(expand);
final Set<String> expanded = expandAll ? new HashSet<String>() :
ExpandSelectHelper.getExpandedPropertyNames(expand.getExpandItems());
ExpandSelectHelper.getExpandedPropertyNames(expand.getExpandItems());
for (final String propertyName : type.getNavigationPropertyNames()) {
if (expandAll || expanded.contains(propertyName)) {
final EdmNavigationProperty property = type.getNavigationProperty(propertyName);
final Link navigationLink = linked.getNavigationLink(property.getName());
final ExpandItem innerOptions = expandAll ? null :
ExpandSelectHelper.getExpandItem(expand.getExpandItems(), propertyName);
ExpandSelectHelper.getExpandItem(expand.getExpandItems(), propertyName);
if (innerOptions != null && innerOptions.getLevelsOption() != null) {
throw new SerializerException("Expand option $levels is not supported.",
SerializerException.MessageKeys.NOT_IMPLEMENTED);
}
writeExpandedNavigationProperty(metadata, property, navigationLink,
innerOptions == null ? null : innerOptions.getExpandOption(),
innerOptions == null ? null : innerOptions.getSelectOption(), json);
innerOptions == null ? null : innerOptions.getSelectOption(), json);
}
}
}
@ -384,17 +384,17 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
protected void writeProperty(final EdmProperty edmProperty, final Property property,
final Set<List<String>> selectedPaths, final JsonGenerator json)
throws IOException, SerializerException {
throws IOException, SerializerException {
json.writeFieldName(edmProperty.getName());
if (property == null || property.isNull()) {
if (edmProperty.isNullable() == Boolean.FALSE) {
throw new SerializerException("Non-nullable property not present!",
SerializerException.MessageKeys.MISSING_PROPERTY, edmProperty.getName());
} else {
if(edmProperty.isCollection()){
if (edmProperty.isCollection()) {
json.writeStartArray();
json.writeEndArray();
}else {
} else {
json.writeNull();
}
}
@ -405,7 +405,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
private void writePropertyValue(final EdmProperty edmProperty,
final Property property, final Set<List<String>> selectedPaths, final JsonGenerator json)
throws IOException, SerializerException {
throws IOException, SerializerException {
final EdmType type = edmProperty.getType();
try {
if (edmProperty.isPrimitive()
@ -439,7 +439,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
private void writePrimitiveCollection(final EdmPrimitiveType type, final Property property,
final Boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale,
final Boolean isUnicode, final JsonGenerator json)
throws IOException, SerializerException {
throws IOException, SerializerException {
json.writeStartArray();
for (Object value : property.asCollection()) {
switch (property.getValueType()) {
@ -466,7 +466,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
private void writeComplexCollection(final EdmComplexType type, final Property property,
final Set<List<String>> selectedPaths, final JsonGenerator json)
throws IOException, SerializerException {
throws IOException, SerializerException {
json.writeStartArray();
for (Object value : property.asCollection()) {
switch (property.getValueType()) {
@ -484,7 +484,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
private void writePrimitive(final EdmPrimitiveType type, final Property property,
final Boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale,
final Boolean isUnicode, final JsonGenerator json)
throws EdmPrimitiveTypeException, IOException, SerializerException {
throws EdmPrimitiveTypeException, IOException, SerializerException {
if (property.isPrimitive()) {
writePrimitiveValue(type, property.asPrimitive(),
isNullable, maxLength, precision, scale, isUnicode, json);
@ -526,14 +526,14 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
protected void writeComplexValue(final EdmComplexType type, final List<Property> properties,
final Set<List<String>> selectedPaths, final JsonGenerator json)
throws IOException, SerializerException {
throws IOException, SerializerException {
json.writeStartObject();
for (final String propertyName : type.getPropertyNames()) {
final Property property = findProperty(propertyName, properties);
if (selectedPaths == null || ExpandSelectHelper.isSelected(selectedPaths, propertyName)) {
writeProperty((EdmProperty) type.getProperty(propertyName), property,
selectedPaths == null ? null : ExpandSelectHelper.getReducedSelectedPaths(selectedPaths, propertyName),
json);
json);
}
}
json.writeEndObject();
@ -567,10 +567,10 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
json.writeFieldName(Constants.VALUE);
writePrimitive(type, property,
options == null ? null : options.isNullable(),
options == null ? null : options.getMaxLength(),
options == null ? null : options.getPrecision(),
options == null ? null : options.getScale(),
options == null ? null : options.isUnicode(), json);
options == null ? null : options.getMaxLength(),
options == null ? null : options.getPrecision(),
options == null ? null : options.getScale(),
options == null ? null : options.isUnicode(), json);
}
json.writeEndObject();
@ -610,16 +610,16 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
}
final List<Property> values =
property.isNull() ? Collections.<Property> emptyList() : property.asComplex().getValue();
writeProperties(type, values, options == null ? null : options.getSelect(), json);
if (!property.isNull() && property.isComplex()) {
writeNavigationProperties(metadata, type, property.asComplex(),
options == null ? null : options.getExpand(), json);
}
json.writeEndObject();
writeProperties(type, values, options == null ? null : options.getSelect(), json);
if (!property.isNull() && property.isComplex()) {
writeNavigationProperties(metadata, type, property.asComplex(),
options == null ? null : options.getExpand(), json);
}
json.writeEndObject();
json.close();
outputStream.close();
return SerializerResultImpl.with().content(buffer.getInputStream()).build();
json.close();
outputStream.close();
return SerializerResultImpl.with().content(buffer.getInputStream()).build();
} catch (final IOException e) {
cachedException =
new SerializerException(IO_EXCEPTION_TEXT, e, SerializerException.MessageKeys.IO_EXCEPTION);
@ -645,10 +645,10 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
json.writeFieldName(Constants.VALUE);
writePrimitiveCollection(type, property,
options == null ? null : options.isNullable(),
options == null ? null : options.getMaxLength(),
options == null ? null : options.getPrecision(),
options == null ? null : options.getScale(),
options == null ? null : options.isUnicode(), json);
options == null ? null : options.getMaxLength(),
options == null ? null : options.getPrecision(),
options == null ? null : options.getScale(),
options == null ? null : options.isUnicode(), json);
json.writeEndObject();
json.close();
@ -725,7 +725,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
@Override
public SerializerResult referenceCollection(final ServiceMetadata metadata, final EdmEntitySet edmEntitySet,
final EntityCollection entityCollection, final ReferenceCollectionSerializerOptions options)
throws SerializerException {
throws SerializerException {
OutputStream outputStream = null;
SerializerException cachedException = null;
@ -767,13 +767,13 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
}
private void writeContextURL(final ContextURL contextURL, JsonGenerator json) throws IOException {
private void writeContextURL(final ContextURL contextURL, final JsonGenerator json) throws IOException {
if (!isODataMetadataNone && contextURL != null) {
json.writeStringField(Constants.JSON_CONTEXT, ContextURLBuilder.create(contextURL).toASCIIString());
}
}
private void writeMetadataETag(final ServiceMetadata metadata, JsonGenerator json) throws IOException {
private void writeMetadataETag(final ServiceMetadata metadata, final JsonGenerator json) throws IOException {
if (!isODataMetadataNone
&& metadata != null
&& metadata.getServiceMetadataETagSupport() != null
@ -783,7 +783,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
}
}
private void writeCount(final EntityCollection entityCollection, JsonGenerator json) throws IOException {
private void writeCount(final EntityCollection entityCollection, final JsonGenerator json) throws IOException {
if (entityCollection.getCount() != null) {
if (isIEEE754Compatible) {
json.writeStringField(Constants.JSON_COUNT, entityCollection.getCount().toString());
@ -793,7 +793,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
}
}
private void writeNextLink(final EntityCollection entitySet, JsonGenerator json) throws IOException {
private void writeNextLink(final EntityCollection entitySet, final JsonGenerator json) throws IOException {
if (entitySet.getNext() != null) {
json.writeStringField(Constants.JSON_NEXT_LINK, entitySet.getNext().toASCIIString());
}

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -58,8 +58,8 @@ public class ServiceDocumentJsonSerializer {
if (!isODataMetadataNone) {
final String metadataUri =
(serviceRoot == null ? "" :
serviceRoot.endsWith("/") ? serviceRoot : (serviceRoot + "/"))
+ Constants.METADATA;
serviceRoot.endsWith("/") ? serviceRoot : (serviceRoot + "/"))
+ Constants.METADATA;
gen.writeObjectField(Constants.JSON_CONTEXT, metadataUri);
if (metadata != null
@ -100,9 +100,9 @@ public class ServiceDocumentJsonSerializer {
}
}
private void writeElement(JsonGenerator gen, final String kind, final String reference, final String name,
private void writeElement(final JsonGenerator gen, final String kind, final String reference, final String name,
final String title)
throws IOException {
throws IOException {
gen.writeStartObject();
gen.writeObjectField(Constants.JSON_NAME, name);
if (title != null) {

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -21,13 +21,13 @@ package org.apache.olingo.server.core.serializer.utils;
import org.apache.olingo.commons.api.format.ContentType;
public class ContentTypeHelper {
private ContentTypeHelper (){
//Private constructor for utility classes
private ContentTypeHelper() {
// Private constructor for utility classes
}
public static boolean isODataMetadataNone(final ContentType contentType) {
return contentType.isCompatible(ContentType.APPLICATION_JSON)
&& ContentType.VALUE_ODATA_METADATA_NONE.equals(contentType.getParameter(ContentType.PARAMETER_ODATA_METADATA));
return contentType.isCompatible(ContentType.APPLICATION_JSON)
&& ContentType.VALUE_ODATA_METADATA_NONE.equals(contentType.getParameter(ContentType.PARAMETER_ODATA_METADATA));
}
}

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -31,17 +31,17 @@ import org.apache.olingo.commons.core.Encoder;
*/
public final class ContextURLBuilder {
private ContextURLBuilder() { /* private ctor for helper class */ }
private ContextURLBuilder() { /* private ctor for helper class */}
public static URI create(final ContextURL contextURL) {
StringBuilder result = new StringBuilder();
if (contextURL.getServiceRoot() != null) {
result.append(contextURL.getServiceRoot());
} else if(contextURL.getODataPath() != null) {
} else if (contextURL.getODataPath() != null) {
String oDataPath = contextURL.getODataPath();
char[] chars = oDataPath.toCharArray();
for (int i = 1; i < chars.length-1; i++) {
if(chars[i] == '/' && chars[i-1] != '/') {
for (int i = 1; i < chars.length - 1; i++) {
if (chars[i] == '/' && chars[i - 1] != '/') {
result.append("../");
}
}
@ -52,8 +52,8 @@ public final class ContextURLBuilder {
result.append('#');
if (contextURL.isCollection()) {
result.append("Collection(")
.append(Encoder.encode(contextURL.getEntitySetOrSingletonOrType()))
.append(")");
.append(Encoder.encode(contextURL.getEntitySetOrSingletonOrType()))
.append(")");
} else {
result.append(Encoder.encode(contextURL.getEntitySetOrSingletonOrType()));
}
@ -79,9 +79,9 @@ public final class ContextURLBuilder {
}
if (contextURL.isCollection()) {
result.append('#')
.append("Collection(")
.append(ContextURL.Suffix.REFERENCE.getRepresentation())
.append(")");
.append("Collection(")
.append(ContextURL.Suffix.REFERENCE.getRepresentation())
.append(")");
} else {
result.append('#').append(ContextURL.Suffix.REFERENCE.getRepresentation());
}

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -38,7 +38,7 @@ import org.apache.olingo.server.api.uri.queryoption.SelectOption;
public final class ContextURLHelper {
private ContextURLHelper() { /* private ctor for helper class */ }
private ContextURLHelper() { /* private ctor for helper class */}
/**
* Builds a list of selected Properties for the ContextURL,
@ -123,12 +123,12 @@ public final class ContextURLHelper {
}
} else {
final List<UriResource> resourceParts = expandItem.getResourcePath().getUriResourceParts();
if(resourceParts.size() > 1) {
if (resourceParts.size() > 1) {
if (result.length() > 0) {
result.append(',');
}
}
final List<String> path = getPropertyPath(resourceParts);
String propertyPath = buildPropertyPath(path);
String propertyPath = buildPropertyPath(path);
result.append(Encoder.encode(propertyName));
result.append("/").append(propertyPath);
}
@ -152,8 +152,9 @@ public final class ContextURLHelper {
for (final String segment : path) {
result.append(result.length() == 0 ? "" : '/').append(Encoder.encode(segment)); //$NON-NLS-1$
}
return result.length() == 0?null:result.toString();
}
return result.length() == 0 ? null : result.toString();
}
private static List<List<String>> getComplexSelectedPaths(final EdmProperty edmProperty,
final Set<List<String>> selectedPaths) {
List<List<String>> result = new ArrayList<List<String>>();

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -226,7 +226,7 @@ public class MetadataDocumentXmlSerializer {
writer.writeEndElement();
}
private void appendTerms(XMLStreamWriter writer, List<EdmTerm> terms) throws XMLStreamException {
private void appendTerms(final XMLStreamWriter writer, final List<EdmTerm> terms) throws XMLStreamException {
for (EdmTerm term : terms) {
writer.writeStartElement(XML_TERM_ATT);
@ -238,15 +238,15 @@ public class MetadataDocumentXmlSerializer {
writer.writeAttribute(XML_BASE_TERM, getAliasedFullQualifiedName(term.getBaseTerm().getFullQualifiedName(),
false));
}
if(term.getAppliesTo() != null && !term.getAppliesTo().isEmpty()){
if (term.getAppliesTo() != null && !term.getAppliesTo().isEmpty()) {
String appliesToString = "";
boolean first = true;
for(TargetType target : term.getAppliesTo()){
if(first){
for (TargetType target : term.getAppliesTo()) {
if (first) {
first = false;
appliesToString = target.toString();
}else{
} else {
appliesToString = appliesToString + " " + target.toString();
}
}
@ -273,20 +273,20 @@ public class MetadataDocumentXmlSerializer {
if (term.getScale() != null) {
writer.writeAttribute(XML_SCALE, "" + term.getScale());
}
appendAnnotations(writer, term);
writer.writeEndElement();
}
}
private void appendAnnotationGroups(XMLStreamWriter writer, List<EdmAnnotations> annotationGroups)
private void appendAnnotationGroups(final XMLStreamWriter writer, final List<EdmAnnotations> annotationGroups)
throws XMLStreamException {
for (EdmAnnotations annotationGroup : annotationGroups) {
appendAnnotationGroup(writer, annotationGroup);
}
}
private void appendAnnotationGroup(XMLStreamWriter writer, EdmAnnotations annotationGroup)
private void appendAnnotationGroup(final XMLStreamWriter writer, final EdmAnnotations annotationGroup)
throws XMLStreamException {
writer.writeStartElement(XML_ANNOTATIONS);
writer.writeAttribute(XML_TARGET, annotationGroup.getTargetPath());
@ -297,7 +297,8 @@ public class MetadataDocumentXmlSerializer {
writer.writeEndElement();
}
private void appendAnnotations(XMLStreamWriter writer, EdmAnnotatable annotatable) throws XMLStreamException {
private void appendAnnotations(final XMLStreamWriter writer, final EdmAnnotatable annotatable)
throws XMLStreamException {
List<EdmAnnotation> annotations = annotatable.getAnnotations();
if (annotations != null && !annotations.isEmpty()) {
for (EdmAnnotation annotation : annotations) {
@ -316,7 +317,8 @@ public class MetadataDocumentXmlSerializer {
}
}
private void appendExpression(XMLStreamWriter writer, EdmExpression expression) throws XMLStreamException {
private void appendExpression(final XMLStreamWriter writer,
final EdmExpression expression) throws XMLStreamException {
if (expression == null) {
return;
}
@ -329,7 +331,8 @@ public class MetadataDocumentXmlSerializer {
}
}
private void appendDynamicExpression(XMLStreamWriter writer, EdmDynamicExpression dynExp) throws XMLStreamException {
private void appendDynamicExpression(final XMLStreamWriter writer, final EdmDynamicExpression dynExp)
throws XMLStreamException {
writer.writeStartElement(dynExp.getExpressionName());
switch (dynExp.getExpressionType()) {
// Logical
@ -469,19 +472,20 @@ public class MetadataDocumentXmlSerializer {
writer.writeEndElement();
}
private void appendNotExpression(XMLStreamWriter writer, EdmNot exp) throws XMLStreamException {
private void appendNotExpression(final XMLStreamWriter writer, final EdmNot exp) throws XMLStreamException {
appendExpression(writer, exp.getLeftExpression());
appendAnnotations(writer, exp);
}
private void appendLogicalOrComparisonExpression(XMLStreamWriter writer, EdmLogicalOrComparisonExpression exp)
private void appendLogicalOrComparisonExpression(final XMLStreamWriter writer,
final EdmLogicalOrComparisonExpression exp)
throws XMLStreamException {
appendExpression(writer, exp.getLeftExpression());
appendExpression(writer, exp.getRightExpression());
appendAnnotations(writer, exp);
}
private void appendConstantExpression(XMLStreamWriter writer, EdmConstantExpression constExp)
private void appendConstantExpression(final XMLStreamWriter writer, final EdmConstantExpression constExp)
throws XMLStreamException {
writer.writeStartElement(constExp.getExpressionName());
writer.writeCharacters(constExp.getValueAsString());
@ -928,12 +932,12 @@ public class MetadataDocumentXmlSerializer {
for (String memberName : enumType.getMemberNames()) {
writer.writeEmptyElement(XML_MEMBER);
writer.writeAttribute(XML_NAME, memberName);
EdmMember member = enumType.getMember(memberName);
if (member.getValue() != null) {
writer.writeAttribute(XML_VALUE, member.getValue());
}
appendAnnotations(writer, member);
}

View File

@ -187,7 +187,8 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
}
}
private void writeErrorDetails(String code, String message, String target, XMLStreamWriter writer)
private void writeErrorDetails(final String code, final String message, final String target,
final XMLStreamWriter writer)
throws XMLStreamException {
if (code != null) {
writer.writeStartElement(Constants.ERROR_CODE);
@ -323,7 +324,7 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
return contextURL;
}
private void writeMetadataETag(final ServiceMetadata metadata, XMLStreamWriter writer)
private void writeMetadataETag(final ServiceMetadata metadata, final XMLStreamWriter writer)
throws XMLStreamException {
if (metadata != null
&& metadata.getServiceMetadataETagSupport() != null
@ -344,7 +345,7 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
protected void writeEntity(final ServiceMetadata metadata, final EdmEntityType entityType,
final Entity entity, final ContextURL contextURL, final ExpandOption expand,
final SelectOption select, final XMLStreamWriter writer, final boolean top)
throws XMLStreamException, SerializerException {
throws XMLStreamException, SerializerException {
writer.writeStartElement(ATOM, Constants.ATOM_ELEM_ENTRY, NS_ATOM);
if (top) {
@ -622,17 +623,18 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
writer.writeEndElement();
}
private String collectionType(EdmType type) {
private String collectionType(final EdmType type) {
return "#Collection(" + type.getFullQualifiedName().getFullQualifiedNameAsString() + ")";
}
private String complexType(ServiceMetadata metadata, EdmComplexType baseType, String definedType)
private String complexType(final ServiceMetadata metadata, final EdmComplexType baseType, final String definedType)
throws SerializerException {
EdmComplexType type = resolveComplexType(metadata, baseType, definedType);
return type.getFullQualifiedName().getFullQualifiedNameAsString();
}
private String derivedComplexType(EdmComplexType baseType, String definedType) throws SerializerException {
private String derivedComplexType(final EdmComplexType baseType,
final String definedType) throws SerializerException {
String derived = baseType.getFullQualifiedName().getFullQualifiedNameAsString();
if (derived.equals(definedType)) {
return null;
@ -987,7 +989,7 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
return entityReference(entity, options);
}
protected SerializerResult entityReference(final Entity entity, ReferenceSerializerOptions options)
protected SerializerResult entityReference(final Entity entity, final ReferenceSerializerOptions options)
throws SerializerException {
OutputStream outputStream = null;
SerializerException cachedException = null;
@ -1016,7 +1018,8 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
}
}
private void writeReference(Entity entity, ContextURL contextURL, XMLStreamWriter writer, boolean top)
private void writeReference(final Entity entity, final ContextURL contextURL, final XMLStreamWriter writer,
final boolean top)
throws XMLStreamException {
writer.writeStartElement(METADATA, "ref", NS_METADATA);
if (top) {
@ -1032,13 +1035,13 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
@Override
public SerializerResult referenceCollection(final ServiceMetadata metadata, final EdmEntitySet edmEntitySet,
final EntityCollection entityCollection, ReferenceCollectionSerializerOptions options)
final EntityCollection entityCollection, final ReferenceCollectionSerializerOptions options)
throws SerializerException {
return entityReferenceCollection(entityCollection, options);
}
protected SerializerResult entityReferenceCollection(final EntityCollection entitySet,
ReferenceCollectionSerializerOptions options) throws SerializerException {
final ReferenceCollectionSerializerOptions options) throws SerializerException {
OutputStream outputStream = null;
SerializerException cachedException = null;
try {
@ -1083,14 +1086,14 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
}
}
private void writeCount(final EntityCollection entitySet, XMLStreamWriter writer)
private void writeCount(final EntityCollection entitySet, final XMLStreamWriter writer)
throws XMLStreamException {
writer.writeStartElement(METADATA, Constants.ATOM_ELEM_COUNT, NS_METADATA);
writer.writeCharacters(String.valueOf(entitySet.getCount()));
writer.writeEndElement();
}
private void writeNextLink(final EntityCollection entitySet, XMLStreamWriter writer)
private void writeNextLink(final EntityCollection entitySet, final XMLStreamWriter writer)
throws XMLStreamException {
writer.writeStartElement(ATOM, Constants.ATOM_ELEM_LINK, NS_ATOM);
writer.writeAttribute(Constants.ATTR_REL, Constants.NEXT_LINK_REL);

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -55,7 +55,7 @@ public class ServiceDocumentXmlSerializer {
public void writeServiceDocument(final XMLStreamWriter writer) throws XMLStreamException {
final String metadataUri =
(serviceRoot == null ? "" : serviceRoot.endsWith("/") ? serviceRoot : (serviceRoot + "/"))
+ Constants.METADATA;
+ Constants.METADATA;
writer.writeStartDocument(ODataSerializer.DEFAULT_CHARSET, "1.0");
writer.writeStartElement(APP, "service", NS_APP);
@ -86,7 +86,7 @@ public class ServiceDocumentXmlSerializer {
writer.writeEndElement(); // end service
}
private void writeServiceDocuments(XMLStreamWriter writer) throws XMLStreamException {
private void writeServiceDocuments(final XMLStreamWriter writer) throws XMLStreamException {
for (EdmxReference reference : metadata.getReferences()) {
final String referenceString = reference.getUri().toASCIIString();
writeElement(writer, false, "service-document", referenceString, referenceString);
@ -118,7 +118,7 @@ public class ServiceDocumentXmlSerializer {
}
}
private void writeElement(XMLStreamWriter writer, final boolean isApp, final String kind, final String name,
private void writeElement(final XMLStreamWriter writer, final boolean isApp, final String kind, final String name,
final String title) throws XMLStreamException {
if (isApp) {
writer.writeStartElement(APP, kind, NS_APP);
@ -126,7 +126,7 @@ public class ServiceDocumentXmlSerializer {
writer.writeStartElement(METADATA, kind, NS_METADATA);
}
writer.writeAttribute(Constants.ATTR_HREF, name);
writer.writeAttribute(METADATA, NS_METADATA, Constants.ATTR_NAME , name);
writer.writeAttribute(METADATA, NS_METADATA, Constants.ATTR_NAME, name);
writer.writeStartElement(ATOM, Constants.ATOM_ELEM_TITLE, NS_ATOM);
if (title != null) {
writer.writeCharacters(title);

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -97,7 +97,7 @@ public class UriHelperImpl implements UriHelper {
}
@Override
public UriResourceEntitySet parseEntityId(Edm edm, String entityId, String rawServiceRoot)
public UriResourceEntitySet parseEntityId(final Edm edm, final String entityId, final String rawServiceRoot)
throws DeserializerException {
String oDataPath = entityId;
@ -111,7 +111,7 @@ public class UriHelperImpl implements UriHelper {
.getUriResourceParts();
if (uriResourceParts.size() == 1 && uriResourceParts.get(0).getKind() == UriResourceKind.entitySet) {
final UriResourceEntitySet entityUriResource = (UriResourceEntitySet) uriResourceParts.get(0);
return entityUriResource;
}

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -26,8 +26,8 @@ import org.apache.olingo.server.api.uri.UriResourceKind;
/**
* Implementation of the {@link UriResourceAction} interface. This class does not extend
* {@link org.apache.olingo.server.core.uri.UriResourceTypedImpl UriResourceTypedImpl}
* since that would allow type filters and subsequent path segments.
* {@link org.apache.olingo.server.core.uri.UriResourceTypedImpl UriResourceTypedImpl} since that would allow type
* filters and subsequent path segments.
*/
public class UriResourceActionImpl extends UriResourceImpl implements UriResourceAction {
@ -74,7 +74,7 @@ public class UriResourceActionImpl extends UriResourceImpl implements UriResourc
}
return null;
}
@Override
public String getSegmentValue(final boolean includeFilters) {
return actionImport == null ? (action == null ? "" : action.getName()) : actionImport.getName();
@ -84,7 +84,7 @@ public class UriResourceActionImpl extends UriResourceImpl implements UriResourc
public String getSegmentValue() {
return getSegmentValue(false);
}
@Override
public String toString(final boolean includeFilters) {
return getSegmentValue(includeFilters);

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -63,10 +63,10 @@ public class UriResourceComplexPropertyImpl extends UriResourceTypedImpl impleme
}
@Override
public String getSegmentValue(){
public String getSegmentValue() {
return property.getName();
}
@Override
public String toString() {
return getSegmentValue();

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -26,9 +26,9 @@ public class UriResourceCountImpl extends UriResourceImpl implements UriResource
public UriResourceCountImpl() {
super(UriResourceKind.count);
}
@Override
public String getSegmentValue(){
public String getSegmentValue() {
return "$count";
}

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -55,12 +55,11 @@ public class UriResourceEntitySetImpl extends UriResourceWithKeysImpl implements
public boolean isCollection() {
return keyPredicates == null;
}
@Override
public String getSegmentValue(){
public String getSegmentValue() {
return edmEntitySet.getName();
}
@Override
public String toString() {

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -46,7 +46,7 @@ public class UriResourceFunctionImpl extends UriResourceWithKeysImpl implements
public List<UriParameter> getParameters() {
return parameters == null ?
Collections.<UriParameter> emptyList() :
Collections.unmodifiableList(parameters);
Collections.unmodifiableList(parameters);
}
public UriResourceFunctionImpl setParameters(final List<UriParameter> parameters) {

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -56,9 +56,9 @@ public class UriResourceItImpl extends UriResourceWithKeysImpl implements UriRes
this.isCollection = isCollection;
return this;
}
@Override
public String getSegmentValue(){
public String getSegmentValue() {
return "$it";
}

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -68,9 +68,9 @@ public class UriResourceLambdaAllImpl extends UriResourceTypedImpl implements Ur
this.expression = expression;
return this;
}
@Override
public String getSegmentValue(){
public String getSegmentValue() {
return "all";
}

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -68,9 +68,9 @@ public class UriResourceLambdaAnyImpl extends UriResourceTypedImpl implements Ur
this.expression = expression;
return this;
}
@Override
public String getSegmentValue(){
public String getSegmentValue() {
return "any";
}

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -64,10 +64,10 @@ public class UriResourceLambdaVarImpl extends UriResourceTypedImpl implements Ur
}
@Override
public String getSegmentValue(){
public String getSegmentValue() {
return variableText;
}
@Override
public String toString() {
return getSegmentValue();

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -54,9 +54,9 @@ public class UriResourceNavigationPropertyImpl extends UriResourceWithKeysImpl i
}
return navigationProperty.isCollection();
}
@Override
public String getSegmentValue(){
public String getSegmentValue() {
return navigationProperty.getName();
}

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -50,10 +50,10 @@ public class UriResourcePrimitivePropertyImpl extends UriResourceTypedImpl imple
public boolean isCollection() {
return property.isCollection();
}
@Override
public String getSegmentValue(){
return property.getName();
public String getSegmentValue() {
return property.getName();
}
@Override

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -27,8 +27,9 @@ public class UriResourceRefImpl extends UriResourceImpl implements UriResourceRe
super(UriResourceKind.ref);
}
@Override
public String getSegmentValue(){
public String getSegmentValue() {
return "$ref";
}

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -53,9 +53,9 @@ public class UriResourceRootImpl extends UriResourceWithKeysImpl implements UriR
this.isCollection = isCollection;
return this;
}
@Override
public String getSegmentValue(){
public String getSegmentValue() {
return "$root";
}

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -62,9 +62,9 @@ public class UriResourceSingletonImpl extends UriResourceTypedImpl implements Ur
public boolean isCollection() {
return false;
}
@Override
public String getSegmentValue(){
public String getSegmentValue() {
return singleton.getName();
}

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -59,10 +59,10 @@ public class UriResourceStartingTypeFilterImpl extends UriResourceWithKeysImpl {
}
@Override
public String getSegmentValue(){
public String getSegmentValue() {
return type.getNamespace() + "." + type.getName();
}
@Override
public String toString() {
return getSegmentValue();

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -40,6 +40,7 @@ public abstract class UriResourceTypedImpl extends UriResourceImpl implements Ur
return this;
}
@Override
public String getSegmentValue(final boolean includeFilters) {
if (includeFilters) {
if (typeFilter != null) {

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -29,7 +29,7 @@ public class UriResourceValueImpl extends UriResourceImpl implements UriResource
}
@Override
public String getSegmentValue(){
public String getSegmentValue() {
return "$value";
}

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -48,7 +48,7 @@ public abstract class UriResourceWithKeysImpl extends UriResourceImpl implements
public List<UriParameter> getKeyPredicates() {
return keyPredicates == null ?
Collections.<UriParameter> emptyList() :
new ArrayList<UriParameter>(keyPredicates);
new ArrayList<UriParameter>(keyPredicates);
}
public UriResourceWithKeysImpl setKeyPredicates(final List<UriParameter> list) {

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -285,9 +285,9 @@ public class Parser {
final Expression expression = ((FilterOption) uriParseTreeVisitor.visitFilterExpressionEOF(filterExpCtx))
.getExpression();
context.contextUriInfo.addAlias((AliasQueryOption) new AliasQueryOptionImpl()
.setAliasValue(expression)
.setName(option.name)
.setText(NULL.equals(option.value) ? null : option.value));
.setAliasValue(expression)
.setName(option.name)
.setText(NULL.equals(option.value) ? null : option.value));
} else {
throw new UriParserSyntaxException("Alias already specified! Name: " + option.name,
UriParserSyntaxException.MessageKeys.DUPLICATED_ALIAS, option.name);
@ -295,8 +295,8 @@ public class Parser {
} else {
context.contextUriInfo.addCustomQueryOption((CustomQueryOption)
new CustomQueryOptionImpl()
.setName(option.name)
.setText(option.value));
.setName(option.name)
.setText(option.value));
}
}
@ -304,7 +304,7 @@ public class Parser {
} catch (ParseCancellationException e) {
throw e.getCause() instanceof UriParserException ?
(UriParserException) e.getCause() :
new UriParserSyntaxException("Syntax error", e, UriParserSyntaxException.MessageKeys.SYNTAX);
new UriParserSyntaxException("Syntax error", e, UriParserSyntaxException.MessageKeys.SYNTAX);
}
}
@ -335,7 +335,7 @@ public class Parser {
// create parser
if (logLevel > 0) {
//TODO: Discuss if we should keep this code
// TODO: Discuss if we should keep this code
lexer = new UriLexer(new ANTLRInputStream(input));
showTokens(input, lexer.getAllTokens());
}

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -63,19 +63,20 @@ public class UriContext {
*/
public ExpandItemImpl contextExpandItemPath;
// CHECKSTYLE:ON (Maven checkstyle)
//CHECKSTYLE:OFF (Maven checkstyle)
// CHECKSTYLE:OFF (Maven checkstyle)
/**
* Set to true in method {@link UriParseTreeVisitor#visitExpandPath} right before
* calling {@link org.apache.olingo.server.core.uri.parser.UriParseTreeVisitor#readResourcePathSegment}
* After reading the path the variable is set back to false
*
* readResourcePathSegment handles all navigation properties, it depends on the context if key predicates are allowed or not.
* In case of expand
* Set to true in method {@link UriParseTreeVisitor#visitExpandPath} right before
* calling {@link org.apache.olingo.server.core.uri.parser.UriParseTreeVisitor#readResourcePathSegment} After reading
* the path the variable is set back to false
*
* readResourcePathSegment handles all navigation properties, it depends on the context if key predicates are allowed
* or not.
* In case of expand
*/
public boolean contextVisitExpandResourcePath;
//CHECKSTYLE:ON (Maven checkstyle)
// CHECKSTYLE:ON (Maven checkstyle)
// CHECKSTYLE:OFF (Maven checkstyle)
/**
* Set within method
@ -95,12 +96,12 @@ public class UriContext {
*/
public UriInfoImpl contextUriInfo;
public boolean contextReadingFunctionParameters;
/**
* Set to true if the parser operates on query part.
*/
public boolean contextReadingQueryPart;
public UriContext() {
contextExpandItemPath = null;

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -93,7 +93,7 @@ public class UriDecoder {
* @return list of elements (can be empty)
*/
static List<String> splitSkipEmpty(final String input, final char c) {
if(input.isEmpty() || input.length() == 1 && input.charAt(0) == c) {
if (input.isEmpty() || input.length() == 1 && input.charAt(0) == c) {
return Collections.emptyList();
}
@ -103,13 +103,13 @@ public class UriDecoder {
int end;
while ((end = input.indexOf(c, start)) >= 0) {
if(start != end) {
if (start != end) {
list.add(input.substring(start, end));
}
start = end + 1;
}
if(input.charAt(input.length()-1) != c) {
if (input.charAt(input.length() - 1) != c) {
list.add(input.substring(start));
}

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -82,9 +82,7 @@ import org.apache.olingo.server.core.uri.UriResourceStartingTypeFilterImpl;
import org.apache.olingo.server.core.uri.UriResourceTypedImpl;
import org.apache.olingo.server.core.uri.UriResourceValueImpl;
import org.apache.olingo.server.core.uri.UriResourceWithKeysImpl;
import org.apache.olingo.server.core.uri.antlr.UriLexer;
import org.apache.olingo.server.core.uri.antlr.UriParserBaseVisitor;
import org.apache.olingo.server.core.uri.antlr.UriParserParser;
import org.apache.olingo.server.core.uri.antlr.*;
import org.apache.olingo.server.core.uri.antlr.UriParserParser.AllEOFContext;
import org.apache.olingo.server.core.uri.antlr.UriParserParser.AllExprContext;
import org.apache.olingo.server.core.uri.antlr.UriParserParser.AltAddContext;
@ -311,7 +309,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
final boolean checkFirst =
context.contextUriInfo.getLastResourcePart() == null
|| context.contextUriInfo.getLastResourcePart() instanceof UriResourceRootImpl;
|| context.contextUriInfo.getLastResourcePart() instanceof UriResourceRootImpl;
String odi = ctx.vODI.getText();
@ -335,7 +333,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
EdmEntitySet edmEntitySet = edmEntityContainer.getEntitySet(odi);
if (edmEntitySet != null
&& (parts.isEmpty() || !(parts.get(0) instanceof UriResourcePartTyped)
|| parts.get(0) instanceof UriResourceRoot)) {
|| parts.get(0) instanceof UriResourceRoot)) {
ensureNamespaceIsNull(ctx.vNS);
context.contextUriInfo.addResourcePart(
new UriResourceEntitySetImpl().setEntitSet(edmEntitySet));
@ -346,7 +344,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
EdmSingleton edmSingleton = edmEntityContainer.getSingleton(odi);
if (edmSingleton != null
&& (parts.isEmpty() || !(parts.get(0) instanceof UriResourcePartTyped)
|| parts.get(0) instanceof UriResourceRoot)) {
|| parts.get(0) instanceof UriResourceRoot)) {
ensureNamespaceIsNull(ctx.vNS);
context.contextUriInfo.addResourcePart(
new UriResourceSingletonImpl().setSingleton(edmSingleton));
@ -357,7 +355,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
EdmActionImport edmActionImport = edmEntityContainer.getActionImport(odi);
if (edmActionImport != null
&& (parts.isEmpty() || !(parts.get(0) instanceof UriResourcePartTyped)
|| parts.get(0) instanceof UriResourceRoot)) {
|| parts.get(0) instanceof UriResourceRoot)) {
ensureNamespaceIsNull(ctx.vNS);
context.contextUriInfo.addResourcePart(
new UriResourceActionImpl().setActionImport(edmActionImport));
@ -366,15 +364,15 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
// check FunctionImport
EdmFunctionImport edmFunctionImport = edmEntityContainer.getFunctionImport(odi);
if(edmFunctionImport != null && context.contextReadingQueryPart) {
throw wrap(new UriParserSemanticException("Function Imports are not allowed in $filter or $orderby",
if (edmFunctionImport != null && context.contextReadingQueryPart) {
throw wrap(new UriParserSemanticException("Function Imports are not allowed in $filter or $orderby",
UriParserSemanticException.MessageKeys.FUNCTION_IMPORT_NOT_ALLOWED, odi));
}
if (edmFunctionImport != null
&& (parts.isEmpty() || !(parts.get(0) instanceof UriResourcePartTyped)
|| parts.get(0) instanceof UriResourceRoot)) {
|| parts.get(0) instanceof UriResourceRoot)) {
// read the URI parameters
if (ctx.vlNVO.isEmpty()) {
@ -391,7 +389,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
ctx.vlNVO.remove(0);
UriResourceFunctionImpl uriResource = new UriResourceFunctionImpl()
.setFunctionImport(edmFunctionImport, parameters);
.setFunctionImport(edmFunctionImport, parameters);
// collect parameter names
List<String> names = new ArrayList<String>();
@ -479,7 +477,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
ctx.depth() > 2 ? // path evaluation inside an expression or for the resource path?
UriParserSemanticException.MessageKeys.EXPRESSION_PROPERTY_NOT_IN_TYPE
: UriParserSemanticException.MessageKeys.PROPERTY_NOT_IN_TYPE,
structType.getFullQualifiedName().getFullQualifiedNameAsString(), odi));
structType.getFullQualifiedName().getFullQualifiedNameAsString(), odi));
}
if (property instanceof EdmProperty) {
@ -488,13 +486,13 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|| property.getType().getKind() == EdmTypeKind.DEFINITION) {
// create simple property
UriResourcePrimitivePropertyImpl simpleResource = new UriResourcePrimitivePropertyImpl()
.setProperty((EdmProperty) property);
.setProperty((EdmProperty) property);
context.contextUriInfo.addResourcePart(simpleResource);
return null;
} else {
// create complex property
UriResourceComplexPropertyImpl complexResource = new UriResourceComplexPropertyImpl()
.setProperty((EdmProperty) property);
.setProperty((EdmProperty) property);
context.contextUriInfo.addResourcePart(complexResource);
return null;
}
@ -507,7 +505,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
}
UriResourceNavigationPropertyImpl navigationResource = new UriResourceNavigationPropertyImpl()
.setNavigationProperty((EdmNavigationProperty) property);
.setNavigationProperty((EdmNavigationProperty) property);
context.contextUriInfo.addResourcePart(navigationResource);
return null;
} else {
@ -534,8 +532,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
if (lastResourcePart == null) {
// this may be the case if a member expression within a filter starts with a typeCast
UriResourceStartingTypeFilterImpl uriResource = new UriResourceStartingTypeFilterImpl()
.setType(filterEntityType)
.setCollection(source.isCollection);
.setType(filterEntityType)
.setCollection(source.isCollection);
if (source.isCollection) {
uriResource.setCollectionTypeFilter(filterEntityType);
} else {
@ -601,15 +599,15 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
throw wrap(new UriParserSemanticException(
"Complex typefilter '" + getName(source.type) + "'not compatible type of previous path segment '"
+ getName(filterComplexType) + "'",
UriParserSemanticException.MessageKeys.INCOMPATIBLE_TYPE_FILTER, getName(source.type)));
UriParserSemanticException.MessageKeys.INCOMPATIBLE_TYPE_FILTER, getName(source.type)));
}
// is simple complex type cast
if (lastResourcePart == null) {
// this may be the case if a member expression within a filter starts with a typeCast
UriResourceStartingTypeFilterImpl uriResource = new UriResourceStartingTypeFilterImpl()
.setType(filterComplexType)
.setCollection(source.isCollection);
.setType(filterComplexType)
.setCollection(source.isCollection);
if (source.isCollection) {
uriResource.setCollectionTypeFilter(filterComplexType);
@ -698,8 +696,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
if (function != null) {
UriResourceFunctionImpl pathInfoFunction = new UriResourceFunctionImpl()
.setFunction(function)
.setParameters(parameters);
.setFunction(function)
.setParameters(parameters);
context.contextUriInfo.addResourcePart(pathInfoFunction);
// mark parameters as consumed
@ -712,8 +710,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
if (function != null) {
UriResourceFunctionImpl pathInfoFunction = new UriResourceFunctionImpl()
.setFunction(function)
.setParameters(parameters);
.setFunction(function)
.setParameters(parameters);
context.contextUriInfo.addResourcePart(pathInfoFunction);
// mark parameters as consumed
@ -1073,16 +1071,16 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
@Override
public ExpressionImpl visitCeilingMethodCallExpr(final CeilingMethodCallExprContext ctx) {
return new MethodImpl()
.setMethod(MethodKind.CEILING)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
.setMethod(MethodKind.CEILING)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
}
@Override
public ExpressionImpl visitConcatMethodCallExpr(final ConcatMethodCallExprContext ctx) {
return new MethodImpl()
.setMethod(MethodKind.CONCAT)
.addParameter((ExpressionImpl) ctx.vE1.accept(this))
.addParameter((ExpressionImpl) ctx.vE2.accept(this));
.setMethod(MethodKind.CONCAT)
.addParameter((ExpressionImpl) ctx.vE1.accept(this))
.addParameter((ExpressionImpl) ctx.vE2.accept(this));
}
@Override
@ -1141,9 +1139,9 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
@Override
public ExpressionImpl visitContainsMethodCallExpr(final ContainsMethodCallExprContext ctx) {
return new MethodImpl()
.setMethod(MethodKind.CONTAINS)
.addParameter((ExpressionImpl) ctx.vE1.accept(this))
.addParameter((ExpressionImpl) ctx.vE2.accept(this));
.setMethod(MethodKind.CONTAINS)
.addParameter((ExpressionImpl) ctx.vE1.accept(this))
.addParameter((ExpressionImpl) ctx.vE2.accept(this));
}
@Override
@ -1176,31 +1174,31 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
@Override
public Object visitDateMethodCallExpr(final DateMethodCallExprContext ctx) {
return new MethodImpl()
.setMethod(MethodKind.DATE)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
.setMethod(MethodKind.DATE)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
}
@Override
public ExpressionImpl visitDayMethodCallExpr(final DayMethodCallExprContext ctx) {
return new MethodImpl()
.setMethod(MethodKind.DAY)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
.setMethod(MethodKind.DAY)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
}
@Override
public ExpressionImpl visitGeoDistanceMethodCallExpr(final GeoDistanceMethodCallExprContext ctx) {
return new MethodImpl()
.setMethod(MethodKind.GEODISTANCE)
.addParameter((ExpressionImpl) ctx.vE1.accept(this))
.addParameter((ExpressionImpl) ctx.vE2.accept(this));
.setMethod(MethodKind.GEODISTANCE)
.addParameter((ExpressionImpl) ctx.vE1.accept(this))
.addParameter((ExpressionImpl) ctx.vE2.accept(this));
}
@Override
public Object visitEndsWithMethodCallExpr(final EndsWithMethodCallExprContext ctx) {
return new MethodImpl()
.setMethod(MethodKind.ENDSWITH)
.addParameter((ExpressionImpl) ctx.vE1.accept(this))
.addParameter((ExpressionImpl) ctx.vE2.accept(this));
.setMethod(MethodKind.ENDSWITH)
.addParameter((ExpressionImpl) ctx.vE1.accept(this))
.addParameter((ExpressionImpl) ctx.vE2.accept(this));
}
@Override
@ -1332,7 +1330,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
return expandItem;
}
private void validate(UriInfoResource uriInfoResource, ExpandItemImpl expandItem) {
private void validate(final UriInfoResource uriInfoResource, final ExpandItemImpl expandItem) {
if (uriInfoResource != null) {
EdmEntityType type = getEntityType(uriInfoResource);
EdmEntityType name = getEntityType(expandItem.getResourcePath());
@ -1343,15 +1341,15 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
throw wrap(new UriParserSemanticException(
"NavigationProperty '" + name.getName() + "' not found in type '"
+ type.getFullQualifiedName().getFullQualifiedNameAsString() + "'",
UriParserSemanticException.MessageKeys.EXPRESSION_PROPERTY_NOT_IN_TYPE,
name.getFullQualifiedName().getFullQualifiedNameAsString(),
type.getFullQualifiedName().getFullQualifiedNameAsString()));
UriParserSemanticException.MessageKeys.EXPRESSION_PROPERTY_NOT_IN_TYPE,
name.getFullQualifiedName().getFullQualifiedNameAsString(),
type.getFullQualifiedName().getFullQualifiedNameAsString()));
}
}
}
}
private EdmEntityType getEntityType(UriInfoResource test) {
private EdmEntityType getEntityType(final UriInfoResource test) {
List<UriResource> parts = test.getUriResourceParts();
if (!parts.isEmpty()) {
UriResource lastPart = parts.get(parts.size() - 1);
@ -1419,7 +1417,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
public Object visitFilter(final FilterContext ctx) {
context.contextReadingQueryPart = true;
final FilterOptionImpl result = new FilterOptionImpl().setExpression((ExpressionImpl) ctx.children.get(2)
.accept(this));
.accept(this));
context.contextReadingQueryPart = false;
return result;
@ -1429,7 +1427,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
public Object visitFilterExpressionEOF(final FilterExpressionEOFContext ctx) {
context.contextReadingQueryPart = true;
final FilterOptionImpl result = new FilterOptionImpl().setExpression((ExpressionImpl) ctx.children.get(0)
.accept(this));
.accept(this));
context.contextReadingQueryPart = false;
return result;
@ -1438,53 +1436,53 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
@Override
public ExpressionImpl visitFloorMethodCallExpr(final FloorMethodCallExprContext ctx) {
return new MethodImpl()
.setMethod(MethodKind.FLOOR)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
.setMethod(MethodKind.FLOOR)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
}
@Override
public ExpressionImpl visitFractionalsecondsMethodCallExpr(final FractionalsecondsMethodCallExprContext ctx) {
return new MethodImpl()
.setMethod(MethodKind.FRACTIONALSECONDS)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
.setMethod(MethodKind.FRACTIONALSECONDS)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
}
@Override
public ExpressionImpl visitGeoLengthMethodCallExpr(final GeoLengthMethodCallExprContext ctx) {
return new MethodImpl()
.setMethod(MethodKind.GEOLENGTH)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
.setMethod(MethodKind.GEOLENGTH)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
}
@Override
public ExpressionImpl visitHourMethodCallExpr(final HourMethodCallExprContext ctx) {
return new MethodImpl()
.setMethod(MethodKind.HOUR)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
.setMethod(MethodKind.HOUR)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
}
@Override
public ExpressionImpl visitIndexOfMethodCallExpr(final IndexOfMethodCallExprContext ctx) {
return new MethodImpl()
.setMethod(MethodKind.INDEXOF)
.addParameter((ExpressionImpl) ctx.vE1.accept(this))
.addParameter((ExpressionImpl) ctx.vE2.accept(this));
.setMethod(MethodKind.INDEXOF)
.addParameter((ExpressionImpl) ctx.vE1.accept(this))
.addParameter((ExpressionImpl) ctx.vE2.accept(this));
}
@Override
public Object visitInlinecount(final InlinecountContext ctx) {
final String text = ctx.children.get(2).getText();
return new CountOptionImpl()
.setValue(text.equalsIgnoreCase("true") ? true : false)
.setText(text);
.setValue(text.equalsIgnoreCase("true") ? true : false)
.setText(text);
}
@Override
public ExpressionImpl visitGeoIntersectsMethodCallExpr(final GeoIntersectsMethodCallExprContext ctx) {
return new MethodImpl()
.setMethod(MethodKind.GEOINTERSECTS)
.addParameter((ExpressionImpl) ctx.vE1.accept(this))
.addParameter((ExpressionImpl) ctx.vE2.accept(this));
.setMethod(MethodKind.GEOINTERSECTS)
.addParameter((ExpressionImpl) ctx.vE1.accept(this))
.addParameter((ExpressionImpl) ctx.vE2.accept(this));
}
@Override
@ -1509,8 +1507,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
@Override
public ExpressionImpl visitLengthMethodCallExpr(final LengthMethodCallExprContext ctx) {
return new MethodImpl()
.setMethod(MethodKind.LENGTH)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
.setMethod(MethodKind.LENGTH)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
}
@Override
@ -1534,7 +1532,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
@Override
public ExpressionImpl visitMaxDateTimeMethodCallExpr(final MaxDateTimeMethodCallExprContext ctx) {
return new MethodImpl()
.setMethod(MethodKind.MAXDATETIME);
.setMethod(MethodKind.MAXDATETIME);
}
@Override
@ -1589,21 +1587,21 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
@Override
public ExpressionImpl visitMinDateTimeMethodCallExpr(final MinDateTimeMethodCallExprContext ctx) {
return new MethodImpl()
.setMethod(MethodKind.MINDATETIME);
.setMethod(MethodKind.MINDATETIME);
}
@Override
public ExpressionImpl visitMinuteMethodCallExpr(final MinuteMethodCallExprContext ctx) {
return new MethodImpl()
.setMethod(MethodKind.MINUTE)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
.setMethod(MethodKind.MINUTE)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
}
@Override
public ExpressionImpl visitMonthMethodCallExpr(final MonthMethodCallExprContext ctx) {
return new MethodImpl()
.setMethod(MethodKind.MONTH)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
.setMethod(MethodKind.MONTH)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
}
@Override
@ -1646,9 +1644,9 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
if (lastKeyPredicates.size() == 1) {
return Collections.singletonList(new UriParameterImpl()
.setName(lastKeyPredicates.get(0))
.setText(valueText)
.setExpression(expression));
.setName(lastKeyPredicates.get(0))
.setText(valueText)
.setExpression(expression));
} else {
throw wrap(new UriParserSemanticException("Wrong number of key properties.",
UriParserSemanticException.MessageKeys.WRONG_NUMBER_OF_KEY_PROPERTIES,
@ -1666,9 +1664,9 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
// so fill the keylist with this key and return.
if (lastKeyPredicates.size() == 1) {
return Collections.singletonList(new UriParameterImpl()
.setName(lastKeyPredicates.get(0))
.setText(valueText)
.setExpression(expression));
.setName(lastKeyPredicates.get(0))
.setText(valueText)
.setExpression(expression));
}
// There are more keys defined in the EDM, but only one is written in the URI. This is allowed only if
@ -1825,8 +1823,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
final UriResource last = context.contextUriInfo.getLastResourcePart();
final int number = last instanceof UriResourcePartTyped ? ((EdmEntityType) ((UriResourcePartTyped) last)
.getType()).getKeyPredicateNames().size() : 0;
throw wrap(new UriParserSemanticException("Wrong number of key properties.",
UriParserSemanticException.MessageKeys.WRONG_NUMBER_OF_KEY_PROPERTIES, Integer.toString(number), "0"));
throw wrap(new UriParserSemanticException("Wrong number of key properties.",
UriParserSemanticException.MessageKeys.WRONG_NUMBER_OF_KEY_PROPERTIES, Integer.toString(number), "0"));
}
}
}
@ -1856,7 +1854,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
@Override
public ExpressionImpl visitNowMethodCallExpr(final NowMethodCallExprContext ctx) {
return new MethodImpl()
.setMethod(MethodKind.NOW);
.setMethod(MethodKind.NOW);
}
@Override
@ -1888,7 +1886,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
@Override
public Object visitOrderByEOF(final OrderByEOFContext ctx) {
context.contextReadingQueryPart = true;
OrderByOptionImpl orderBy = new OrderByOptionImpl();
for (OrderByItemContext item : ((OrderListContext) ctx.getChild(0)).vlOI) {
@ -1917,7 +1915,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
/*
* if (contextUriInfo.getLastResourcePart() == null ||
* contextUriInfo.getLastResourcePart() instanceof UriResourceRootImpl) {
*
*
* } else {
* readNextPathInfoSegment(ctx);
* }
@ -1936,7 +1934,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
@SuppressWarnings("unchecked")
List<UriParameter> list = (List<UriParameter>) ctx.vlNVO.get(0).accept(this);
((UriResourceWithKeysImpl) pathInfoSegment)
.setKeyPredicates(list);
.setKeyPredicates(list);
} else {
throw wrap(new UriParserSemanticException("Key properties not allowed",
UriParserSemanticException.MessageKeys.KEY_NOT_ALLOWED));
@ -1986,7 +1984,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
}
@Override
public Object visitBinaryLiteral(BinaryLiteralContext ctx) {
public Object visitBinaryLiteral(final BinaryLiteralContext ctx) {
return new LiteralImpl().setText(ctx.getText())
.setType(EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Binary));
}
@ -2002,7 +2000,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
final EdmType type = EdmPrimitiveTypeFactory.getInstance(
ctx.getText().contains("e") || ctx.getText().contains("E") ?
EdmPrimitiveTypeKind.Double :
EdmPrimitiveTypeKind.Decimal);
EdmPrimitiveTypeKind.Decimal);
return new LiteralImpl().setText(ctx.getText()).setType(type);
}
@ -2119,22 +2117,22 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
}
return new MemberImpl()
.setResourcePath(uriInfoImplpath);
.setResourcePath(uriInfoImplpath);
}
@Override
public ExpressionImpl visitRoundMethodCallExpr(final RoundMethodCallExprContext ctx) {
return new MethodImpl()
.setMethod(MethodKind.ROUND)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
.setMethod(MethodKind.ROUND)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
}
@Override
public ExpressionImpl visitSecondMethodCallExpr(final SecondMethodCallExprContext ctx) {
return new MethodImpl()
.setMethod(MethodKind.SECOND)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
.setMethod(MethodKind.SECOND)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
}
@Override
@ -2157,7 +2155,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
final QueryOptionImpl result = new SelectOptionImpl().setSelectItems(selectItems).setText(ctx.getText());
context.contextReadingQueryPart = false;
return result;
}
@ -2353,7 +2351,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
* if ((et.compatibleTo((EdmStructuralType) prevType))) {
* UriResourceStartingTypeFilterImpl resourcePart = new UriResourceStartingTypeFilterImpl();
* resourcePart.setEntryTypeFilter(et);
*
*
* uriInfo.addResourcePart(resourcePart);
* return this;
* }
@ -2409,8 +2407,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
public Object visitSkip(final SkipContext ctx) {
final String text = ctx.children.get(2).getText();
return new SkipOptionImpl()
.setValue(Integer.parseInt(text))
.setText(text);
.setValue(Integer.parseInt(text))
.setText(text);
}
@Override
@ -2422,9 +2420,9 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
@Override
public ExpressionImpl visitStartsWithMethodCallExpr(final StartsWithMethodCallExprContext ctx) {
return new MethodImpl()
.setMethod(MethodKind.STARTSWITH)
.addParameter((ExpressionImpl) ctx.vE1.accept(this))
.addParameter((ExpressionImpl) ctx.vE2.accept(this));
.setMethod(MethodKind.STARTSWITH)
.addParameter((ExpressionImpl) ctx.vE1.accept(this))
.addParameter((ExpressionImpl) ctx.vE2.accept(this));
}
@Override
@ -2445,58 +2443,58 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
@Override
public ExpressionImpl visitTimeMethodCallExpr(final TimeMethodCallExprContext ctx) {
return new MethodImpl()
.setMethod(MethodKind.TIME)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
.setMethod(MethodKind.TIME)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
}
@Override
public Object visitTop(final TopContext ctx) {
final String text = ctx.children.get(2).getText();
return new TopOptionImpl()
.setValue(Integer.parseInt(text))
.setText(text);
.setValue(Integer.parseInt(text))
.setText(text);
}
@Override
public ExpressionImpl visitToLowerMethodCallExpr(final ToLowerMethodCallExprContext ctx) {
return new MethodImpl()
.setMethod(MethodKind.TOLOWER)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
.setMethod(MethodKind.TOLOWER)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
}
@Override
public ExpressionImpl visitTotalOffsetMinutesMethodCallExpr(final TotalOffsetMinutesMethodCallExprContext ctx) {
return new MethodImpl()
.setMethod(MethodKind.TOTALOFFSETMINUTES)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
.setMethod(MethodKind.TOTALOFFSETMINUTES)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
}
@Override
public ExpressionImpl visitTotalsecondsMethodCallExpr(final TotalsecondsMethodCallExprContext ctx) {
return new MethodImpl()
.setMethod(MethodKind.TOTALSECONDS)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
.setMethod(MethodKind.TOTALSECONDS)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
}
@Override
public ExpressionImpl visitToUpperMethodCallExpr(final ToUpperMethodCallExprContext ctx) {
return new MethodImpl()
.setMethod(MethodKind.TOUPPER)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
.setMethod(MethodKind.TOUPPER)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
}
@Override
public ExpressionImpl visitTrimMethodCallExpr(final TrimMethodCallExprContext ctx) {
return new MethodImpl()
.setMethod(MethodKind.TRIM)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
.setMethod(MethodKind.TRIM)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
}
@Override
public ExpressionImpl visitYearMethodCallExpr(final YearMethodCallExprContext ctx) {
return new MethodImpl()
.setMethod(MethodKind.YEAR)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
.setMethod(MethodKind.YEAR)
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
}
private ParseCancellationException wrap(final UriParserException uriParserException) {
@ -2533,13 +2531,13 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
return new LiteralImpl().setText(ctx.getText()).setType(null);
}
@Override
public Object visitExpandItemsEOF(ExpandItemsEOFContext ctx) {
public Object visitExpandItemsEOF(final ExpandItemsEOFContext ctx) {
context.contextReadingQueryPart = true;
final Object result = super.visitExpandItemsEOF(ctx);
context.contextReadingQueryPart = false;
return result;
}
}

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -79,12 +79,12 @@ public class UriParserSemanticException extends UriParserException {
/** parameter: not implemented part */
NOT_IMPLEMENTED,
/** parameter: namespace **/
NAMESPACE_NOT_ALLOWED_AT_FIRST_ELEMENT,
NAMESPACE_NOT_ALLOWED_AT_FIRST_ELEMENT,
/** parameter: complex parameter value */
COMPLEX_PARAMETER_IN_RESOURCE_PATH,
COMPLEX_PARAMETER_IN_RESOURCE_PATH,
/** parameter: function import name */
FUNCTION_IMPORT_NOT_ALLOWED;
@Override
public String getKey() {
return name();

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -35,7 +35,7 @@ public class UriParserSyntaxException extends UriParserException {
/** parameter: $format option value */
WRONG_VALUE_FOR_SYSTEM_QUERY_OPTION_FORMAT,
SYSTEM_QUERY_OPTION_LEVELS_NOT_ALLOWED_HERE,
SYNTAX,
SYNTAX,
/** parameter: alias name */
DUPLICATED_ALIAS;

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -28,7 +28,8 @@ public class SearchBinaryImpl extends SearchExpressionImpl implements SearchBina
private final SearchExpression left;
private final SearchExpression right;
public SearchBinaryImpl(SearchExpression left, SearchBinaryOperatorKind operator, SearchExpression right) {
public SearchBinaryImpl(final SearchExpression left, final SearchBinaryOperatorKind operator,
final SearchExpression right) {
this.left = left;
this.operator = operator;
this.right = right;

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

Some files were not shown because too many files have changed in this diff Show More