From 371bf9a55c4c35c80705c828fc5028494004c196 Mon Sep 17 00:00:00 2001 From: Christian Amend Date: Fri, 18 Dec 2015 13:44:20 +0100 Subject: [PATCH] [OLINGO-841] CleanUp ServerCore --- .../olingo/server/core/ContentNegotiator.java | 18 +- .../core/ContentNegotiatorException.java | 4 +- .../server/core/DefaultRedirectProcessor.java | 4 +- .../olingo/server/core/ODataDispatcher.java | 130 +++++----- .../server/core/ODataExceptionHelper.java | 14 +- .../olingo/server/core/ODataHandler.java | 18 +- .../server/core/ODataHandlerException.java | 6 +- .../server/core/ODataHttpHandlerImpl.java | 8 +- .../apache/olingo/server/core/ODataImpl.java | 10 +- .../olingo/server/core/RedirectProcessor.java | 4 +- .../server/core/ServiceMetadataImpl.java | 8 +- .../core/batchhandler/BatchFacadeImpl.java | 8 +- .../core/batchhandler/BatchHandler.java | 4 +- .../core/batchhandler/BatchPartHandler.java | 6 +- .../BatchReferenceRewriter.java | 4 +- .../core/debug/DebugResponseHelperImpl.java | 118 ++++----- .../olingo/server/core/debug/DebugTab.java | 5 +- .../server/core/debug/DebugTabBody.java | 12 +- .../server/core/debug/DebugTabRequest.java | 28 +- .../server/core/debug/DebugTabResponse.java | 14 +- .../server/core/debug/DebugTabRuntime.java | 34 +-- .../server/core/debug/DebugTabServer.java | 14 +- .../server/core/debug/DebugTabStacktrace.java | 24 +- .../olingo/server/core/debug/DebugTabUri.java | 49 ++-- .../core/debug/ExpressionJsonVisitor.java | 12 +- .../server/core/debug/ServerCoreDebugger.java | 12 +- .../deserializer/DeserializerResultImpl.java | 4 +- .../FixedFormatDeserializerImpl.java | 10 +- .../deserializer/batch/BatchBodyPart.java | 8 +- .../batch/BatchChangeSetPart.java | 4 +- .../deserializer/batch/BatchLineReader.java | 44 ++-- .../core/deserializer/batch/BatchParser.java | 10 +- .../deserializer/batch/BatchParserCommon.java | 14 +- .../core/deserializer/batch/BatchPart.java | 4 +- .../batch/BatchQueryOperation.java | 4 +- .../batch/BatchRequestTransformator.java | 20 +- .../batch/BatchTransformatorCommon.java | 8 +- .../core/deserializer/batch/Header.java | 4 +- .../core/deserializer/batch/HeaderField.java | 4 +- .../batch/HttpRequestStatusLine.java | 6 +- .../server/core/deserializer/batch/Line.java | 4 +- .../helper/ExpandTreeBuilder.java | 4 +- .../helper/ExpandTreeBuilderImpl.java | 4 +- .../json/ODataJsonDeserializer.java | 113 ++++---- .../xml/ODataXmlDeserializer.java | 34 +-- .../server/core/etag/ETagHelperImpl.java | 8 +- .../server/core/etag/ETagInformation.java | 4 +- .../olingo/server/core/etag/ETagParser.java | 22 +- .../core/etag/PreconditionsValidator.java | 14 +- .../server/core/prefer/PreferParser.java | 40 +-- .../server/core/prefer/PreferencesImpl.java | 13 +- .../serializer/AbstractODataSerializer.java | 7 +- .../serializer/AsyncResponseSerializer.java | 18 +- .../serializer/BatchResponseSerializer.java | 45 ++-- .../serializer/FixedFormatSerializerImpl.java | 6 +- .../core/serializer/SerializerResultImpl.java | 4 +- .../serializer/json/ODataErrorSerializer.java | 4 +- .../serializer/json/ODataJsonSerializer.java | 94 +++---- .../json/ServiceDocumentJsonSerializer.java | 12 +- .../serializer/utils/CircleStreamBuffer.java | 4 +- .../serializer/utils/ContentTypeHelper.java | 16 +- .../serializer/utils/ContextURLBuilder.java | 22 +- .../serializer/utils/ContextURLHelper.java | 17 +- .../serializer/utils/ExpandSelectHelper.java | 4 +- .../xml/MetadataDocumentXmlSerializer.java | 38 +-- .../serializer/xml/ODataXmlSerializer.java | 27 +- .../xml/ServiceDocumentXmlSerializer.java | 12 +- .../olingo/server/core/uri/UriHelperImpl.java | 8 +- .../olingo/server/core/uri/UriInfoImpl.java | 4 +- .../server/core/uri/UriParameterImpl.java | 4 +- .../core/uri/UriResourceActionImpl.java | 12 +- .../uri/UriResourceComplexPropertyImpl.java | 8 +- .../server/core/uri/UriResourceCountImpl.java | 8 +- .../core/uri/UriResourceEntitySetImpl.java | 9 +- .../core/uri/UriResourceFunctionImpl.java | 6 +- .../server/core/uri/UriResourceImpl.java | 4 +- .../server/core/uri/UriResourceItImpl.java | 8 +- .../core/uri/UriResourceLambdaAllImpl.java | 8 +- .../core/uri/UriResourceLambdaAnyImpl.java | 8 +- .../core/uri/UriResourceLambdaVarImpl.java | 8 +- .../UriResourceNavigationPropertyImpl.java | 8 +- .../uri/UriResourcePrimitivePropertyImpl.java | 10 +- .../server/core/uri/UriResourceRefImpl.java | 7 +- .../server/core/uri/UriResourceRootImpl.java | 8 +- .../core/uri/UriResourceSingletonImpl.java | 8 +- .../UriResourceStartingTypeFilterImpl.java | 8 +- .../server/core/uri/UriResourceTypedImpl.java | 5 +- .../server/core/uri/UriResourceValueImpl.java | 6 +- .../core/uri/UriResourceWithKeysImpl.java | 6 +- .../uri/parser/CheckFullContextListener.java | 4 +- .../olingo/server/core/uri/parser/Parser.java | 18 +- .../olingo/server/core/uri/parser/RawUri.java | 4 +- .../server/core/uri/parser/UriContext.java | 29 ++- .../server/core/uri/parser/UriDecoder.java | 10 +- .../core/uri/parser/UriParseTreeVisitor.java | 242 +++++++++--------- .../core/uri/parser/UriParserException.java | 4 +- .../parser/UriParserSemanticException.java | 10 +- .../uri/parser/UriParserSyntaxException.java | 6 +- .../uri/parser/search/SearchBinaryImpl.java | 7 +- .../parser/search/SearchExpressionImpl.java | 4 +- .../core/uri/parser/search/SearchParser.java | 60 ++--- .../parser/search/SearchParserException.java | 6 +- .../uri/parser/search/SearchQueryToken.java | 9 +- .../uri/parser/search/SearchTermImpl.java | 6 +- .../uri/parser/search/SearchTokenizer.java | 129 +++++----- .../search/SearchTokenizerException.java | 6 +- .../uri/parser/search/SearchUnaryImpl.java | 6 +- .../uri/queryoption/AliasQueryOptionImpl.java | 4 +- .../core/uri/queryoption/CountOptionImpl.java | 4 +- .../queryoption/CustomQueryOptionImpl.java | 4 +- .../core/uri/queryoption/ExpandItemImpl.java | 8 +- .../uri/queryoption/ExpandOptionImpl.java | 4 +- .../uri/queryoption/FilterOptionImpl.java | 4 +- .../uri/queryoption/FormatOptionImpl.java | 4 +- .../core/uri/queryoption/IdOptionImpl.java | 4 +- .../uri/queryoption/LevelsOptionImpl.java | 4 +- .../core/uri/queryoption/OrderByItemImpl.java | 4 +- .../uri/queryoption/OrderByOptionImpl.java | 4 +- .../core/uri/queryoption/QueryOptionImpl.java | 4 +- .../uri/queryoption/SearchOptionImpl.java | 6 +- .../core/uri/queryoption/SelectItemImpl.java | 4 +- .../uri/queryoption/SelectOptionImpl.java | 4 +- .../core/uri/queryoption/SkipOptionImpl.java | 4 +- .../uri/queryoption/SkipTokenOptionImpl.java | 4 +- .../queryoption/SystemQueryOptionImpl.java | 4 +- .../core/uri/queryoption/TopOptionImpl.java | 4 +- .../uri/queryoption/expression/AliasImpl.java | 4 +- .../queryoption/expression/BinaryImpl.java | 4 +- .../expression/EnumerationImpl.java | 4 +- .../expression/ExpressionImpl.java | 4 +- .../queryoption/expression/LambdaRefImpl.java | 4 +- .../queryoption/expression/LiteralImpl.java | 4 +- .../queryoption/expression/MemberImpl.java | 4 +- .../queryoption/expression/MethodImpl.java | 4 +- .../expression/TypeLiteralImpl.java | 4 +- .../uri/queryoption/expression/UnaryImpl.java | 4 +- .../uri/validator/UriValidationException.java | 7 +- .../core/uri/validator/UriValidator.java | 233 +++++++++-------- .../server/core/ContentNegotiatorTest.java | 8 +- .../server/core/ExceptionHelperTest.java | 6 +- .../server/core/ODataHttpHandlerImplTest.java | 6 +- .../olingo/server/core/ODataImplTest.java | 4 +- .../TranslatedExceptionSubclassesTest.java | 4 +- .../batchhandler/MockedBatchHandlerTest.java | 4 +- .../core/debug/AbstractDebugTabTest.java | 8 +- .../server/core/debug/DebugTabBodyTest.java | 4 +- .../core/debug/DebugTabRequestTest.java | 4 +- .../core/debug/DebugTabResponseTest.java | 4 +- .../server/core/debug/DebugTabServerTest.java | 6 +- .../core/debug/ServerCoreDebuggerTest.java | 6 +- .../FixedFormatDeserializerTest.java | 4 +- .../batch/BatchLineReaderTest.java | 4 +- .../batch/BatchParserCommonTest.java | 4 +- .../batch/BatchRequestParserTest.java | 16 +- .../core/deserializer/batch/HeaderTest.java | 4 +- .../batch/HttpRequestStatusLineTest.java | 4 +- .../json/ODataJsonDeserializerBasicTest.java | 4 +- .../server/core/etag/ETagHelperTest.java | 4 +- .../server/core/etag/ETagParserTest.java | 4 +- .../server/core/prefer/PreferencesTest.java | 8 +- .../AsyncResponseSerializerTest.java | 18 +- .../BatchResponseSerializerTest.java | 20 +- .../serializer/FixedFormatSerializerTest.java | 4 +- .../json/ServerErrorSerializerTest.java | 8 +- .../utils/CircleStreamBufferTest.java | 5 +- .../utils/ContextURLBuilderTest.java | 4 +- .../MetadataDocumentXmlSerializerTest.java | 205 +++++++-------- .../xml/ServerErrorXmlSerializerTest.java | 18 +- .../xml/ServiceDocumentXmlSerializerTest.java | 24 +- .../search/SearchParserAndTokenizerTest.java | 119 ++++----- .../uri/parser/search/SearchParserTest.java | 17 +- .../parser/search/SearchTokenizerTest.java | 113 ++++---- 172 files changed, 1546 insertions(+), 1514 deletions(-) diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java index e47d864ee..86697d5ba 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java @@ -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 getSupportedContentTypes( final CustomContentTypeSupport customContentTypeSupport, final RepresentationType representationType) - throws ContentNegotiatorException { + throws ContentNegotiatorException { final List defaultSupportedContentTypes = getDefaultSupportedContentTypes(representationType); final List 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 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 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; diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiatorException.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiatorException.java index a76c5495b..12a05828e 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiatorException.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiatorException.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/DefaultRedirectProcessor.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/DefaultRedirectProcessor.java index efe3e711b..a6460fa1a 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/DefaultRedirectProcessor.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/DefaultRedirectProcessor.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataDispatcher.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataDispatcher.java index bbe73e073..4971c8e7b 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataDispatcher.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataDispatcher.java @@ -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); diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataExceptionHelper.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataExceptionHelper.java index 2de59d509..47896c957 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataExceptionHelper.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataExceptionHelper.java @@ -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; } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java index 12f2dfd99..52c98d15d 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java @@ -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; } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandlerException.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandlerException.java index 82afe97f2..acf7c38b8 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandlerException.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandlerException.java @@ -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; diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java index 162494304..55c11943e 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java @@ -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 createEnvironmentVariablesMap(HttpServletRequest request) { + private Map createEnvironmentVariablesMap(final HttpServletRequest request) { Map environment = new LinkedHashMap(); 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 { diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java index ad7d41067..4c2642cfd 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java @@ -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); } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/RedirectProcessor.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/RedirectProcessor.java index 4e99d3178..f5aec43af 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/RedirectProcessor.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/RedirectProcessor.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ServiceMetadataImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ServiceMetadataImpl.java index 9fb080bd1..4f07af0b0 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ServiceMetadataImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ServiceMetadataImpl.java @@ -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 references; private final ServiceMetadataETagSupport serviceMetadataETagSupport; - public ServiceMetadataImpl(CsdlEdmProvider edmProvider, List references, - ServiceMetadataETagSupport serviceMetadataETagSupport) { + public ServiceMetadataImpl(final CsdlEdmProvider edmProvider, final List references, + final ServiceMetadataETagSupport serviceMetadataETagSupport) { edm = new EdmProviderImpl(edmProvider); this.references = new ArrayList(); this.references.addAll(references); diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/batchhandler/BatchFacadeImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/batchhandler/BatchFacadeImpl.java index 9bb042d1c..9fe52c86f 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/batchhandler/BatchFacadeImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/batchhandler/BatchFacadeImpl.java @@ -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); } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/batchhandler/BatchHandler.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/batchhandler/BatchHandler.java index 18cc69b9d..ca253dcce 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/batchhandler/BatchHandler.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/batchhandler/BatchHandler.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/batchhandler/BatchPartHandler.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/batchhandler/BatchPartHandler.java index 653fd5f08..712ff3e2c 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/batchhandler/BatchPartHandler.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/batchhandler/BatchPartHandler.java @@ -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()); } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/batchhandler/referenceRewriting/BatchReferenceRewriter.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/batchhandler/referenceRewriting/BatchReferenceRewriter.java index a05b1e9a0..c4f8d595a 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/batchhandler/referenceRewriting/BatchReferenceRewriter.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/batchhandler/referenceRewriting/BatchReferenceRewriter.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugResponseHelperImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugResponseHelperImpl.java index 3fc797b7a..5ee63b8dc 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugResponseHelperImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugResponseHelperImpl.java @@ -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("\n") - .append("\n") - .append("\n") - .append("\n") - .append("") - .append(escapeHtml(title)) - .append("\n") - .append("\n") - .append("\n") - .append("\n"); + .append(" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n") + .append("\n") + .append("\n") + .append("\n") + .append("") + .append(escapeHtml(title)) + .append("\n") + .append("\n") + .append("\n") + .append("\n"); char count = '0'; for (final DebugTab part : parts) { writer.append("
\n") - .append("

") - .append(part.getName()) - .append("

\n") - .append("
\n") - .append("
\n"); + .append("

") + .append(part.getName()) + .append("

\n") + .append("
\n") + .append("
\n"); part.appendHtml(writer); writer.append("
\n"); } writer.append("\n") - .append("\n") - .close(); + .append("\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("&", "&").replace("<", "<").replace(">", ">"); } - protected static void appendJsonTable(JsonGenerator gen, final Map entries) + protected static void appendJsonTable(final JsonGenerator gen, final Map 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 entries) throws IOException { + protected static void appendHtmlTable(final Writer writer, final Map entries) throws IOException { writer.append("\n\n") - .append("\n") - .append("\n\n"); + .append("\n") + .append("\n\n"); if (entries != null && !entries.isEmpty()) { for (final String name : entries.keySet()) { writer.append("") - .append("\n"); + .append("\n"); } } writer.append("\n
NameValue
NameValue
").append(name).append("") - .append(escapeHtml(entries.get(name))) - .append("
") + .append(escapeHtml(entries.get(name))) + .append("
\n"); diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTab.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTab.java index 76384b047..ede8f986c 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTab.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTab.java @@ -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. */ diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabBody.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabBody.java index c75b6f62d..b0c5314aa 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabBody.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabBody.java @@ -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("\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); diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabRequest.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabRequest.java index 4f9bc5c3c..e2084174c 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabRequest.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabRequest.java @@ -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> 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("

Request Method

\n") - .append("

").append(method).append("

\n") - .append("

Request URI

\n") - .append("

").append(DebugResponseHelperImpl.escapeHtml(uri)).append("

\n") - .append("

Request Protocol

\n") - .append("

").append(DebugResponseHelperImpl.escapeHtml(protocol)).append("

\n"); + .append("

").append(method).append("

\n") + .append("

Request URI

\n") + .append("

").append(DebugResponseHelperImpl.escapeHtml(uri)).append("

\n") + .append("

Request Protocol

\n") + .append("

").append(DebugResponseHelperImpl.escapeHtml(protocol)).append("

\n"); writer.append("

Request Headers

\n"); writer.append("\n\n") - .append("\n") - .append("\n\n"); + .append("\n") + .append("\n\n"); for (final Map.Entry> entry : headers.entrySet()) { List headersList = entry.getValue(); if (headersList != null && !headersList.isEmpty()) { for (String headerValue : headersList) { writer.append("") - .append("\n"); + .append("\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); diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabResponse.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabResponse.java index 12ffc00ea..03ae26248 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabResponse.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabResponse.java @@ -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> 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 map(Map> headers) { + private Map map(final Map> headers) { Map result = new HashMap(); for (Map.Entry> 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("

Status Code

\n") - .append("

").append(Integer.toString(status.getStatusCode())).append(' ') - .append(status.getInfo()).append("

\n") - .append("

Response Headers

\n"); + .append("

").append(Integer.toString(status.getStatusCode())).append(' ') + .append(status.getInfo()).append("

\n") + .append("

Response Headers

\n"); DebugResponseHelperImpl.appendHtmlTable(writer, map(headers)); writer.append("

Response Body

\n"); if (response != null && response.getContent() != null) { diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabRuntime.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabRuntime.java index 757a8b38d..573764608 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabRuntime.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabRuntime.java @@ -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 runtimeInformation) { + public DebugTabRuntime(final List 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("
  • \n") - .append("") - .append("").append(draw) - .append(isLast ? "└" : "├").append("─ ") - .append("").append(node.className).append(".") - .append("").append(node.methodName).append("(…)") - .append(""); + .append("") + .append("").append(draw) + .append(isLast ? "└" : "├").append("─ ") + .append("").append(node.className).append(".") + .append("").append(node.methodName).append("(…)") + .append(""); long time = node.timeStopped == 0 ? 0 : (node.timeStopped - node.timeStarted) / 1000; writer.append("").append(time == 0 ? "unfinished" : Long.toString(time) + " µs") - .append("\n"); + .append("\" title=\"").append(time == 0 ? "Stop time missing" : "Gross duration") + .append("\">").append(time == 0 ? "unfinished" : Long.toString(time) + " µs") + .append("\n"); } if (!node.children.isEmpty()) { writer.append("
      \n"); for (final RuntimeNode childNode : node.children) { appendRuntimeNode(childNode, node.className == null ? draw : draw + (isLast ? " " : "│") + "  ", - node.children.indexOf(childNode) == node.children.size() - 1, - writer); + node.children.indexOf(childNode) == node.children.size() - 1, + writer); } writer.append("
    \n"); } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabServer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabServer.java index 1601075ba..9c762466f 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabServer.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabServer.java @@ -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 serverEnvironmentVariables; - public DebugTabServer(Map serverEnvironmentVariables) { + public DebugTabServer(final Map 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("

    Library Version

    \n") - .append("

    ").append(DebugResponseHelperImpl.getVersion()).append("

    \n") - .append("

    Server Environment

    \n"); + .append("

    ").append(DebugResponseHelperImpl.getVersion()).append("

    \n") + .append("

    Server Environment

    \n"); DebugResponseHelperImpl.appendHtmlTable(writer, serverEnvironmentVariables); } } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabStacktrace.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabStacktrace.java index 0d79e855a..3cc94b6f4 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabStacktrace.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabStacktrace.java @@ -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("

    ").append(throwable.getClass().getCanonicalName()).append("

    \n") - .append("

    ") - .append(DebugResponseHelperImpl.escapeHtml(getMessageText(throwable))) - .append("

    \n"); + .append("

    ") + .append(DebugResponseHelperImpl.escapeHtml(getMessageText(throwable))) + .append("

    \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("
  • NameValue
    NameValue
    ").append(entry.getKey()).append("") - .append(DebugResponseHelperImpl.escapeHtml(headerValue)) - .append("
    ") + .append(DebugResponseHelperImpl.escapeHtml(headerValue)) + .append("
    \n\n") - .append("\n\n") - .append("\n") - .append("\n\n") - .append("\n\n"); + .append("\n\n") + .append("\n") + .append("\n\n") + .append("\n\n"); } writer.append("\n\n") - .append("\n") - .append("\n\n"); + .append("\n") + .append("\n\n"); if (isLast) { writer.append("\n
    ClassMethodLine number in class
    ClassMethodLine number in class
    ").append(stackTraceElement.getClassName()).append("").append(stackTraceElement.getMethodName()).append("").append(Integer.toString(stackTraceElement.getLineNumber())) - .append("
    ").append(stackTraceElement.getMethodName()).append("").append(Integer.toString(stackTraceElement.getLineNumber())) + .append("
    \n"); } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabUri.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabUri.java index d36221d1c..906db1950 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabUri.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabUri.java @@ -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 uriResourceParts) throws IOException { + private void appendURIResourceParts(final JsonGenerator gen, final List 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 parameters) + private void appendParameters(final JsonGenerator gen, final String name, final List parameters) throws IOException { if (!parameters.isEmpty()) { Map parameterMap = new LinkedHashMap(); @@ -184,7 +187,7 @@ public class DebugTabUri implements DebugTab { } } - private void appendOrderByItemsJson(JsonGenerator gen, final List orders) throws IOException { + private void appendOrderByItemsJson(final JsonGenerator gen, final List 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 expandItems) throws IOException { + private void appendExpandedPropertiesJson(final JsonGenerator gen, final List 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 selectItems) throws IOException { + private void appendSelectedPropertiesJson(final JsonGenerator gen, final List 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("

    Resource Path

    \n") - .append("
      \n
    • "); + .append("
        \n
      • "); 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("

        Search Option

        \n") - .append("
          \n
        • "); + .append("
            \n
          • "); 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("

            Filter Option

            \n") - .append("
              \n
            • "); + .append("
                \n
              • "); 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("

                OrderBy Option

                \n") - .append("
                  \n
                • "); + .append("
                    \n
                  • "); 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("

                    Expand Option

                    \n") - .append("
                      \n
                    • "); + .append("
                        \n
                      • "); 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("

                        Selected Properties

                        \n") - .append("
                          \n"); + .append("
                            \n"); for (final SelectItem selectItem : uriInfo.getSelectOption().getSelectItems()) { writer.append("
                          • ").append(getSelectString(selectItem)).append("
                          • \n"); } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/ExpressionJsonVisitor.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/ExpressionJsonVisitor.java index cb87b08de..bf3797314 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/ExpressionJsonVisitor.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/ExpressionJsonVisitor.java @@ -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 { @Override public JsonNode visitEnum(final EdmEnumType type, final List 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 { } } - 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 { 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(); } } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/ServerCoreDebugger.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/ServerCoreDebugger.java index 0ca965fb5..6aef2fbf4 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/ServerCoreDebugger.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/ServerCoreDebugger.java @@ -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 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; } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/DeserializerResultImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/DeserializerResultImpl.java index 4ea30ad78..01642c38f 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/DeserializerResultImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/DeserializerResultImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/FixedFormatDeserializerImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/FixedFormatDeserializerImpl.java index df6b4cc7d..bc77e66de 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/FixedFormatDeserializerImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/FixedFormatDeserializerImpl.java @@ -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 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); diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchBodyPart.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchBodyPart.java index 6c88da2ab..7cb031e37 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchBodyPart.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchBodyPart.java @@ -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 consumeChangeSet(List remainingMessage) + private List consumeChangeSet(final List remainingMessage) throws BatchDeserializerException { final List> changeRequests = splitChangeSet(remainingMessage); final List requestList = new LinkedList(); @@ -84,7 +84,7 @@ public class BatchBodyPart implements BatchPart { return requestList; } - private List> splitChangeSet(List remainingMessage) throws BatchDeserializerException { + private List> splitChangeSet(final List remainingMessage) throws BatchDeserializerException { final HeaderField contentTypeField = headers.getHeaderField(HttpHeader.CONTENT_TYPE); final String changeSetBoundary = BatchParserCommon.getBoundary(contentTypeField.getValue(), diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchChangeSetPart.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchChangeSetPart.java index 3c596fd8e..526880ae6 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchChangeSetPart.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchChangeSetPart.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchLineReader.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchLineReader.java index c0a1e206f..1a79985cf 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchLineReader.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchLineReader.java @@ -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 toList() throws IOException { final List result = new ArrayList(); String currentLine = readLine(); - if(currentLine != null) { + if (currentLine != null) { currentBoundary = currentLine.trim(); result.add(currentLine); @@ -80,7 +80,7 @@ public class BatchLineReader { public List toLineList() throws IOException { final List result = new ArrayList(); 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; } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchParser.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchParser.java index 243cbe0ca..c6c4c4922 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchParser.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchParser.java @@ -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 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 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> splitBodyParts(final InputStream in, final String boundary) throws IOException, - BatchDeserializerException { + BatchDeserializerException { final BatchLineReader reader = new BatchLineReader(in); final List message = reader.toLineList(); reader.close(); diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchParserCommon.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchParserCommon.java index bdb819573..055a56db8 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchParserCommon.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchParserCommon.java @@ -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 list) { + private static void removeEndingCRLFFromList(final List 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 remainingMessage) { + public static Header consumeHeaders(final List remainingMessage) { final int headerLineNumber = remainingMessage.size() != 0 ? remainingMessage.get(0).getLineNumber() : 0; final Header headers = new Header(headerLineNumber); final Iterator iter = remainingMessage.iterator(); @@ -189,7 +189,7 @@ public class BatchParserCommon { return headers; } - public static void consumeBlankLine(List remainingMessage, final boolean isStrict) + public static void consumeBlankLine(final List 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 list, final Charset charset, - final int length) { + final int length) { final String message = trimLineListToLength(list, length); return new ByteArrayInputStream(message.getBytes(charset)); diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchPart.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchPart.java index 13986c424..da969daa9 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchPart.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchPart.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchQueryOperation.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchQueryOperation.java index 8bbcb8191..ba32cedf9 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchQueryOperation.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchQueryOperation.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchRequestTransformator.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchRequestTransformator.java index 20ef8eadd..b9174c915 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchRequestTransformator.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchRequestTransformator.java @@ -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 { diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchTransformatorCommon.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchTransformatorCommon.java index 2f3d8bb37..d319f8639 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchTransformatorCommon.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchTransformatorCommon.java @@ -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) diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/Header.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/Header.java index 1391f94c6..66372abb4 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/Header.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/Header.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/HeaderField.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/HeaderField.java index fc0e156a2..9ad33434d 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/HeaderField.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/HeaderField.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/HttpRequestStatusLine.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/HttpRequestStatusLine.java index f2d006a99..1600ee6e2 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/HttpRequestStatusLine.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/HttpRequestStatusLine.java @@ -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())); } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/Line.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/Line.java index 6485a495d..341767091 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/Line.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/Line.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/helper/ExpandTreeBuilder.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/helper/ExpandTreeBuilder.java index 549cf3326..640100b7f 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/helper/ExpandTreeBuilder.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/helper/ExpandTreeBuilder.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/helper/ExpandTreeBuilderImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/helper/ExpandTreeBuilderImpl.java index f154074ca..b0287ff18 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/helper/ExpandTreeBuilderImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/helper/ExpandTreeBuilderImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java index 9639b3d37..7bbc4a03b 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java @@ -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 toRemove = new ArrayList(); Iterator> 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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializer.java index eb1f5de55..d3876b6bb 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializer.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializer.java @@ -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 entityRefCollection(XMLEventReader reader, StartElement start) + private List entityRefCollection(final XMLEventReader reader, final StartElement start) throws XMLStreamException { boolean foundEndElement = false; ArrayList references = new ArrayList(); @@ -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 references = new ArrayList(); @@ -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 parameters = new LinkedHashMap(); 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 parameters) throws DeserializerException, + private void consumeParameters(final EdmAction edmAction, final XMLEventReader reader, + final StartElement start, final Map parameters) throws DeserializerException, EdmPrimitiveTypeException, XMLStreamException { List 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); diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/etag/ETagHelperImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/etag/ETagHelperImpl.java index 81cefe3cf..168541f9d 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/etag/ETagHelperImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/etag/ETagHelperImpl.java @@ -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 ifMatchHeaders, final Collection 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 ifMatchHeaders, final Collection ifNoneMatchHeaders) - throws PreconditionException { + throws PreconditionException { if (eTag != null) { final ETagInformation ifMatch = createETagInformation(ifMatchHeaders); final ETagInformation ifNoneMatch = createETagInformation(ifNoneMatchHeaders); diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/etag/ETagInformation.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/etag/ETagInformation.java index 03310eca7..f71bcded2 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/etag/ETagInformation.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/etag/ETagInformation.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/etag/ETagParser.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/etag/ETagParser.java index 805a29c15..dee4c03be 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/etag/ETagParser.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/etag/ETagParser.java @@ -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; *

                            See RFC 7232 for details; * there the following grammar is defined:

                            *
                            - *     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
                              * 
                            *

                            Values with illegal syntax do not contribute to the result but no exception is thrown.

                            */ 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 parse(final Collection values) { diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/etag/PreconditionsValidator.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/etag/PreconditionsValidator.java index a8690d1fa..414eacda2 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/etag/PreconditionsValidator.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/etag/PreconditionsValidator.java @@ -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()); diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/prefer/PreferParser.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/prefer/PreferParser.java index eee795959..d142f09cf 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/prefer/PreferParser.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/prefer/PreferParser.java @@ -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; *

                            See RFC 7240 for details; * there the following grammar is defined:

                            *
                            - *     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
                              * 
                            *

                            Values with illegal syntax do not contribute to the result but no exception is thrown.

                            */ @@ -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 parse(final Collection values) { @@ -77,7 +77,7 @@ public class PreferParser { return result; } - private static void parse(final String value, Map result) { + private static void parse(final String value, final Map result) { Map partResult = new HashMap(); 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 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; diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/prefer/PreferencesImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/prefer/PreferencesImpl.java index ecafdc45f..85a724dad 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/prefer/PreferencesImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/prefer/PreferencesImpl.java @@ -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()); } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/AbstractODataSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/AbstractODataSerializer.java index 0f0eff62a..d29b3ff45 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/AbstractODataSerializer.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/AbstractODataSerializer.java @@ -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 { diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/AsyncResponseSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/AsyncResponseSerializer.java index 6f431d4af..ac779fc8e 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/AsyncResponseSerializer.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/AsyncResponseSerializer.java @@ -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> header = response.getAllHeaders(); - for (final Map.Entry> entry: header.entrySet()) { + for (final Map.Entry> 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); diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/BatchResponseSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/BatchResponseSerializer.java index d99d94303..a5afba1fd 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/BatchResponseSerializer.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/BatchResponseSerializer.java @@ -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() { diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/FixedFormatSerializerImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/FixedFormatSerializerImpl.java index 3066839d2..f21f06404 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/FixedFormatSerializerImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/FixedFormatSerializerImpl.java @@ -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); } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/SerializerResultImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/SerializerResultImpl.java index 53dca1999..0d35f2c3d 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/SerializerResultImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/SerializerResultImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataErrorSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataErrorSerializer.java index c3c39d0ea..9a84c27b2 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataErrorSerializer.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataErrorSerializer.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java index b5a2c6aab..a9128627a 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java @@ -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 properties, final SelectOption select, final JsonGenerator json) - throws IOException, SerializerException { + throws IOException, SerializerException { final boolean all = ExpandSelectHelper.isAll(select); final Set selected = all ? new HashSet() : - 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> 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 expanded = expandAll ? new HashSet() : - 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> 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> 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> 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 properties, final Set> 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 values = property.isNull() ? Collections. 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()); } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentJsonSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentJsonSerializer.java index 9625a4c88..682e47821 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentJsonSerializer.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentJsonSerializer.java @@ -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) { diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/CircleStreamBuffer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/CircleStreamBuffer.java index 20d9ca539..ac91b84bb 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/CircleStreamBuffer.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/CircleStreamBuffer.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ContentTypeHelper.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ContentTypeHelper.java index 87101587c..68d85f7a0 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ContentTypeHelper.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ContentTypeHelper.java @@ -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)); } } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ContextURLBuilder.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ContextURLBuilder.java index 8c7a8d57a..39649abb3 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ContextURLBuilder.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ContextURLBuilder.java @@ -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()); } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ContextURLHelper.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ContextURLHelper.java index 22a2301dc..129f24254 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ContextURLHelper.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ContextURLHelper.java @@ -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 resourceParts = expandItem.getResourcePath().getUriResourceParts(); - if(resourceParts.size() > 1) { + if (resourceParts.size() > 1) { if (result.length() > 0) { result.append(','); - } + } final List 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> getComplexSelectedPaths(final EdmProperty edmProperty, final Set> selectedPaths) { List> result = new ArrayList>(); diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ExpandSelectHelper.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ExpandSelectHelper.java index 30810f088..13e158f76 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ExpandSelectHelper.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ExpandSelectHelper.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java index 4a3a6ef84..a0fd0217c 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java @@ -226,7 +226,7 @@ public class MetadataDocumentXmlSerializer { writer.writeEndElement(); } - private void appendTerms(XMLStreamWriter writer, List terms) throws XMLStreamException { + private void appendTerms(final XMLStreamWriter writer, final List 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 annotationGroups) + private void appendAnnotationGroups(final XMLStreamWriter writer, final List 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 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); } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializer.java index 2af8edeac..52d12e41f 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializer.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializer.java @@ -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); diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ServiceDocumentXmlSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ServiceDocumentXmlSerializer.java index 19d132bbb..835194506 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ServiceDocumentXmlSerializer.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ServiceDocumentXmlSerializer.java @@ -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); diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriHelperImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriHelperImpl.java index c463765d0..f1bd75ea7 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriHelperImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriHelperImpl.java @@ -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; } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriInfoImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriInfoImpl.java index bc396f7dd..e6fe05733 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriInfoImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriInfoImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriParameterImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriParameterImpl.java index b650cc5e9..7ab2abe0d 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriParameterImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriParameterImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceActionImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceActionImpl.java index 4126110d3..d7f02ae27 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceActionImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceActionImpl.java @@ -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); diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceComplexPropertyImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceComplexPropertyImpl.java index 63db69cb6..8e78b16e2 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceComplexPropertyImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceComplexPropertyImpl.java @@ -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(); diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceCountImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceCountImpl.java index e1859a6f3..59cd677b6 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceCountImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceCountImpl.java @@ -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"; } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceEntitySetImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceEntitySetImpl.java index 467596472..888a34b3d 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceEntitySetImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceEntitySetImpl.java @@ -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() { diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceFunctionImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceFunctionImpl.java index a47a6ab75..42361e05b 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceFunctionImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceFunctionImpl.java @@ -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 getParameters() { return parameters == null ? Collections. emptyList() : - Collections.unmodifiableList(parameters); + Collections.unmodifiableList(parameters); } public UriResourceFunctionImpl setParameters(final List parameters) { diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceImpl.java index 9fbcbd013..46c1c00d9 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceItImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceItImpl.java index fc31910e9..461c59b55 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceItImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceItImpl.java @@ -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"; } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaAllImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaAllImpl.java index b57d12c87..89674f96d 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaAllImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaAllImpl.java @@ -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"; } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaAnyImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaAnyImpl.java index 49be2fe5e..6cad64805 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaAnyImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaAnyImpl.java @@ -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"; } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaVarImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaVarImpl.java index f7fa6fc3a..90b29ca96 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaVarImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaVarImpl.java @@ -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(); diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceNavigationPropertyImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceNavigationPropertyImpl.java index 1a4fa444c..0a6319c99 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceNavigationPropertyImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceNavigationPropertyImpl.java @@ -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(); } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourcePrimitivePropertyImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourcePrimitivePropertyImpl.java index d470ef4c1..a666c18e7 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourcePrimitivePropertyImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourcePrimitivePropertyImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceRefImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceRefImpl.java index 0c45f9a35..850b94054 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceRefImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceRefImpl.java @@ -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"; } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceRootImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceRootImpl.java index 5d8737f68..906f07b4e 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceRootImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceRootImpl.java @@ -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"; } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceSingletonImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceSingletonImpl.java index 72289f6a1..30e29c78a 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceSingletonImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceSingletonImpl.java @@ -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(); } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceStartingTypeFilterImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceStartingTypeFilterImpl.java index 24d371356..a42cf8f3d 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceStartingTypeFilterImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceStartingTypeFilterImpl.java @@ -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(); diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceTypedImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceTypedImpl.java index d6710adba..cdfa0130b 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceTypedImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceTypedImpl.java @@ -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) { diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceValueImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceValueImpl.java index 73f86c402..2cc89cb6b 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceValueImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceValueImpl.java @@ -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"; } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceWithKeysImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceWithKeysImpl.java index 54d62a1d6..83ec32d95 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceWithKeysImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceWithKeysImpl.java @@ -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 getKeyPredicates() { return keyPredicates == null ? Collections. emptyList() : - new ArrayList(keyPredicates); + new ArrayList(keyPredicates); } public UriResourceWithKeysImpl setKeyPredicates(final List list) { diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/CheckFullContextListener.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/CheckFullContextListener.java index 86efdca86..bdfdf4c69 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/CheckFullContextListener.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/CheckFullContextListener.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java index d12b85370..fc806eef7 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java @@ -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()); } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/RawUri.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/RawUri.java index 42e0a0f31..231317f87 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/RawUri.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/RawUri.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriContext.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriContext.java index b6b6fda10..b0312ceba 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriContext.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriContext.java @@ -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; diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriDecoder.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriDecoder.java index 4649ac55a..72bab53a0 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriDecoder.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriDecoder.java @@ -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 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)); } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java index 1e33a190d..e4772c433 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java @@ -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 { 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 { 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 { 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 { 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 { // 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 { ctx.vlNVO.remove(0); UriResourceFunctionImpl uriResource = new UriResourceFunctionImpl() - .setFunctionImport(edmFunctionImport, parameters); + .setFunctionImport(edmFunctionImport, parameters); // collect parameter names List names = new ArrayList(); @@ -479,7 +477,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { 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 { || 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 { } 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 { 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 { 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 { 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 { 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 { @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 { @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 { @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 { 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 { 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 parts = test.getUriResourceParts(); if (!parts.isEmpty()) { UriResource lastPart = parts.get(parts.size() - 1); @@ -1419,7 +1417,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { 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 { 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 { @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 { @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 { @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 { @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 { 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 { // 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 { 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 { @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 { @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 { /* * if (contextUriInfo.getLastResourcePart() == null || * contextUriInfo.getLastResourcePart() instanceof UriResourceRootImpl) { - * + * * } else { * readNextPathInfoSegment(ctx); * } @@ -1936,7 +1934,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { @SuppressWarnings("unchecked") List list = (List) 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 { } @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 { 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 { } 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 { final QueryOptionImpl result = new SelectOptionImpl().setSelectItems(selectItems).setText(ctx.getText()); context.contextReadingQueryPart = false; - + return result; } @@ -2353,7 +2351,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { * 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 { 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 { @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 { @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 { 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; } } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParserException.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParserException.java index 8623d12fc..44b3783cd 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParserException.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParserException.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParserSemanticException.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParserSemanticException.java index 9135dd84d..33dd321ce 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParserSemanticException.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParserSemanticException.java @@ -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(); diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParserSyntaxException.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParserSyntaxException.java index 31f69d304..895e31eb2 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParserSyntaxException.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParserSyntaxException.java @@ -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; diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchBinaryImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchBinaryImpl.java index 418d9e75a..950383c2d 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchBinaryImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchBinaryImpl.java @@ -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; diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchExpressionImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchExpressionImpl.java index ee5a19773..b2970bdd4 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchExpressionImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchExpressionImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchParser.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchParser.java index ac0bb7d19..4fccb81a5 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchParser.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchParser.java @@ -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,11 +31,11 @@ import org.apache.olingo.server.core.uri.queryoption.SearchOptionImpl; /* * Rewritten grammar * - * SearchExpr ::= ExprOR - * ExprOR ::= ExprAnd ('OR' ExprAnd)* - * ExprAnd ::= Term ('AND'? Term)* - * Term ::= ('NOT')? (Word | Phrase) - * | '(' Expr ')' + * SearchExpr ::= ExprOR + * ExprOR ::= ExprAnd ('OR' ExprAnd)* + * ExprAnd ::= Term ('AND'? Term)* + * Term ::= ('NOT')? (Word | Phrase) + * | '(' Expr ')' */ public class SearchParser { @@ -43,7 +43,7 @@ public class SearchParser { private Iterator tokens; private SearchQueryToken token; - public SearchOption parse(String searchQuery) throws SearchParserException, SearchTokenizerException { + public SearchOption parse(final String searchQuery) throws SearchParserException, SearchTokenizerException { SearchTokenizer tokenizer = new SearchTokenizer(); SearchExpression searchExpression; try { @@ -51,21 +51,21 @@ public class SearchParser { } catch (SearchTokenizerException e) { String message = e.getMessage(); throw new SearchParserException("Tokenizer exception with message: " + message, - SearchParserException.MessageKeys.TOKENIZER_EXCEPTION, message); + SearchParserException.MessageKeys.TOKENIZER_EXCEPTION, message); } final SearchOptionImpl searchOption = new SearchOptionImpl(); searchOption.setSearchExpression(searchExpression); return searchOption; } - protected SearchExpression parse(List tokens) throws SearchParserException { + protected SearchExpression parse(final List tokens) throws SearchParserException { this.tokens = tokens.iterator(); nextToken(); if (token == null) { throw new SearchParserException("No search String", SearchParserException.MessageKeys.NO_EXPRESSION_FOUND); } SearchExpression searchExpression = processSearchExpression(); - if(!isEof()) { + if (!isEof()) { throw new SearchParserException("Token left after end of search query parsing.", SearchParserException.MessageKeys.INVALID_END_OF_QUERY, getTokenAsString()); } @@ -73,41 +73,41 @@ public class SearchParser { } private SearchExpression processSearchExpression() throws SearchParserException { - return processExprOr(); + return processExprOr(); } private SearchExpression processExprOr() throws SearchParserException { SearchExpression left = processExprAnd(); - - while(isToken(Token.OR)) { - nextToken(); // Match OR + + while (isToken(Token.OR)) { + nextToken(); // Match OR final SearchExpression right = processExprAnd(); left = new SearchBinaryImpl(left, SearchBinaryOperatorKind.OR, right); } - + return left; } private SearchExpression processExprAnd() throws SearchParserException { SearchExpression left = processTerm(); - - while(isToken(Token.AND) || isTerm()) { - if(isToken(Token.AND)) { - nextToken(); // Match AND + + while (isToken(Token.AND) || isTerm()) { + if (isToken(Token.AND)) { + nextToken(); // Match AND } final SearchExpression right = processTerm(); left = new SearchBinaryImpl(left, SearchBinaryOperatorKind.AND, right); } - + return left; } private SearchExpression processTerm() throws SearchParserException { - if(isToken(SearchQueryToken.Token.OPEN)) { - nextToken(); // Match OPEN + if (isToken(SearchQueryToken.Token.OPEN)) { + nextToken(); // Match OPEN final SearchExpression expr = processExprOr(); processClose(); - + return expr; } else { // ('NOT')? (Word | Phrase) @@ -137,14 +137,14 @@ public class SearchParser { throw new SearchParserException("NOT must be followed by a term not a " + tokenAsString, SearchParserException.MessageKeys.INVALID_NOT_OPERAND, tokenAsString); } - + private SearchTerm processWordOrPhrase() throws SearchParserException { if (isToken(Token.PHRASE)) { return processPhrase(); } else if (isToken(Token.WORD)) { return processWord(); } - + final String tokenName = getTokenAsString(); throw new SearchParserException("Expected PHRASE||WORD found: " + tokenName, SearchParserException.MessageKeys.EXPECTED_DIFFERENT_TOKEN, @@ -160,21 +160,21 @@ public class SearchParser { private SearchTerm processPhrase() { String literal = token.getLiteral(); nextToken(); - return new SearchTermImpl(literal.substring(1,literal.length()-1)); + return new SearchTermImpl(literal.substring(1, literal.length() - 1)); } - + private boolean isTerm() { return isToken(SearchQueryToken.Token.NOT) || isToken(SearchQueryToken.Token.PHRASE) || isToken(SearchQueryToken.Token.WORD) || isToken(SearchQueryToken.Token.OPEN); } - + private boolean isEof() { return token == null; } - private boolean isToken(SearchQueryToken.Token toCheckToken) { + private boolean isToken(final SearchQueryToken.Token toCheckToken) { return token != null && token.getToken() == toCheckToken; } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchParserException.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchParserException.java index d7af4d438..293bc3133 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchParserException.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchParserException.java @@ -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 @@ -36,7 +36,7 @@ public class SearchParserException extends UriParserSyntaxException { EXPECTED_DIFFERENT_TOKEN, /** parameter: actual token */ INVALID_END_OF_QUERY; - + @Override public String getKey() { return name(); diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchQueryToken.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchQueryToken.java index 3fb66f1ac..0fbab47c1 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchQueryToken.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchQueryToken.java @@ -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 @@ -19,8 +19,11 @@ package org.apache.olingo.server.core.uri.parser.search; public interface SearchQueryToken { - enum Token {OPEN, NOT, AND, OR, WORD, PHRASE, CLOSE} + enum Token { + OPEN, NOT, AND, OR, WORD, PHRASE, CLOSE + } Token getToken(); + String getLiteral(); } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchTermImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchTermImpl.java index efd728028..54f707541 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchTermImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchTermImpl.java @@ -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,7 @@ import org.apache.olingo.server.api.uri.queryoption.search.SearchTerm; public class SearchTermImpl extends SearchExpressionImpl implements SearchTerm { private final String term; - public SearchTermImpl(String term) { + public SearchTermImpl(final String term) { this.term = term; } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchTokenizer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchTokenizer.java index 546135d31..4b888699f 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchTokenizer.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchTokenizer.java @@ -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,39 +62,40 @@ public class SearchTokenizer { protected static final char CHAR_CLOSE = ')'; protected static final char CHAR_OPEN = '('; - public State() { - } - public State(Token t) { + public State() {} + + public State(final Token t) { token = t; } - public State(Token t, boolean finished) { + + public State(final Token t, final boolean finished) { this(t); this.finished = finished; } protected abstract State nextChar(char c) throws SearchTokenizerException; - public State allowed(char c) { + public State allowed(final char c) { return this; } - public State forbidden(char c) throws SearchTokenizerException { - throw new SearchTokenizerException("Forbidden character in state " + this.getToken() + "->" + c, + public State forbidden(final char c) throws SearchTokenizerException { + throw new SearchTokenizerException("Forbidden character in state " + getToken() + "->" + c, SearchTokenizerException.MessageKeys.FORBIDDEN_CHARACTER, "" + c); } public State invalid() throws SearchTokenizerException { - throw new SearchTokenizerException("Token " + this.getToken() + " is in invalid state.", + throw new SearchTokenizerException("Token " + getToken() + " is in invalid state.", SearchTokenizerException.MessageKeys.INVALID_TOKEN_STATE); } public State finish() { - this.finished = true; + finished = true; return this; } - public State finishAs(Token token) { - this.finished = true; + public State finishAs(final Token token) { + finished = true; return changeToken(token); } @@ -102,12 +103,13 @@ public class SearchTokenizer { return finished; } + @Override public Token getToken() { return token; } public String getTokenName() { - if(token == null) { + if (token == null) { return "NULL"; } return token.name(); @@ -117,7 +119,7 @@ public class SearchTokenizer { return this; } - protected State changeToken(Token token) { + protected State changeToken(final Token token) { this.token = token; return this; } @@ -172,13 +174,12 @@ public class SearchTokenizer { return isQCharUnescaped(character) || character == '%'; } - /** * qchar-unescaped = unreserved / pct-encoded-unescaped / other-delims / ":" / "@" / "/" / "?" / "$" / "'" / "=" * @param character which is checked * @return true if character is allowed */ - private static boolean isQCharUnescaped(char character) { + private static boolean isQCharUnescaped(final char character) { return isUnreserved(character) || isOtherDelims(character) || character == ':' @@ -194,7 +195,7 @@ public class SearchTokenizer { * @param character which is checked * @return true if character is allowed */ - private static boolean isOtherDelims(char character) { + private static boolean isOtherDelims(final char character) { return character == '!' || character == '(' || character == ')' @@ -209,7 +210,7 @@ public class SearchTokenizer { * @param character which is checked * @return true if character is allowed */ - private static boolean isUnreserved(char character) { + private static boolean isUnreserved(final char character) { return isAlphaOrDigit(character) || character == '-' || character == '.' @@ -223,7 +224,7 @@ public class SearchTokenizer { * @param character which is checked * @return true if character is allowed */ - private static boolean isAlphaOrDigit(char character) { + private static boolean isAlphaOrDigit(final char character) { return 'A' <= character && character <= 'Z' // case A..Z || 'a' <= character && character <= 'z' // case a..z || '0' <= character && character <= '9'; // case 0..9 @@ -248,20 +249,23 @@ public class SearchTokenizer { private static abstract class LiteralState extends State { protected final StringBuilder literal = new StringBuilder(); + public LiteralState() { super(); } - public LiteralState(Token t, char c) throws SearchTokenizerException { + + public LiteralState(final Token t, final char c) throws SearchTokenizerException { super(t); init(c); } - public LiteralState(Token t, String initLiteral) { + public LiteralState(final Token t, final String initLiteral) { super(t); literal.append(initLiteral); } - public State allowed(char c) { + @Override + public State allowed(final char c) { literal.append(c); return this; } @@ -271,7 +275,7 @@ public class SearchTokenizer { return literal.toString(); } - public State init(char c) throws SearchTokenizerException { + public State init(final char c) throws SearchTokenizerException { if (isFinished()) { throw new SearchTokenizerException(toString() + " is already finished.", SearchTokenizerException.MessageKeys.ALREADY_FINISHED, getTokenName()); @@ -283,7 +287,7 @@ public class SearchTokenizer { private class SearchExpressionState extends LiteralState { @Override - public State nextChar(char c) throws SearchTokenizerException { + public State nextChar(final char c) throws SearchTokenizerException { if (c == CHAR_OPEN) { return new OpenState(); } else if (isWhitespace(c)) { @@ -296,14 +300,14 @@ public class SearchTokenizer { } @Override - public State init(char c) throws SearchTokenizerException { + public State init(final char c) throws SearchTokenizerException { return nextChar(c); } } private class SearchTermState extends LiteralState { @Override - public State nextChar(char c) throws SearchTokenizerException { + public State nextChar(final char c) throws SearchTokenizerException { if (c == CHAR_N) { return new NotState(c); } else if (c == QUOTATION_MARK) { @@ -315,20 +319,20 @@ public class SearchTokenizer { } @Override - public State init(char c) throws SearchTokenizerException { + public State init(final char c) throws SearchTokenizerException { return nextChar(c); } } private class SearchWordState extends LiteralState { - public SearchWordState(char c) throws SearchTokenizerException { + public SearchWordState(final char c) throws SearchTokenizerException { super(Token.WORD, c); if (!isAllowedWord(c)) { forbidden(c); } } - public SearchWordState(State toConsume) throws SearchTokenizerException { + public SearchWordState(final State toConsume) throws SearchTokenizerException { super(Token.WORD, toConsume.getLiteral()); for (int i = 0; i < literal.length(); i++) { if (!isAllowedWord(literal.charAt(i))) { @@ -338,7 +342,7 @@ public class SearchTokenizer { } @Override - public State nextChar(char c) throws SearchTokenizerException { + public State nextChar(final char c) throws SearchTokenizerException { if (isAllowedWord(c)) { return allowed(c); } else if (c == CHAR_CLOSE) { @@ -354,13 +358,13 @@ public class SearchTokenizer { @Override public State finish() { String tmpLiteral = literal.toString(); - if(tmpLiteral.length() == 3) { - if(Token.AND.name().equals(tmpLiteral)) { + if (tmpLiteral.length() == 3) { + if (Token.AND.name().equals(tmpLiteral)) { return finishAs(Token.AND); - } else if(Token.NOT.name().equals(tmpLiteral)) { + } else if (Token.NOT.name().equals(tmpLiteral)) { return finishAs(Token.NOT); } - } else if(tmpLiteral.length() == 2 && Token.OR.name().equals(tmpLiteral)) { + } else if (tmpLiteral.length() == 2 && Token.OR.name().equals(tmpLiteral)) { return finishAs(Token.OR); } return super.finish(); @@ -375,7 +379,8 @@ public class SearchTokenizer { private class SearchPhraseState extends LiteralState { private boolean closed = false; private boolean escaped = false; - public SearchPhraseState(char c) throws SearchTokenizerException { + + public SearchPhraseState(final char c) throws SearchTokenizerException { super(Token.PHRASE, c); if (c != QUOTATION_MARK) { forbidden(c); @@ -383,22 +388,22 @@ public class SearchTokenizer { } @Override - public State nextChar(char c) throws SearchTokenizerException { - if(closed) { + public State nextChar(final char c) throws SearchTokenizerException { + if (closed) { finish(); if (c == CHAR_CLOSE) { return new CloseState(); } else if (isWhitespace(c)) { return new RwsState(); } - } else if(escaped) { + } else if (escaped) { escaped = false; - if(c == QUOTATION_MARK || c == PHRASE_ESCAPE_CHAR) { + if (c == QUOTATION_MARK || c == PHRASE_ESCAPE_CHAR) { return allowed(c); } else { return forbidden(c); } - } else if(c == PHRASE_ESCAPE_CHAR) { + } else if (c == PHRASE_ESCAPE_CHAR) { escaped = true; return this; } else if (isAllowedPhrase(c)) { @@ -406,7 +411,7 @@ public class SearchTokenizer { } else if (isWhitespace(c)) { return allowed(c); } else if (c == QUOTATION_MARK) { - if(literal.length() == 1) { + if (literal.length() == 1) { return invalid(); } closed = true; @@ -417,7 +422,7 @@ public class SearchTokenizer { @Override public State close() throws SearchTokenizerException { - if(closed) { + if (closed) { return finish(); } return invalid(); @@ -430,7 +435,7 @@ public class SearchTokenizer { } @Override - public State nextChar(char c) throws SearchTokenizerException { + public State nextChar(final char c) throws SearchTokenizerException { finish(); if (isWhitespace(c)) { return forbidden(c); @@ -445,13 +450,13 @@ public class SearchTokenizer { } @Override - public State nextChar(char c) throws SearchTokenizerException { + public State nextChar(final char c) throws SearchTokenizerException { return new SearchExpressionState().init(c); } } private class NotState extends LiteralState { - public NotState(char c) throws SearchTokenizerException { + public NotState(final char c) throws SearchTokenizerException { super(Token.NOT, c); if (c != CHAR_N) { forbidden(c); @@ -459,7 +464,7 @@ public class SearchTokenizer { } @Override - public State nextChar(char c) throws SearchTokenizerException { + public State nextChar(final char c) throws SearchTokenizerException { if (literal.length() == 1 && c == CHAR_O) { return allowed(c); } else if (literal.length() == 2 && c == CHAR_T) { @@ -467,16 +472,17 @@ public class SearchTokenizer { } else if (literal.length() == 3 && isWhitespace(c)) { finish(); return new BeforePhraseOrWordRwsState(); - } else if(isWhitespace(c)) { + } else if (isWhitespace(c)) { changeToken(Token.WORD).finish(); return new RwsState(); } literal.append(c); return new SearchWordState(this); } + @Override public State close() throws SearchTokenizerException { - if(Token.NOT.name().equals(literal.toString())) { + if (Token.NOT.name().equals(literal.toString())) { return finish(); } return changeToken(Token.WORD).finish(); @@ -484,7 +490,7 @@ public class SearchTokenizer { } private class AndState extends LiteralState { - public AndState(char c) throws SearchTokenizerException { + public AndState(final char c) throws SearchTokenizerException { super(Token.AND, c); if (c != CHAR_A) { forbidden(c); @@ -492,7 +498,7 @@ public class SearchTokenizer { } @Override - public State nextChar(char c) throws SearchTokenizerException { + public State nextChar(final char c) throws SearchTokenizerException { if (literal.length() == 1 && c == CHAR_N) { return allowed(c); } else if (literal.length() == 2 && c == CHAR_D) { @@ -500,16 +506,17 @@ public class SearchTokenizer { } else if (literal.length() == 3 && isWhitespace(c)) { finish(); return new BeforeSearchExpressionRwsState(); - } else if(isWhitespace(c)) { + } else if (isWhitespace(c)) { changeToken(Token.WORD).finish(); return new RwsState(); } literal.append(c); return new SearchWordState(this); } + @Override public State close() throws SearchTokenizerException { - if(Token.AND.name().equals(literal.toString())) { + if (Token.AND.name().equals(literal.toString())) { return finish(); } return changeToken(Token.WORD).finish(); @@ -517,29 +524,31 @@ public class SearchTokenizer { } private class OrState extends LiteralState { - public OrState(char c) throws SearchTokenizerException { + public OrState(final char c) throws SearchTokenizerException { super(Token.OR, c); if (c != CHAR_O) { forbidden(c); } } + @Override - public State nextChar(char c) throws SearchTokenizerException { + public State nextChar(final char c) throws SearchTokenizerException { if (literal.length() == 1 && (c == CHAR_R)) { return allowed(c); } else if (literal.length() == 2 && isWhitespace(c)) { finish(); return new BeforeSearchExpressionRwsState(); - } else if(isWhitespace(c)) { + } else if (isWhitespace(c)) { changeToken(Token.WORD).finish(); return new RwsState(); } literal.append(c); return new SearchWordState(this); } + @Override public State close() throws SearchTokenizerException { - if(Token.OR.name().equals(literal.toString())) { + if (Token.OR.name().equals(literal.toString())) { return finish(); } return changeToken(Token.WORD).finish(); @@ -550,7 +559,7 @@ public class SearchTokenizer { // RWS [ 'AND' RWS ] searchExpr private class BeforeSearchExpressionRwsState extends State { @Override - public State nextChar(char c) throws SearchTokenizerException { + public State nextChar(final char c) throws SearchTokenizerException { if (isWhitespace(c)) { return allowed(c); } else { @@ -561,7 +570,7 @@ public class SearchTokenizer { private class BeforePhraseOrWordRwsState extends State { @Override - public State nextChar(char c) throws SearchTokenizerException { + public State nextChar(final char c) throws SearchTokenizerException { if (isWhitespace(c)) { return allowed(c); } else if (c == QUOTATION_MARK) { @@ -574,7 +583,7 @@ public class SearchTokenizer { private class RwsState extends State { @Override - public State nextChar(char c) throws SearchTokenizerException { + public State nextChar(final char c) throws SearchTokenizerException { if (isWhitespace(c)) { return allowed(c); } else if (c == CHAR_O) { diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchTokenizerException.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchTokenizerException.java index 6ebec5ae8..bf3baf245 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchTokenizerException.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchTokenizerException.java @@ -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 @@ -25,7 +25,7 @@ public class SearchTokenizerException extends UriParserSyntaxException { private static final long serialVersionUID = -8295456415309640166L; public enum MessageKeys implements MessageKey { - /** parameter: character, TOKEN */ + /** parameter: character, TOKEN */ FORBIDDEN_CHARACTER, /** parameter: TOKEN */ NOT_EXPECTED_TOKEN, diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchUnaryImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchUnaryImpl.java index 51e3a2449..8e9335f29 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchUnaryImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchUnaryImpl.java @@ -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 @@ -25,7 +25,7 @@ import org.apache.olingo.server.api.uri.queryoption.search.SearchUnaryOperatorKi public class SearchUnaryImpl extends SearchExpressionImpl implements SearchUnary { private final SearchTerm operand; - public SearchUnaryImpl(SearchTerm operand) { + public SearchUnaryImpl(final SearchTerm operand) { this.operand = operand; } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/AliasQueryOptionImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/AliasQueryOptionImpl.java index 3a4fdf1bd..2f9492512 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/AliasQueryOptionImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/AliasQueryOptionImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/CountOptionImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/CountOptionImpl.java index fa35d2ed9..c4bfa7dbe 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/CountOptionImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/CountOptionImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/CustomQueryOptionImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/CustomQueryOptionImpl.java index 371377cde..2fe8a0148 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/CustomQueryOptionImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/CustomQueryOptionImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/ExpandItemImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/ExpandItemImpl.java index fb1a84e0b..3ccea062a 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/ExpandItemImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/ExpandItemImpl.java @@ -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 @@ -81,7 +81,7 @@ public class ExpandItemImpl implements ExpandItem { topOption = (TopOption) sysItem; } else if (sysItem instanceof LevelsExpandOption) { if (levelsExpandOption != null) { - throw new ODataRuntimeException("$levels"); + throw new ODataRuntimeException("$levels"); } levelsExpandOption = (LevelsExpandOption) sysItem; } @@ -90,7 +90,7 @@ public class ExpandItemImpl implements ExpandItem { private void validateDoubleSystemQueryOption(final SystemQueryOption oldOption, final SystemQueryOption newOption) { if (oldOption != null) { - throw new ODataRuntimeException(newOption.getName()); + throw new ODataRuntimeException(newOption.getName()); } } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/ExpandOptionImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/ExpandOptionImpl.java index bb4986dc1..05ee26052 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/ExpandOptionImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/ExpandOptionImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/FilterOptionImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/FilterOptionImpl.java index 50e8c46d7..4ca1f4466 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/FilterOptionImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/FilterOptionImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/FormatOptionImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/FormatOptionImpl.java index 607afbb3c..e0a47b802 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/FormatOptionImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/FormatOptionImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/IdOptionImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/IdOptionImpl.java index 309b30a9b..4295630d0 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/IdOptionImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/IdOptionImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/LevelsOptionImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/LevelsOptionImpl.java index dc17fdc7a..4388a0514 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/LevelsOptionImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/LevelsOptionImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/OrderByItemImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/OrderByItemImpl.java index aac33f0bb..a1276d329 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/OrderByItemImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/OrderByItemImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/OrderByOptionImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/OrderByOptionImpl.java index 5ff50dcc3..c23ddb693 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/OrderByOptionImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/OrderByOptionImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/QueryOptionImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/QueryOptionImpl.java index ac3f72199..26fb22d97 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/QueryOptionImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/QueryOptionImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/SearchOptionImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/SearchOptionImpl.java index 51323a852..45a0cd470 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/SearchOptionImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/SearchOptionImpl.java @@ -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 SearchOptionImpl extends SystemQueryOptionImpl implements SearchOpt return searchExpression; } - public void setSearchExpression(SearchExpression searchExpression) { + public void setSearchExpression(final SearchExpression searchExpression) { this.searchExpression = searchExpression; } } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/SelectItemImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/SelectItemImpl.java index 13d643626..8ead48969 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/SelectItemImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/SelectItemImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/SelectOptionImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/SelectOptionImpl.java index d9147e517..35c789f7d 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/SelectOptionImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/SelectOptionImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/SkipOptionImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/SkipOptionImpl.java index 84549e48f..aa63b87ba 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/SkipOptionImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/SkipOptionImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/SkipTokenOptionImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/SkipTokenOptionImpl.java index d440781f2..44b58e0a3 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/SkipTokenOptionImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/SkipTokenOptionImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/SystemQueryOptionImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/SystemQueryOptionImpl.java index ac27a59a7..c0f700f8c 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/SystemQueryOptionImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/SystemQueryOptionImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/TopOptionImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/TopOptionImpl.java index aa33120b8..c53c1aecc 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/TopOptionImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/TopOptionImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/AliasImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/AliasImpl.java index 09af93ff7..9489d0dec 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/AliasImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/AliasImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/BinaryImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/BinaryImpl.java index a28f92c8f..c5a9fc926 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/BinaryImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/BinaryImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/EnumerationImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/EnumerationImpl.java index 8f7df3a22..90530f4c3 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/EnumerationImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/EnumerationImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/ExpressionImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/ExpressionImpl.java index c9cc707a3..e64a363b0 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/ExpressionImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/ExpressionImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/LambdaRefImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/LambdaRefImpl.java index 8198204f0..0bf09fd7d 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/LambdaRefImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/LambdaRefImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/LiteralImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/LiteralImpl.java index 1dd9fa76a..bd9344028 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/LiteralImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/LiteralImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/MemberImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/MemberImpl.java index 5f6162fd2..307e17c83 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/MemberImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/MemberImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/MethodImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/MethodImpl.java index 7104a9ff8..bd982cde2 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/MethodImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/MethodImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/TypeLiteralImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/TypeLiteralImpl.java index f5f6f06c0..549db3301 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/TypeLiteralImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/TypeLiteralImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/UnaryImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/UnaryImpl.java index 796191f6f..4268d0837 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/UnaryImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/UnaryImpl.java @@ -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 diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidationException.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidationException.java index 01af75dc4..2d8f84207 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidationException.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidationException.java @@ -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,13 +54,12 @@ public class UriValidationException extends ODataLibraryException { /** parameter: unallowed kind before $value */ UNALLOWED_KIND_BEFORE_VALUE, /** parameter: unallowed kind before $count */ - UNALLOWED_KIND_BEFORE_COUNT, + UNALLOWED_KIND_BEFORE_COUNT, /** parameter: unallowed resource path */ UNALLOWED_RESOURCE_PATH, /** parameter: missing parameter name */ MISSING_PARAMETER; - @Override public String getKey() { return name(); diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java index f840e8e5a..9ffe69618 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java @@ -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 @@ -223,14 +223,14 @@ public class UriValidator { private RowIndexForUriType rowIndexForResourceKind(final UriInfo uriInfo) throws UriValidationException { RowIndexForUriType idx; - + final int nonComposableFunctionIndex = getIndexOfLastNonComposableFunction(uriInfo); - if(nonComposableFunctionIndex != -1 && (uriInfo.getUriResourceParts().size() - 1) > nonComposableFunctionIndex) { - throw new UriValidationException("Non composable functions followed by further resource parts are not allowed", - UriValidationException.MessageKeys.UNALLOWED_RESOURCE_PATH, + if (nonComposableFunctionIndex != -1 && (uriInfo.getUriResourceParts().size() - 1) > nonComposableFunctionIndex) { + throw new UriValidationException("Non composable functions followed by further resource parts are not allowed", + UriValidationException.MessageKeys.UNALLOWED_RESOURCE_PATH, uriInfo.getUriResourceParts().get(nonComposableFunctionIndex + 1).getSegmentValue()); } - + int lastPathSegmentIndex = uriInfo.getUriResourceParts().size() - 1; UriResource lastPathSegment = uriInfo.getUriResourceParts().get(lastPathSegmentIndex); @@ -249,7 +249,7 @@ public class UriValidator { idx = rowIndexForEntitySet(lastPathSegment); break; case function: - if(nonComposableFunctionIndex == -1) { + if (nonComposableFunctionIndex == -1) { idx = rowIndexForFunction(lastPathSegment); } else { idx = RowIndexForUriType.none; @@ -279,17 +279,17 @@ public class UriValidator { } private int getIndexOfLastNonComposableFunction(final UriInfo uriInfo) { - for(int i = 0; i < uriInfo.getUriResourceParts().size(); i++) { + for (int i = 0; i < uriInfo.getUriResourceParts().size(); i++) { final UriResource resourcePath = uriInfo.getUriResourceParts().get(i); - - if(resourcePath instanceof UriResourceFunction) { + + if (resourcePath instanceof UriResourceFunction) { final UriResourceFunction resourceFuntion = (UriResourceFunction) resourcePath; - if(!resourceFuntion.getFunction().isComposable()) { + if (!resourceFuntion.getFunction().isComposable()) { return i; } } } - + return -1; } @@ -312,9 +312,9 @@ public class UriValidator { final EdmFunctionImport functionImport = uriFunction.getFunctionImport(); final EdmFunction function = functionImport == null ? uriFunction.getFunction() : functionImport.getUnboundFunctions().get(0); - idx = function.getReturnType().getType().getKind() == EdmTypeKind.ENTITY ? - RowIndexForUriType.mediaStream : RowIndexForUriType.propertyPrimitiveValue; - break; + idx = function.getReturnType().getType().getKind() == EdmTypeKind.ENTITY ? + RowIndexForUriType.mediaStream : RowIndexForUriType.propertyPrimitiveValue; + break; default: throw new UriValidationException("Unexpected kind in path segment before $value: " + secondLastPathSegment.getKind(), UriValidationException.MessageKeys.UNALLOWED_KIND_BEFORE_VALUE, @@ -355,11 +355,10 @@ public class UriValidator { UriResourceFunction urf = (UriResourceFunction) lastPathSegment; EdmReturnType rt = urf.getFunction().getReturnType(); - if(!urf.getFunction().isComposable()) { + if (!urf.getFunction().isComposable()) { return RowIndexForUriType.none; } - - + switch (rt.getType().getKind()) { case ENTITY: idx = rt.isCollection() && urf.getKeyPredicates().isEmpty() ? @@ -450,24 +449,24 @@ public class UriValidator { final EdmFunctionImport functionImport = uriFunction.getFunctionImport(); final EdmFunction function = functionImport == null ? uriFunction.getFunction() : functionImport.getUnboundFunctions().get(0); - final EdmType returnType = function.getReturnType().getType(); - switch (returnType.getKind()) { - case ENTITY: - idx = RowIndexForUriType.entitySetCount; - break; - case COMPLEX: - idx = RowIndexForUriType.propertyComplexCollectionCount; - break; - case PRIMITIVE: - case ENUM: - case DEFINITION: - idx = RowIndexForUriType.propertyPrimitiveCollectionCount; - break; - default: - throw new UriValidationException("Unsupported return type: " + returnType.getKind(), - UriValidationException.MessageKeys.UNSUPPORTED_FUNCTION_RETURN_TYPE, returnType.getKind().toString()); - } - break; + final EdmType returnType = function.getReturnType().getType(); + switch (returnType.getKind()) { + case ENTITY: + idx = RowIndexForUriType.entitySetCount; + break; + case COMPLEX: + idx = RowIndexForUriType.propertyComplexCollectionCount; + break; + case PRIMITIVE: + case ENUM: + case DEFINITION: + idx = RowIndexForUriType.propertyPrimitiveCollectionCount; + break; + default: + throw new UriValidationException("Unsupported return type: " + returnType.getKind(), + UriValidationException.MessageKeys.UNSUPPORTED_FUNCTION_RETURN_TYPE, returnType.getKind().toString()); + } + break; default: throw new UriValidationException("Illegal path part kind before $count: " + secondLastPathSegment.getKind(), UriValidationException.MessageKeys.UNALLOWED_KIND_BEFORE_COUNT, secondLastPathSegment.toString()); @@ -560,136 +559,136 @@ public class UriValidator { private void validateParameters(final UriInfo uriInfo) throws UriValidationException { for (UriResource pathSegment : uriInfo.getUriResourceParts()) { final boolean isFunction = pathSegment.getKind() == UriResourceKind.function; - - if(isFunction) { + + if (isFunction) { final UriResourceFunction functionPathSegement = (UriResourceFunction) pathSegment; final EdmFunction edmFuntion = functionPathSegement.getFunction(); - + final Map parameters = new HashMap(); - for(final UriParameter parameter : functionPathSegement.getParameters()) { + for (final UriParameter parameter : functionPathSegement.getParameters()) { parameters.put(parameter.getName(), parameter); } - + boolean firstParameter = true; - for(final String parameterName : edmFuntion.getParameterNames()) { + for (final String parameterName : edmFuntion.getParameterNames()) { final UriParameter parameter = parameters.get(parameterName); final boolean isNullable = edmFuntion.getParameter(parameterName).isNullable(); - - if(parameter != null) { + + if (parameter != null) { /** No alias, value explicit null */ - if(parameter.getText() == null + if (parameter.getText() == null && parameter.getAlias() == null && !isNullable) { - throw new UriValidationException("Missing non nullable parameter " + parameterName, + throw new UriValidationException("Missing non nullable parameter " + parameterName, UriValidationException.MessageKeys.MISSING_PARAMETER, parameterName); - } else if(parameter.getText() == null && parameter.getAlias() != null) { + } else if (parameter.getText() == null && parameter.getAlias() != null) { final String valueForAlias = uriInfo.getValueForAlias(parameter.getAlias()); /** Alias value is missing or explicit null **/ - if(valueForAlias == null && !isNullable) { - throw new UriValidationException("Missing non nullable parameter " + parameterName, + if (valueForAlias == null && !isNullable) { + throw new UriValidationException("Missing non nullable parameter " + parameterName, UriValidationException.MessageKeys.MISSING_PARAMETER, parameterName); } } - + parameters.remove(parameterName); - } else if(!isNullable && !(firstParameter && edmFuntion.isBound())) { + } else if (!isNullable && !(firstParameter && edmFuntion.isBound())) { // The first parameter of bound functions is implicit provided by the preceding path segment - throw new UriValidationException("Missing non nullable parameter " + parameterName, + throw new UriValidationException("Missing non nullable parameter " + parameterName, UriValidationException.MessageKeys.MISSING_PARAMETER, parameterName); } - + firstParameter = false; } - - if(!parameters.isEmpty()) { + + if (!parameters.isEmpty()) { final String parameterName = parameters.keySet().iterator().next(); - throw new UriValidationException("Unsupported parameter " + parameterName, + throw new UriValidationException("Unsupported parameter " + parameterName, UriValidationException.MessageKeys.UNSUPPORTED_PARAMETER, parameterName); } } } } - + private void validateKeyPredicates(final UriInfo uriInfo) throws UriValidationException { for (UriResource pathSegment : uriInfo.getUriResourceParts()) { final boolean isEntitySet = pathSegment.getKind() == UriResourceKind.entitySet; final boolean isEntityColFunction = isEntityColFunction(pathSegment); - + if (isEntitySet || pathSegment.getKind() == UriResourceKind.navigationProperty || isEntityColFunction) { final List keyPredicates = isEntitySet ? ((UriResourceEntitySet) pathSegment).getKeyPredicates() : - isEntityColFunction ? ((UriResourceFunction) pathSegment).getKeyPredicates() - : ((UriResourceNavigation) pathSegment).getKeyPredicates(); - + isEntityColFunction ? ((UriResourceFunction) pathSegment).getKeyPredicates() + : ((UriResourceNavigation) pathSegment).getKeyPredicates(); + if (keyPredicates != null) { - final EdmEntityType entityType = isEntitySet ? - ((UriResourceEntitySet) pathSegment).getEntityType() : - isEntityColFunction ? (EdmEntityType) ((UriResourceFunction) pathSegment).getType() - : (EdmEntityType) ((UriResourceNavigation) pathSegment).getType(); - final List keyPredicateNames = entityType.getKeyPredicateNames(); - Map edmKeys = new HashMap(); - for (EdmKeyPropertyRef key : entityType.getKeyPropertyRefs()) { - edmKeys.put(key.getName(), key); - final String alias = key.getAlias(); - if (alias != null) { - edmKeys.put(alias, key); - } - } + final EdmEntityType entityType = isEntitySet ? + ((UriResourceEntitySet) pathSegment).getEntityType() : + isEntityColFunction ? (EdmEntityType) ((UriResourceFunction) pathSegment).getType() + : (EdmEntityType) ((UriResourceNavigation) pathSegment).getType(); + final List keyPredicateNames = entityType.getKeyPredicateNames(); + Map edmKeys = new HashMap(); + for (EdmKeyPropertyRef key : entityType.getKeyPropertyRefs()) { + edmKeys.put(key.getName(), key); + final String alias = key.getAlias(); + if (alias != null) { + edmKeys.put(alias, key); + } + } - for (UriParameter keyPredicate : keyPredicates) { - final String name = keyPredicate.getName(); - final String alias = keyPredicate.getAlias(); + for (UriParameter keyPredicate : keyPredicates) { + final String name = keyPredicate.getName(); + final String alias = keyPredicate.getAlias(); - if (keyPredicate.getReferencedProperty() == null) { - final String value = alias == null ? - keyPredicate.getText() : - uriInfo.getValueForAlias(alias); + if (keyPredicate.getReferencedProperty() == null) { + final String value = alias == null ? + keyPredicate.getText() : + uriInfo.getValueForAlias(alias); - EdmKeyPropertyRef edmKey = edmKeys.get(name); - if (edmKey == null) { - if (keyPredicateNames.contains(name)) { - throw new UriValidationException("Double key property: " + name, - UriValidationException.MessageKeys.DOUBLE_KEY_PROPERTY, name); - } else { - throw new UriValidationException("Unknown key property: " + name, - UriValidationException.MessageKeys.INVALID_KEY_PROPERTY, name); - } + EdmKeyPropertyRef edmKey = edmKeys.get(name); + if (edmKey == null) { + if (keyPredicateNames.contains(name)) { + throw new UriValidationException("Double key property: " + name, + UriValidationException.MessageKeys.DOUBLE_KEY_PROPERTY, name); + } else { + throw new UriValidationException("Unknown key property: " + name, + UriValidationException.MessageKeys.INVALID_KEY_PROPERTY, name); + } + } + + final EdmProperty property = edmKey.getProperty(); + final EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) property.getType(); + try { + if (!edmPrimitiveType.validate(edmPrimitiveType.fromUriLiteral(value), + property.isNullable(), property.getMaxLength(), + property.getPrecision(), property.getScale(), property.isUnicode())) { + throw new UriValidationException("PrimitiveTypeException", + UriValidationException.MessageKeys.INVALID_KEY_PROPERTY, name); + } + } catch (EdmPrimitiveTypeException e) { + throw new UriValidationException("PrimitiveTypeException", e, + UriValidationException.MessageKeys.INVALID_KEY_PROPERTY, name); + } + } + + edmKeys.remove(name); + edmKeys.remove(alias); + } } - - final EdmProperty property = edmKey.getProperty(); - final EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) property.getType(); - try { - if (!edmPrimitiveType.validate(edmPrimitiveType.fromUriLiteral(value), - property.isNullable(), property.getMaxLength(), - property.getPrecision(), property.getScale(), property.isUnicode())) { - throw new UriValidationException("PrimitiveTypeException", - UriValidationException.MessageKeys.INVALID_KEY_PROPERTY, name); - } - } catch (EdmPrimitiveTypeException e) { - throw new UriValidationException("PrimitiveTypeException", e, - UriValidationException.MessageKeys.INVALID_KEY_PROPERTY, name); - } - } - - edmKeys.remove(name); - edmKeys.remove(alias); - } - } } } } private boolean isEntityColFunction(final UriResource pathSegment) { - if(pathSegment.getKind() == UriResourceKind.function) { + if (pathSegment.getKind() == UriResourceKind.function) { final UriResourceFunction resourceFunction = (UriResourceFunction) pathSegment; final EdmReturnType returnType = resourceFunction.getFunction().getReturnType(); - + return returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY; } else { return false; } } - + private void validatePropertyOperations(final UriInfo uriInfo, final HttpMethod method) throws UriValidationException { final List parts = uriInfo.getUriResourceParts(); @@ -697,9 +696,9 @@ public class UriValidator { final UriResource previous = parts.size() > 1 ? parts.get(parts.size() - 2) : null; if (last != null && (last.getKind() == UriResourceKind.primitiveProperty - || last.getKind() == UriResourceKind.complexProperty - || (last.getKind() == UriResourceKind.value - && previous != null && previous.getKind() == UriResourceKind.primitiveProperty))) { + || last.getKind() == UriResourceKind.complexProperty + || (last.getKind() == UriResourceKind.value + && previous != null && previous.getKind() == UriResourceKind.primitiveProperty))) { final EdmProperty property = ((UriResourceProperty) (last.getKind() == UriResourceKind.value ? previous : last)).getProperty(); if (method == HttpMethod.PATCH && property.isCollection()) { diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java index 999a20cde..ce0abe7a3 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java @@ -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,7 +77,7 @@ public class ContentNegotiatorTest { { ACCEPT_CASE_MIN_UTF8_IEEE754, null, ACCEPT_CASE_MIN_UTF8_IEEE754, null }, { ACCEPT_CASE_MIN_IEEE754, ACCEPT_CASE_MIN_IEEE754, ACCEPT_CASE_MIN , null }, { ACCEPT_CASE_XML, "xml", null, null }, - { ACCEPT_CASE_XML, null, ACCEPT_CASE_XML, null } + { ACCEPT_CASE_XML, null, ACCEPT_CASE_XML, null } }; String[][] casesMetadata = { @@ -191,7 +191,7 @@ public class ContentNegotiatorTest { } final CustomContentTypeSupport customContentTypeSupport = useCase[3] == null ? null : - createCustomContentTypeSupport(useCase[3]); + createCustomContentTypeSupport(useCase[3]); final ContentType requestedContentType = ContentNegotiator.doContentNegotiation( formatOption, request, customContentTypeSupport, representationType); diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/ExceptionHelperTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/ExceptionHelperTest.java index b3d59da9a..c4eb24c0a 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/ExceptionHelperTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/ExceptionHelperTest.java @@ -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 @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import org.apache.olingo.commons.api.http.HttpStatusCode; -import org.apache.olingo.server.api.ODataLibraryException.MessageKey; import org.apache.olingo.server.api.ODataLibraryException; +import org.apache.olingo.server.api.ODataLibraryException.MessageKey; import org.apache.olingo.server.api.ODataServerError; import org.apache.olingo.server.api.deserializer.DeserializerException; import org.apache.olingo.server.api.etag.PreconditionException; diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/ODataHttpHandlerImplTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/ODataHttpHandlerImplTest.java index 1fcef84b0..1a66609f9 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/ODataHttpHandlerImplTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/ODataHttpHandlerImplTest.java @@ -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 static org.mockito.Mockito.when; import javax.servlet.http.HttpServletRequest; import org.apache.olingo.commons.api.http.HttpMethod; -import org.apache.olingo.server.api.ODataRequest; import org.apache.olingo.server.api.ODataLibraryException; +import org.apache.olingo.server.api.ODataRequest; import org.junit.Test; public class ODataHttpHandlerImplTest { diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/ODataImplTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/ODataImplTest.java index 3954a5ac0..c289b9366 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/ODataImplTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/ODataImplTest.java @@ -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 diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/TranslatedExceptionSubclassesTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/TranslatedExceptionSubclassesTest.java index 2df68aa48..ce7c4c048 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/TranslatedExceptionSubclassesTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/TranslatedExceptionSubclassesTest.java @@ -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 diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/batchhandler/MockedBatchHandlerTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/batchhandler/MockedBatchHandlerTest.java index 8b49bd2c8..8b5513efb 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/batchhandler/MockedBatchHandlerTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/batchhandler/MockedBatchHandlerTest.java @@ -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 diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/debug/AbstractDebugTabTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/debug/AbstractDebugTabTest.java index 13a690fdd..95a3ba126 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/debug/AbstractDebugTabTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/debug/AbstractDebugTabTest.java @@ -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,14 +26,14 @@ import com.fasterxml.jackson.core.JsonGenerator; public abstract class AbstractDebugTabTest { - protected String createHtml(DebugTab tab) throws IOException { + protected String createHtml(final DebugTab tab) throws IOException { StringWriter writer = new StringWriter(); tab.appendHtml(writer); writer.flush(); return writer.toString(); } - protected String createJson(DebugTab tab) throws IOException { + protected String createJson(final DebugTab tab) throws IOException { StringWriter writer = new StringWriter(); JsonGenerator gen = new JsonFactory().createGenerator(writer); tab.appendJson(gen); diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/debug/DebugTabBodyTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/debug/DebugTabBodyTest.java index 16f0e1517..088e398f5 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/debug/DebugTabBodyTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/debug/DebugTabBodyTest.java @@ -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 diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/debug/DebugTabRequestTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/debug/DebugTabRequestTest.java index 24732baac..3ae565c54 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/debug/DebugTabRequestTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/debug/DebugTabRequestTest.java @@ -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 diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/debug/DebugTabResponseTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/debug/DebugTabResponseTest.java index 8ca530628..b26854547 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/debug/DebugTabResponseTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/debug/DebugTabResponseTest.java @@ -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 diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/debug/DebugTabServerTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/debug/DebugTabServerTest.java index fa54c3d68..53a56930c 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/debug/DebugTabServerTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/debug/DebugTabServerTest.java @@ -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,7 +64,7 @@ public class DebugTabServerTest extends AbstractDebugTabTest { assertTrue(html.contains("key2value2")); assertTrue(html.endsWith("\n")); } - + @Test public void twoParametersWithNull() throws Exception { Map env = new LinkedHashMap(); diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/debug/ServerCoreDebuggerTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/debug/ServerCoreDebuggerTest.java index 3d994a9ac..280ff3833 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/debug/ServerCoreDebuggerTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/debug/ServerCoreDebuggerTest.java @@ -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 @@ -49,7 +49,7 @@ public class ServerCoreDebuggerTest { DebugSupport processor = mock(DebugSupport.class); when(processor.isUserAuthorized()).thenReturn(true); when(processor.createDebugResponse(anyString(), any(DebugInformation.class))) - .thenThrow(new ODataRuntimeException("Test")); + .thenThrow(new ODataRuntimeException("Test")); debugger.setDebugSupportProcessor(processor); } diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/FixedFormatDeserializerTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/FixedFormatDeserializerTest.java index e1d129f85..77be67fb4 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/FixedFormatDeserializerTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/FixedFormatDeserializerTest.java @@ -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 diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/batch/BatchLineReaderTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/batch/BatchLineReaderTest.java index 9861b7f0c..ea202db78 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/batch/BatchLineReaderTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/batch/BatchLineReaderTest.java @@ -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 diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/batch/BatchParserCommonTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/batch/BatchParserCommonTest.java index 137c89a39..276c5b287 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/batch/BatchParserCommonTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/batch/BatchParserCommonTest.java @@ -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 diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/batch/BatchRequestParserTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/batch/BatchRequestParserTest.java index 008fdbe79..059b32fcd 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/batch/BatchRequestParserTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/batch/BatchRequestParserTest.java @@ -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 @@ -474,30 +474,30 @@ public class BatchRequestParserTest { + CRLF + CRLF + "--batch_8194-cf13-1f56--"; - + List requests = parse(batch); assertEquals(HttpMethod.POST, requests.get(0).getRequests().get(0).getMethod()); assertEquals("/Employees", requests.get(0).getRequests().get(0).getRawODataPath()); assertEquals("{ \"Name\": \"Foo\" }", IOUtils.toString(requests.get(0).getRequests().get(0).getBody())); - + requests = parse(batch); assertEquals(HttpMethod.DELETE, requests.get(1).getRequests().get(0).getMethod()); assertEquals("/Employees('1')", requests.get(1).getRequests().get(0).getRawODataPath()); - + requests = parse(batch); assertEquals(HttpMethod.PATCH, requests.get(2).getRequests().get(0).getMethod()); assertEquals("{ \"Name\": \"Foo\" }", IOUtils.toString(requests.get(0).getRequests().get(0).getBody())); assertEquals("/Employees('1')", requests.get(2).getRequests().get(0).getRawODataPath()); - + requests = parse(batch); assertEquals(HttpMethod.PUT, requests.get(3).getRequests().get(0).getMethod()); assertEquals("{ \"Name\": \"Foo\" }", IOUtils.toString(requests.get(0).getRequests().get(0).getBody())); assertEquals("/Employees('1')", requests.get(3).getRequests().get(0).getRawODataPath()); - + requests = parse(batch); assertEquals(HttpMethod.GET, requests.get(4).getRequests().get(0).getMethod()); assertEquals("/Employees('1')", requests.get(4).getRequests().get(0).getRawODataPath()); - + } @Test diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/batch/HeaderTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/batch/HeaderTest.java index e808cb155..f87ffca8b 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/batch/HeaderTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/batch/HeaderTest.java @@ -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 diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/batch/HttpRequestStatusLineTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/batch/HttpRequestStatusLineTest.java index 1d3bb1f09..eb87baa58 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/batch/HttpRequestStatusLineTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/batch/HttpRequestStatusLineTest.java @@ -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 diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerBasicTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerBasicTest.java index 8160165a7..419ab8068 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerBasicTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerBasicTest.java @@ -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 diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/etag/ETagHelperTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/etag/ETagHelperTest.java index e992a5c10..58a845773 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/etag/ETagHelperTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/etag/ETagHelperTest.java @@ -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 diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/etag/ETagParserTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/etag/ETagParserTest.java index 3e68af61c..06a432b0e 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/etag/ETagParserTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/etag/ETagParserTest.java @@ -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 diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/prefer/PreferencesTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/prefer/PreferencesTest.java index b0e8d74af..9f4a45e15 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/prefer/PreferencesTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/prefer/PreferencesTest.java @@ -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,8 +53,8 @@ public class PreferencesTest { public void all() { final Preferences preferences = new PreferencesImpl(Collections.singleton( "odata.allow-entityreferences, odata.callback;url=\"callbackURI\"," - + "odata.continue-on-error, odata.include-annotations=\"*\", odata.maxpagesize=42," - + "odata.track-changes, return=representation, respond-async, wait=12345")); + + "odata.continue-on-error, odata.include-annotations=\"*\", odata.maxpagesize=42," + + "odata.track-changes, return=representation, respond-async, wait=12345")); assertTrue(preferences.hasAllowEntityReferences()); assertEquals(URI.create("callbackURI"), preferences.getCallback()); assertNotNull(preferences.getPreference("odata.callback")); diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/AsyncResponseSerializerTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/AsyncResponseSerializerTest.java index d70de6225..1095fb322 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/AsyncResponseSerializerTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/AsyncResponseSerializerTest.java @@ -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,6 +18,11 @@ */ package org.apache.olingo.server.core.serializer; +import static org.junit.Assert.assertEquals; + +import java.io.InputStream; +import java.util.Random; + import org.apache.commons.io.IOUtils; import org.apache.olingo.commons.api.format.ContentType; import org.apache.olingo.commons.api.http.HttpHeader; @@ -25,11 +30,6 @@ import org.apache.olingo.commons.api.http.HttpStatusCode; import org.apache.olingo.server.api.ODataResponse; import org.junit.Test; -import java.io.InputStream; -import java.util.Random; - -import static org.junit.Assert.assertEquals; - public class AsyncResponseSerializerTest { private static final String CRLF = "\r\n"; @@ -70,11 +70,11 @@ public class AsyncResponseSerializerTest { + testData, result); } - private String testData(int amount) { + private String testData(final int amount) { StringBuilder result = new StringBuilder(); Random r = new Random(); for (int i = 0; i < amount; i++) { - result.append((char)(r.nextInt(26) + 'a')); + result.append((char) (r.nextInt(26) + 'a')); } return result.toString(); diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/BatchResponseSerializerTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/BatchResponseSerializerTest.java index b57340d08..1f0d7a394 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/BatchResponseSerializerTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/BatchResponseSerializerTest.java @@ -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 @@ -106,7 +106,7 @@ public class BatchResponseSerializerTest { ODataResponse response = new ODataResponse(); response.setStatusCode(HttpStatusCode.OK.getStatusCode()); response.setHeader(HttpHeader.CONTENT_TYPE, - ContentType.APPLICATION_JSON.toContentTypeString() + "; charset=UTF-8"); + ContentType.APPLICATION_JSON.toContentTypeString() + "; charset=UTF-8"); response.setContent(IOUtils.toInputStream("Wälter Winter" + CRLF)); List responses = new ArrayList(1); @@ -124,7 +124,7 @@ public class BatchResponseSerializerTest { final InputStream content = serializer.serialize(parts, BOUNDARY); assertNotNull(content); final BatchLineReader reader = - new BatchLineReader(content); + new BatchLineReader(content); final List body = reader.toList(); reader.close(); @@ -233,8 +233,8 @@ public class BatchResponseSerializerTest { changeSetResponse.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode()); changeSetResponse.setHeader(HttpHeader.CONTENT_ID, "1"); -// byte[] umlauts = "äüö".getBytes(CS_UTF_8); -// changeSetResponse.setHeader("Custom-Header", new String(umlauts, CS_UTF_8)); + // byte[] umlauts = "äüö".getBytes(CS_UTF_8); + // changeSetResponse.setHeader("Custom-Header", new String(umlauts, CS_UTF_8)); changeSetResponse.setHeader("Custom-Header", "äüö"); responses = new ArrayList(1); responses.add(changeSetResponse); @@ -251,7 +251,7 @@ public class BatchResponseSerializerTest { assertEquals(25, body.size()); // TODO: check: with latest change in BatchResponseSerializer is not possible // to set header values with UTF-8 (only iso-8859-1) -// assertEquals("Custom-Header: äüö" + CRLF, body.get(19)); + // assertEquals("Custom-Header: äüö" + CRLF, body.get(19)); assertEquals("Custom-Header: äüö" + CRLF, body.get(19)); } @@ -261,7 +261,7 @@ public class BatchResponseSerializerTest { ODataResponse response = new ODataResponse(); response.setStatusCode(HttpStatusCode.OK.getStatusCode()); response.setHeader(HttpHeader.CONTENT_TYPE, - ContentType.APPLICATION_JSON.toContentTypeString() + "; charset=iso-8859-1"); + ContentType.APPLICATION_JSON.toContentTypeString() + "; charset=iso-8859-1"); byte[] payload = ("Wälter Winter" + CRLF).getBytes("iso-8859-1"); response.setContent(new ByteArrayInputStream(payload)); @@ -280,7 +280,7 @@ public class BatchResponseSerializerTest { final InputStream content = serializer.serialize(parts, BOUNDARY); assertNotNull(content); final BatchLineReader reader = - new BatchLineReader(content); + new BatchLineReader(content); final List body = reader.toList(); reader.close(); @@ -419,7 +419,7 @@ public class BatchResponseSerializerTest { assertNotNull(content); final BatchLineReader reader = - new BatchLineReader(content); + new BatchLineReader(content); final List body = reader.toList(); reader.close(); diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/FixedFormatSerializerTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/FixedFormatSerializerTest.java index 21c767754..a0586e34d 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/FixedFormatSerializerTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/FixedFormatSerializerTest.java @@ -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 diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ServerErrorSerializerTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ServerErrorSerializerTest.java index febd3eb3e..c0e21213b 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ServerErrorSerializerTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ServerErrorSerializerTest.java @@ -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 @@ -111,8 +111,8 @@ public class ServerErrorSerializerTest { public void verifiedWithJacksonParser() throws Exception { ODataServerError error = new ODataServerError().setCode("Code").setMessage("Message").setTarget("Target") - .setDetails(Collections.singletonList( - new ODataErrorDetail().setCode("detailCode").setMessage("detailMessage").setTarget("detailTarget"))); + .setDetails(Collections.singletonList( + new ODataErrorDetail().setCode("detailCode").setMessage("detailMessage").setTarget("detailTarget"))); InputStream stream = ser.error(error).getContent(); JsonNode tree = new ObjectMapper().readTree(stream); assertNotNull(tree); diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/utils/CircleStreamBufferTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/utils/CircleStreamBufferTest.java index b5c28bc93..e6d45c2d1 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/utils/CircleStreamBufferTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/utils/CircleStreamBufferTest.java @@ -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 @@ -159,7 +159,6 @@ public class CircleStreamBufferTest { assertEquals(testData, result); } - @Test public void testSimpleWriteMoreThenDefaultBufferSize() throws Exception { CircleStreamBuffer csb = new CircleStreamBuffer(); diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/utils/ContextURLBuilderTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/utils/ContextURLBuilderTest.java index ee53bc3a8..392898542 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/utils/ContextURLBuilderTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/utils/ContextURLBuilderTest.java @@ -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 diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java index 8c6e4ede3..db8806247 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java @@ -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 @@ -205,18 +205,18 @@ public class MetadataDocumentXmlSerializerTest { "" + "" + - "")); + "")); assertTrue(metadataString.contains( "" + "" + "" + - "")); + "")); assertTrue(metadataString.contains( "" + "" + "" + - "")); + "")); assertTrue(metadataString.contains( "" + "" + @@ -225,7 +225,7 @@ public class MetadataDocumentXmlSerializerTest { "Qualifier=\"Q.4\" TargetNamespace=\"TargetNS.4\"/>" + "" + - "")); + "")); assertTrue(metadataString.contains( "" + "" + @@ -235,7 +235,7 @@ public class MetadataDocumentXmlSerializerTest { "" + "" + - "")); + "")); } @Test @@ -404,12 +404,12 @@ public class MetadataDocumentXmlSerializerTest { private final FullQualifiedName nameString = EdmPrimitiveTypeKind.String.getFullQualifiedName(); private final FullQualifiedName nameUARTPrimParam = new FullQualifiedName(nameSpace, "UARTPrimParam"); private final CsdlProperty propertyInt16_NotNullable = new CsdlProperty() - .setName("PropertyInt16") - .setType(nameInt16) - .setNullable(false); + .setName("PropertyInt16") + .setType(nameInt16) + .setNullable(false); private final CsdlProperty propertyString = new CsdlProperty() - .setName("PropertyString") - .setType(nameString); + .setName("PropertyString") + .setType(nameString); private final FullQualifiedName nameCTTwoPrim = new FullQualifiedName(nameSpace, "CTTwoPrim"); private final FullQualifiedName nameCTTwoPrimBase = new FullQualifiedName(nameSpace, "CTTwoPrimBase"); @@ -426,10 +426,10 @@ public class MetadataDocumentXmlSerializerTest { public CsdlEnumType getEnumType(final FullQualifiedName enumTypeName) throws ODataException { if (nameENString.equals(enumTypeName)) { return new CsdlEnumType() - .setName(nameENString.getName()) - .setFlags(true) - .setUnderlyingType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName()) - .setMembers(Collections.singletonList(new CsdlEnumMember().setName("String1").setValue("1"))); + .setName(nameENString.getName()) + .setFlags(true) + .setUnderlyingType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName()) + .setMembers(Collections.singletonList(new CsdlEnumMember().setName("String1").setValue("1"))); } return null; } @@ -438,16 +438,16 @@ public class MetadataDocumentXmlSerializerTest { public CsdlEntityType getEntityType(final FullQualifiedName entityTypeName) throws ODataException { if (entityTypeName.equals(nameETAbstract)) { return new CsdlEntityType() - .setName("ETAbstract") - .setAbstract(true) - .setProperties(Collections.singletonList(propertyString)); + .setName("ETAbstract") + .setAbstract(true) + .setProperties(Collections.singletonList(propertyString)); } else if (entityTypeName.equals(nameETAbstractBase)) { return new CsdlEntityType() - .setName("ETAbstractBase") - .setBaseType(nameETAbstract) - .setKey(Collections.singletonList(new CsdlPropertyRef().setName("PropertyInt16"))) - .setProperties(Collections.singletonList(propertyInt16_NotNullable)); + .setName("ETAbstractBase") + .setBaseType(nameETAbstract) + .setKey(Collections.singletonList(new CsdlPropertyRef().setName("PropertyInt16"))) + .setProperties(Collections.singletonList(propertyInt16_NotNullable)); } return null; } @@ -456,15 +456,15 @@ public class MetadataDocumentXmlSerializerTest { public CsdlComplexType getComplexType(final FullQualifiedName complexTypeName) throws ODataException { if (complexTypeName.equals(nameCTTwoPrim)) { return new CsdlComplexType() - .setName("CTTwoPrim") - .setProperties(Arrays.asList(propertyInt16_NotNullable, propertyString)); + .setName("CTTwoPrim") + .setProperties(Arrays.asList(propertyInt16_NotNullable, propertyString)); } if (complexTypeName.equals(nameCTTwoPrimBase)) { return new CsdlComplexType() - .setName("CTTwoPrimBase") - .setBaseType(nameCTTwoPrim) - .setProperties(Arrays.asList(propertyInt16_NotNullable, propertyString)); + .setName("CTTwoPrimBase") + .setBaseType(nameCTTwoPrim) + .setProperties(Arrays.asList(propertyInt16_NotNullable, propertyString)); } return null; @@ -475,8 +475,8 @@ public class MetadataDocumentXmlSerializerTest { if (actionName.equals(nameUARTPrimParam)) { return Collections.singletonList( new CsdlAction().setName("UARTPrimParam") - .setParameters(Collections.singletonList( - new CsdlParameter().setName("ParameterInt16").setType(nameInt16))) + .setParameters(Collections.singletonList( + new CsdlParameter().setName("ParameterInt16").setType(nameInt16))) .setReturnType(new CsdlReturnType().setType(nameString))); } return null; @@ -487,9 +487,9 @@ public class MetadataDocumentXmlSerializerTest { if (functionName.equals(nameUFNRTInt16)) { return Collections.singletonList( new CsdlFunction() - .setName("UFNRTInt16") - .setParameters(Collections. emptyList()) - .setReturnType(new CsdlReturnType().setType(nameInt16))); + .setName("UFNRTInt16") + .setParameters(Collections. emptyList()) + .setReturnType(new CsdlReturnType().setType(nameInt16))); } return null; } @@ -499,8 +499,8 @@ public class MetadataDocumentXmlSerializerTest { throws ODataException { if (entitySetName.equals("ESAllPrim")) { return new CsdlEntitySet() - .setName("ESAllPrim") - .setType(nameETAbstractBase); + .setName("ESAllPrim") + .setType(nameETAbstractBase); } return null; } @@ -510,8 +510,8 @@ public class MetadataDocumentXmlSerializerTest { throws ODataException { if (singletonName.equals("SI")) { return new CsdlSingleton() - .setName("SI") - .setType(nameETAbstractBase); + .setName("SI") + .setType(nameETAbstractBase); } return null; } @@ -522,8 +522,8 @@ public class MetadataDocumentXmlSerializerTest { if (entityContainer.equals(nameContainer)) { if (actionImportName.equals("AIRTPrimParam")) { return new CsdlActionImport() - .setName("AIRTPrimParam") - .setAction(nameUARTPrimParam); + .setName("AIRTPrimParam") + .setAction(nameUARTPrimParam); } } return null; @@ -532,13 +532,13 @@ public class MetadataDocumentXmlSerializerTest { @Override public CsdlFunctionImport getFunctionImport(final FullQualifiedName entityContainer, final String functionImportName) - throws ODataException { + throws ODataException { if (entityContainer.equals(nameContainer)) { if (functionImportName.equals("FINRTInt16")) { return new CsdlFunctionImport() - .setName("FINRTInt16") - .setFunction(nameUFNRTInt16) - .setIncludeInServiceDocument(true); + .setName("FINRTInt16") + .setFunction(nameUFNRTInt16) + .setIncludeInServiceDocument(true); } } return null; @@ -576,9 +576,9 @@ public class MetadataDocumentXmlSerializerTest { // EntityContainer schema.setEntityContainer(getEntityContainer()); - //Terms + // Terms schema.setTerms(Arrays.asList( - getTerm(new FullQualifiedName("ns","term")), + getTerm(new FullQualifiedName("ns", "term")), getTerm(new FullQualifiedName("namespace", "Term1")), getTerm(new FullQualifiedName("ns", "Term2")), getTerm(new FullQualifiedName("ns", "Term3")), @@ -621,27 +621,27 @@ public class MetadataDocumentXmlSerializerTest { } @Override - public CsdlTypeDefinition getTypeDefinition(FullQualifiedName typeDefinitionName) throws ODataException { + public CsdlTypeDefinition getTypeDefinition(final FullQualifiedName typeDefinitionName) throws ODataException { return null; } @Override - public CsdlTerm getTerm(FullQualifiedName termName) throws ODataException { + public CsdlTerm getTerm(final FullQualifiedName termName) throws ODataException { if (new FullQualifiedName("ns", "term").equals(termName)) { return new CsdlTerm().setType("Edm.String").setName("term"); - } else if(new FullQualifiedName("namespace", "Term1").equals(termName)){ + } else if (new FullQualifiedName("namespace", "Term1").equals(termName)) { return new CsdlTerm().setType("Edm.String").setName("Term1"); - } else if(new FullQualifiedName("ns", "Term2").equals(termName)){ + } else if (new FullQualifiedName("ns", "Term2").equals(termName)) { return new CsdlTerm().setType("Edm.String").setName("Term2") .setNullable(false).setDefaultValue("default").setMaxLength(1).setPrecision(2).setScale(3); - } else if(new FullQualifiedName("ns", "Term3").equals(termName)){ + } else if (new FullQualifiedName("ns", "Term3").equals(termName)) { return new CsdlTerm().setType("Edm.String").setName("Term3") .setAppliesTo(Arrays.asList("Property", "EntitySet", "Schema")); - } else if(new FullQualifiedName("ns", "Term4").equals(termName)){ + } else if (new FullQualifiedName("ns", "Term4").equals(termName)) { return new CsdlTerm().setType("Edm.String").setName("Term4").setBaseTerm("namespace.Term1"); } @@ -649,7 +649,8 @@ public class MetadataDocumentXmlSerializerTest { } @Override - public CsdlAnnotations getAnnotationsGroup(FullQualifiedName targetName, String qualifier) throws ODataException { + public CsdlAnnotations getAnnotationsGroup(final FullQualifiedName targetName, final String qualifier) + throws ODataException { if (new FullQualifiedName("Alias", "ETAbstract").equals(targetName) && "Tablett".equals(qualifier)) { CsdlAnnotations annoGroup = new CsdlAnnotations(); annoGroup.setTarget("Alias.ETAbstract"); @@ -690,50 +691,50 @@ public class MetadataDocumentXmlSerializerTest { // logical expressions annotationsList.add(new CsdlAnnotation().setTerm("ns.term") .setExpression(new CsdlLogicalOrComparisonExpression(LogicalOrComparisonExpressionType.And) - .setLeft(new CsdlConstantExpression(ConstantExpressionType.Bool, "true")) - .setRight(new CsdlConstantExpression(ConstantExpressionType.Bool, "false")) - .setAnnotations(innerAnnotations))); + .setLeft(new CsdlConstantExpression(ConstantExpressionType.Bool, "true")) + .setRight(new CsdlConstantExpression(ConstantExpressionType.Bool, "false")) + .setAnnotations(innerAnnotations))); annotationsList.add(new CsdlAnnotation().setTerm("ns.term") .setExpression(new CsdlLogicalOrComparisonExpression(LogicalOrComparisonExpressionType.Or) - .setLeft(new CsdlConstantExpression(ConstantExpressionType.Bool, "true")) - .setRight(new CsdlConstantExpression(ConstantExpressionType.Bool, "false")) - .setAnnotations(innerAnnotations))); + .setLeft(new CsdlConstantExpression(ConstantExpressionType.Bool, "true")) + .setRight(new CsdlConstantExpression(ConstantExpressionType.Bool, "false")) + .setAnnotations(innerAnnotations))); annotationsList.add(new CsdlAnnotation().setTerm("ns.term") .setExpression(new CsdlLogicalOrComparisonExpression(LogicalOrComparisonExpressionType.Not) - .setLeft(new CsdlConstantExpression(ConstantExpressionType.Bool, "true")) - .setAnnotations(innerAnnotations))); + .setLeft(new CsdlConstantExpression(ConstantExpressionType.Bool, "true")) + .setAnnotations(innerAnnotations))); // comparison annotationsList.add(new CsdlAnnotation().setTerm("ns.term") .setExpression(new CsdlLogicalOrComparisonExpression(LogicalOrComparisonExpressionType.Eq) - .setLeft(new CsdlConstantExpression(ConstantExpressionType.Bool, "true")) - .setRight(new CsdlConstantExpression(ConstantExpressionType.Bool, "false")) - .setAnnotations(innerAnnotations))); + .setLeft(new CsdlConstantExpression(ConstantExpressionType.Bool, "true")) + .setRight(new CsdlConstantExpression(ConstantExpressionType.Bool, "false")) + .setAnnotations(innerAnnotations))); annotationsList.add(new CsdlAnnotation().setTerm("ns.term") .setExpression(new CsdlLogicalOrComparisonExpression(LogicalOrComparisonExpressionType.Ne) - .setLeft(new CsdlConstantExpression(ConstantExpressionType.Bool, "true")) - .setRight(new CsdlConstantExpression(ConstantExpressionType.Bool, "false")) - .setAnnotations(innerAnnotations))); + .setLeft(new CsdlConstantExpression(ConstantExpressionType.Bool, "true")) + .setRight(new CsdlConstantExpression(ConstantExpressionType.Bool, "false")) + .setAnnotations(innerAnnotations))); annotationsList.add(new CsdlAnnotation().setTerm("ns.term") .setExpression(new CsdlLogicalOrComparisonExpression(LogicalOrComparisonExpressionType.Gt) - .setLeft(new CsdlConstantExpression(ConstantExpressionType.Bool, "true")) - .setRight(new CsdlConstantExpression(ConstantExpressionType.Bool, "false")) - .setAnnotations(innerAnnotations))); + .setLeft(new CsdlConstantExpression(ConstantExpressionType.Bool, "true")) + .setRight(new CsdlConstantExpression(ConstantExpressionType.Bool, "false")) + .setAnnotations(innerAnnotations))); annotationsList.add(new CsdlAnnotation().setTerm("ns.term") .setExpression(new CsdlLogicalOrComparisonExpression(LogicalOrComparisonExpressionType.Ge) - .setLeft(new CsdlConstantExpression(ConstantExpressionType.Bool, "true")) - .setRight(new CsdlConstantExpression(ConstantExpressionType.Bool, "false")) - .setAnnotations(innerAnnotations))); + .setLeft(new CsdlConstantExpression(ConstantExpressionType.Bool, "true")) + .setRight(new CsdlConstantExpression(ConstantExpressionType.Bool, "false")) + .setAnnotations(innerAnnotations))); annotationsList.add(new CsdlAnnotation().setTerm("ns.term") .setExpression(new CsdlLogicalOrComparisonExpression(LogicalOrComparisonExpressionType.Lt) - .setLeft(new CsdlConstantExpression(ConstantExpressionType.Bool, "true")) - .setRight(new CsdlConstantExpression(ConstantExpressionType.Bool, "false")) - .setAnnotations(innerAnnotations))); + .setLeft(new CsdlConstantExpression(ConstantExpressionType.Bool, "true")) + .setRight(new CsdlConstantExpression(ConstantExpressionType.Bool, "false")) + .setAnnotations(innerAnnotations))); annotationsList.add(new CsdlAnnotation().setTerm("ns.term") .setExpression(new CsdlLogicalOrComparisonExpression(LogicalOrComparisonExpressionType.Le) - .setLeft(new CsdlConstantExpression(ConstantExpressionType.Bool, "true")) - .setRight(new CsdlConstantExpression(ConstantExpressionType.Bool, "false")) - .setAnnotations(innerAnnotations))); + .setLeft(new CsdlConstantExpression(ConstantExpressionType.Bool, "true")) + .setRight(new CsdlConstantExpression(ConstantExpressionType.Bool, "false")) + .setAnnotations(innerAnnotations))); // Other annotationsList.add(new CsdlAnnotation().setTerm("ns.term") @@ -748,12 +749,12 @@ public class MetadataDocumentXmlSerializerTest { annotationsList.add(new CsdlAnnotation().setTerm("ns.term") .setExpression(new CsdlCast() - .setValue(new CsdlConstantExpression(ConstantExpressionType.String, "value")) - .setMaxLength(1) - .setPrecision(2) - .setScale(3) - .setType("Edm.String") - .setAnnotations(innerAnnotations))); + .setValue(new CsdlConstantExpression(ConstantExpressionType.String, "value")) + .setMaxLength(1) + .setPrecision(2) + .setScale(3) + .setType("Edm.String") + .setAnnotations(innerAnnotations))); List items = new ArrayList(); items.add(new CsdlConstantExpression(ConstantExpressionType.Bool, "true")); @@ -764,25 +765,25 @@ public class MetadataDocumentXmlSerializerTest { annotationsList.add(new CsdlAnnotation().setTerm("ns.term") .setExpression(new CsdlIf() - .setGuard(new CsdlConstantExpression(ConstantExpressionType.Bool, "true")) - .setThen(new CsdlConstantExpression(ConstantExpressionType.String, "Then")) - .setElse(new CsdlConstantExpression(ConstantExpressionType.String, "Else")) - .setAnnotations(innerAnnotations))); + .setGuard(new CsdlConstantExpression(ConstantExpressionType.Bool, "true")) + .setThen(new CsdlConstantExpression(ConstantExpressionType.String, "Then")) + .setElse(new CsdlConstantExpression(ConstantExpressionType.String, "Else")) + .setAnnotations(innerAnnotations))); annotationsList.add(new CsdlAnnotation().setTerm("ns.term") .setExpression(new CsdlIsOf() - .setMaxLength(1) - .setPrecision(2) - .setScale(3) - .setType("Edm.String") - .setValue(new CsdlConstantExpression(ConstantExpressionType.String, "value")) - .setAnnotations(innerAnnotations))); + .setMaxLength(1) + .setPrecision(2) + .setScale(3) + .setType("Edm.String") + .setValue(new CsdlConstantExpression(ConstantExpressionType.String, "value")) + .setAnnotations(innerAnnotations))); annotationsList.add(new CsdlAnnotation().setTerm("ns.term") .setExpression(new CsdlLabeledElement() - .setName("NameAtt") - .setValue(new CsdlConstantExpression(ConstantExpressionType.String, "value")) - .setAnnotations(innerAnnotations))); + .setName("NameAtt") + .setValue(new CsdlConstantExpression(ConstantExpressionType.String, "value")) + .setAnnotations(innerAnnotations))); annotationsList.add(new CsdlAnnotation().setTerm("ns.term") .setExpression(new CsdlLabeledElementReference().setValue("LabeledElementReferenceValue"))); @@ -800,9 +801,9 @@ public class MetadataDocumentXmlSerializerTest { .setExpression(new CsdlPropertyPath().setValue("PropertyPathValue"))); CsdlPropertyValue prop = new CsdlPropertyValue() - .setProperty("PropName") - .setValue(new CsdlConstantExpression(ConstantExpressionType.String, "value")) - .setAnnotations(innerAnnotations); + .setProperty("PropName") + .setValue(new CsdlConstantExpression(ConstantExpressionType.String, "value")) + .setAnnotations(innerAnnotations); annotationsList.add(new CsdlAnnotation().setTerm("ns.term") .setExpression(new CsdlRecord().setType("Alias.ETAbstract") .setPropertyValues(Arrays.asList(prop)) @@ -810,8 +811,8 @@ public class MetadataDocumentXmlSerializerTest { annotationsList.add(new CsdlAnnotation().setTerm("ns.term") .setExpression(new CsdlUrlRef() - .setValue(new CsdlConstantExpression(ConstantExpressionType.String, "URLRefValue")) - .setAnnotations(innerAnnotations))); + .setValue(new CsdlConstantExpression(ConstantExpressionType.String, "URLRefValue")) + .setAnnotations(innerAnnotations))); return annoGroup; } diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/ServerErrorXmlSerializerTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/ServerErrorXmlSerializerTest.java index 907228f0c..ee9618d60 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/ServerErrorXmlSerializerTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/ServerErrorXmlSerializerTest.java @@ -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,13 +62,13 @@ public class ServerErrorXmlSerializerTest { @Test public void singleDetailNothingSet() throws Exception { ODataServerError error = new ODataServerError() - .setCode("code") - .setMessage("err message") - .setTarget("target") - .setDetails(Collections.singletonList( - new ODataErrorDetail() - .setCode("detail code") - .setMessage("detail message"))); + .setCode("code") + .setMessage("err message") + .setTarget("target") + .setDetails(Collections.singletonList( + new ODataErrorDetail() + .setCode("detail code") + .setMessage("detail message"))); InputStream stream = ser.error(error).getContent(); String jsonString = IOUtils.toString(stream); diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/ServiceDocumentXmlSerializerTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/ServiceDocumentXmlSerializerTest.java index 846efc56b..c3e35988a 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/ServiceDocumentXmlSerializerTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/ServiceDocumentXmlSerializerTest.java @@ -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 @@ -76,7 +76,7 @@ public class ServiceDocumentXmlSerializerTest { @Test public void writeServiceDocument() throws Exception { CsdlEdmProvider provider = new MetadataDocumentXmlSerializerTest.LocalProvider(); - ServiceMetadata serviceMetadata = new ServiceMetadataImpl(provider, + ServiceMetadata serviceMetadata = new ServiceMetadataImpl(provider, Collections. emptyList(), null); InputStream metadataStream = serializer.serviceDocument(serviceMetadata, "http://host/svc").getContent(); String metadata = IOUtils.toString(metadataStream); @@ -87,15 +87,15 @@ public class ServiceDocumentXmlSerializerTest { + "metadata:context=\"http://host/svc/$metadata\">" + "" + "org.olingo.container" - + "" - + "ESAllPrim" - + "" - + "" - + "FINRTInt16" - + "" - + "" - + "SI" - + "" + + "" + + "ESAllPrim" + + "" + + "" + + "FINRTInt16" + + "" + + "" + + "SI" + + "" + "" + "", metadata); diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/parser/search/SearchParserAndTokenizerTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/parser/search/SearchParserAndTokenizerTest.java index e028cfee9..40c6200fd 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/parser/search/SearchParserAndTokenizerTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/parser/search/SearchParserAndTokenizerTest.java @@ -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 SearchParserAndTokenizerTest { assertQuery("a AND b AND c").resultsIn("{{'a' AND 'b'} AND 'c'}"); assertQuery("a OR b").resultsIn("{'a' OR 'b'}"); assertQuery("a OR b OR c").resultsIn("{{'a' OR 'b'} OR 'c'}"); - + assertQuery("NOT a NOT b").resultsIn("{{NOT 'a'} AND {NOT 'b'}}"); assertQuery("NOT a AND NOT b").resultsIn("{{NOT 'a'} AND {NOT 'b'}}"); assertQuery("NOT a OR NOT b").resultsIn("{{NOT 'a'} OR {NOT 'b'}}"); @@ -59,16 +59,16 @@ public class SearchParserAndTokenizerTest { assertQuery("a AND (b OR c)").resultsIn("{'a' AND {'b' OR 'c'}}"); assertQuery("(a OR b) AND NOT c").resultsIn("{{'a' OR 'b'} AND {NOT 'c'}}"); assertQuery("(a OR B) AND (c OR d AND NOT e OR (f))") - .resultsIn("{{'a' OR 'B'} AND {{'c' OR {'d' AND {NOT 'e'}}} OR 'f'}}"); + .resultsIn("{{'a' OR 'B'} AND {{'c' OR {'d' AND {NOT 'e'}}} OR 'f'}}"); assertQuery("(a OR B) (c OR d NOT e OR (f))") - .resultsIn("{{'a' OR 'B'} AND {{'c' OR {'d' AND {NOT 'e'}}} OR 'f'}}"); + .resultsIn("{{'a' OR 'B'} AND {{'c' OR {'d' AND {NOT 'e'}}} OR 'f'}}"); assertQuery("((((a))))").resultsIn("'a'"); assertQuery("((((a)))) ((((a))))").resultsIn("{'a' AND 'a'}"); assertQuery("((((a)))) OR ((((a))))").resultsIn("{'a' OR 'a'}"); assertQuery("((((((a)))) ((((c))) OR (((C)))) ((((a))))))").resultsIn("{{'a' AND {'c' OR 'C'}} AND 'a'}"); assertQuery("((((\"a\")))) OR ((((\"a\"))))").resultsIn("{'a' OR 'a'}"); } - + @Test public void parseImplicitAnd() throws Exception { assertQuery("a b").resultsIn("{'a' AND 'b'}"); @@ -103,7 +103,7 @@ public class SearchParserAndTokenizerTest { assertQuery("((a AND b OR c)").resultsIn(SearchParserException.MessageKeys.MISSING_CLOSE); assertQuery("a AND (b OR c").resultsIn(SearchParserException.MessageKeys.MISSING_CLOSE); assertQuery("(a AND ((b OR c)").resultsIn(SearchParserException.MessageKeys.MISSING_CLOSE); - + assertQuery("NOT NOT a").resultsIn(SearchParserException.MessageKeys.INVALID_NOT_OPERAND); assertQuery("NOT (a)").resultsIn(SearchParserException.MessageKeys.TOKENIZER_EXCEPTION); } @@ -119,83 +119,81 @@ public class SearchParserAndTokenizerTest { */ @Test public void searchQueryPhraseAbnfTestcases() throws Exception { - // + // assertQuery("\"blue green\"").resultsIn("'blue green'"); - // + // assertQuery("\"blue green\"").resultsIn("'blue green'"); - // - // $search="blue\"green" + // + // $search="blue\"green" assertQuery("\"blue\\\"green\"").resultsIn("'blue\"green'"); - // - // $search="blue\\green" + // + // $search="blue\\green" assertQuery("\"blue\\\\green\"").resultsIn("'blue\\green'"); - // + // assertQuery("\"blue\"green\"").resultsIn(SearchParserException.MessageKeys.TOKENIZER_EXCEPTION); - // + // assertQuery("\"blue\"green\"").resultsIn(SearchParserException.MessageKeys.TOKENIZER_EXCEPTION); - // - // $search=blue green + // + // $search=blue green assertQuery("blue green").resultsIn("{'blue' AND 'green'}"); - // + // assertQuery("blue green").resultsIn("{'blue' AND 'green'}"); - // - // $search=blue AND green + // + // $search=blue AND green assertQuery("blue AND green").resultsIn("{'blue' AND 'green'}"); - // - // $search=blue OR green + // + // $search=blue OR green assertQuery("blue OR green").resultsIn("{'blue' OR 'green'}"); - // - // $search=blue NOT green + // + // $search=blue NOT green assertQuery("blue NOT green").resultsIn("{'blue' AND {NOT 'green'}}"); - // - // $search=NOT blue + // + // $search=NOT blue assertQuery("NOT blue").resultsIn("{NOT 'blue'}"); - // - // $search=foo AND bar OR foo AND baz OR that AND bar OR that AND baz + // + // $search=foo AND bar OR foo AND baz OR that AND bar OR that AND baz assertQuery("foo AND bar OR foo AND baz OR that AND bar OR that AND baz") - .resultsIn("{{{{'foo' AND 'bar'} OR {'foo' AND 'baz'}} OR {'that' AND 'bar'}} OR {'that' AND 'baz'}}"); + .resultsIn("{{{{'foo' AND 'bar'} OR {'foo' AND 'baz'}} OR {'that' AND 'bar'}} OR {'that' AND 'baz'}}"); - // - // $search=(foo OR that) AND (bar OR baz) + // + // $search=(foo OR that) AND (bar OR baz) assertQuery("(foo OR that) AND (bar OR baz)").resultsIn("{{'foo' OR 'that'} AND {'bar' OR 'baz'}}"); - // - // $search=foo AND (bar OR baz) + // + // $search=foo AND (bar OR baz) assertQuery("foo AND (bar OR baz)").resultsIn("{'foo' AND {'bar' OR 'baz'}}"); - // - // $search=(foo AND bar) OR baz + // + // $search=(foo AND bar) OR baz assertQuery("(foo AND bar) OR baz").resultsIn("{{'foo' AND 'bar'} OR 'baz'}"); - // - // $search=(NOT foo) OR baz + // + // $search=(NOT foo) OR baz assertQuery("(NOT foo) OR baz").resultsIn("{{NOT 'foo'} OR 'baz'}"); - // - // $search=(NOT foo) + // + // $search=(NOT foo) assertQuery("(NOT foo)").resultsIn("{NOT 'foo'}"); - // - // http://serviceRoot/Products?$search=blue + // + // http://serviceRoot/Products?$search=blue assertQuery("blue").resultsIn("'blue'"); - // below cases can not be tested here - // - // http://serviceRoot/Model.Container/$all?$search=blue - // - // http://serviceRoot/$all?$search=blue + // + // http://serviceRoot/Model.Container/$all?$search=blue + // + // http://serviceRoot/$all?$search=blue } - - private static Validator assertQuery(String searchQuery) { + private static Validator assertQuery(final String searchQuery) { return Validator.init(searchQuery); } @@ -203,28 +201,22 @@ public class SearchParserAndTokenizerTest { private boolean log; private final String searchQuery; - private Validator(String searchQuery) { + private Validator(final String searchQuery) { this.searchQuery = searchQuery; } - private static Validator init(String searchQuery) { + private static Validator init(final String searchQuery) { return new Validator(searchQuery); } - @SuppressWarnings("unused") - private Validator withLogging() { - log = true; - return this; - } - - private void resultsIn(SearchParserException.MessageKey key) - throws SearchTokenizerException { + private void resultsIn(final SearchParserException.MessageKey key) + throws SearchTokenizerException { try { resultsIn(searchQuery); } catch (SearchParserException e) { Assert.assertEquals("SearchParserException with unexpected message '" + e.getMessage() + "' was thrown.", key, e.getMessageKey()); - if(log) { + if (log) { System.out.println("Caught SearchParserException with message key " + e.getMessageKey() + " and message " + e.getMessage()); } @@ -232,17 +224,18 @@ public class SearchParserAndTokenizerTest { } Assert.fail("SearchParserException with message key " + key.getKey() + " was not thrown."); } - + public void resultsInExpectedTerm(final String actualToken) throws SearchTokenizerException { try { resultsIn(searchQuery); - } catch(SearchParserException e) { + } catch (SearchParserException e) { Assert.assertEquals(SearchParserException.MessageKeys.EXPECTED_DIFFERENT_TOKEN, e.getMessageKey()); Assert.assertEquals("Expected PHRASE||WORD found: " + actualToken, e.getMessage()); } } - - private void resultsIn(String expectedSearchExpression) throws SearchTokenizerException, SearchParserException { + + private void resultsIn(final String expectedSearchExpression) throws SearchTokenizerException, + SearchParserException { final SearchExpression searchExpression = getSearchExpression(); Assert.assertEquals(expectedSearchExpression, searchExpression.toString()); } diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/parser/search/SearchParserTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/parser/search/SearchParserTest.java index 4d2b560e1..780c209aa 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/parser/search/SearchParserTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/parser/search/SearchParserTest.java @@ -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 @@ -176,7 +176,6 @@ public class SearchParserTest extends SearchParser { runEx(SearchParserException.MessageKeys.INVALID_NOT_OPERAND, Token.NOT, Token.AND); } - @Test public void notNotWord() throws Exception { runEx(SearchParserException.MessageKeys.INVALID_NOT_OPERAND, Token.NOT, Token.NOT, Token.WORD); @@ -195,12 +194,12 @@ public class SearchParserTest extends SearchParser { runEx(MessageKeys.EXPECTED_DIFFERENT_TOKEN, Token.NOT, Token.WORD, Token.AND); runEx(MessageKeys.INVALID_END_OF_QUERY, Token.WORD, Token.AND, Token.WORD, Token.CLOSE); } - + @Test public void invalidQueryStarts() throws Exception { run(Token.WORD, Token.AND, Token.WORD, Token.AND, Token.WORD); } - + @Test public void singleAnd() { runEx(SearchParserException.MessageKeys.EXPECTED_DIFFERENT_TOKEN, Token.AND); @@ -222,7 +221,7 @@ public class SearchParserTest extends SearchParser { runEx(SearchParserException.MessageKeys.NO_EXPRESSION_FOUND, emptyArray); } - private void runEx(MessageKeys key, Token... tokenArray) { + private void runEx(final MessageKeys key, final Token... tokenArray) { try { run(tokenArray); fail("Expected UriParserSyntaxException with key " + key); @@ -230,15 +229,15 @@ public class SearchParserTest extends SearchParser { assertEquals(key, e.getMessageKey()); } } - - private SearchExpression run(SearchQueryToken.Token... tokenArray) throws SearchParserException { + + private SearchExpression run(final SearchQueryToken.Token... tokenArray) throws SearchParserException { List tokenList = prepareTokens(tokenArray); SearchExpression se = parse(tokenList); assertNotNull(se); return se; } - public List prepareTokens(SearchQueryToken.Token... tokenArray) { + public List prepareTokens(final SearchQueryToken.Token... tokenArray) { ArrayList tokenList = new ArrayList(); int wordNumber = 1; int phraseNumber = 1; diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/parser/search/SearchTokenizerTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/parser/search/SearchTokenizerTest.java index c2a390af8..a6c13758c 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/parser/search/SearchTokenizerTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/parser/search/SearchTokenizerTest.java @@ -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,6 @@ import java.util.Iterator; import java.util.List; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; public class SearchTokenizerTest { @@ -58,7 +57,7 @@ public class SearchTokenizerTest { assertQuery("notAw0rd").resultsIn(SearchTokenizerException.MessageKeys.FORBIDDEN_CHARACTER); } - private Validator.Tuple word(String literal) { + private Validator.Tuple word(final String literal) { return Validator.tuple(WORD, literal); } @@ -72,20 +71,20 @@ public class SearchTokenizerTest { // result = tokenizer.tokenize("\"abc\""); Assert.assertNotNull(result); - + Assert.assertEquals(PHRASE, result.get(0).getToken()); // result = tokenizer.tokenize("\"9988 abs\""); Assert.assertNotNull(result); - + Assert.assertEquals(PHRASE, result.get(0).getToken()); Assert.assertEquals("\"9988 abs\"", result.get(0).getLiteral()); // result = tokenizer.tokenize("\"99_88.\""); Assert.assertNotNull(result); - + Assert.assertEquals(PHRASE, result.get(0).getToken()); Assert.assertEquals("\"99_88.\"", result.get(0).getLiteral()); @@ -136,7 +135,7 @@ public class SearchTokenizerTest { assertQuery("abc xyz").resultsIn(WORD, WORD); assertQuery("abc AND xyz AND olingo").resultsIn(WORD, AND, WORD, AND, WORD); assertQuery("abc AND \"x-y_z\" AND olingo") - .resultsIn(WORD, AND, PHRASE, AND, WORD); + .resultsIn(WORD, AND, PHRASE, AND, WORD); } @Test @@ -146,7 +145,6 @@ public class SearchTokenizerTest { assertQuery("abc AND ANDsomething").addExpected(WORD, AND, WORD); } - @Test public void parseCombinations() throws Exception { assertQuery("word O NO").resultsIn(word("word"), word("O"), word("NO")); @@ -156,27 +154,25 @@ public class SearchTokenizerTest { assertQuery("abc AND NOT xyz OR olingo").resultsIn(WORD, AND, NOT, WORD, OR, WORD); assertQuery("foo AND bar OR foo AND baz OR that AND bar OR that AND baz") - .addExpected(WORD, "foo").addExpected(AND) - .addExpected(WORD, "bar").addExpected(OR) - .addExpected(WORD, "foo").addExpected(AND) - .addExpected(WORD, "baz").addExpected(OR) - .addExpected(WORD, "that").addExpected(AND) - .addExpected(WORD, "bar").addExpected(OR) - .addExpected(WORD, "that").addExpected(AND) - .addExpected(WORD, "baz") - .validate(); - + .addExpected(WORD, "foo").addExpected(AND) + .addExpected(WORD, "bar").addExpected(OR) + .addExpected(WORD, "foo").addExpected(AND) + .addExpected(WORD, "baz").addExpected(OR) + .addExpected(WORD, "that").addExpected(AND) + .addExpected(WORD, "bar").addExpected(OR) + .addExpected(WORD, "that").addExpected(AND) + .addExpected(WORD, "baz") + .validate(); assertQuery("(foo OR that) AND (bar OR baz)") - .addExpected(OPEN) - .addExpected(WORD, "foo").addExpected(OR).addExpected(WORD, "that") - .addExpected(CLOSE).addExpected(AND).addExpected(OPEN) - .addExpected(WORD, "bar").addExpected(OR).addExpected(WORD, "baz") - .addExpected(CLOSE) - .validate(); + .addExpected(OPEN) + .addExpected(WORD, "foo").addExpected(OR).addExpected(WORD, "that") + .addExpected(CLOSE).addExpected(AND).addExpected(OPEN) + .addExpected(WORD, "bar").addExpected(OR).addExpected(WORD, "baz") + .addExpected(CLOSE) + .validate(); } - @Test public void parseSpecial() throws Exception { assertQuery("NOT abc AND nothing").resultsIn(NOT, WORD, AND, WORD); @@ -192,23 +188,23 @@ public class SearchTokenizerTest { public void unicodeInWords() throws Exception { // Ll, Lm, Lo, Lt, Lu, Nl assertQuery("abc OR Ll\u01E3Lm\u02B5Lo\u00AALt\u01F2Lu\u03D3Nl\u216F") - .resultsIn(WORD, OR, WORD); + .resultsIn(WORD, OR, WORD); } /** - * unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" - * other-delims = "!" / "(" / ")" / "*" / "+" / "," / ";" - * qchar-unescaped = unreserved / pct-encoded-unescaped / other-delims / ":" / "@" / "/" / "?" / "$" / "'" / "=" - * pct-encoded-unescaped = "%" ( "0" / "1" / "3" / "4" / "6" / "7" / "8" / "9" / A-to-F ) HEXDIG - * / "%" "2" ( "0" / "1" / "3" / "4" / "5" / "6" / "7" / "8" / "9" / A-to-F ) - * / "%" "5" ( DIGIT / "A" / "B" / "D" / "E" / "F" ) + * unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" + * other-delims = "!" / "(" / ")" / "*" / "+" / "," / ";" + * qchar-unescaped = unreserved / pct-encoded-unescaped / other-delims / ":" / "@" / "/" / "?" / "$" / "'" / "=" + * pct-encoded-unescaped = "%" ( "0" / "1" / "3" / "4" / "6" / "7" / "8" / "9" / A-to-F ) HEXDIG + * / "%" "2" ( "0" / "1" / "3" / "4" / "5" / "6" / "7" / "8" / "9" / A-to-F ) + * / "%" "5" ( DIGIT / "A" / "B" / "D" / "E" / "F" ) * - * qchar-no-AMP-DQUOTE = qchar-unescaped / escape ( escape / quotation-mark ) + * qchar-no-AMP-DQUOTE = qchar-unescaped / escape ( escape / quotation-mark ) * - * escape = "\" / "%5C" ; reverse solidus U+005C - * quotation-mark = DQUOTE / "%22" - * ALPHA = %x41-5A / %x61-7A - * DIGIT = %x30-39 + * escape = "\" / "%5C" ; reverse solidus U+005C + * quotation-mark = DQUOTE / "%22" + * ALPHA = %x41-5A / %x61-7A + * DIGIT = %x30-39 * DQUOTE = %x22 * * @throws Exception @@ -218,7 +214,7 @@ public class SearchTokenizerTest { assertQuery("\"123\" OR \"ALPHA-._~\"").resultsIn(PHRASE, OR, PHRASE); assertQuery("\"100%Olingo\"").resultsIn(new Validator.Tuple(PHRASE, "\"100%Olingo\"")); assertQuery("\"100'Olingo\"").resultsIn(new Validator.Tuple(PHRASE, "\"100'Olingo\"")); - //escaped characters + // escaped characters assertQuery("\"\\\"123\" OR \"\\\\abc\"").resultsIn(new Validator.Tuple(PHRASE, "\"\"123\""), new Validator.Tuple(OR), new Validator.Tuple(PHRASE, "\"\\abc\"")); assertQuery("\"\\\"1\\\\23\"").resultsIn(new Validator.Tuple(PHRASE, "\"\"1\\23\"")); @@ -294,15 +290,15 @@ public class SearchTokenizerTest { assertQuery("abc AND \"something\" )").resultsIn(WORD, AND, PHRASE, CLOSE); } - public void validate(String query) throws SearchTokenizerException { + public void validate(final String query) throws SearchTokenizerException { new Validator(query); } - public Validator assertQuery(String query) throws SearchTokenizerException { + public Validator assertQuery(final String query) throws SearchTokenizerException { return new Validator(query); } - public void validate(String query, SearchQueryToken.Token ... tokens) throws SearchTokenizerException { + public void validate(final String query, final SearchQueryToken.Token... tokens) throws SearchTokenizerException { Validator sv = new Validator(query); for (SearchQueryToken.Token token : tokens) { sv.addExpected(token); @@ -315,32 +311,37 @@ public class SearchTokenizerTest { private boolean log; private final String searchQuery; - public void resultsIn(SearchQueryToken.Token... tokens) throws SearchTokenizerException { + public void resultsIn(final SearchQueryToken.Token... tokens) throws SearchTokenizerException { addExpected(tokens); validate(); } - public void resultsIn(Tuple... tuple) throws SearchTokenizerException { + + public void resultsIn(final Tuple... tuple) throws SearchTokenizerException { for (Tuple t : tuple) { addExpected(t.token, t.literal); } validate(); } - public static Tuple tuple(SearchQueryToken.Token token, String literal) { + + public static Tuple tuple(final SearchQueryToken.Token token, final String literal) { return new Tuple(token, literal); } + private static class Tuple { final SearchQueryToken.Token token; final String literal; - public Tuple(SearchQueryToken.Token token, String literal) { + + public Tuple(final SearchQueryToken.Token token, final String literal) { this.token = token; this.literal = literal; } - public Tuple(SearchQueryToken.Token token) { + + public Tuple(final SearchQueryToken.Token token) { this(token, null); } } - private Validator(String searchQuery) { + private Validator(final String searchQuery) { this.searchQuery = searchQuery; } @@ -348,24 +349,26 @@ public class SearchTokenizerTest { log = true; return this; } - private Validator addExpected(SearchQueryToken.Token token, String literal) { + + private Validator addExpected(final SearchQueryToken.Token token, final String literal) { validations.add(new Tuple(token, literal)); return this; } - private Validator addExpected(SearchQueryToken.Token ... token) { + + private Validator addExpected(final SearchQueryToken.Token... token) { for (SearchQueryToken.Token t : token) { validations.add(new Tuple(t)); } return this; } - private void resultsIn(SearchTokenizerException.MessageKey key) + private void resultsIn(final SearchTokenizerException.MessageKey key) throws SearchTokenizerException { try { validate(); } catch (SearchTokenizerException e) { Assert.assertEquals("SearchTokenizerException with unexpected message was thrown.", key, e.getMessageKey()); - if(log) { + if (log) { System.out.println("Caught SearchTokenizerException with message key " + e.getMessageKey() + " and message " + e.getMessage()); } @@ -378,17 +381,17 @@ public class SearchTokenizerTest { SearchTokenizer tokenizer = new SearchTokenizer(); List result = tokenizer.tokenize(searchQuery); Assert.assertNotNull(result); - if(log) { + if (log) { System.out.println(result); } - if(validations.size() != 0) { + if (validations.size() != 0) { Assert.assertEquals(validations.size(), result.size()); Iterator validationIt = validations.iterator(); for (SearchQueryToken iToken : result) { Tuple validation = validationIt.next(); Assert.assertEquals(validation.token, iToken.getToken()); - if(validation.literal != null) { + if (validation.literal != null) { Assert.assertEquals(validation.literal, iToken.getLiteral()); } }