[OLINGO-482] More refactoring
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/03c27702 Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/03c27702 Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/03c27702 Branch: refs/heads/master Commit: 03c2770202763511385f20368eac6a3afadeb988 Parents: 0a50812 Author: Michael Bolz <[email protected]> Authored: Mon Dec 15 16:08:51 2014 +0100 Committer: Michael Bolz <[email protected]> Committed: Mon Dec 15 16:13:19 2014 +0100 ---------------------------------------------------------------------- .../olingo/server/api/batch/BatchFacade.java | 4 +- .../server/api/processor/BatchProcessor.java | 24 ++- .../processor/ComplexCollectionProcessor.java | 33 ++++- .../server/api/processor/ComplexProcessor.java | 28 ++++ .../server/api/processor/DeltaProcessor.java | 34 ++--- .../processor/EntityCollectionProcessor.java | 2 +- .../server/api/processor/EntityProcessor.java | 19 ++- .../server/api/processor/ErrorProcessor.java | 1 + .../api/processor/MediaEntityProcessor.java | 15 ++ .../server/api/processor/MetadataProcessor.java | 2 +- .../processor/PrimitiveCollectionProcessor.java | 33 ++++- .../api/processor/PrimitiveProcessor.java | 31 +++- .../api/processor/ReferenceProcessor.java | 18 ++- .../api/processor/ServiceDocumentProcessor.java | 2 +- .../apache/olingo/server/core/ODataHandler.java | 11 +- .../core/batchhandler/BatchPartHandler.java | 2 +- .../processor/TechnicalBatchProcessor.java | 45 +++--- .../processor/TechnicalEntityProcessor.java | 43 ++++-- .../TechnicalPrimitiveComplexProcessor.java | 147 +++++++++++++------ .../olingo/server/core/ODataHandlerTest.java | 11 +- .../server/sample/processor/CarsProcessor.java | 50 +++++++ 21 files changed, 429 insertions(+), 126 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/03c27702/lib/server-api/src/main/java/org/apache/olingo/server/api/batch/BatchFacade.java ---------------------------------------------------------------------- diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/batch/BatchFacade.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/batch/BatchFacade.java index f961784..080a15e 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/batch/BatchFacade.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/batch/BatchFacade.java @@ -30,8 +30,8 @@ import org.apache.olingo.server.api.processor.BatchProcessor; * Within a {@link BatchProcessor} implementation BatchRequestsParts should be passed to * {@link BatchFacade#handleBatchRequest(BatchRequestPart)}. If only if the BatchRequests part represents * a change set, the request will be delegated to - * {@link BatchProcessor#executeChangeSet(BatchFacade, java.util.List, BatchRequestPart)}. Otherwise the requests - * will be directly executed. + * {@link org.apache.olingo.server.api.processor.BatchProcessor#processChangeSet(BatchFacade, java.util.List)}. + * Otherwise the requests will be directly executed. * * The processor implementation could use {@link BatchFacade#handleODataRequest(ODataRequest)} to processes * requests in a change set. http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/03c27702/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/BatchProcessor.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 2b3f1d0..b15d47b 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 @@ -23,14 +23,34 @@ import java.util.List; import org.apache.olingo.server.api.ODataRequest; import org.apache.olingo.server.api.ODataResponse; import org.apache.olingo.server.api.batch.BatchFacade; +import org.apache.olingo.server.api.batch.exception.BatchDeserializerException; import org.apache.olingo.server.api.batch.exception.BatchException; import org.apache.olingo.server.api.deserializer.batch.ODataResponsePart; import org.apache.olingo.server.api.serializer.SerializerException; +/** + * Processor interface for handling a single instance of an Entity Type. + */ public interface BatchProcessor extends Processor { - // TODO:Check exception signature + + /** + * Process a complete batch request and puts serialized content and status into the response. + * @param facade BatchFacade which should be used for further batch part handling + * @param request OData request object containing raw HTTP information + * @param response OData response object for collecting response data + * @throws BatchException if the service implementation encounters a failure + * @throws BatchDeserializerException if de-serialization failed + */ void processBatch(BatchFacade facade, ODataRequest request, ODataResponse response) throws SerializerException, BatchException; - ODataResponsePart processChangeSet(BatchFacade facade, List<ODataRequest> requests); + /** + * Process a batch change set (containing several batch requests) + * and puts serialized content and status into the response. + * @param facade BatchFacade which should be used for further batch part handling + * @param requests List of ODataRequests which are included in the to be processed change set + * @throws BatchDeserializerException if de-serialization failed + */ + ODataResponsePart processChangeSet(BatchFacade facade, List<ODataRequest> requests) + throws BatchDeserializerException; } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/03c27702/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ComplexCollectionProcessor.java ---------------------------------------------------------------------- diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ComplexCollectionProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ComplexCollectionProcessor.java index e861375..1fe0b0c 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ComplexCollectionProcessor.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ComplexCollectionProcessor.java @@ -22,6 +22,7 @@ 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; @@ -43,4 +44,34 @@ public interface ComplexCollectionProcessor extends Processor { */ void readComplexCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType responseFormat) throws ODataApplicationException, SerializerException; -} + + /** + * Update (replace) complex-type collection with send data in the persistence and + * puts content, status, and Location into the response. + * Update of complex-type collection is equal to a complete replace + * of the property (see chapter "11.4.9.4 Update a Collection Property"). + * @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 de-serialization failed + * @throws SerializerException if serialization failed + */ + void updateComplexCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo, + ContentType requestFormat, ContentType responseFormat) + throws ODataApplicationException, DeserializerException, SerializerException; + + /** + * Deletes complex-type collection from an entity and puts the status into the response. + * Deletion for complex-type collection is equal to + * set the content to <code>EMPTY</code>. + * @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 deleteComplexCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo) + throws ODataApplicationException; +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/03c27702/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ComplexProcessor.java ---------------------------------------------------------------------- diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ComplexProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ComplexProcessor.java index 5349461..280f42b 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ComplexProcessor.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ComplexProcessor.java @@ -22,6 +22,7 @@ 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; @@ -42,4 +43,31 @@ public interface ComplexProcessor extends Processor { */ void readComplex(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType responseFormat) throws ODataApplicationException, SerializerException; + /** + * Update complex-type instance with send 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 de-serialization failed + * @throws SerializerException if serialization failed + */ + void updateComplex(ODataRequest request, ODataResponse response, UriInfo uriInfo, + ContentType requestFormat, ContentType responseFormat) + throws ODataApplicationException, DeserializerException, SerializerException; + + /** + * Deletes complex-type value from an entity and puts the status into the response. + * Deletion for complex-type values is equal to + * set the value to <code>NULL</code> (see chapter "11.4.9.2 Set a Value to Null") + * @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 deleteComplex(ODataRequest request, ODataResponse response, UriInfo uriInfo) + throws ODataApplicationException; } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/03c27702/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DeltaProcessor.java ---------------------------------------------------------------------- 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 index e19397e..a834657 100644 --- 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 @@ -18,28 +18,22 @@ */ 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; -} +// NOT YET AVAILABLE +// /** +// * 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; +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/03c27702/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/EntityCollectionProcessor.java ---------------------------------------------------------------------- diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/EntityCollectionProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/EntityCollectionProcessor.java index 09d7143..d1c927c 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/EntityCollectionProcessor.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/EntityCollectionProcessor.java @@ -41,4 +41,4 @@ public interface EntityCollectionProcessor extends Processor { */ void readEntityCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType responseFormat) throws ODataApplicationException, SerializerException; -} +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/03c27702/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/EntityProcessor.java ---------------------------------------------------------------------- diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/EntityProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/EntityProcessor.java index 2c9078c..6e4610b 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/EntityProcessor.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/EntityProcessor.java @@ -42,8 +42,9 @@ public interface EntityProcessor extends Processor { */ void readEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType responseFormat) throws ODataApplicationException, SerializerException; + /** - * Creates entity media data in the persistence and puts content, status, and Location into the response. + * Creates an entity with send 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 @@ -57,9 +58,23 @@ public interface EntityProcessor extends Processor { ContentType requestFormat, ContentType responseFormat) throws ODataApplicationException, DeserializerException, SerializerException; + /** + * Update entity data with send 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 updateEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, + ContentType requestFormat, ContentType responseFormat) + throws ODataApplicationException, DeserializerException, SerializerException; /** - * Deletes entity media data from persistence and puts the status into the response. + * Deletes entity 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 http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/03c27702/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ErrorProcessor.java ---------------------------------------------------------------------- diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ErrorProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ErrorProcessor.java index 15d5ce0..145fb5b 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ErrorProcessor.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ErrorProcessor.java @@ -30,6 +30,7 @@ public interface ErrorProcessor extends Processor { /** * 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 http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/03c27702/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/MediaEntityProcessor.java ---------------------------------------------------------------------- diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/MediaEntityProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/MediaEntityProcessor.java index 945c5af..e700fa1 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/MediaEntityProcessor.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/MediaEntityProcessor.java @@ -44,6 +44,21 @@ public interface MediaEntityProcessor extends EntityProcessor { throws ODataApplicationException, SerializerException; /** + * Creates an entity with send media 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 createMediaEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, + ContentType requestFormat, ContentType responseFormat) + throws ODataApplicationException, DeserializerException, SerializerException; + + /** * Updates entity media data in the persistence and puts content and status into the response. * @param request OData request object containing raw HTTP information * @param response OData response object for collecting response data http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/03c27702/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/MetadataProcessor.java ---------------------------------------------------------------------- diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/MetadataProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/MetadataProcessor.java index 211220a..5faa56d 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/MetadataProcessor.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/MetadataProcessor.java @@ -31,7 +31,7 @@ import org.apache.olingo.server.api.uri.UriInfo; public interface MetadataProcessor extends Processor { /** - * Reads data from persistency and puts serialized content and status into the response. + * Reads data from persistence and puts 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 http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/03c27702/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/PrimitiveCollectionProcessor.java ---------------------------------------------------------------------- diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/PrimitiveCollectionProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/PrimitiveCollectionProcessor.java index 330b2d4..07f3678 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/PrimitiveCollectionProcessor.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/PrimitiveCollectionProcessor.java @@ -22,6 +22,7 @@ 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; @@ -44,4 +45,34 @@ public interface PrimitiveCollectionProcessor extends Processor { void readPrimitiveCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType responseFormat) throws ODataApplicationException, SerializerException; -} + + /** + * Update (replace) primitive-type collection with send data in the persistence and + * puts content, status, and Location into the response. + * Update of primitive-type collection is equal to a complete replace + * of the property (see chapter "11.4.9.4 Update a Collection Property"). + * @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 updatePrimitiveCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo, + ContentType requestFormat, ContentType responseFormat) + throws ODataApplicationException, DeserializerException, SerializerException; + + /** + * Deletes primitive-type collection from an entity and puts the status into the response. + * Deletion for primitive-type collection is equal to + * set the content to <code>EMPTY</code>. + * @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 deletePrimitiveCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo) + throws ODataApplicationException; +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/03c27702/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/PrimitiveProcessor.java ---------------------------------------------------------------------- diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/PrimitiveProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/PrimitiveProcessor.java index a7d4b68..e1bf0f0 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/PrimitiveProcessor.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/PrimitiveProcessor.java @@ -22,6 +22,7 @@ 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; @@ -43,4 +44,32 @@ public interface PrimitiveProcessor extends Processor { */ void readPrimitive(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType responseFormat) throws ODataApplicationException, SerializerException; -} + + /** + * Update primitive-type instance with send 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 updatePrimitive(ODataRequest request, ODataResponse response, UriInfo uriInfo, + ContentType requestFormat, ContentType responseFormat) + throws ODataApplicationException, DeserializerException, SerializerException; + + /** + * Deletes primitive-type value from an entity and puts the status into the response. + * Deletion for primitive-type values is equal to + * set the value to <code>NULL</code> (see chapter "11.4.9.2 Set a Value to Null") + * @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 deletePrimitive(ODataRequest request, ODataResponse response, UriInfo uriInfo) + throws ODataApplicationException; +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/03c27702/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/ReferenceProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ReferenceProcessor.java index c1568d8..6d19b40 100644 --- 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 @@ -44,14 +44,14 @@ public interface ReferenceProcessor extends Processor { throws ODataApplicationException, SerializerException; /** - * Creates entity reference data in the persistence and puts content, status, and Location into the response. + * Creates entity 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 DeserializerException if de-serialization failed * @throws SerializerException if serialization failed */ void createReference(ODataRequest request, ODataResponse response, UriInfo uriInfo, @@ -59,27 +59,29 @@ public interface ReferenceProcessor extends Processor { throws ODataApplicationException, DeserializerException, SerializerException; /** - * Update entity media reference in the persistence and puts content, status, and Location into the response. + * Update entity 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 DeserializerException if de-serialization 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. + * Deletes reference to an entity from persistence and puts the status into the response. + * Delete on a reference only removes the reference to and not the entity itself + * (see chapter "11.4.6.2 Remove a Reference to an Entity") * @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; -} + void deleteReference(ODataRequest request, ODataResponse response, UriInfo uriInfo) + throws ODataApplicationException; +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/03c27702/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ServiceDocumentProcessor.java ---------------------------------------------------------------------- diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ServiceDocumentProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ServiceDocumentProcessor.java index c040ec3..5f0d4f9 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ServiceDocumentProcessor.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/ServiceDocumentProcessor.java @@ -31,7 +31,7 @@ import org.apache.olingo.server.api.uri.UriInfo; public interface ServiceDocumentProcessor extends Processor { /** - * Reads service-document information from persistency and puts serialized content and status into the response. + * Reads service-document information from persistence and puts 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 http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/03c27702/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java ---------------------------------------------------------------------- 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 6b74efd..9efeb37 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 @@ -222,12 +222,15 @@ public class ODataHandler { if (isMedia(lastPathSegment)) { final ContentType requestFormat = ContentType.parse(request.getHeader(HttpHeader.CONTENT_TYPE)); final ContentType responseFormat = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(), - request, customContentTypeSupport, RepresentationType.ENTITY); + request, customContentTypeSupport, RepresentationType.ENTITY); selectProcessor(MediaEntityProcessor.class) - .createEntity(request, response, uriInfo, requestFormat, responseFormat); + .createMediaEntity(request, response, uriInfo, requestFormat, responseFormat); } else { - throw new ODataHandlerException("not implemented", - ODataHandlerException.MessageKeys.FUNCTIONALITY_NOT_IMPLEMENTED); + final ContentType requestFormat = ContentType.parse(request.getHeader(HttpHeader.CONTENT_TYPE)); + final ContentType responseFormat = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(), + request, customContentTypeSupport, RepresentationType.ENTITY); + selectProcessor(EntityProcessor.class) + .createEntity(request, response, uriInfo, requestFormat, responseFormat); } } else { throw new ODataHandlerException("HTTP method not allowed.", http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/03c27702/lib/server-core/src/main/java/org/apache/olingo/server/core/batchhandler/BatchPartHandler.java ---------------------------------------------------------------------- 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 d72b6f4..b140b0b 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 @@ -80,7 +80,7 @@ public class BatchPartHandler { return response; } - private ODataResponsePart handleChangeSet(BatchRequestPart request) { + private ODataResponsePart handleChangeSet(BatchRequestPart request) throws BatchDeserializerException { return batchProcessor.processChangeSet(batchFascade, request.getRequests()); } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/03c27702/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalBatchProcessor.java ---------------------------------------------------------------------- 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 ad1ba61..1e521be 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 @@ -132,33 +132,30 @@ public class TechnicalBatchProcessor extends TechnicalProcessor implements Batch } @Override - public ODataResponsePart processChangeSet(BatchFacade fascade, List<ODataRequest> requests) { + public ODataResponsePart processChangeSet(BatchFacade fascade, List<ODataRequest> requests) + throws BatchDeserializerException { List<ODataResponse> responses = new ArrayList<ODataResponse>(); for (ODataRequest request : requests) { - try { - final ODataResponse oDataResponse = fascade.handleODataRequest(request); - final int statusCode = oDataResponse.getStatusCode(); - - if (statusCode < 400) { - responses.add(oDataResponse); - } else { - // Rollback - // ... - - // OData Version 4.0 Part 1: Protocol Plus Errata 01 - // 11.7.4 Responding to a Batch Request - // - // When a request within a change set fails, the change set response is not represented using - // the multipart/mixed media type. Instead, a single response, using the application/http media type - // and a Content-Transfer-Encoding header with a value of binary, is returned that applies to all requests - // in the change set and MUST be formatted according to the Error Handling defined - // for the particular response format. - - return new ODataResponsePart(oDataResponse, false); - } - } catch (BatchDeserializerException e) { - throw new ODataRuntimeException(e); + final ODataResponse oDataResponse = fascade.handleODataRequest(request); + final int statusCode = oDataResponse.getStatusCode(); + + if (statusCode < 400) { + responses.add(oDataResponse); + } else { + // Rollback + // ... + + // OData Version 4.0 Part 1: Protocol Plus Errata 01 + // 11.7.4 Responding to a Batch Request + // + // When a request within a change set fails, the change set response is not represented using + // the multipart/mixed media type. Instead, a single response, using the application/http media type + // and a Content-Transfer-Encoding header with a value of binary, is returned that applies to all requests + // in the change set and MUST be formatted according to the Error Handling defined + // for the particular response format. + + return new ODataResponsePart(oDataResponse, false); } } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/03c27702/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java ---------------------------------------------------------------------- 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 045b729..b1f3ba4 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 @@ -152,9 +152,10 @@ public class TechnicalEntityProcessor extends TechnicalProcessor } @Override - public void createEntity(final ODataRequest request, ODataResponse response, final UriInfo uriInfo, - final ContentType requestFormat, final ContentType responseFormat) - throws ODataApplicationException, DeserializerException, SerializerException { + public void createMediaEntity(final ODataRequest request, ODataResponse response, final UriInfo uriInfo, + final ContentType requestFormat, final ContentType responseFormat) + throws ODataApplicationException, DeserializerException, SerializerException { + blockNavigation(uriInfo); final UriResourceEntitySet resourceEntitySet = (UriResourceEntitySet) uriInfo.getUriResourceParts().get(0); final EdmEntitySet edmEntitySet = resourceEntitySet.getEntitySet(); @@ -162,27 +163,45 @@ public class TechnicalEntityProcessor extends TechnicalProcessor if (edmEntitySet.getEntityType().hasStream()) { if (requestFormat == null) { throw new ODataApplicationException("The content type has not been set in the request.", - HttpStatusCode.BAD_REQUEST.getStatusCode(), Locale.ROOT); + HttpStatusCode.BAD_REQUEST.getStatusCode(), Locale.ROOT); } entity = dataProvider.create(edmEntitySet); dataProvider.setMedia(entity, odata.createFixedFormatDeserializer().binary(request.getBody()), - requestFormat.toContentTypeString()); + requestFormat.toContentTypeString()); } else { - throw new ODataApplicationException("Entity creation is not supported yet.", - HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT); + throw new ODataApplicationException("Requested Entity is not a media resource.", + HttpStatusCode.BAD_REQUEST.getStatusCode(), Locale.ROOT); } final ODataFormat format = ODataFormat.fromContentType(responseFormat); ODataSerializer serializer = odata.createSerializer(format); response.setContent(serializer.entity(edmEntitySet.getEntityType(), entity, - EntitySerializerOptions.with() - .contextURL(format == ODataFormat.JSON_NO_METADATA ? null : - getContextUrl(edmEntitySet, true, null, null)) - .build())); + EntitySerializerOptions.with() + .contextURL(format == ODataFormat.JSON_NO_METADATA ? null : + getContextUrl(edmEntitySet, true, null, null)) + .build())); response.setStatusCode(HttpStatusCode.CREATED.getStatusCode()); response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString()); response.setHeader(HttpHeader.LOCATION, - request.getRawBaseUri() + '/' + odata.createUriHelper().buildCanonicalURL(edmEntitySet, entity)); + request.getRawBaseUri() + '/' + odata.createUriHelper().buildCanonicalURL(edmEntitySet, entity)); + } + + @Override + public void createEntity(final ODataRequest request, ODataResponse response, final UriInfo uriInfo, + final ContentType requestFormat, final ContentType responseFormat) + throws ODataApplicationException, DeserializerException, SerializerException { + + throw new ODataApplicationException("Entity creation is not supported yet.", + HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT); + } + + @Override + public void updateEntity(final ODataRequest request, final ODataResponse response, + final UriInfo uriInfo, final ContentType requestFormat, + final ContentType responseFormat) + throws ODataApplicationException, DeserializerException, SerializerException { + throw new ODataApplicationException("Entity update is not supported yet.", + HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT); } @Override http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/03c27702/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java ---------------------------------------------------------------------- diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java index 3482d03..94d7257 100644 --- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java +++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java @@ -39,6 +39,7 @@ import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; 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.processor.ComplexCollectionProcessor; import org.apache.olingo.server.api.processor.ComplexProcessor; import org.apache.olingo.server.api.processor.PrimitiveCollectionProcessor; @@ -66,7 +67,7 @@ import org.apache.olingo.server.tecsvc.data.DataProvider; * Technical Processor which provides functionality related to primitive and complex types and collections thereof. */ public class TechnicalPrimitiveComplexProcessor extends TechnicalProcessor - implements PrimitiveProcessor, PrimitiveValueProcessor, PrimitiveCollectionProcessor, + implements PrimitiveProcessor, PrimitiveValueProcessor, PrimitiveCollectionProcessor, ComplexProcessor, ComplexCollectionProcessor { public TechnicalPrimitiveComplexProcessor(final DataProvider dataProvider) { @@ -75,30 +76,87 @@ public class TechnicalPrimitiveComplexProcessor extends TechnicalProcessor @Override public void readPrimitive(final ODataRequest request, ODataResponse response, final UriInfo uriInfo, - final ContentType contentType) throws ODataApplicationException, SerializerException { + final ContentType contentType) throws ODataApplicationException, SerializerException { readProperty(response, uriInfo, contentType, RepresentationType.PRIMITIVE); } @Override + public void updatePrimitive(final ODataRequest request, final ODataResponse response, + final UriInfo uriInfo, final ContentType requestFormat, + final ContentType responseFormat) + throws ODataApplicationException, DeserializerException, SerializerException { + throw new UnsupportedOperationException("Actual not yet supported"); + } + + @Override + public void deletePrimitive(ODataRequest request, ODataResponse response, UriInfo uriInfo) throws + ODataApplicationException { + throw new UnsupportedOperationException("Actual not yet supported"); + } + + @Override public void readPrimitiveCollection(final ODataRequest request, ODataResponse response, final UriInfo uriInfo, final ContentType contentType) throws ODataApplicationException, SerializerException { readProperty(response, uriInfo, contentType, RepresentationType.COLLECTION_PRIMITIVE); } @Override + public void updatePrimitiveCollection(final ODataRequest request, final ODataResponse response, + final UriInfo uriInfo, final ContentType requestFormat, + final ContentType responseFormat) + throws ODataApplicationException, DeserializerException, SerializerException { + throw new UnsupportedOperationException("Actual not yet supported"); + } + + @Override + public void deletePrimitiveCollection(final ODataRequest request, final ODataResponse response, + final UriInfo uriInfo) throws ODataApplicationException { + throw new UnsupportedOperationException("Actual not yet supported"); + } + + @Override public void readComplex(final ODataRequest request, ODataResponse response, final UriInfo uriInfo, - final ContentType contentType) throws ODataApplicationException, SerializerException { + final ContentType contentType) throws ODataApplicationException, SerializerException { readProperty(response, uriInfo, contentType, RepresentationType.COMPLEX); } @Override + public void updateComplex(final ODataRequest request, final ODataResponse response, + final UriInfo uriInfo, final ContentType requestFormat, + final ContentType responseFormat) + throws ODataApplicationException, DeserializerException, SerializerException { + throw new UnsupportedOperationException("Actual not yet supported"); + } + + @Override + public void deleteComplex(final ODataRequest request, final ODataResponse response, final UriInfo uriInfo) + throws ODataApplicationException { + throw new UnsupportedOperationException("Actual not yet supported"); + } + + @Override public void readComplexCollection(final ODataRequest request, ODataResponse response, final UriInfo uriInfo, final ContentType contentType) throws ODataApplicationException, SerializerException { readProperty(response, uriInfo, contentType, RepresentationType.COLLECTION_COMPLEX); } - private void readProperty(ODataResponse response, final UriInfo uriInfo, final ContentType contentType, - final RepresentationType representationType) throws ODataApplicationException, SerializerException { + @Override + public void updateComplexCollection(final ODataRequest request, final ODataResponse response, + final UriInfo uriInfo, final ContentType requestFormat, + final ContentType responseFormat) + throws ODataApplicationException, DeserializerException, SerializerException { + throw new UnsupportedOperationException("Actual not yet supported"); + } + + @Override + public void deleteComplexCollection(final ODataRequest request, final ODataResponse response, final UriInfo uriInfo) + throws ODataApplicationException { + throw new UnsupportedOperationException("Actual not yet supported"); + } + + private void readProperty(final ODataResponse response, final UriInfo uriInfo, final ContentType contentType, + final RepresentationType representationType) + throws ODataApplicationException, SerializerException { final UriInfoResource resource = uriInfo.asUriInfoResource(); validateOptions(resource); validatePath(resource); @@ -124,36 +182,37 @@ public class TechnicalPrimitiveComplexProcessor extends TechnicalProcessor final SelectOption select = uriInfo.getSelectOption(); final UriHelper helper = odata.createUriHelper(); final ContextURL contextURL = format == ODataFormat.JSON_NO_METADATA ? null : - ContextURL.with().entitySet(edmEntitySet) - .keyPath(helper.buildContextURLKeyPredicate( - ((UriResourceEntitySet) resourceParts.get(0)).getKeyPredicates())) - .navOrPropertyPath(buildPropertyPath(path)) - .selectList(edmProperty.isPrimitive() ? null : - helper.buildContextURLSelectList((EdmStructuredType) edmProperty.getType(), expand, select)) - .build(); + ContextURL.with().entitySet(edmEntitySet) + .keyPath(helper.buildContextURLKeyPredicate( + ((UriResourceEntitySet) resourceParts.get(0)).getKeyPredicates())) + .navOrPropertyPath(buildPropertyPath(path)) + .selectList(edmProperty.isPrimitive() ? null : + helper.buildContextURLSelectList((EdmStructuredType) edmProperty.getType(), expand, + select)) + .build(); switch (representationType) { - case PRIMITIVE: - response.setContent(serializer.primitive((EdmPrimitiveType) edmProperty.getType(), property, - PrimitiveSerializerOptions.with().contextURL(contextURL).facetsFrom(edmProperty).build())); - break; - case COMPLEX: - response.setContent(serializer.complex((EdmComplexType) edmProperty.getType(), property, - ComplexSerializerOptions.with().contextURL(contextURL) - .expand(expand).select(select) - .build())); - break; - case COLLECTION_PRIMITIVE: - response.setContent(serializer.primitiveCollection((EdmPrimitiveType) edmProperty.getType(), property, - PrimitiveSerializerOptions.with().contextURL(contextURL).facetsFrom(edmProperty).build())); - break; - case COLLECTION_COMPLEX: - response.setContent(serializer.complexCollection((EdmComplexType) edmProperty.getType(), property, - ComplexSerializerOptions.with().contextURL(contextURL) - .expand(expand).select(select) - .build())); - break; - default: - break; + case PRIMITIVE: + response.setContent(serializer.primitive((EdmPrimitiveType) edmProperty.getType(), property, + PrimitiveSerializerOptions.with().contextURL(contextURL).facetsFrom(edmProperty).build())); + break; + case COMPLEX: + response.setContent(serializer.complex((EdmComplexType) edmProperty.getType(), property, + ComplexSerializerOptions.with().contextURL(contextURL) + .expand(expand).select(select) + .build())); + break; + case COLLECTION_PRIMITIVE: + response.setContent(serializer.primitiveCollection((EdmPrimitiveType) edmProperty.getType(), property, + PrimitiveSerializerOptions.with().contextURL(contextURL).facetsFrom(edmProperty).build())); + break; + case COLLECTION_COMPLEX: + response.setContent(serializer.complexCollection((EdmComplexType) edmProperty.getType(), property, + ComplexSerializerOptions.with().contextURL(contextURL) + .expand(expand).select(select) + .build())); + break; + default: + break; } response.setStatusCode(HttpStatusCode.OK.getStatusCode()); response.setHeader(HttpHeader.CONTENT_TYPE, contentType.toContentTypeString()); @@ -162,7 +221,7 @@ public class TechnicalPrimitiveComplexProcessor extends TechnicalProcessor } private Property getPropertyData(final UriResourceEntitySet resourceEntitySet, final List<String> path) - throws ODataApplicationException { + throws ODataApplicationException { final Entity entity = dataProvider.read(resourceEntitySet.getEntitySet(), resourceEntitySet.getKeyPredicates()); if (entity == null) { throw new ODataApplicationException("Nothing found.", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ROOT); @@ -171,7 +230,7 @@ public class TechnicalPrimitiveComplexProcessor extends TechnicalProcessor for (final String name : path.subList(1, path.size())) { if (property != null && (property.isLinkedComplex() || property.isComplex())) { final List<Property> complex = property.isLinkedComplex() ? - property.asLinkedComplex().getValue() : property.asComplex(); + property.asLinkedComplex().getValue() : property.asComplex(); property = null; for (final Property innerProperty : complex) { if (innerProperty.getName().equals(name)) { @@ -205,7 +264,7 @@ public class TechnicalPrimitiveComplexProcessor extends TechnicalProcessor @Override public void readPrimitiveValue(final ODataRequest request, ODataResponse response, final UriInfo uriInfo, - final ContentType contentType) throws ODataApplicationException, SerializerException { + final ContentType contentType) throws ODataApplicationException, SerializerException { final UriInfoResource resource = uriInfo.asUriInfoResource(); validateOptions(resource); validatePath(resource); @@ -223,9 +282,9 @@ public class TechnicalPrimitiveComplexProcessor extends TechnicalProcessor final EdmPrimitiveType type = (EdmPrimitiveType) edmProperty.getType(); final FixedFormatSerializer serializer = odata.createFixedFormatSerializer(); response.setContent(type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Binary) ? - serializer.binary((byte[]) property.getValue()) : - serializer.primitiveValue(type, property.getValue(), - PrimitiveValueSerializerOptions.with().facetsFrom(edmProperty).build())); + serializer.binary((byte[]) property.getValue()) : + serializer.primitiveValue(type, property.getValue(), + PrimitiveValueSerializerOptions.with().facetsFrom(edmProperty).build())); response.setHeader(HttpHeader.CONTENT_TYPE, contentType.toContentTypeString()); response.setStatusCode(HttpStatusCode.OK.getStatusCode()); } @@ -236,11 +295,11 @@ public class TechnicalPrimitiveComplexProcessor extends TechnicalProcessor for (final UriResource segment : resourcePaths.subList(1, resourcePaths.size())) { final UriResourceKind kind = segment.getKind(); if (kind != UriResourceKind.primitiveProperty - && kind != UriResourceKind.complexProperty - && kind != UriResourceKind.count - && kind != UriResourceKind.value) { + && kind != UriResourceKind.complexProperty + && kind != UriResourceKind.count + && kind != UriResourceKind.value) { throw new ODataApplicationException("Invalid resource type.", - HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT); + HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT); } } } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/03c27702/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java ---------------------------------------------------------------------- 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 24521ca..ec9aa3d 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 @@ -267,6 +267,15 @@ public class ODataHandlerTest { } @Test + public void dispatchEntityCreate() throws Exception { + final EntityProcessor processor = mock(EntityProcessor.class); + dispatch(HttpMethod.POST, "ESAllPrim", processor); + + verify(processor).createEntity(any(ODataRequest.class), any(ODataResponse.class), + any(UriInfo.class), any(ContentType.class), any(ContentType.class)); + } + + @Test public void dispatchMedia() throws Exception { final MediaEntityProcessor processor = mock(MediaEntityProcessor.class); dispatch(HttpMethod.GET, "ESMedia(1)/$value", processor); @@ -280,7 +289,7 @@ public class ODataHandlerTest { final MediaEntityProcessor processor = mock(MediaEntityProcessor.class); dispatch(HttpMethod.POST, "ESMedia", processor); - verify(processor).createEntity(any(ODataRequest.class), any(ODataResponse.class), + verify(processor).createMediaEntity(any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class), any(ContentType.class), any(ContentType.class)); } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/03c27702/samples/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java ---------------------------------------------------------------------- diff --git a/samples/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java b/samples/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java index 3b0b08e..3f15483 100644 --- a/samples/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java +++ b/samples/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java @@ -55,6 +55,7 @@ import org.apache.olingo.server.api.serializer.EntityCollectionSerializerOptions import org.apache.olingo.server.api.serializer.EntitySerializerOptions; import org.apache.olingo.server.api.serializer.ODataSerializer; import org.apache.olingo.server.api.serializer.PrimitiveSerializerOptions; +import org.apache.olingo.server.api.serializer.RepresentationType; import org.apache.olingo.server.api.serializer.SerializerException; import org.apache.olingo.server.api.uri.UriHelper; import org.apache.olingo.server.api.uri.UriInfo; @@ -318,4 +319,53 @@ public class CarsProcessor implements EntityCollectionProcessor, EntityProcessor .navOrPropertyPath(navOrPropertyPath) .build(); } + + @Override + public void updatePrimitive(final ODataRequest request, final ODataResponse response, + final UriInfo uriInfo, final ContentType requestFormat, + final ContentType responseFormat) + throws ODataApplicationException, DeserializerException, SerializerException { + throw new ODataApplicationException("Primitive property update is not supported yet.", + HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT); + } + + @Override + public void deletePrimitive(ODataRequest request, ODataResponse response, UriInfo uriInfo) throws + ODataApplicationException { + throw new ODataApplicationException("Primitive property delete is not supported yet.", + HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT); + } + + @Override + public void updateComplex(final ODataRequest request, final ODataResponse response, + final UriInfo uriInfo, final ContentType requestFormat, + final ContentType responseFormat) + throws ODataApplicationException, DeserializerException, SerializerException { + throw new ODataApplicationException("Complex property update is not supported yet.", + HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT); + } + + @Override + public void deleteComplex(final ODataRequest request, final ODataResponse response, final UriInfo uriInfo) + throws ODataApplicationException { + throw new ODataApplicationException("Complex property delete is not supported yet.", + HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT); + } + + @Override + public void createMediaEntity(final ODataRequest request, ODataResponse response, final UriInfo uriInfo, + final ContentType requestFormat, final ContentType responseFormat) + throws ODataApplicationException, DeserializerException, SerializerException { + throw new ODataApplicationException("MediaEntity create is not supported yet.", + HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT); + } + + @Override + public void updateEntity(final ODataRequest request, final ODataResponse response, + final UriInfo uriInfo, final ContentType requestFormat, + final ContentType responseFormat) + throws ODataApplicationException, DeserializerException, SerializerException { + throw new ODataApplicationException("Entity update is not supported yet.", + HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT); + } }
