org.apache.olingo.odata2.api.processor
Class ODataSingleProcessor

java.lang.Object
  extended by org.apache.olingo.odata2.api.processor.ODataSingleProcessor
All Implemented Interfaces:
CustomContentType, ODataProcessorFeature, ODataProcessor, BatchProcessor, EntityComplexPropertyProcessor, EntityLinkProcessor, EntityLinksProcessor, EntityMediaProcessor, EntityProcessor, EntitySetProcessor, EntitySimplePropertyProcessor, EntitySimplePropertyValueProcessor, FunctionImportProcessor, FunctionImportValueProcessor, MetadataProcessor, ServiceDocumentProcessor
Direct Known Subclasses:
ListsProcessor, ODataJPAProcessor

public abstract class ODataSingleProcessor
extends Object
implements MetadataProcessor, ServiceDocumentProcessor, EntityProcessor, EntitySetProcessor, EntityComplexPropertyProcessor, EntityLinkProcessor, EntityLinksProcessor, EntityMediaProcessor, EntitySimplePropertyProcessor, EntitySimplePropertyValueProcessor, FunctionImportProcessor, FunctionImportValueProcessor, BatchProcessor, CustomContentType

A default ODataProcessor that implements all processor features in a single class.

It is recommended to derive from this class and it is required by the ODataServiceFactory to build an ODataService.

This abstract class provides a default behavior, returning the correct response for requests for the service or the metadata document, respectively, and throwing an ODataNotImplementedException for all other requests. Sub classes have to override only methods they want to support.


Constructor Summary
ODataSingleProcessor()
           
 
Method Summary
 ODataResponse countEntityLinks(GetEntitySetLinksCountUriInfo uriInfo, String contentType)
          Counts the number of target entities of a navigation property.
 ODataResponse countEntitySet(GetEntitySetCountUriInfo uriInfo, String contentType)
          Counts the number of requested entities.
 ODataResponse createEntity(PostUriInfo uriInfo, InputStream content, String requestContentType, String contentType)
          Creates an entity.
 ODataResponse createEntityLink(PostUriInfo uriInfo, InputStream content, String requestContentType, String contentType)
          Creates a new link to a target entity of a navigation property.
 ODataResponse deleteEntity(DeleteUriInfo uriInfo, String contentType)
          Deletes an entity.
 ODataResponse deleteEntityLink(DeleteUriInfo uriInfo, String contentType)
          Deletes the link to the target entity of a navigation property.
 ODataResponse deleteEntityMedia(DeleteUriInfo uriInfo, String contentType)
          Deletes the media resource of an entity.
 ODataResponse deleteEntitySimplePropertyValue(DeleteUriInfo uriInfo, String contentType)
          Deletes the value of a simple property of an entity.
 ODataResponse executeBatch(BatchHandler handler, String contentType, InputStream content)
          Executes a OData batch request and provide Batch Response as ODataResponse
 BatchResponsePart executeChangeSet(BatchHandler handler, List<ODataRequest> requests)
          Executes a Change Set and provide BatchResponsePart as BatchResponsePart that contains the responses to change requests.
 ODataResponse executeFunctionImport(GetFunctionImportUriInfo uriInfo, String contentType)
          Executes a function import and returns the result.
 ODataResponse executeFunctionImportValue(GetFunctionImportUriInfo uriInfo, String contentType)
          Returns the unformatted value of a function import.
 ODataResponse existsEntity(GetEntityCountUriInfo uriInfo, String contentType)
          Checks whether an entity exists.
 ODataResponse existsEntityLink(GetEntityLinkCountUriInfo uriInfo, String contentType)
          Returns whether the target entity of a navigation property exists.
 ODataContext getContext()
           
 List<String> getCustomContentTypes(Class<? extends ODataProcessor> processorFeature)
          The OData library will consider these additional content types during negotiation of http content type header.
 ODataResponse readEntity(GetEntityUriInfo uriInfo, String contentType)
          Reads an entity.
 ODataResponse readEntityComplexProperty(GetComplexPropertyUriInfo uriInfo, String contentType)
          Reads a complex property of an entity.
 ODataResponse readEntityLink(GetEntityLinkUriInfo uriInfo, String contentType)
          Reads the URI of the target entity of a navigation property.
 ODataResponse readEntityLinks(GetEntitySetLinksUriInfo uriInfo, String contentType)
          Reads the URIs of the target entities of a navigation property.
 ODataResponse readEntityMedia(GetMediaResourceUriInfo uriInfo, String contentType)
          Reads the media resource of an entity.
 ODataResponse readEntitySet(GetEntitySetUriInfo uriInfo, String contentType)
          Reads entities.
 ODataResponse readEntitySimpleProperty(GetSimplePropertyUriInfo uriInfo, String contentType)
          Reads a simple property of an entity.
 ODataResponse readEntitySimplePropertyValue(GetSimplePropertyUriInfo uriInfo, String contentType)
          Reads the unformatted value of a simple property of an entity.
 ODataResponse readMetadata(GetMetadataUriInfo uriInfo, String contentType)
           
 ODataResponse readServiceDocument(GetServiceDocumentUriInfo uriInfo, String contentType)
           
 void setContext(ODataContext context)
           
 ODataResponse updateEntity(PutMergePatchUriInfo uriInfo, InputStream content, String requestContentType, boolean merge, String contentType)
          Updates an entity.
 ODataResponse updateEntityComplexProperty(PutMergePatchUriInfo uriInfo, InputStream content, String requestContentType, boolean merge, String contentType)
          Updates a complex property of an entity.
 ODataResponse updateEntityLink(PutMergePatchUriInfo uriInfo, InputStream content, String requestContentType, String contentType)
          Updates the link to the target entity of a navigation property.
 ODataResponse updateEntityMedia(PutMergePatchUriInfo uriInfo, InputStream content, String requestContentType, String contentType)
          Updates the media resource of an entity.
 ODataResponse updateEntitySimpleProperty(PutMergePatchUriInfo uriInfo, InputStream content, String requestContentType, String contentType)
          Updates a simple property of an entity.
 ODataResponse updateEntitySimplePropertyValue(PutMergePatchUriInfo uriInfo, InputStream content, String requestContentType, String contentType)
          Updates a simple property of an entity with an unformatted value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ODataSingleProcessor

