|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.olingo.odata2.api.ep.EntityProvider
public final class EntityProvider
Entity Provider
An EntityProvider provides all necessary read and write
methods for accessing the entities defined in an Entity Data Model.
Therefore this library provides (in its core packages) as convenience
basic entity providers for accessing entities in the XML and JSON
formats.
| Nested Class Summary | |
|---|---|
static interface |
EntityProvider.EntityProviderInterface
(Internal) interface for all EntityProvider necessary read and write methods for accessing
entities defined in an Entity Data Model. |
| Constructor Summary | |
|---|---|
EntityProvider()
|
|
| Method Summary | |
|---|---|
static List<BatchRequestPart> |
parseBatchRequest(String contentType,
InputStream content,
EntityProviderBatchProperties properties)
Parse Batch Request body inputStream (as InputStream) and provide a list of Batch Request
parts as BatchRequestPart |
static List<BatchSingleResponse> |
parseBatchResponse(InputStream content,
String contentType)
Parse Batch Response body (as InputStream) and provide a list of single responses as
BatchSingleResponse |
static byte[] |
readBinary(InputStream content)
Read (de-serialize) binary data from content (as InputStream) and provide it as
byte[]. |
static ODataDeltaFeed |
readDeltaFeed(String contentType,
EdmEntitySet entitySet,
InputStream content,
EntityProviderReadProperties properties)
Read (de-serialize) a delta data feed from content (as InputStream) in specified format
(given as contentType) based on entity data model (given as EdmEntitySet) and
provide this data as ODataEntry . |
static ODataEntry |
readEntry(String contentType,
EdmEntitySet entitySet,
InputStream content,
EntityProviderReadProperties properties)
Read (de-serialize) data from content (as InputStream) in specified format (given as
contentType)
based on entity data model (given as EdmEntitySet) and provide this data as ODataEntry
. |
static ODataErrorContext |
readErrorDocument(InputStream errorDocument,
String contentType)
Read (de-serialize) data from error document as InputStream and provide according ODataErrorContext
. |
static ODataFeed |
readFeed(String contentType,
EdmEntitySet entitySet,
InputStream content,
EntityProviderReadProperties properties)
Read (de-serialize) a data feed from content (as InputStream) in specified format (given as
contentType)
based on entity data model (given as EdmEntitySet) and provide this data as ODataEntry
. |
static Object |
readFunctionImport(String contentType,
EdmFunctionImport functionImport,
InputStream content,
EntityProviderReadProperties properties)
Reads (de-serializes) function-import data from content (as InputStream) in specified format
(given as contentType) based on entity data model (given as EdmFunctionImport)
and provide this data as Object. |
static String |
readLink(String contentType,
EdmEntitySet entitySet,
InputStream content)
Read (de-serialize) a link from content (as InputStream) in specified format (given as
contentType)
based on entity data model (given as EdmEntitySet) and provide the link as String. |
static List<String> |
readLinks(String contentType,
EdmEntitySet entitySet,
InputStream content)
Read (de-serialize) a link collection from content (as InputStream)
in specified format (given as contentType) based on entity data model
(given as EdmEntitySet) and provide the links as List of Strings. |
static Edm |
readMetadata(InputStream metadataXml,
boolean validate)
Read (de-serialize) data from metadata inputStream (as InputStream) and provide Edm as
Edm |
static Map<String,Object> |
readProperty(String contentType,
EdmProperty edmProperty,
InputStream content,
EntityProviderReadProperties properties)
Read (de-serialize) properties from content (as InputStream) in specified format (given as
contentType)
based on entity data model (given as EdmProperty) and provide this data as Map which
contains
the read data in form of property name to property value mapping. |
static Object |
readPropertyValue(EdmProperty edmProperty,
InputStream content)
Read (de-serialize) a property value from content (as InputStream) in format
text/plain
based on entity data model (given as EdmProperty) and provide this data as Object. |
static Object |
readPropertyValue(EdmProperty edmProperty,
InputStream content,
Class<?> typeMapping)
Read (de-serialize) a property value from content (as InputStream) in format
text/plain
based on entity data model (given as EdmProperty) and provide this data as Object. |
static ServiceDocument |
readServiceDocument(InputStream serviceDocument,
String contentType)
Read (de-serialize) data from service document inputStream (as InputStream) and provide
ServiceDocument as ServiceDocument |
static InputStream |
writeBatchRequest(List<BatchPart> batchParts,
String boundary)
Create Batch Request body as InputStream. |
static ODataResponse |
writeBatchResponse(List<BatchResponsePart> batchResponseParts)
Write responses of Batch Response Parts in Batch Response as ODataResponse. |
static ODataResponse |
writeBinary(String mimeType,
byte[] data)
Write binary content with content type header set to given mime type parameter. |
static ODataResponse |
writeEntry(String contentType,
EdmEntitySet entitySet,
Map<String,Object> data,
EntityProviderWriteProperties properties)
Write given data (which is given in form of a Map for which contains all properties
as property name to property value mapping) for the entry in the specified
format (given as contentType) based on entity data model for an entity set (given as
EdmEntitySet)
and properties for this entity provider (given as EntityProviderWriteProperties). |
static ODataResponse |
writeErrorDocument(ODataErrorContext context)
Serializes an error message according to the OData standard. |
static ODataResponse |
writeFeed(String contentType,
EdmEntitySet entitySet,
List<Map<String,Object>> data,
EntityProviderWriteProperties properties)
Write given data (which is given in form of a List with a Map for each entity. |
static ODataResponse |
writeFunctionImport(String contentType,
EdmFunctionImport functionImport,
Object data,
EntityProviderWriteProperties properties)
Write data result (given as Object) of function import based on return type
of EdmFunctionImport in specified format (given as contentType). |
static ODataResponse |
writeLink(String contentType,
EdmEntitySet entitySet,
Map<String,Object> data,
EntityProviderWriteProperties properties)
Write link for key property based on entity data model for an entity set (given as
EdmEntitySet)
in the specified format (given as contentType). |
static ODataResponse |
writeLinks(String contentType,
EdmEntitySet entitySet,
List<Map<String,Object>> data,
EntityProviderWriteProperties properties)
Write all links for key property based on entity data model for an entity set (given as
EdmEntitySet)
in the specified format (given as contentType) for a set of entries. |
static ODataResponse |
writeMetadata(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. |
static ODataResponse |
writeProperty(String contentType,
EdmProperty edmProperty,
Object value)
Write given value (which is given in form of an Object) for the property in the specified
format (given as contentType) based on given entity data model for an entity property
(given as EdmProperty). |
static ODataResponse |
writePropertyValue(EdmProperty edmProperty,
Object value)
Write property as content type application/octet-stream or text/plain. |
static ODataResponse |
writeServiceDocument(String contentType,
Edm edm,
String serviceRoot)
Write service document based on given Edm and service root as
given content type. |
static ODataResponse |
writeText(String value)
Write text value as content type text/plain. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public EntityProvider()
| Method Detail |
|---|
public static ODataResponse writeErrorDocument(ODataErrorContext context)
Serializes an error message according to the OData standard.
An exception is not thrown because this method is used in exception handling.
context - contains error details see ODataErrorContext
ODataResponse containing the serialized error message
public static ODataResponse writeMetadata(List<Schema> schemas,
Map<String,String> predefinedNamespaces)
throws EntityProviderException
schemas - all XML schemas which will be writtenpredefinedNamespaces - type of Map<prefix,namespace> and may be null or an empty Map
ODataResponse with written metadata content.
EntityProviderException - if writing of data (serialization) fails
public static ODataResponse writeServiceDocument(String contentType,
Edm edm,
String serviceRoot)
throws EntityProviderException
Edm and service root as
given content type.
contentType - format in which service document should be writtenedm - entity data model to be writtenserviceRoot - service root for the written service document
ODataResponse with written service document content.
EntityProviderException - if writing of data (serialization) fails
public static ODataResponse writePropertyValue(EdmProperty edmProperty,
Object value)
throws EntityProviderException
application/octet-stream or text/plain.
edmProperty - entity data model for to be written propertyvalue - property which will be written
ODataResponse with written property value content.
EntityProviderException - if writing of data (serialization) fails
public static ODataResponse writeText(String value)
throws EntityProviderException
text/plain.
value - text value which will be written
ODataResponse with written text/plain content.
EntityProviderException - if writing of data (serialization) fails
public static ODataResponse writeBinary(String mimeType,
byte[] data)
throws EntityProviderException
mime type parameter.
mimeType - mime type which is written and used as content type header information.data - which is written to ODataResponse.
ODataResponse with written binary content.
EntityProviderException - if writing of data (serialization) fails
public static ODataResponse writeFeed(String contentType,
EdmEntitySet entitySet,
List<Map<String,Object>> data,
EntityProviderWriteProperties properties)
throws EntityProviderException
data (which is given in form of a List with a Map for each entity. Such a
Map contains all properties [as property name to property value mapping] for the
entry) in the specified
format (given as contentType) based on given entity data model for an entity set (given
as EdmEntitySet)
and properties for this entity provider (given as EntityProviderWriteProperties).
contentType - format in which the feed should be writtenentitySet - entity data model for given entity data setdata - set of entries in form of a List with a Map for each entity (such a Map
contains all properties [as property name to property value mapping).properties - additional properties necessary for writing of data
ODataResponse with written feed content.
EntityProviderException - if writing of data (serialization) fails
public static ODataResponse writeEntry(String contentType,
EdmEntitySet entitySet,
Map<String,Object> data,
EntityProviderWriteProperties properties)
throws EntityProviderException
data (which is given in form of a Map for which contains all properties
as property name to property value mapping) for the entry in the specified
format (given as contentType) based on entity data model for an entity set (given as
EdmEntitySet)
and properties for this entity provider (given as EntityProviderWriteProperties).
contentType - format in which the entry should be writtenentitySet - entity data model for given entity data setdata - which contains all properties as property name to property value mapping for
the entryproperties - additional properties necessary for writing of data
ODataResponse with written entry content
EntityProviderException - if writing of data (serialization) fails
public static ODataResponse writeProperty(String contentType,
EdmProperty edmProperty,
Object value)
throws EntityProviderException
value (which is given in form of an Object) for the property in the specified
format (given as contentType) based on given entity data model for an entity property
(given as EdmProperty).
contentType - format in which the property should be writtenedmProperty - entity data model for given propertyvalue - data which is written
ODataResponse with written property content.
EntityProviderException - if writing of data (serialization) fails
public static ODataResponse writeLink(String contentType,
EdmEntitySet entitySet,
Map<String,Object> data,
EntityProviderWriteProperties properties)
throws EntityProviderException
entity data model for an entity set (given as
EdmEntitySet)
in the specified format (given as contentType).
The necessary key property values must be provided within the data (in the form of property
name
to property value mapping) and properties for this entity provider must be set
(given as EntityProviderWriteProperties).
contentType - format in which the entry should be writtenentitySet - entity data model for given entity data setdata - which contains all key properties as property name to property value mapping
for the entryproperties - additional properties necessary for writing of data
ODataResponse with written link content.
EntityProviderException - if writing of data (serialization) fails
public static ODataResponse writeLinks(String contentType,
EdmEntitySet entitySet,
List<Map<String,Object>> data,
EntityProviderWriteProperties properties)
throws EntityProviderException
entity data model for an entity set (given as
EdmEntitySet)
in the specified format (given as contentType) for a set of entries.
The necessary key property values must be provided within the data (in form of a List with a
Map for each entry. Such a Map contains all key properties [as property name to
property value mapping] for the entry) and properties for this entity provider must be
set
(given as EntityProviderWriteProperties).
contentType - format in which the entry should be writtenentitySet - entity data model for given entity data setdata - set of entries in form of a List with a Map for each entry (such a Map contains
all key properties [as property name to property value mapping).properties - additional properties necessary for writing of data
ODataResponse with written links content.
EntityProviderException - if writing of data (serialization) fails
public static ODataResponse writeFunctionImport(String contentType,
EdmFunctionImport functionImport,
Object data,
EntityProviderWriteProperties properties)
throws EntityProviderException
data result (given as Object) of function import based on return type
of EdmFunctionImport in specified format (given as contentType). Additional
properties
for this entity provider must be set (given as EntityProviderWriteProperties).
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
ODataResponse with written function import result content.
EntityProviderException - if writing of data (serialization) fails
public static ODataFeed readFeed(String contentType,
EdmEntitySet entitySet,
InputStream content,
EntityProviderReadProperties properties)
throws EntityProviderException
content (as InputStream) in specified format (given as
contentType)
based on entity data model (given as EdmEntitySet) and provide this data as ODataEntry
.
contentType - format of content in the given input stream.entitySet - entity data model for entity set to be readcontent - feed data in form of an InputStream which contains the data in specified formatproperties - additional properties necessary for reading content from InputStream into Map.
Must not be null.
ODataFeed object
EntityProviderException - if reading of data (de-serialization) fails
public static ODataDeltaFeed readDeltaFeed(String contentType,
EdmEntitySet entitySet,
InputStream content,
EntityProviderReadProperties properties)
throws EntityProviderException
content (as InputStream) in specified format
(given as contentType) based on entity data model (given as EdmEntitySet) and
provide this data as ODataEntry .
contentType - format of content in the given input stream.entitySet - entity data model for entity set to be readcontent - feed data in form of an InputStream which contains the data in specified formatproperties - additional properties necessary for reading content from InputStream into Map.
Must not be null.
ODataDeltaFeed object
EntityProviderException - if reading of data (de-serialization) fails
public static ODataEntry readEntry(String contentType,
EdmEntitySet entitySet,
InputStream content,
EntityProviderReadProperties properties)
throws EntityProviderException
content (as InputStream) in specified format (given as
contentType)
based on entity data model (given as EdmEntitySet) and provide this data as ODataEntry
.
contentType - format of content in the given input stream.entitySet - entity data model for entity set to be readcontent - data in form of an InputStream which contains the data in specified formatproperties - additional properties necessary for reading content from InputStream into Map.
Must not be null.
ODataEntry
EntityProviderException - if reading of data (de-serialization) fails
public static Map<String,Object> readProperty(String contentType,
EdmProperty edmProperty,
InputStream content,
EntityProviderReadProperties properties)
throws EntityProviderException
content (as InputStream) in specified format (given as
contentType)
based on entity data model (given as EdmProperty) and provide this data as Map which
contains
the read data in form of property name to property value mapping.
contentType - format of content in the given input stream.edmProperty - entity data model for entity property to be readcontent - data in form of an InputStream which contains the data in specified formatproperties - additional properties necessary for reading content from InputStream into Map.
Must not be null.
EntityProviderException - if reading of data (de-serialization) fails
public static Object readPropertyValue(EdmProperty edmProperty,
InputStream content)
throws EntityProviderException
content (as InputStream) in format
text/plain
based on entity data model (given as EdmProperty) and provide this data as Object.
edmProperty - entity data model for entity property to be readcontent - data in form of an InputStream which contains the data in format text/plain
EntityProviderException - if reading of data (de-serialization) fails
public static Object readPropertyValue(EdmProperty edmProperty,
InputStream content,
Class<?> typeMapping)
throws EntityProviderException
content (as InputStream) in format
text/plain
based on entity data model (given as EdmProperty) and provide this data as Object.
edmProperty - entity data model for entity property to be readcontent - data in form of an InputStream which contains the data in format text/plaintypeMapping - defines the mapping for this edm property to a java class which should
be used
during read of the content. If according edm property can not be read
into given java class an EntityProviderException is thrown.
Supported mappings are documented in EdmSimpleType.
EntityProviderException - if reading of data (de-serialization) fails
public static Object readFunctionImport(String contentType,
EdmFunctionImport functionImport,
InputStream content,
EntityProviderReadProperties properties)
throws EntityProviderException
content (as InputStream) in specified format
(given as contentType) based on entity data model (given as EdmFunctionImport)
and provide this data as Object.
contentType - format of content in the given input stream.functionImport - entity data model for Function Import to be readcontent - data in form of an InputStream which contains the data in specified formatproperties - additional properties necessary for reading content from InputStream into Map.
Must not be null.
Object
EntityProviderException - if reading of data (de-serialization) fails
public static String readLink(String contentType,
EdmEntitySet entitySet,
InputStream content)
throws EntityProviderException
content (as InputStream) in specified format (given as
contentType)
based on entity data model (given as EdmEntitySet) and provide the link as String.
contentType - format of content in the given input stream.entitySet - entity data model for entity property to be readcontent - data in form of an InputStream which contains the data in specified format
EntityProviderException - if reading of data (de-serialization) fails
public static List<String> readLinks(String contentType,
EdmEntitySet entitySet,
InputStream content)
throws EntityProviderException
content (as InputStream)
in specified format (given as contentType) based on entity data model
(given as EdmEntitySet) and provide the links as List of Strings.
contentType - format of content in the given input stream.entitySet - entity data model for entity property to be readcontent - data in form of an InputStream which contains the data in specified format
EntityProviderException - if reading of data (de-serialization) fails
public static byte[] readBinary(InputStream content)
throws EntityProviderException
content (as InputStream) and provide it as
byte[].
content - data in form of an InputStream which contains the binary data
EntityProviderException - if reading of data (de-serialization) fails
public static Edm readMetadata(InputStream metadataXml,
boolean validate)
throws EntityProviderException
inputStream (as InputStream) and provide Edm as
Edm
metadataXml - a metadata xml input stream (means the metadata document)validate - has to be true if metadata should be validated
Edm
EntityProviderException - if reading of data (de-serialization) fails
public static ODataErrorContext readErrorDocument(InputStream errorDocument,
String contentType)
throws EntityProviderException
InputStream and provide according ODataErrorContext
.
errorDocument - error document which is readcontentType - format of content in the given input stream
EntityProviderException - if reading of data (de-serialization) fails
public static ServiceDocument readServiceDocument(InputStream serviceDocument,
String contentType)
throws EntityProviderException
inputStream (as InputStream) and provide
ServiceDocument as ServiceDocument
serviceDocument - the given input streamcontentType - format of content in the given input stream
ServiceDocument
EntityProviderException - if reading of data (de-serialization) fails
public static List<BatchRequestPart> parseBatchRequest(String contentType,
InputStream content,
EntityProviderBatchProperties properties)
throws BatchException
inputStream (as InputStream) and provide a list of Batch Request
parts as BatchRequestPart
contentType - format of content in the given input streamcontent - request bodyproperties - additional properties necessary for parsing. Must not be null.
BatchRequestPart
BatchException - if parsing fails
public static ODataResponse writeBatchResponse(List<BatchResponsePart> batchResponseParts)
throws BatchException
ODataResponse.
Batch Response body matches one-to-one with the corresponding Batch Request body
batchResponseParts - a list of BatchResponsePart
ODataResponse
BatchException
public static InputStream writeBatchRequest(List<BatchPart> batchParts,
String boundary)
batchParts - a list of BatchPartRequests BatchPartboundary -
public static List<BatchSingleResponse> parseBatchResponse(InputStream content,
String contentType)
throws BatchException
InputStream) and provide a list of single responses as
BatchSingleResponse
content - response bodycontentType - format of content in the given input stream (inclusive boundary parameter)
BatchSingleResponse
BatchException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||