From a961214d1fe032d416c7bd08f86e6058900eae85 Mon Sep 17 00:00:00 2001 From: Michael Bolz Date: Wed, 10 Dec 2014 11:28:05 +0100 Subject: [PATCH] [OLINGO-482] Added new Processor Interfaces --- .../server/api/processor/BatchProcessor.java | 4 +- .../CountComplexCollectionProcessor.java | 5 +- .../CountEntityCollectionProcessor.java | 4 +- .../api/processor/DefaultProcessor.java | 6 +- .../server/api/processor/DeltaProcessor.java | 45 ++++++++++ ...tionProcessor.java => ErrorProcessor.java} | 16 ++-- .../ReferenceCollectionProcessor.java | 47 ++++++++++ .../api/processor/ReferenceProcessor.java | 85 +++++++++++++++++++ .../olingo/server/core/ODataHandler.java | 10 +-- .../core/batchhandler/BatchHandler.java | 2 +- .../core/batchhandler/BatchPartHandler.java | 2 +- .../batchhandler/MockedBatchHandlerTest.java | 4 +- .../processor/TechnicalBatchProcessor.java | 4 +- .../processor/TechnicalEntityProcessor.java | 7 +- .../olingo/server/core/ODataHandlerTest.java | 4 +- 15 files changed, 209 insertions(+), 36 deletions(-) create mode 100644 lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DeltaProcessor.java rename lib/server-api/src/main/java/org/apache/olingo/server/api/processor/{ExceptionProcessor.java => ErrorProcessor.java} (65%) create mode 100644 lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ReferenceCollectionProcessor.java create mode 100644 lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ReferenceProcessor.java diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/BatchProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/BatchProcessor.java index 390dfe94d..2b3f1d0ee 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/BatchProcessor.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/BatchProcessor.java @@ -29,8 +29,8 @@ import org.apache.olingo.server.api.serializer.SerializerException; public interface BatchProcessor extends Processor { // TODO:Check exception signature - void executeBatch(BatchFacade facade, ODataRequest request, ODataResponse response) + void processBatch(BatchFacade facade, ODataRequest request, ODataResponse response) throws SerializerException, BatchException; - ODataResponsePart executeChangeSet(BatchFacade facade, List requests); + ODataResponsePart processChangeSet(BatchFacade facade, List requests); } diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/CountComplexCollectionProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/CountComplexCollectionProcessor.java index 4ccf31066..29b152829 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/CountComplexCollectionProcessor.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/CountComplexCollectionProcessor.java @@ -18,7 +18,6 @@ */ package org.apache.olingo.server.api.processor; -import org.apache.olingo.commons.api.format.ContentType; import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.ODataRequest; import org.apache.olingo.server.api.ODataResponse; @@ -36,11 +35,9 @@ public interface CountComplexCollectionProcessor extends Processor { * @param request OData request object containing raw HTTP information. * @param response OData response object for collecting response data * @param uriInfo information of a parsed OData URI - * @param responseFormat requested content type after content negotiation * @throws ODataApplicationException if the service implementation encounters a failure * @throws SerializerException if serialization failed */ - void countComplexCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo, - ContentType responseFormat) + void countComplexCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo) throws ODataApplicationException, SerializerException; } diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/CountEntityCollectionProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/CountEntityCollectionProcessor.java index c2464dc81..d64c6ce54 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/CountEntityCollectionProcessor.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/CountEntityCollectionProcessor.java @@ -18,7 +18,6 @@ */ package org.apache.olingo.server.api.processor; -import org.apache.olingo.commons.api.format.ContentType; import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.ODataRequest; import org.apache.olingo.server.api.ODataResponse; @@ -36,10 +35,9 @@ public interface CountEntityCollectionProcessor extends Processor { * @param request OData request object containing raw HTTP information. * @param response OData response object for collecting response data * @param uriInfo information of a parsed OData URI - * @param responseFormat requested content type after content negotiation * @throws ODataApplicationException if the service implementation encounters a failure * @throws SerializerException if serialization failed */ - void countEntityCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType responseFormat) + void countEntityCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo) throws ODataApplicationException, SerializerException; } diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java index 0bc9ff1eb..302959af4 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java @@ -42,7 +42,7 @@ import org.apache.olingo.server.api.uri.UriInfo; *

This implementation is registered in the ODataHandler by default. * The default can be replaced by re-registering a custom implementation.

*/ -public class DefaultProcessor implements MetadataProcessor, ServiceDocumentProcessor, ExceptionProcessor { +public class DefaultProcessor implements MetadataProcessor, ServiceDocumentProcessor, ErrorProcessor { private OData odata; private ServiceMetadata serviceMetadata; @@ -71,8 +71,8 @@ public class DefaultProcessor implements MetadataProcessor, ServiceDocumentProce } @Override - public void processException(ODataRequest request, ODataResponse response, ODataServerError serverError, - ContentType requestedContentType) { + public void processError(ODataRequest request, ODataResponse response, ODataServerError serverError, + ContentType requestedContentType) { try { ODataSerializer serializer = odata.createSerializer(ODataFormat.fromContentType(requestedContentType)); response.setContent(serializer.error(serverError)); diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DeltaProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DeltaProcessor.java new file mode 100644 index 000000000..e19397ea1 --- /dev/null +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DeltaProcessor.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.server.api.processor; + +import org.apache.olingo.commons.api.format.ContentType; +import org.apache.olingo.server.api.ODataApplicationException; +import org.apache.olingo.server.api.ODataRequest; +import org.apache.olingo.server.api.ODataResponse; +import org.apache.olingo.server.api.serializer.SerializerException; +import org.apache.olingo.server.api.uri.UriInfo; + +/** + * Processor interface for handling a single instance of an Delta Response. + */ +public interface DeltaProcessor extends Processor { + + /** + * Reads delta information from persistence and put it as serialized content and + * with according status into the response. + * @param request OData request object containing raw HTTP information + * @param response OData response object for collecting response data + * @param uriInfo information of a parsed OData URI + * @param responseFormat requested content type after content negotiation + * @throws ODataApplicationException if the service implementation encounters a failure + * @throws SerializerException if serialization failed + */ + void readDelta(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType responseFormat) + throws ODataApplicationException, SerializerException; +} diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ExceptionProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ErrorProcessor.java similarity index 65% rename from lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ExceptionProcessor.java rename to lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ErrorProcessor.java index b98d41a8b..15d5ce0e9 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ExceptionProcessor.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ErrorProcessor.java @@ -24,17 +24,17 @@ import org.apache.olingo.server.api.ODataResponse; import org.apache.olingo.server.api.ODataServerError; /** - * Processor which is called if any exception occurs inside the library or another processor. + * Processor which is called if any error/exception occurs inside the library or another processor. */ -public interface ExceptionProcessor extends Processor { +public interface ErrorProcessor extends Processor { /** - * Processes an exception. MUST NOT throw an exception! - * @param request the request - * @param response the response + * Processes an error/exception. MUST NOT throw an exception! + * @param request OData request object containing raw HTTP information + * @param response OData response object for collecting response data * @param serverError the server error - * @param responseFormat the requested format for the error message + * @param responseFormat requested content type after content negotiation */ - public void processException(ODataRequest request, ODataResponse response, ODataServerError serverError, - ContentType responseFormat); + public void processError(ODataRequest request, ODataResponse response, ODataServerError serverError, + ContentType responseFormat); } diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ReferenceCollectionProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ReferenceCollectionProcessor.java new file mode 100644 index 000000000..041d89519 --- /dev/null +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ReferenceCollectionProcessor.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.server.api.processor; + +import org.apache.olingo.commons.api.format.ContentType; +import org.apache.olingo.server.api.ODataApplicationException; +import org.apache.olingo.server.api.ODataRequest; +import org.apache.olingo.server.api.ODataResponse; +import org.apache.olingo.server.api.deserializer.DeserializerException; +import org.apache.olingo.server.api.serializer.SerializerException; +import org.apache.olingo.server.api.uri.UriInfo; + +/** + * Processor interface for handling a collection an Entity References. + */ +public interface ReferenceCollectionProcessor extends Processor { + + /** + * Reads entity references from persistence and put them as serialized content and with + * according status into the response. + * @param request OData request object containing raw HTTP information + * @param response OData response object for collecting response data + * @param uriInfo information of a parsed OData URI + * @param responseFormat requested content type after content negotiation + * @throws ODataApplicationException if the service implementation encounters a failure + * @throws SerializerException if serialization failed + */ + void readReferenceCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo, + ContentType responseFormat) + throws ODataApplicationException, SerializerException; +} diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ReferenceProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ReferenceProcessor.java new file mode 100644 index 000000000..c1568d839 --- /dev/null +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ReferenceProcessor.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.server.api.processor; + +import org.apache.olingo.commons.api.format.ContentType; +import org.apache.olingo.server.api.ODataApplicationException; +import org.apache.olingo.server.api.ODataRequest; +import org.apache.olingo.server.api.ODataResponse; +import org.apache.olingo.server.api.deserializer.DeserializerException; +import org.apache.olingo.server.api.serializer.SerializerException; +import org.apache.olingo.server.api.uri.UriInfo; + +/** + * Processor interface for handling a single instance of an Entity Reference. + */ +public interface ReferenceProcessor extends Processor { + + /** + * Reads entity reference from persistence and put it as serialized content and status into the response. + * @param request OData request object containing raw HTTP information + * @param response OData response object for collecting response data + * @param uriInfo information of a parsed OData URI + * @param responseFormat requested content type after content negotiation + * @throws ODataApplicationException if the service implementation encounters a failure + * @throws SerializerException if serialization failed + */ + void readReference(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType responseFormat) + throws ODataApplicationException, SerializerException; + + /** + * Creates entity reference data in the persistence and puts content, status, and Location into the response. + * @param request OData request object containing raw HTTP information + * @param response OData response object for collecting response data + * @param uriInfo information of a parsed OData URI + * @param requestFormat content type of body sent with request + * @param responseFormat requested content type after content negotiation + * @throws ODataApplicationException if the service implementation encounters a failure + * @throws DeserializerException if deserialization failed + * @throws SerializerException if serialization failed + */ + void createReference(ODataRequest request, ODataResponse response, UriInfo uriInfo, + ContentType requestFormat, ContentType responseFormat) + throws ODataApplicationException, DeserializerException, SerializerException; + + /** + * Update entity media reference in the persistence and puts content, status, and Location into the response. + * @param request OData request object containing raw HTTP information + * @param response OData response object for collecting response data + * @param uriInfo information of a parsed OData URI + * @param requestFormat content type of body sent with request + * @param responseFormat requested content type after content negotiation + * @throws ODataApplicationException if the service implementation encounters a failure + * @throws DeserializerException if deserialization failed + * @throws SerializerException if serialization failed + */ + void updateReference(ODataRequest request, ODataResponse response, UriInfo uriInfo, + ContentType requestFormat, ContentType responseFormat) + throws ODataApplicationException, DeserializerException, SerializerException; + + + /** + * Deletes entity (related to reference) from persistence and puts the status into the response. + * @param request OData request object containing raw HTTP information + * @param response OData response object for collecting response data + * @param uriInfo information of a parsed OData URI + * @throws ODataApplicationException if the service implementation encounters a failure + */ + void deleteReference(ODataRequest request, ODataResponse response, UriInfo uriInfo) throws ODataApplicationException; +} 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 3f899decb..3ba055be3 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 @@ -45,7 +45,7 @@ import org.apache.olingo.server.api.processor.CountEntityCollectionProcessor; import org.apache.olingo.server.api.processor.DefaultProcessor; import org.apache.olingo.server.api.processor.EntityCollectionProcessor; import org.apache.olingo.server.api.processor.EntityProcessor; -import org.apache.olingo.server.api.processor.ExceptionProcessor; +import org.apache.olingo.server.api.processor.ErrorProcessor; import org.apache.olingo.server.api.processor.MediaEntityProcessor; import org.apache.olingo.server.api.processor.MetadataProcessor; import org.apache.olingo.server.api.processor.PrimitiveCollectionProcessor; @@ -183,9 +183,9 @@ public class ODataHandler { } public void handleException(ODataRequest request, ODataResponse response, ODataServerError serverError) { - ExceptionProcessor exceptionProcessor; + ErrorProcessor exceptionProcessor; try { - exceptionProcessor = selectProcessor(ExceptionProcessor.class); + exceptionProcessor = selectProcessor(ErrorProcessor.class); } catch (ODataHandlerException e) { // This cannot happen since there is always an ExceptionProcessor registered. exceptionProcessor = new DefaultProcessor(); @@ -198,7 +198,7 @@ public class ODataHandler { } catch (final ContentNegotiatorException e) { requestedContentType = ODataFormat.JSON.getContentType(ODataServiceVersion.V40); } - exceptionProcessor.processException(request, response, serverError, requestedContentType); + exceptionProcessor.processError(request, response, serverError, requestedContentType); } private void handleResourceDispatching(final ODataRequest request, final ODataResponse response) @@ -261,7 +261,7 @@ public class ODataHandler { final UriResource resource = uriInfo.getUriResourceParts().get(lastPathSegmentIndex - 1); if (resource instanceof UriResourceEntitySet || resource instanceof UriResourceNavigation) { selectProcessor(CountEntityCollectionProcessor.class) - .countEntityCollection(request, response, uriInfo, ContentType.TEXT_PLAIN); + .countEntityCollection(request, response, uriInfo); } else { throw new ODataHandlerException( "Count of collections of primitive-type or complex-type instances is not implemented.", 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 b2d86470d..d4b2c6584 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 @@ -46,7 +46,7 @@ public class BatchHandler { validateRequest(request); final BatchFacade operation = new BatchFascadeImpl(oDataHandler, request, batchProcessor, isStrict); - batchProcessor.executeBatch(operation, request, response); + batchProcessor.processBatch(operation, request, response); } private void validateRequest(final ODataRequest request) throws BatchDeserializerException { 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 74b048824..d72b6f486 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 @@ -81,7 +81,7 @@ public class BatchPartHandler { } private ODataResponsePart handleChangeSet(BatchRequestPart request) { - return batchProcessor.executeChangeSet(batchFascade, request.getRequests()); + return batchProcessor.processChangeSet(batchFascade, request.getRequests()); } } 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 8d4b357a4..c3a47dafd 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 @@ -580,7 +580,7 @@ public class MockedBatchHandlerTest { } @Override - public ODataResponsePart executeChangeSet(BatchFacade fascade, List requests) { + public ODataResponsePart processChangeSet(BatchFacade fascade, List requests) { List responses = new ArrayList(); for (ODataRequest request : requests) { @@ -595,7 +595,7 @@ public class MockedBatchHandlerTest { } @Override - public void executeBatch(BatchFacade fascade, ODataRequest request, ODataResponse response) + public void processBatch(BatchFacade fascade, ODataRequest request, ODataResponse response) throws BatchException, SerializerException { final String boundary = getBoundary(request.getHeader(HttpHeader.CONTENT_TYPE)); final BatchOptions options = BatchOptions.with().isStrict(true).rawBaseUri(BASE_URI).build(); diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalBatchProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalBatchProcessor.java index 7db70889a..ad1ba6126 100644 --- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalBatchProcessor.java +++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalBatchProcessor.java @@ -49,7 +49,7 @@ public class TechnicalBatchProcessor extends TechnicalProcessor implements Batch } @Override - public void executeBatch(BatchFacade fascade, ODataRequest request, ODataResponse response) + public void processBatch(BatchFacade fascade, ODataRequest request, ODataResponse response) throws SerializerException, BatchException { // TODO refactor isContinueOnError @@ -132,7 +132,7 @@ public class TechnicalBatchProcessor extends TechnicalProcessor implements Batch } @Override - public ODataResponsePart executeChangeSet(BatchFacade fascade, List requests) { + public ODataResponsePart processChangeSet(BatchFacade fascade, List requests) { List responses = new ArrayList(); for (ODataRequest request : requests) { diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java index 016b7b295..9c37f8b98 100644 --- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java +++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java @@ -28,6 +28,7 @@ import org.apache.olingo.commons.api.data.EntitySet; import org.apache.olingo.commons.api.edm.EdmEntitySet; import org.apache.olingo.commons.api.format.ContentType; import org.apache.olingo.commons.api.format.ODataFormat; +import org.apache.olingo.commons.api.http.HttpContentType; import org.apache.olingo.commons.api.http.HttpHeader; import org.apache.olingo.commons.api.http.HttpStatusCode; import org.apache.olingo.server.api.ODataApplicationException; @@ -89,8 +90,8 @@ public class TechnicalEntityProcessor extends TechnicalProcessor } @Override - public void countEntityCollection(final ODataRequest request, ODataResponse response, final UriInfo uriInfo, - final ContentType requestedContentType) throws ODataApplicationException, SerializerException { + public void countEntityCollection(final ODataRequest request, ODataResponse response, final UriInfo uriInfo) + throws ODataApplicationException, SerializerException { validateOptions(uriInfo.asUriInfoResource()); blockNavigation(uriInfo); @@ -103,7 +104,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor } else { response.setContent(odata.createFixedFormatSerializer().count(entitySet.getCount())); response.setStatusCode(HttpStatusCode.OK.getStatusCode()); - response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString()); + response.setHeader(HttpHeader.CONTENT_TYPE, HttpContentType.TEXT_PLAIN); } } diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java index 67ce094ae..d211a32a5 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java @@ -235,7 +235,7 @@ public class ODataHandlerTest { dispatch(HttpMethod.GET, "ESAllPrim/$count", processor); verify(processor).countEntityCollection( - any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class), eq(ContentType.TEXT_PLAIN)); + any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class)); dispatchMethodNotAllowed(HttpMethod.POST, "ESAllPrim/$count", processor); } @@ -246,7 +246,7 @@ public class ODataHandlerTest { dispatch(HttpMethod.GET, "ESAllPrim(0)/NavPropertyETTwoPrimMany/$count", processor); verify(processor).countEntityCollection( - any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class), eq(ContentType.TEXT_PLAIN)); + any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class)); } @Test