public ODataSingleProcessor()
Method Detail

setContext

public void setContext(ODataContext context)
Specified by:
setContext in interface ODataProcessor
Parameters:
context - A request context object which is usually injected by the OData library itself.
See Also:
ODataProcessor

getContext

public ODataContext getContext()
Specified by:
getContext in interface ODataProcessor
Returns:
A request context object.
See Also:
ODataProcessor

executeBatch

public ODataResponse executeBatch(BatchHandler handler,
                                  String contentType,
                                  InputStream content)
                           throws ODataException
Description copied from interface: BatchProcessor
Executes a OData batch request and provide Batch Response as ODataResponse

Specified by:
executeBatch in interface BatchProcessor
Parameters:
handler - batch handler
contentType - the content type of the request
content - Batch Request body
Returns:
a ODataResponse object
Throws:
ODataException
See Also:
BatchProcessor

executeChangeSet

public BatchResponsePart executeChangeSet(BatchHandler handler,
                                          List<ODataRequest> requests)
                                   throws ODataException
Description copied from interface: BatchProcessor
Executes a Change Set and provide BatchResponsePart as BatchResponsePart that contains the responses to change requests. The method has to define a rollback semantic that may be applied when a request within a Change Set fails (all-or-nothing requirement). If a request within a Change Set fails, instead of Change Set Response should be returned the error response

Specified by:
executeChangeSet in interface BatchProcessor
Parameters:
handler - batch handler
requests - list of single change requests
Returns:
a BatchResponsePart object
Throws:
ODataNotImplementedException
ODataException
See Also:
BatchProcessor

executeFunctionImport

public ODataResponse executeFunctionImport(GetFunctionImportUriInfo uriInfo,
                                           String contentType)
                                    throws ODataException
Description copied from interface: FunctionImportProcessor
Executes a function import and returns the result.

Specified by:
executeFunctionImport in interface FunctionImportProcessor
Parameters:
uriInfo - information about the request URI
contentType - the content type of the response
Returns:
an ODataResponse object
Throws:
ODataException
See Also:
FunctionImportProcessor

executeFunctionImportValue

public ODataResponse executeFunctionImportValue(GetFunctionImportUriInfo uriInfo,
                                                String contentType)
                                         throws ODataException
Description copied from interface: FunctionImportValueProcessor
Returns the unformatted value of a function import.

Specified by:
executeFunctionImportValue in interface FunctionImportValueProcessor
Parameters:
uriInfo - information about the request URI
contentType - the content type of the response
Returns:
an ODataResponse object
Throws:
ODataException
See Also:
FunctionImportValueProcessor

readEntitySimplePropertyValue

public ODataResponse readEntitySimplePropertyValue(GetSimplePropertyUriInfo uriInfo,
                                                   String contentType)
                                            throws ODataException
Description copied from interface: EntitySimplePropertyValueProcessor
Reads the unformatted value of a simple property of an entity.

