Package org.apache.olingo.odata2.core.ep
Class ProviderFacadeImpl
java.lang.Object
org.apache.olingo.odata2.core.ep.ProviderFacadeImpl
- All Implemented Interfaces:
EntityProvider.EntityProviderInterface
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionparseBatchRequest(String contentType, InputStream content, EntityProviderBatchProperties properties) Parse Batch Request bodyinputStream(asInputStream) and provide a list of Batch Parts asBatchPartparseBatchResponse(String contentType, InputStream content) Parse Batch Response body (asInputStream) and provide a list of single responses asBatchSingleResponsebyte[]readBinary(InputStream content) readDeltaFeed(String contentType, EdmEntitySet entitySet, InputStream content, EntityProviderReadProperties properties) Read (de-serialize) a delta data feed fromcontent(asInputStream) in specified format (given ascontentType) based onentity data model(given asEdmEntitySet) and provide this data asODataDeltaFeed.readEntry(String contentType, EdmEntitySet entitySet, InputStream content, EntityProviderReadProperties properties) Reads (de-serializes) data fromcontent(asInputStream) in specified format (given ascontentType) based onentity data model(given asEdmEntitySet) and provides this data asODataEntry.readErrorDocument(InputStream errorDocument, String contentType) Read (de-serialize) data from error document asInputStreamand provide accordingODataErrorContext.readFeed(String contentType, EdmEntitySet entitySet, InputStream content, EntityProviderReadProperties properties) Read (de-serialize) a data feed fromcontent(asInputStream) in specified format (given ascontentType) based onentity data model(given asEdmEntitySet) and provide this data asODataFeed.readFunctionImport(String contentType, EdmFunctionImport functionImport, InputStream content, EntityProviderReadProperties properties) Reads (de-serializes) function-import data fromcontent(asInputStream) in specified format (given ascontentType) based onentity data model(given asEdmFunctionImport) and provide this data asObject.readLink(String contentType, EdmEntitySet entitySet, InputStream content) Read (de-serialize) a link fromcontent(asInputStream) in specified format (given ascontentType) based onentity data model(given asEdmEntitySet) and provide the link asString.readLinks(String contentType, EdmEntitySet entitySet, InputStream content) Read (de-serialize) all links fromcontent(asInputStream) in specified format (given ascontentType) based onentity data model(given asEdmEntitySet) and provide the link as List of Strings.readMetadata(InputStream inputStream, boolean validate) readProperty(String contentType, EdmProperty edmProperty, InputStream content, EntityProviderReadProperties properties) Read (de-serialize) properties fromcontent(asInputStream) in specified format (given ascontentType) based onentity data model(given asEdmProperty) and provide this data asMapwhich contains the read data in form ofproperty nametoproperty valuemapping.readPropertyValue(EdmProperty edmProperty, InputStream content, Class<?> typeMapping) Read (de-serialize) a property value fromcontent(asInputStream) in formattext/plainbased onentity data model(given asEdmProperty) and provide this data asObject.readServiceDocument(InputStream serviceDocument, String contentType) Read (de-serialize) data from service documentinputStream(asInputStream) and provide ServiceDocument asServiceDocumentwriteBatchRequest(List<BatchPart> batchParts, String boundary) Create Batch Request body as InputStream.writeBatchResponse(List<BatchResponsePart> batchResponseParts) Write responses of Batch Response Parts in Batch Response asODataResponse.writeBinary(String mimeType, byte[] data) Write binary content with content type header set to givenmime typeparameter.writeEntry(String contentType, EdmEntitySet entitySet, Map<String, Object> data, EntityProviderWriteProperties properties) Write givendata(which is given in form of aMapfor which contains all properties asproperty nametoproperty valuemapping) for the entry in the specified format (given ascontentType) based onentity data model for an entity set(given asEdmEntitySet) andpropertiesfor this entity provider (given asEntityProviderWriteProperties).writeErrorDocument(ODataErrorContext context) Serializes an error message according to the OData standard.writeFeed(String contentType, EdmEntitySet entitySet, List<Map<String, Object>> data, EntityProviderWriteProperties properties) writeFunctionImport(String contentType, EdmFunctionImport functionImport, Object data, EntityProviderWriteProperties properties) Writedataresult (given asObject) of function import based onreturn typeofEdmFunctionImportin specified format (given ascontentType).writeLink(String contentType, EdmEntitySet entitySet, Map<String, Object> data, EntityProviderWriteProperties properties) Write link for key property based onentity data model for an entity set(given asEdmEntitySet) in the specified format (given ascontentType).writeLinks(String contentType, EdmEntitySet entitySet, List<Map<String, Object>> data, EntityProviderWriteProperties properties) Write all links for key property based onentity data model for an entity set(given asEdmEntitySet) in the specified format (given ascontentType) for a set of entries.Write metadata document in XML format for the given schemas and the provided predefined namespaces at the EDMX element.writeMetadata(DataServices seriviceMetadata, Map<String, String> predefinedNamespaces) Write metadata document in XML format for the given schemas and the provided predefined namespaces at the EDMX element.writeProperty(String contentType, EdmProperty edmProperty, Object value) Write givenvalue(which is given in form of anObject) for the property in the specified format (given ascontentType) based on givenentity data model for an entity property(given asEdmProperty).writePropertyValue(EdmProperty edmProperty, Object value) Write property as content typeapplication/octet-streamortext/plain.writeServiceDocument(String contentType, Edm edm, String serviceRoot) Write service document based on givenEdmandservice rootas given content type.Write text value as content typetext/plain.
-
Constructor Details
-
ProviderFacadeImpl
public ProviderFacadeImpl()
-
-
Method Details
-
writeErrorDocument
Description copied from interface:EntityProvider.EntityProviderInterfaceSerializes an error message according to the OData standard.
- Specified by:
writeErrorDocumentin interfaceEntityProvider.EntityProviderInterface- Parameters:
context- contains error details seeODataErrorContext- Returns:
- an
ODataResponsecontaining the serialized error message
-
writeServiceDocument
public ODataResponse writeServiceDocument(String contentType, Edm edm, String serviceRoot) throws EntityProviderException Description copied from interface:EntityProvider.EntityProviderInterfaceWrite service document based on givenEdmandservice rootas given content type.- Specified by:
writeServiceDocumentin interfaceEntityProvider.EntityProviderInterface- Parameters:
contentType- format in which service document should be writtenedm- entity data model to be writtenserviceRoot- service root for the written service document- Returns:
- resulting
ODataResponsewith written service document content. - Throws:
EntityProviderException- if writing of data (serialization) fails
-
writePropertyValue
public ODataResponse writePropertyValue(EdmProperty edmProperty, Object value) throws EntityProviderException Description copied from interface:EntityProvider.EntityProviderInterfaceWrite property as content typeapplication/octet-streamortext/plain.- Specified by:
writePropertyValuein interfaceEntityProvider.EntityProviderInterface- Parameters:
edmProperty- entity data model for to be written propertyvalue- property which will be written- Returns:
- resulting
ODataResponsewith written property value content. - Throws:
EntityProviderException- if writing of data (serialization) fails
-
writeText
Description copied from interface:EntityProvider.EntityProviderInterfaceWrite text value as content typetext/plain.- Specified by:
writeTextin interfaceEntityProvider.EntityProviderInterface- Parameters:
value- text value which will be written- Returns:
- resulting
ODataResponsewith written text/plain content. - Throws:
EntityProviderException- if writing of data (serialization) fails
-
writeBinary
Description copied from interface:EntityProvider.EntityProviderInterfaceWrite binary content with content type header set to givenmime typeparameter.- Specified by:
writeBinaryin interfaceEntityProvider.EntityProviderInterface- Parameters:
mimeType- mime type which is written and used as content type header information.data- which is written toODataResponse.- Returns:
- response object resulting
ODataResponsewith written binary content. - Throws:
EntityProviderException- if writing of data (serialization) fails
-
writeFeed
public ODataResponse writeFeed(String contentType, EdmEntitySet entitySet, List<Map<String, Object>> data, EntityProviderWriteProperties properties) throws EntityProviderExceptionDescription copied from interface:EntityProvider.EntityProviderInterfaceWrite givendata(which is given in form of aListwith aMapfor each entity. Such aMapcontains all properties [asproperty nametoproperty valuemapping] for the entry) in the specified format (given ascontentType) based on givenentity data model for an entity set(given asEdmEntitySet) andpropertiesfor this entity provider (given asEntityProviderWriteProperties).- Specified by:
writeFeedin interfaceEntityProvider.EntityProviderInterface- Parameters:
contentType- format in which the feed should be writtenentitySet- entity data model for given entity data setdata- set of entries in form of aListwith aMapfor each entity (such aMapcontains all properties [asproperty nametoproperty valuemapping).properties- additional properties necessary for writing of data- Returns:
- resulting
ODataResponsewith written feed content. - Throws:
EntityProviderException- if writing of data (serialization) fails
-
writeEntry
public ODataResponse writeEntry(String contentType, EdmEntitySet entitySet, Map<String, Object> data, EntityProviderWriteProperties properties) throws EntityProviderExceptionDescription copied from interface:EntityProvider.EntityProviderInterfaceWrite givendata(which is given in form of aMapfor which contains all properties asproperty nametoproperty valuemapping) for the entry in the specified format (given ascontentType) based onentity data model for an entity set(given asEdmEntitySet) andpropertiesfor this entity provider (given asEntityProviderWriteProperties).- Specified by:
writeEntryin interfaceEntityProvider.EntityProviderInterface- Parameters:
contentType- format in which the entry should be writtenentitySet- entity data model for given entity data setdata- which contains all properties asproperty nametoproperty valuemapping for the entryproperties- additional properties necessary for writing of data- Returns:
- resulting
ODataResponsewith written entry content - Throws:
EntityProviderException- if writing of data (serialization) fails
-
writeProperty
public ODataResponse writeProperty(String contentType, EdmProperty edmProperty, Object value) throws EntityProviderException Description copied from interface:EntityProvider.EntityProviderInterfaceWrite givenvalue(which is given in form of anObject) for the property in the specified format (given ascontentType) based on givenentity data model for an entity property(given asEdmProperty).- Specified by:
writePropertyin interfaceEntityProvider.EntityProviderInterface- Parameters:
contentType- format in which the property should be writtenedmProperty- entity data model for given propertyvalue- data which is written- Returns:
- resulting
ODataResponsewith written property content. - Throws:
EntityProviderException- if writing of data (serialization) fails
-
writeLink
public ODataResponse writeLink(String contentType, EdmEntitySet entitySet, Map<String, Object> data, EntityProviderWriteProperties properties) throws EntityProviderExceptionDescription copied from interface:EntityProvider.EntityProviderInterfaceWrite link for key property based onentity data model for an entity set(given asEdmEntitySet) in the specified format (given ascontentType). The necessary key property values must be provided within thedata(in the form ofproperty nametoproperty valuemapping) andpropertiesfor this entity provider must be set (given asEntityProviderWriteProperties).- Specified by:
writeLinkin interfaceEntityProvider.EntityProviderInterface- Parameters:
contentType- format in which the entry should be writtenentitySet- entity data model for given entity data setdata- which contains all key properties asproperty nametoproperty valuemapping for the entryproperties- additional properties necessary for writing of data- Returns:
- resulting
ODataResponsewith written link content. - Throws:
EntityProviderException- if writing of data (serialization) fails
-
writeLinks
public ODataResponse writeLinks(String contentType, EdmEntitySet entitySet, List<Map<String, Object>> data, EntityProviderWriteProperties properties) throws EntityProviderExceptionDescription copied from interface:EntityProvider.EntityProviderInterfaceWrite all links for key property based onentity data model for an entity set(given asEdmEntitySet) in the specified format (given ascontentType) for a set of entries. The necessary key property values must be provided within thedata(in form of aListwith aMapfor each entry. Such aMapcontains all key properties [asproperty nametoproperty valuemapping] for the entry) andpropertiesfor this entity provider must be set (given asEntityProviderWriteProperties).- Specified by:
writeLinksin interfaceEntityProvider.EntityProviderInterface- Parameters:
contentType- format in which the entry should be writtenentitySet- entity data model for given entity data setdata- set of entries in form of aListwith aMapfor each entry (such aMapcontains all key properties [asproperty nametoproperty valuemapping).properties- additional properties necessary for writing of data- Returns:
- resulting
ODataResponsewith written links content. - Throws:
EntityProviderException- if writing of data (serialization) fails
-
writeFunctionImport
public ODataResponse writeFunctionImport(String contentType, EdmFunctionImport functionImport, Object data, EntityProviderWriteProperties properties) throws EntityProviderException Description copied from interface:EntityProvider.EntityProviderInterfaceWritedataresult (given asObject) of function import based onreturn typeofEdmFunctionImportin specified format (given ascontentType). Additionalpropertiesfor this entity provider must be set (given asEntityProviderWriteProperties).- Specified by:
writeFunctionImportin interfaceEntityProvider.EntityProviderInterface- Parameters:
contentType- format in which the entry should be writtenfunctionImport- entity data model for executed function importdata- result of function importproperties- additional properties necessary for writing of data- Returns:
- resulting
ODataResponsewith written function import result content. - Throws:
EntityProviderException- if writing of data (serialization) fails
-
readErrorDocument
public ODataErrorContext readErrorDocument(InputStream errorDocument, String contentType) throws EntityProviderException Description copied from interface:EntityProvider.EntityProviderInterfaceRead (de-serialize) data from error document asInputStreamand provide accordingODataErrorContext.- Specified by:
readErrorDocumentin interfaceEntityProvider.EntityProviderInterface- Parameters:
errorDocument- error document which is readcontentType- format of content in the given input stream- Returns:
- read error document
- Throws:
EntityProviderException- if reading of data (de-serialization) fails
-
readFeed
public ODataFeed readFeed(String contentType, EdmEntitySet entitySet, InputStream content, EntityProviderReadProperties properties) throws EntityProviderException Description copied from interface:EntityProvider.EntityProviderInterfaceRead (de-serialize) a data feed fromcontent(asInputStream) in specified format (given ascontentType) based onentity data model(given asEdmEntitySet) and provide this data asODataFeed.- Specified by:
readFeedin interfaceEntityProvider.EntityProviderInterface- Parameters:
contentType- format of content in the given input stream.entitySet- entity data model for entity set to be readcontent- feed data in form of anInputStreamwhich contains the data in specified formatproperties- additional properties necessary for reading content fromInputStreamintoMap.- Returns:
- an
ODataFeedobject - Throws:
EntityProviderException- if reading of data (de-serialization) fails
-
readDeltaFeed
public ODataDeltaFeed readDeltaFeed(String contentType, EdmEntitySet entitySet, InputStream content, EntityProviderReadProperties properties) throws EntityProviderException Description copied from interface:EntityProvider.EntityProviderInterfaceRead (de-serialize) a delta data feed fromcontent(asInputStream) in specified format (given ascontentType) based onentity data model(given asEdmEntitySet) and provide this data asODataDeltaFeed.- Specified by:
readDeltaFeedin interfaceEntityProvider.EntityProviderInterface- Parameters:
contentType- format of content in the given input stream.entitySet- entity data model for entity set to be readcontent- delta feed data in form of anInputStreamwhich contains the data in specified formatproperties- additional properties necessary for reading content fromInputStreamintoMap.- Returns:
- an
ODataDeltaFeedobject - Throws:
EntityProviderException- if reading of data (de-serialization) fails
-
readEntry
public ODataEntry readEntry(String contentType, EdmEntitySet entitySet, InputStream content, EntityProviderReadProperties properties) throws EntityProviderException Description copied from interface:EntityProvider.EntityProviderInterfaceReads (de-serializes) data fromcontent(asInputStream) in specified format (given ascontentType) based onentity data model(given asEdmEntitySet) and provides this data asODataEntry. Does not return complete entry data but only data present in the de-serialized content.- Specified by:
readEntryin interfaceEntityProvider.EntityProviderInterface- Parameters:
contentType- format of content in the given input streamentitySet- entity data model for entity set to be readcontent- data in form of anInputStreamwhich contains the data in specified formatproperties- additional properties necessary for reading content fromInputStreamintoMap.- Returns:
- entry as
ODataEntry - Throws:
EntityProviderException- if reading of data (de-serialization) fails
-
readProperty
public Map<String,Object> readProperty(String contentType, EdmProperty edmProperty, InputStream content, EntityProviderReadProperties properties) throws EntityProviderException Description copied from interface:EntityProvider.EntityProviderInterfaceRead (de-serialize) properties fromcontent(asInputStream) in specified format (given ascontentType) based onentity data model(given asEdmProperty) and provide this data asMapwhich contains the read data in form ofproperty nametoproperty valuemapping.- Specified by:
readPropertyin interfaceEntityProvider.EntityProviderInterface- Parameters:
contentType- format of content in the given input stream.edmProperty- entity data model for entity property to be readcontent- data in form of anInputStreamwhich contains the data in specified formatproperties- additional properties necessary for reading content fromInputStreamintoMap.- Returns:
- property as name and value in a map
- Throws:
EntityProviderException- if reading of data (de-serialization) fails
-
readPropertyValue
public Object readPropertyValue(EdmProperty edmProperty, InputStream content, Class<?> typeMapping) throws EntityProviderException Description copied from interface:EntityProvider.EntityProviderInterfaceRead (de-serialize) a property value fromcontent(asInputStream) in formattext/plainbased onentity data model(given asEdmProperty) and provide this data asObject.- Specified by:
readPropertyValuein interfaceEntityProvider.EntityProviderInterface- Parameters:
edmProperty- entity data model for entity property to be readcontent- data in form of anInputStreamwhich contains the data in formattext/plaintypeMapping- defines the mapping for thisedm propertyto ajava classwhich should be used during read of the content. If accordingedm propertycan not be read into givenjava classanEntityProviderExceptionis thrown. Supported mappings are documented inEdmSimpleType.- Returns:
- property value as object
- Throws:
EntityProviderException- if reading of data (de-serialization) fails
-
readFunctionImport
public Object readFunctionImport(String contentType, EdmFunctionImport functionImport, InputStream content, EntityProviderReadProperties properties) throws EntityProviderException Description copied from interface:EntityProvider.EntityProviderInterfaceReads (de-serializes) function-import data fromcontent(asInputStream) in specified format (given ascontentType) based onentity data model(given asEdmFunctionImport) and provide this data asObject.- Specified by:
readFunctionImportin interfaceEntityProvider.EntityProviderInterface- Parameters:
contentType- format of content in the given input stream.functionImport- entity data model for Function Import to be readcontent- data in form of anInputStreamwhich contains the data in specified formatproperties- additional properties necessary for reading content fromInputStreamintoMap. Must not be null.- Returns:
- data as
Object - Throws:
EntityProviderException- if reading of data (de-serialization) fails
-
readLinks
public List<String> readLinks(String contentType, EdmEntitySet entitySet, InputStream content) throws EntityProviderException Description copied from interface:EntityProvider.EntityProviderInterfaceRead (de-serialize) all links fromcontent(asInputStream) in specified format (given ascontentType) based onentity data model(given asEdmEntitySet) and provide the link as List of Strings.- Specified by:
readLinksin interfaceEntityProvider.EntityProviderInterface- Parameters:
contentType- format of content in the given input stream.entitySet- entity data model for entity property to be readcontent- data in form of anInputStreamwhich contains the data in specified format- Returns:
- links as List of Strings
- Throws:
EntityProviderException- if reading of data (de-serialization) fails
-
readLink
public String readLink(String contentType, EdmEntitySet entitySet, InputStream content) throws EntityProviderException Description copied from interface:EntityProvider.EntityProviderInterfaceRead (de-serialize) a link fromcontent(asInputStream) in specified format (given ascontentType) based onentity data model(given asEdmEntitySet) and provide the link asString.- Specified by:
readLinkin interfaceEntityProvider.EntityProviderInterface- Parameters:
contentType- format of content in the given input stream.entitySet- entity data model for entity property to be readcontent- data in form of anInputStreamwhich contains the data in specified format- Returns:
- link as string
- Throws:
EntityProviderException- if reading of data (de-serialization) fails
-
readBinary
Description copied from interface:EntityProvider.EntityProviderInterface- Specified by:
readBinaryin interfaceEntityProvider.EntityProviderInterface- Parameters:
content- data in form of anInputStreamwhich contains the binary data- Returns:
- binary data as bytes
- Throws:
EntityProviderException- if reading of data (de-serialization) fails
-
writeMetadata
public ODataResponse writeMetadata(List<Schema> schemas, Map<String, String> predefinedNamespaces) throws EntityProviderExceptionDescription copied from interface:EntityProvider.EntityProviderInterfaceWrite metadata document in XML format for the given schemas and the provided predefined namespaces at the EDMX element. PredefinedNamespaces is of type Map<prefix,namespace> and may be null or an empty Map.- Specified by:
writeMetadatain interfaceEntityProvider.EntityProviderInterface- Parameters:
schemas- all XML schemas which will be writtenpredefinedNamespaces- type of Map<prefix,namespace> and may be null or an empty Map- Returns:
- resulting
ODataResponsewith written metadata content. - Throws:
EntityProviderException- if writing of data (serialization) fails
-
writeMetadata
public ODataResponse writeMetadata(DataServices seriviceMetadata, Map<String, String> predefinedNamespaces) throws EntityProviderExceptionDescription copied from interface:EntityProvider.EntityProviderInterfaceWrite metadata document in XML format for the given schemas and the provided predefined namespaces at the EDMX element. PredefinedNamespaces is of type Map<prefix,namespace> and may be null or an empty Map. Important This method takes edmx references into account This method will not calculate the DataServiceVersion but will instead take the version provided via the signature if no version is set the default version 2.0 is used.- Specified by:
writeMetadatain interfaceEntityProvider.EntityProviderInterfacepredefinedNamespaces- type of Map<prefix,namespace> and may be null or an empty Map- Returns:
- resulting
ODataResponsewith written metadata content. - Throws:
EntityProviderException- if writing of data (serialization) fails
-
readMetadata
Description copied from interface:EntityProvider.EntityProviderInterface- Specified by:
readMetadatain interfaceEntityProvider.EntityProviderInterface- Parameters:
inputStream- the given input streamvalidate- has to be true if metadata should be validated- Returns:
- Edm as
Edm - Throws:
EntityProviderException- if reading of data (de-serialization) fails
-
readServiceDocument
public ServiceDocument readServiceDocument(InputStream serviceDocument, String contentType) throws EntityProviderException Description copied from interface:EntityProvider.EntityProviderInterfaceRead (de-serialize) data from service documentinputStream(asInputStream) and provide ServiceDocument asServiceDocument- Specified by:
readServiceDocumentin interfaceEntityProvider.EntityProviderInterface- Parameters:
serviceDocument- the given input streamcontentType- format of content in the given input stream- Returns:
- ServiceDocument as
ServiceDocument - Throws:
EntityProviderException- if reading of data (de-serialization) fails
-
parseBatchRequest
public List<BatchRequestPart> parseBatchRequest(String contentType, InputStream content, EntityProviderBatchProperties properties) throws BatchException Description copied from interface:EntityProvider.EntityProviderInterfaceParse Batch Request bodyinputStream(asInputStream) and provide a list of Batch Parts asBatchPart- Specified by:
parseBatchRequestin interfaceEntityProvider.EntityProviderInterface- Parameters:
contentType- format of content in the given input streamcontent- request bodyproperties- additional properties necessary for parsing. Must not be null.- Returns:
- list of
BatchPart - Throws:
BatchException- if parsing fails
-
writeBatchResponse
public ODataResponse writeBatchResponse(List<BatchResponsePart> batchResponseParts) throws BatchException Description copied from interface:EntityProvider.EntityProviderInterfaceWrite responses of Batch Response Parts in Batch Response asODataResponse. Batch Response body matches one-to-one with the corresponding Batch Request body- Specified by:
writeBatchResponsein interfaceEntityProvider.EntityProviderInterface- Parameters:
batchResponseParts- a list ofBatchResponsePart- Returns:
- Batch Response as
ODataResponse - Throws:
BatchException
-
writeBatchRequest
Description copied from interface:EntityProvider.EntityProviderInterfaceCreate Batch Request body as InputStream.- Specified by:
writeBatchRequestin interfaceEntityProvider.EntityProviderInterface- Parameters:
batchParts- a list of BatchPartRequestsBatchPart- Returns:
- Batch Request as InputStream
-
parseBatchResponse
public List<BatchSingleResponse> parseBatchResponse(String contentType, InputStream content) throws BatchException Description copied from interface:EntityProvider.EntityProviderInterfaceParse Batch Response body (asInputStream) and provide a list of single responses asBatchSingleResponse- Specified by:
parseBatchResponsein interfaceEntityProvider.EntityProviderInterface- Parameters:
contentType- format of content in the given input stream (incl. boundary parameter)content- response body- Returns:
- list of
BatchSingleResponse - Throws:
BatchException
-