Package org.apache.olingo.odata2.api.ep
Interface EntityProvider.EntityProviderInterface
-
- Enclosing class:
- EntityProvider
public static interface EntityProvider.EntityProviderInterface(Internal) interface for allEntityProvidernecessary read and write methods for accessing entities defined in anEntity Data Model.This interface is declared as inner interface (class) because the
EntityProviderprovides a convenience access (and basic implementation for XML and JSON format) to all interface methods.
Hence, it is not recommended to implement this interface (it is possible to implement it and to provide an ownEntityProviderfor support of additional formats but it is recommended to handle additional formats directly within anODataProcessor).
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description List<BatchRequestPart>parseBatchRequest(String contentType, InputStream content, EntityProviderBatchProperties properties)Parse Batch Request bodyinputStream(asInputStream) and provide a list of Batch Parts asBatchPartList<BatchSingleResponse>parseBatchResponse(String contentType, InputStream content)Parse Batch Response body (asInputStream) and provide a list of single responses asBatchSingleResponsebyte[]readBinary(InputStream content)ODataDeltaFeedreadDeltaFeed(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.ODataEntryreadEntry(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.ODataErrorContextreadErrorDocument(InputStream errorDocument, String contentType)Read (de-serialize) data from error document asInputStreamand provide accordingODataErrorContext.ODataFeedreadFeed(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.ObjectreadFunctionImport(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.StringreadLink(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.List<String>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.EdmreadMetadata(InputStream inputStream, boolean validate)Map<String,Object>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.ObjectreadPropertyValue(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.ServiceDocumentreadServiceDocument(InputStream serviceDocument, String contentType)Read (de-serialize) data from service documentinputStream(asInputStream) and provide ServiceDocument asServiceDocumentInputStreamwriteBatchRequest(List<BatchPart> batchParts, String boundary)Create Batch Request body as InputStream.ODataResponsewriteBatchResponse(List<BatchResponsePart> batchResponseParts)Write responses of Batch Response Parts in Batch Response asODataResponse.ODataResponsewriteBinary(String mimeType, byte[] data)Write binary content with content type header set to givenmime typeparameter.ODataResponsewriteEntry(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).ODataResponsewriteErrorDocument(ODataErrorContext context)Serializes an error message according to the OData standard.ODataResponsewriteFeed(String contentType, EdmEntitySet entitySet, List<Map<String,Object>> data, EntityProviderWriteProperties properties)ODataResponsewriteFunctionImport(String contentType, EdmFunctionImport functionImport, Object data, EntityProviderWriteProperties properties)Writedataresult (given asObject) of function import based onreturn typeofEdmFunctionImportin specified format (given ascontentType).ODataResponsewriteLink(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).ODataResponsewriteLinks(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.ODataResponsewriteMetadata(List<Schema> schemas, Map<String,String> predefinedNamespaces)Write metadata document in XML format for the given schemas and the provided predefined namespaces at the EDMX element.ODataResponsewriteMetadata(DataServices serviceMetadata, Map<String,String> predefinedNamespaces)Write metadata document in XML format for the given schemas and the provided predefined namespaces at the EDMX element.ODataResponsewriteProperty(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).ODataResponsewritePropertyValue(EdmProperty edmProperty, Object value)Write property as content typeapplication/octet-streamortext/plain.ODataResponsewriteServiceDocument(String contentType, Edm edm, String serviceRoot)Write service document based on givenEdmandservice rootas given content type.ODataResponsewriteText(String value)Write text value as content typetext/plain.
-
-
-
Method Detail
-
writeMetadata
ODataResponse writeMetadata(List<Schema> schemas, Map<String,String> predefinedNamespaces) throws EntityProviderException
Write 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.- 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
ODataResponse writeMetadata(DataServices serviceMetadata, Map<String,String> predefinedNamespaces) throws EntityProviderException
Write 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.- Parameters:
serviceMetadata- MetadatapredefinedNamespaces- 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
-
writeServiceDocument
ODataResponse writeServiceDocument(String contentType, Edm edm, String serviceRoot) throws EntityProviderException
Write service document based on givenEdmandservice rootas given content type.- 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
ODataResponse writePropertyValue(EdmProperty edmProperty, Object value) throws EntityProviderException
Write property as content typeapplication/octet-streamortext/plain.- 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
ODataResponse writeText(String value) throws EntityProviderException
Write text value as content typetext/plain.- Parameters:
value- text value which will be written- Returns:
- resulting
ODataResponsewith written text/plain content. - Throws:
EntityProviderException- if writing of data (serialization) fails
-
writeBinary
ODataResponse writeBinary(String mimeType, byte[] data) throws EntityProviderException
Write binary content with content type header set to givenmime typeparameter.- 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
ODataResponse writeFeed(String contentType, EdmEntitySet entitySet, List<Map<String,Object>> data, EntityProviderWriteProperties properties) throws EntityProviderException
Write 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).- 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
ODataResponse writeEntry(String contentType, EdmEntitySet entitySet, Map<String,Object> data, EntityProviderWriteProperties properties) throws EntityProviderException
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).- 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
ODataResponse writeProperty(String contentType, EdmProperty edmProperty, Object value) throws EntityProviderException
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).- 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
ODataResponse writeLink(String contentType, EdmEntitySet entitySet, Map<String,Object> data, EntityProviderWriteProperties properties) throws EntityProviderException
Write 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).- 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
ODataResponse writeLinks(String contentType, EdmEntitySet entitySet, List<Map<String,Object>> data, EntityProviderWriteProperties properties) throws EntityProviderException
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. 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).- 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
ODataResponse writeFunctionImport(String contentType, EdmFunctionImport functionImport, Object data, EntityProviderWriteProperties properties) throws EntityProviderException
Writedataresult (given asObject) of function import based onreturn typeofEdmFunctionImportin specified format (given ascontentType). Additionalpropertiesfor this entity provider must be set (given asEntityProviderWriteProperties).- 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
-
readFeed
ODataFeed readFeed(String contentType, EdmEntitySet entitySet, InputStream content, EntityProviderReadProperties properties) throws EntityProviderException
Read (de-serialize) a data feed fromcontent(asInputStream) in specified format (given ascontentType) based onentity data model(given asEdmEntitySet) and provide this data asODataFeed.- 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
ODataDeltaFeed readDeltaFeed(String contentType, EdmEntitySet entitySet, InputStream content, EntityProviderReadProperties properties) throws EntityProviderException
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.- 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
ODataEntry readEntry(String contentType, EdmEntitySet entitySet, InputStream content, EntityProviderReadProperties properties) throws EntityProviderException
Reads (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.- 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
Map<String,Object> readProperty(String contentType, EdmProperty edmProperty, InputStream content, EntityProviderReadProperties properties) throws EntityProviderException
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.- 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
Object readPropertyValue(EdmProperty edmProperty, InputStream content, Class<?> typeMapping) throws EntityProviderException
Read (de-serialize) a property value fromcontent(asInputStream) in formattext/plainbased onentity data model(given asEdmProperty) and provide this data asObject.- 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
Object readFunctionImport(String contentType, EdmFunctionImport functionImport, InputStream content, EntityProviderReadProperties properties) throws EntityProviderException
Reads (de-serializes) function-import data fromcontent(asInputStream) in specified format (given ascontentType) based onentity data model(given asEdmFunctionImport) and provide this data asObject.- 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
-
readLink
String readLink(String contentType, EdmEntitySet entitySet, InputStream content) throws EntityProviderException
Read (de-serialize) a link fromcontent(asInputStream) in specified format (given ascontentType) based onentity data model(given asEdmEntitySet) and provide the link asString.- 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
-
readLinks
List<String> readLinks(String contentType, EdmEntitySet entitySet, InputStream content) throws EntityProviderException
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.- 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
-
readMetadata
Edm readMetadata(InputStream inputStream, boolean validate) throws EntityProviderException
- 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
-
readBinary
byte[] readBinary(InputStream content) throws EntityProviderException
- 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
-
writeErrorDocument
ODataResponse writeErrorDocument(ODataErrorContext context)
Serializes an error message according to the OData standard.
- Parameters:
context- contains error details seeODataErrorContext- Returns:
- an
ODataResponsecontaining the serialized error message
-
readServiceDocument
ServiceDocument readServiceDocument(InputStream serviceDocument, String contentType) throws EntityProviderException
Read (de-serialize) data from service documentinputStream(asInputStream) and provide ServiceDocument asServiceDocument- 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
List<BatchRequestPart> parseBatchRequest(String contentType, InputStream content, EntityProviderBatchProperties properties) throws BatchException
Parse Batch Request bodyinputStream(asInputStream) and provide a list of Batch Parts asBatchPart- 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
ODataResponse writeBatchResponse(List<BatchResponsePart> batchResponseParts) throws BatchException
Write responses of Batch Response Parts in Batch Response asODataResponse. Batch Response body matches one-to-one with the corresponding Batch Request body- Parameters:
batchResponseParts- a list ofBatchResponsePart- Returns:
- Batch Response as
ODataResponse - Throws:
BatchException- Caso ocorra exceção
-
writeBatchRequest
InputStream writeBatchRequest(List<BatchPart> batchParts, String boundary)
Create Batch Request body as InputStream.- Parameters:
batchParts- a list of BatchPartRequestsBatchPartboundary- Boundary- Returns:
- Batch Request as InputStream
-
parseBatchResponse
List<BatchSingleResponse> parseBatchResponse(String contentType, InputStream content) throws BatchException
Parse Batch Response body (asInputStream) and provide a list of single responses asBatchSingleResponse- Parameters:
content- response bodycontentType- format of content in the given input stream (incl. boundary parameter)- Returns:
- list of
BatchSingleResponse - Throws:
BatchException- Caso ocorra exceção
-
readErrorDocument
ODataErrorContext readErrorDocument(InputStream errorDocument, String contentType) throws EntityProviderException
Read (de-serialize) data from error document asInputStreamand provide accordingODataErrorContext.- 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
-
-