Specified by:
readEntitySimplePropertyValue in interface EntitySimplePropertyValueProcessor
Parameters:
uriInfo - information about the request URI
contentType - the content type of the response
Returns:
an ODataResponse object
Throws:
ODataException
See Also:
EntitySimplePropertyValueProcessor

updateEntitySimplePropertyValue

public ODataResponse updateEntitySimplePropertyValue(PutMergePatchUriInfo uriInfo,
                                                     InputStream content,
                                                     String requestContentType,
                                                     String contentType)
                                              throws ODataException
Description copied from interface: EntitySimplePropertyValueProcessor
Updates a simple property of an entity with an unformatted value.

Specified by:
updateEntitySimplePropertyValue in interface EntitySimplePropertyValueProcessor
Parameters:
uriInfo - information about the request URI
content - the content of the request, containing the new value
requestContentType - the content type of the request body (important for a binary property)
contentType - the content type of the response
Returns:
an ODataResponse object
Throws:
ODataException
See Also:
EntitySimplePropertyValueProcessor

deleteEntitySimplePropertyValue

public ODataResponse deleteEntitySimplePropertyValue(DeleteUriInfo uriInfo,
                                                     String contentType)
                                              throws ODataException
Description copied from interface: EntitySimplePropertyValueProcessor
Deletes the value of a simple property of an entity.

Specified by:
deleteEntitySimplePropertyValue in interface EntitySimplePropertyValueProcessor
Parameters:
uriInfo - information about the request URI
contentType - the content type of the response
Returns:
a ODataResponse object
Throws:
ODataException
See Also:
EntitySimplePropertyValueProcessor

readEntitySimpleProperty

public ODataResponse readEntitySimpleProperty(GetSimplePropertyUriInfo uriInfo,
                                              String contentType)
                                       throws ODataException
Description copied from interface: EntitySimplePropertyProcessor
Reads a simple property of an entity.

Specified by:
readEntitySimpleProperty in interface EntitySimplePropertyProcessor
contentType - the content type of the response
Returns:
a ODataResponse object
Throws:
ODataException
See Also:
EntitySimplePropertyProcessor

updateEntitySimpleProperty

public ODataResponse updateEntitySimpleProperty(PutMergePatchUriInfo uriInfo,
                                                InputStream content,
                                                String requestContentType,
                                                String contentType)
                                         throws ODataException
Description copied from interface: EntitySimplePropertyProcessor
Updates a simple property of an entity.

Specified by:
updateEntitySimpleProperty in interface EntitySimplePropertyProcessor
Parameters:
uriInfo - information about the request URI
content - the content of the request, containing the updated property data
requestContentType - the content type of the request body
contentType - the content type of the response
Returns:
a ODataResponse object
Throws:
ODataException
See Also:
EntitySimplePropertyProcessor

readEntityMedia

public ODataResponse readEntityMedia(GetMediaResourceUriInfo uriInfo,
                                     String contentType)
                              throws ODataException
Description copied from interface: EntityMediaProcessor
Reads the media resource of an entity.

Specified by:
readEntityMedia in interface EntityMediaProcessor
Parameters:
uriInfo - information about the request URI
contentType - the content type of the response
Returns:
an ODataResponse object
Throws:
ODataException
See Also:
EntityMediaProcessor

updateEntityMedia

public ODataResponse updateEntityMedia(PutMergePatchUriInfo uriInfo,
                                       InputStream content,
                                       String requestContentType,
                                       String contentType)
                                throws ODataException
Description copied from interface: EntityMediaProcessor
Updates the media resource of an entity.

Specified by:
updateEntityMedia in interface EntityMediaProcessor
Parameters:
uriInfo - information about the request URI
content - the content of the request
requestContentType - the content type of the request body
contentType - the content type of the response
Returns:
an ODataResponse object
Throws:
ODataException
See Also:
EntityMediaProcessor

deleteEntityMedia

public ODataResponse deleteEntityMedia(DeleteUriInfo uriInfo,
                                       String contentType)
                                throws ODataException
Description copied from interface: EntityMediaProcessor
Deletes the media resource of an entity.

Specified by:
deleteEntityMedia in interface EntityMediaProcessor
Parameters:
uriInfo - information about the request URI
contentType - the content type of the response
Returns:
an ODataResponse object
Throws:
ODataException
See Also:
EntityMediaProcessor

readEntityLinks

public ODataResponse readEntityLinks(GetEntitySetLinksUriInfo uriInfo,
                                     String contentType)
                              throws ODataException
Description copied from interface: EntityLinksProcessor
Reads the URIs of the target entities of a navigation property.

