public class ODataService
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
protected static class |
ODataService.TokenCache |
| Modifier and Type | Field and Description |
|---|---|
protected EdmxProvider |
edmxProvider |
protected HttpURLConnectionService |
httpURLConnectionService |
protected ODataConvertEdmService |
oDataConvertEdmService |
protected java.lang.String |
password |
protected java.net.Proxy |
proxy |
protected java.lang.String |
rootUrl |
protected java.lang.String |
sapClient |
protected ODataService.TokenCache |
token |
protected java.lang.String |
user |
protected static java.lang.String |
X_CSRF_TOKEN |
| Constructor and Description |
|---|
ODataService() |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
bufferStream(java.io.InputStream stream)
Read
InputStream and return a byte array. |
protected void |
checkStatus(HttpURLConnectionResponse response) |
protected JsonObject |
convertMapToJSON(EdmEntityType entityType,
java.util.Map<?,?> data) |
byte[] |
convertMapToJSONPayload(java.lang.String entitySetName,
java.util.Map<java.lang.String,java.lang.Object> data)
Convert an entity map into a JSON payload reading to be transfered.
|
java.lang.String |
convertMapToJSONString(EdmEntityType entityType,
java.util.Map<java.lang.String,java.lang.Object> data)
Convert an entity map into a JSON String.
|
java.util.Map<java.lang.String,java.lang.String> |
convertMapToURIParameters(java.lang.String functionImportName,
java.util.Map<java.lang.String,java.lang.Object> data)
Build properly formated String value arguments for OData Function Import.
|
protected JsonElement |
convertObjectToJsonElement(java.lang.Object value,
EdmElement element) |
protected JsonElement |
convertObjectToJsonElement(java.lang.Object value,
EdmNavigationProperty navigation) |
protected java.lang.String |
convertObjectToString(java.lang.Object value,
EdmLiteralKind literalKind,
EdmElement element) |
java.lang.String |
createResourcePath(java.lang.String entitySetName,
java.util.Map<java.lang.String,java.lang.Object> data)
Create $batch part URL accessing entity by keys for Addressing Entries.
|
java.net.URL |
createURL(java.lang.String resourcePath)
Create an absolute URL accessing the OData service at the resource path provided.
|
java.net.URL |
createURL(java.lang.String resourcePath,
java.util.Map<java.lang.String,java.lang.String> queryOptions)
Create an absolute URL accessing the OData service at the resourcePath provided using OData query options.
|
java.net.URL |
createURL(java.lang.String resourcePath,
java.lang.String... queryOptions)
Create an absolute URL accessing the OData service at the resourcePath provided using OData query options.
|
protected byte[] |
decompressIfGZIP(byte[] payload) |
protected HttpURLConnectionResponse |
executeWithBasicAuth(HttpURLConnectionRequest request)
Execute the request with Authorization : "Basic BASE64user:pass".
Using this method will create a new http session (unnecessary cost) on the yMKT side. It is preferable to use executeWithRetry(HttpURLConnectionRequest) for most execution scenarios. |
HttpURLConnectionResponse |
executeWithRetry(HttpURLConnectionRequest request)
Execute the request with "cookie" & "x-csrf-token".
If the existing session and/or token expired, those are refreshed and the request is re-tried. |
ODataFilterBuilder |
filter(java.lang.String entitySetName)
Create an
ODataFilterBuilder starting on the entitySetName provided. |
protected java.lang.StringBuilder |
getCustomQueryOptions() |
Edm |
getEdm()
Provide buffered olingo's
Edm of the OData service. |
EdmEntitySet |
getEntitySet(java.lang.String entitySetName)
Simple wrapping with improved error handling of :
this.getEdm().getDefaultEntityContainer().getEntitySet(entitySetName); |
protected ODataService.TokenCache |
getTokenCache() |
protected ODataService.TokenCache |
refreshToken(ODataService.TokenCache token) |
void |
setHttpURLConnectionService(HttpURLConnectionService httpURLConnectionService) |
void |
setODataConvertEdmService(ODataConvertEdmService oDataConvertEdmService) |
void |
setPassword(java.lang.String password) |
void |
setProxy(java.lang.String proxy) |
void |
setRootUrl(java.lang.String rootUrl) |
void |
setSapClient(java.lang.String sapClient) |
void |
setUser(java.lang.String user) |
protected static final java.lang.String X_CSRF_TOKEN
protected volatile EdmxProvider edmxProvider
protected HttpURLConnectionService httpURLConnectionService
protected ODataConvertEdmService oDataConvertEdmService
protected java.lang.String password
protected java.net.Proxy proxy
protected java.lang.String rootUrl
protected java.lang.String sapClient
protected volatile ODataService.TokenCache token
protected java.lang.String user
public byte[] bufferStream(java.io.InputStream stream)
throws java.io.IOException
InputStream and return a byte array.stream - InputStream to read.InputStreamjava.io.IOException - from InputStream.read(byte[])HttpURLConnectionService.bufferStream(InputStream)protected void checkStatus(HttpURLConnectionResponse response) throws java.io.IOException
java.io.IOExceptionprotected JsonObject convertMapToJSON(EdmEntityType entityType,
java.util.Map<?,?> data)
throws java.io.IOException,
EdmException
java.io.IOExceptionEdmExceptionpublic byte[] convertMapToJSONPayload(java.lang.String entitySetName,
java.util.Map<java.lang.String,java.lang.Object> data)
throws java.io.IOException
entitySetName - <EntitySet Name> value found in the DefaultEntityContainer of the OData service.data - Map containing the <Property/NavigationProperty Name> and value to be converted.java.io.IOException - if an I/O error occurs.EdmLiteralKind#JSONpublic java.lang.String convertMapToJSONString(EdmEntityType entityType,
java.util.Map<java.lang.String,java.lang.Object> data)
throws java.io.IOException
entityType - EdmEntityType of the OData entity to be converted.data - Map containing the <Parameter> Name and value to be converted.java.io.IOException - if an I/O error occurs.EdmLiteralKind#JSONpublic java.util.Map<java.lang.String,java.lang.String> convertMapToURIParameters(java.lang.String functionImportName,
java.util.Map<java.lang.String,java.lang.Object> data)
throws java.io.IOException
functionImportName - Attribute Name value found in the <FunctionImport> of the OData service.data - Map containing the <Parameter> Name and value to be converted.Map containing the <Parameter> Name and converted value.java.io.IOException - if an I/O error occurs.EdmLiteralKind#URIprotected JsonElement convertObjectToJsonElement(java.lang.Object value,
EdmElement element)
throws EdmException
EdmExceptionprotected JsonElement convertObjectToJsonElement(java.lang.Object value,
EdmNavigationProperty navigation)
throws EdmException,
java.io.IOException
EdmExceptionjava.io.IOExceptionprotected java.lang.String convertObjectToString(java.lang.Object value,
EdmLiteralKind literalKind,
EdmElement element)
throws EdmException
EdmExceptionpublic java.lang.String createResourcePath(java.lang.String entitySetName,
java.util.Map<java.lang.String,java.lang.Object> data)
throws java.io.IOException
entitySetName - <EntitySet Name> value found in the DefaultEntityContainer of the OData service.data - Map containing the <Property/NavigationProperty Name> and value to be converted.java.io.IOException - if an I/O error occurs.public java.net.URL createURL(java.lang.String resourcePath)
resourcePath - Resource path of the OData service.URLpublic java.net.URL createURL(java.lang.String resourcePath,
java.util.Map<java.lang.String,java.lang.String> queryOptions)
resourcePath - Resource path of the OData service.queryOptions - OData Query String Options.URLpublic java.net.URL createURL(java.lang.String resourcePath,
java.lang.String... queryOptions)
resourcePath - Resource path of the OData service.queryOptions - OData Query String Options.URLprotected byte[] decompressIfGZIP(byte[] payload)
throws java.io.IOException
java.io.IOExceptionprotected HttpURLConnectionResponse executeWithBasicAuth(HttpURLConnectionRequest request) throws java.io.IOException
executeWithRetry(HttpURLConnectionRequest) for most execution scenarios.request - HttpURLConnectionRequest to execute.HttpURLConnectionResponse executed.java.io.IOException - If the HTTP request was not successful.URLConnection.setRequestProperty(java.lang.String, java.lang.String)public HttpURLConnectionResponse executeWithRetry(HttpURLConnectionRequest request) throws java.io.IOException
request - HttpURLConnectionRequest to execute.HttpURLConnectionResponse executed.java.io.IOException - If the HTTP request was not successful.public ODataFilterBuilder filter(java.lang.String entitySetName) throws java.io.IOException
ODataFilterBuilder starting on the entitySetName provided.entitySetName - <EntitySet Name> value found in the DefaultEntityContainer of the OData service.ODataFilterBuilderjava.io.IOException - if an I/O error occurs.protected java.lang.StringBuilder getCustomQueryOptions()
public Edm getEdm()
throws java.io.IOException
Edm of the OData service.Edm $metadata for the service end point set by
setRootUrl(String).java.io.IOException - If Edm could not be returned.public EdmEntitySet getEntitySet(java.lang.String entitySetName)
throws java.io.IOException
this.getEdm().getDefaultEntityContainer().getEntitySet(entitySetName);entitySetName - <EntitySet Name> value found in the DefaultEntityContainer of the OData service.EdmEntitySetjava.io.IOException - In case of communication errors.protected ODataService.TokenCache getTokenCache() throws java.io.IOException
java.io.IOExceptionprotected ODataService.TokenCache refreshToken(ODataService.TokenCache token) throws java.io.IOException
java.io.IOExceptionpublic void setHttpURLConnectionService(HttpURLConnectionService httpURLConnectionService)
public void setODataConvertEdmService(ODataConvertEdmService oDataConvertEdmService)
public void setPassword(java.lang.String password)
password - Password used to login with setUser(String) at the setRootUrl(String) address.public void setProxy(java.lang.String proxy)
throws java.net.MalformedURLException
java.net.MalformedURLExceptionpublic void setRootUrl(java.lang.String rootUrl)
rootUrl - OData service root URL.https://localhost:50100/sap/opu/odata/sap/PROD_RECO_RUNTIME_SRV/ localhost should be replaced with the proper SAP Marketing server host name.public void setSapClient(java.lang.String sapClient)
sapClient - the sapClient to setpublic void setUser(java.lang.String user)
user - Username used to login at the setRootUrl(String) address.Copyright © 2018 SAP SE. All Rights Reserved.