Specified by:
readEntityLinks in interface EntityLinksProcessor
Parameters:
uriInfo - information about the request URI
contentType - the content type of the response
Returns:
an OData response object
Throws:
ODataException
See Also:
EntityLinksProcessor

countEntityLinks

public ODataResponse countEntityLinks(GetEntitySetLinksCountUriInfo uriInfo,
                                      String contentType)
                               throws ODataException
Description copied from interface: EntityLinksProcessor
Counts the number of target entities of a navigation property.

Specified by:
countEntityLinks in interface EntityLinksProcessor
Parameters:
uriInfo - information about the request URI
contentType - the content type of the response
Returns:
an OData response object
Throws:
ODataException
See Also:
EntityLinksProcessor

createEntityLink

public ODataResponse createEntityLink(PostUriInfo uriInfo,
                                      InputStream content,
                                      String requestContentType,
                                      String contentType)
                               throws ODataException
Description copied from interface: EntityLinksProcessor
Creates a new link to a target entity of a navigation property.

Specified by:
createEntityLink in interface EntityLinksProcessor
Parameters:
uriInfo - information about the request URI
content - the content of the request, containing the link data
requestContentType - the content type of the request body
contentType - the content type of the response
Returns:
an OData response object
Throws:
ODataException
See Also:
EntityLinkProcessor

readEntityLink

public ODataResponse readEntityLink(GetEntityLinkUriInfo uriInfo,
                                    String contentType)
                             throws ODataException
Description copied from interface: EntityLinkProcessor
Reads the URI of the target entity of a navigation property.

Specified by:
readEntityLink in interface EntityLinkProcessor
Parameters:
uriInfo - information about the request URI
contentType - the content type of the response
Returns:
an ODataResponse object
Throws:
ODataException
See Also:
EntityLinkProcessor

existsEntityLink

public ODataResponse existsEntityLink(GetEntityLinkCountUriInfo uriInfo,
                                      String contentType)
                               throws ODataException
Description copied from interface: EntityLinkProcessor
Returns whether the target entity of a navigation property exists.

Specified by:
existsEntityLink in interface EntityLinkProcessor
Parameters:
uriInfo - information about the request URI
contentType - the content type of the response
Returns:
an ODataResponse object
Throws:
ODataException
See Also:
EntityLinkProcessor

updateEntityLink

public ODataResponse updateEntityLink(PutMergePatchUriInfo uriInfo,
                                      InputStream content,
                                      String requestContentType,
                                      String contentType)
                               throws ODataException
Description copied from interface: EntityLinkProcessor
Updates the link to the target entity of a navigation property.

Specified by:
updateEntityLink in interface EntityLinkProcessor
Parameters:
uriInfo - information about the request URI
content - the content of the request, containing the new URI
requestContentType - the content type of the request body
contentType - the content type of the response
Returns:
an ODataResponse object
Throws:
ODataException
See Also:
EntityLinkProcessor

deleteEntityLink

public ODataResponse deleteEntityLink(DeleteUriInfo uriInfo,
                                      String contentType)
                               throws ODataException
Description copied from interface: EntityLinkProcessor
Deletes the link to the target entity of a navigation property.

Specified by:
deleteEntityLink in interface EntityLinkProcessor
Parameters:
uriInfo - information about the request URI
contentType - the content type of the response
Returns:
an ODataResponse object
Throws:
ODataException
See Also:
EntityLinkProcessor

readEntityComplexProperty

public ODataResponse readEntityComplexProperty(GetComplexPropertyUriInfo uriInfo,
                                               String contentType)
                                        throws ODataException
Description copied from interface: EntityComplexPropertyProcessor
Reads a complex property of an entity.

Specified by:
readEntityComplexProperty in interface EntityComplexPropertyProcessor
Parameters:
uriInfo - information about the request URI
contentType - the content type of the response
Returns:
a ODataResponse object
Throws:
ODataException
See Also:
EntityComplexPropertyProcessor

updateEntityComplexProperty

public ODataResponse updateEntityComplexProperty(PutMergePatchUriInfo uriInfo,
                                                 InputStream content,
                                                 String requestContentType,
                                                 boolean merge,
                                                 String contentType)
                                          throws ODataException
Description copied from interface: EntityComplexPropertyProcessor
Updates a complex property of an entity.

Specified by:
updateEntityComplexProperty in interface EntityComplexPropertyProcessor
Parameters:
uriInfo - information about the request URI
content - the content of the request, containing the updated property data
requestContentType - the content type of the request body
merge - if true, properties not present in the data are left unchanged; if false, they are reset
contentType - the content type of the response
Returns:
a ODataResponse object
Throws:
ODataException
See Also:
EntityComplexPropertyProcessor

readEntitySet

public ODataResponse readEntitySet(GetEntitySetUriInfo uriInfo,
                                   String contentType)
                            throws ODataException
Description copied from interface: EntitySetProcessor
Reads entities.

Specified by:
readEntitySet in interface EntitySetProcessor
Parameters:
uriInfo - information about the request URI
contentType - the content type of the response
Returns:
an ODataResponse object
Throws:
ODataException
See Also:
EntitySetProcessor

countEntitySet

public ODataResponse countEntitySet(GetEntitySetCountUriInfo uriInfo,
                                    String contentType)
                             throws ODataException
Description copied from interface: EntitySetProcessor
Counts the number of requested entities.

Specified by:
countEntitySet in interface EntitySetProcessor
Parameters:
uriInfo - information about the request URI
contentType - the content type of the response
Returns:
an ODataResponse object
Throws:
ODataException
See Also:
EntitySetProcessor

createEntity

public ODataResponse createEntity(PostUriInfo uriInfo,
                                  InputStream content,
                                  String requestContentType,
                                  String contentType)
                           throws ODataException
Description copied from interface: EntitySetProcessor
Creates an entity.

Specified by:
createEntity in interface EntitySetProcessor
Parameters:
uriInfo - information about the request URI
content - the content of the request, containing the data of the new entity
requestContentType - the content type of the request body
contentType - the content type of the response
Returns:
an ODataResponse object
Throws:
ODataException
See Also:
EntitySetProcessor

readEntity

public ODataResponse readEntity(GetEntityUriInfo uriInfo,
                                String contentType)
                         throws ODataException
Description copied from interface: EntityProcessor
Reads an entity.

Specified by:
readEntity in interface EntityProcessor
contentType - the content type of the response
Returns:
an ODataResponse object
Throws:
ODataException
See Also:
EntityProcessor

existsEntity

public ODataResponse existsEntity(GetEntityCountUriInfo uriInfo,
                                  String contentType)
                           throws ODataException
Description copied from interface: EntityProcessor
Checks whether an entity exists.

Specified by:
existsEntity in interface EntityProcessor
contentType - the content type of the response
Returns:
an ODataResponse object
Throws:
ODataException
See Also:
EntityProcessor

updateEntity

public ODataResponse updateEntity(PutMergePatchUriInfo uriInfo,
                                  InputStream content,
                                  String requestContentType,
                                  boolean merge,
                                  String contentType)
                           throws ODataException
Description copied from interface: EntityProcessor
Updates an entity.

Specified by:
updateEntity in interface EntityProcessor
Parameters:
uriInfo - information about the request URI
content - the content of the request, containing the updated entity data
requestContentType - the content type of the request body
merge - if true, properties not present in the data are left unchanged; if false, they are reset
contentType - the content type of the response
Returns:
an ODataResponse object
Throws:
ODataException
See Also:
EntityProcessor

deleteEntity

public ODataResponse deleteEntity(DeleteUriInfo uriInfo,
                                  String contentType)
                           throws ODataException
Description copied from interface: EntityProcessor
Deletes an entity.

Specified by:
deleteEntity in interface EntityProcessor
Parameters:
uriInfo - a DeleteUriInfo object with information from the URI parser
contentType - the content type of the response
Returns:
an ODataResponse object
Throws:
ODataException
See Also:
EntityProcessor

readServiceDocument

public ODataResponse readServiceDocument(GetServiceDocumentUriInfo uriInfo,
                                         String contentType)
                                  throws ODataException
Specified by:
readServiceDocument in interface ServiceDocumentProcessor
Returns:
a ODataResponse object
Throws:
ODataException
See Also:
ServiceDocumentProcessor

readMetadata

public ODataResponse readMetadata(GetMetadataUriInfo uriInfo,
                                  String contentType)
                           throws ODataException
Specified by:
readMetadata in interface MetadataProcessor
Returns:
a ODataResponse object
Throws:
ODataException
See Also:
MetadataProcessor

getCustomContentTypes

public List<String> getCustomContentTypes(Class<? extends ODataProcessor> processorFeature)
                                   throws ODataException
Description copied from interface: CustomContentType
The OData library will consider these additional content types during negotiation of http content type header.

Specified by:
getCustomContentTypes in interface CustomContentType
Returns:
a list of additional supported content types in the format "type/sub type"
Throws:
ODataException
See Also:
CustomContentType


Copyright © 2013-2015 The Apache Software Foundation. All Rights Reserved.