public interface ODataStoreAsync extends ODataStore
ODataStore
whose operations are asynchronous. This interface is in strong correlation with
ODataStoreSync
:
ODataStoreSync.execute*
methods have their counterparts in this interface prefixed by
schedule*
.schedule*
is the same as that of the corresponding execute*
method in the synchronous interface.schedule*
methods take an ODataRequestListener
through which they return their results. Furthermore,
each of these methods return an ODataRequestExecution
object using which the asynchronous operation can be monitored or even
cancelled.
ODataEntity newTravelagency = new ODataEntityDefaultImpl("RMTSAMPLEFLIGHT.Travelagency");
store.allocateProperties(newTravelagency, PropMode.All);
ODataPropMap propMap = newTravelagency.getProperties();
ODataProperty agencynum = new ODataPropertyDefaultImpl("agencynum", String.valueOf("id"));
propMap.put("agencynum", agencynum);
ODataRequestListener listener = new ODataRequestListener() {
@Override
public void requestStarted(ODataRequestExecution requestExecution) {
// request started - always called
// ODataRequestExecution.getStatus==Status.Initialized
// ODataRequestExecution.getResponse==null
// handle this: e.g. application shows a progress indicator
}
@Override
public void requestServerResponse(ODataRequestExecution requestExecution) {
// server response arrived - only if HTTP 2XX server response arrived, requestFailed otherwise
// ODataRequestExecution.getStatus==Status.InProgress
// ODataRequestExecution.getResponse==
// handle this: e.g. application modifies its data model and the UI
}
@Override
public void requestFinished(ODataRequestExecution requestExecution) {
// server response arrived - always called
// ODataRequestExecution.getStatus==Status.Completed or Status.Error
// ODataRequestExecution.getResponse==null, or
// handle this: e.g. application shows an error toast
}
@Override
public void requestFailed(ODataRequestExecution requestExecution, ODataException exception) {
// server response arrived - only if error occured
// ODataRequestExecution.getStatus==Status.Error
// ODataRequestExecution.getResponse== if exist
// handle this: e.g. application refresh its data model and UI
}
@Override
public void requestCacheResponse(ODataRequestExecution requestExecution) {
// server response arrived - only if cache enabled and read request is executed. In case of batch request if it contains at least one read operation, then this callback is called.
// ODataRequestExecution.getStatus==Status.InProgress
// ODataRequestExecution.getResponse==
}
};
store.scheduleCreateEntity(newTravelagency, "TravelagencyCollection", listener, null);
If an error occured during the asynchronous request execution an exception is send to
ODataRequestListener.requestFailed(ODataRequestExecution, ODataException)
method. The root cause of the errors can be a
network error, parsing error, OData Error Response, etc. (see com.sap.smp.client.odata.exception
)ODataRequestExecution.getResponse()
method.
ODataRequestListener listener = new ODataRequestListener() {
// ...
@Override
public void requestFailed(ODataRequestExecution requestExecution, ODataException exception) {
// server response arrived - only if error occured
// ODataRequestExecution.getStatus==Status.Error
// ODataRequestExecution.getResponse== if exist
// handle this: e.g. application refresh its data model and UI
if(exception instanceof ODataNetworkException) {
// maybe server error response available
ODataResponse errorResponse = requestExecution.getResponse();
}
}
// ...
}
For asynchronous batch requests scheduleRequest
method MUST be used (other methods handle only single
request/response). This case the request parameter is ODataRequestParamBatch
and the response is ODataResponseBatch
.ODataStore.PropMode
Modifier and Type | Method and Description |
---|---|
ODataRequestExecution |
scheduleCreateEntity(ODataEntity entity,
java.lang.String collectionPath,
ODataRequestListener listener,
java.util.Map<java.lang.String,java.lang.String> options)
Scheduling method for creating an Entity.
|
ODataRequestExecution |
scheduleDeleteEntity(ODataEntity entity,
ODataRequestListener listener,
java.util.Map<java.lang.String,java.lang.String> options)
Scheduling method for deleting an Entity.
|
ODataRequestExecution |
scheduleDeleteEntity(java.lang.String resourcePath,
java.lang.String etag,
ODataRequestListener listener,
java.util.Map<java.lang.String,java.lang.String> options)
Scheduling method for deleting an Entity.
|
ODataRequestExecution |
scheduleFunction(java.lang.String resourcePath,
ODataRequestListener listener,
java.util.Map<java.lang.String,java.lang.String> options)
Scheduling method for calling a function.
|
ODataDownloadMediaExecution |
scheduleMediaDownload(java.net.URL url,
ODataDownloadMediaListener listener)
Scheduling method for download media content from an URL.
|
ODataRequestExecution |
schedulePatchEntity(ODataEntity entity,
ODataRequestListener listener,
java.util.Map<java.lang.String,java.lang.String> options)
Scheduling method for patching an Entity.
|
ODataRequestExecution |
scheduleReadEntity(ODataEntity entity,
ODataRequestListener listener,
java.util.Map<java.lang.String,java.lang.String> options)
Scheduling method for reading an Entity.
|
ODataRequestExecution |
scheduleReadEntity(java.lang.String resourcePath,
ODataRequestListener listener,
java.util.Map<java.lang.String,java.lang.String> options)
Scheduling method for reading an Entity.
|
ODataRequestExecution |
scheduleReadEntitySet(java.lang.String resourcePath,
ODataRequestListener listener,
java.util.Map<java.lang.String,java.lang.String> options)
Scheduling method for reading an Entity set.
|
ODataRequestExecution |
scheduleReadLink(java.lang.String resourcePath,
ODataRequestListener listener,
java.util.Map<java.lang.String,java.lang.String> options)
Scheduling method for reading a link.
|
ODataRequestExecution |
scheduleReadLinkSet(java.lang.String resourcePath,
ODataRequestListener listener,
java.util.Map<java.lang.String,java.lang.String> options)
Scheduling method for reading a link set.
|
ODataRequestExecution |
scheduleReadPropertyComplex(java.lang.String resourcePath,
ODataRequestListener listener,
java.util.Map<java.lang.String,java.lang.String> options)
Scheduling method for reading a complex property.
|
ODataRequestExecution |
scheduleReadPropertyPrimitive(java.lang.String resourcePath,
ODataRequestListener listener,
java.util.Map<java.lang.String,java.lang.String> options)
Scheduling method for reading a primitive property.
|
ODataRequestExecution |
scheduleReadPropertyRaw(java.lang.String resourcePath,
ODataRequestListener listener,
java.util.Map<java.lang.String,java.lang.String> options)
Scheduling method for reading the raw value of a property.
|
ODataRequestExecution |
scheduleRequest(ODataRequestParam request,
ODataRequestListener listener)
General-purpose scheduling method for all kinds of requests.
|
ODataRequestExecution |
scheduleUpdateEntity(ODataEntity entity,
ODataRequestListener listener,
java.util.Map<java.lang.String,java.lang.String> options)
Scheduling method for updating an Entity.
|
allocateNavigationProperties, allocateProperties, determineEntitySet, determineEntityType, determineODataType, getMetadata
ODataRequestExecution scheduleRequest(ODataRequestParam request, ODataRequestListener listener) throws ODataException
request
- the request to send asynchronously. MUST be non-null, otherwise NullPointerException is thrownlistener
- the listener to invoke at key events of the operation, MUST be non-null, otherwise NullPointerException is thrownODataException
- in case of error. E.g. the store is closed, missing resource path, missing batch item.java.lang.NullPointerException
- if request or listener parameter is nullODataRequestExecution scheduleReadEntitySet(java.lang.String resourcePath, ODataRequestListener listener, java.util.Map<java.lang.String,java.lang.String> options) throws ODataException
resourcePath
- resource path of the Entity set. MUST be non-null, otherwise NullPointerException is thrownlistener
- the listener to invoke at key events of the operation. MUST be non-null, otherwise NullPointerException is thrownoptions
- the options set for this requestODataException
- in case of error. E.g. the store is closed, missing resource path.java.lang.NullPointerException
- if resourcePath or listener is nullODataRequestExecution scheduleReadEntity(java.lang.String resourcePath, ODataRequestListener listener, java.util.Map<java.lang.String,java.lang.String> options) throws ODataException
resourcePath
- resource path of the Entity to be read. MUST be non-null, otherwise NullPointerException is thrownlistener
- the listener to invoke at key events of the operation. MUST be non-null, otherwise NullPointerException is thrownoptions
- the options set for this request, can be nullODataException
- in case of error. E.g. the store is closed, missing resource path.java.lang.NullPointerException
- if resourcePath or listener is nullODataRequestExecution scheduleReadEntity(ODataEntity entity, ODataRequestListener listener, java.util.Map<java.lang.String,java.lang.String> options) throws ODataException
entity
- the Entity to be read. MUST be non-null, otherwise NullPointerException is thrownlistener
- the listener to invoke at key events of the operation. MUST be non-null, otherwise NullPointerException is thrownoptions
- the options set for this requestODataException
- in case of error. E.g. the store is closed, missing resource path.java.lang.NullPointerException
- if entity or listener is nullODataRequestExecution scheduleCreateEntity(ODataEntity entity, java.lang.String collectionPath, ODataRequestListener listener, java.util.Map<java.lang.String,java.lang.String> options) throws ODataException
entity
- the Entity to be created. MUST be non-null, otherwise NullPointerException is throwncollectionPath
- path of the collection the Entity to be added to. MUST be non-null, otherwise NullPointerException is thrownlistener
- the listener to invoke at key events of the operation. MUST be non-null, otherwise NullPointerException is thrownoptions
- the options set for this request, can be nullODataException
- in case of error. E.g. the store is closed, missing resource path.java.lang.NullPointerException
- if entity, collectionPath or listener is nullODataRequestExecution scheduleUpdateEntity(ODataEntity entity, ODataRequestListener listener, java.util.Map<java.lang.String,java.lang.String> options) throws ODataException
entity
- the Entity to be updated. MUST be non-null, otherwise NullPointerException is thrownlistener
- the listener to invoke at key events of the operation. MUST be non-null, otherwise NullPointerException is thrownoptions
- the options set for this requestODataException
- in case of error. E.g. the store is closed, missing resource path.java.lang.NullPointerException
- if entity or listener is nullODataRequestExecution schedulePatchEntity(ODataEntity entity, ODataRequestListener listener, java.util.Map<java.lang.String,java.lang.String> options) throws ODataException
entity
- the Entity to be patched. MUST be non-null, otherwise NullPointerException is thrownlistener
- the listener to invoke at key events of the operation. MUST be non-null, otherwise NullPointerException is thrownoptions
- the options set for this requestODataException
- in case of error. E.g. the store is closed, missing resource path.java.lang.NullPointerException
- if entity or listener is nullODataRequestExecution scheduleDeleteEntity(ODataEntity entity, ODataRequestListener listener, java.util.Map<java.lang.String,java.lang.String> options) throws ODataException
entity
- the Entity to be deleted. MUST be non-null, otherwise NullPointerException is thrownlistener
- the listener to invoke at key events of the operation. MUST be non-null, otherwise NullPointerException is thrownoptions
- the options set for this requestODataException
- in case of error. E.g. the store is closed, missing resource path.java.lang.NullPointerException
- if entity or listener is nullODataRequestExecution scheduleDeleteEntity(java.lang.String resourcePath, java.lang.String etag, ODataRequestListener listener, java.util.Map<java.lang.String,java.lang.String> options) throws ODataException
resourcePath
- resource path of the Entity to be deleted. MUST be non-null, otherwise NullPointerException is thrownetag
- ETag can be set for a request for concurrency handling in the server. It sets the "If-Match" header in the HTTP
request. Can be nulllistener
- the listener to invoke at key events of the operation. MUST be non-null, otherwise NullPointerException is thrownoptions
- the options set for this request, can be nullODataException
- in case of error. E.g. the store is closed, missing resource path.java.lang.NullPointerException
- if resourcePath or listener is nullODataRequestExecution scheduleReadPropertyPrimitive(java.lang.String resourcePath, ODataRequestListener listener, java.util.Map<java.lang.String,java.lang.String> options) throws ODataException
resourcePath
- resource path of the property to be read. MUST be non-null, otherwise NullPointerException is thrownlistener
- the listener to invoke at key events of the operation. MUST be non-null, otherwise NullPointerException is thrownoptions
- the options set for this requestODataException
- in case of error. E.g. the store is closed, missing resource path.java.lang.NullPointerException
- if resourcePath or listener is nullODataRequestExecution scheduleReadPropertyComplex(java.lang.String resourcePath, ODataRequestListener listener, java.util.Map<java.lang.String,java.lang.String> options) throws ODataException
resourcePath
- resource path of the property to be read. MUST be non-null, otherwise NullPointerException is thrownlistener
- the listener to invoke at key events of the operation. MUST be non-null, otherwise NullPointerException is thrownoptions
- the options set for this requestODataException
- in case of error. E.g. the store is closed, missing resource path.java.lang.NullPointerException
- if resourcePath or listener is nullODataRequestExecution scheduleReadPropertyRaw(java.lang.String resourcePath, ODataRequestListener listener, java.util.Map<java.lang.String,java.lang.String> options) throws ODataException
resourcePath
- resource path of the raw value of a property to be read. MUST be non-null, otherwise NullPointerException is thrownlistener
- the listener to invoke at key events of the operation. MUST be non-null, otherwise NullPointerException is thrownoptions
- the options set for this requestODataException
- in case of error. E.g. the store is closed, missing resource path.java.lang.NullPointerException
- if resourcePath or listener is nullODataRequestExecution scheduleReadLink(java.lang.String resourcePath, ODataRequestListener listener, java.util.Map<java.lang.String,java.lang.String> options) throws ODataException
resourcePath
- resource path of the link to be read. MUST be non-null, otherwise NullPointerException is thrownlistener
- the listener to invoke at key events of the operation. MUST be non-null, otherwise NullPointerException is thrownoptions
- the options set for this requestODataException
- in case of error. E.g. the store is closed, missing resource path.java.lang.NullPointerException
- if resourcePath or listener is nullODataRequestExecution scheduleReadLinkSet(java.lang.String resourcePath, ODataRequestListener listener, java.util.Map<java.lang.String,java.lang.String> options) throws ODataException
resourcePath
- resource path of the link set to be read. MUST be non-null, otherwise NullPointerException is thrownlistener
- the listener to invoke at key events of the operation. MUST be non-null, otherwise NullPointerException is thrownoptions
- the options set for this requestODataException
- in case of error. E.g. the store is closed, missing resource path.java.lang.NullPointerException
- if resourcePath or listener is nullODataRequestExecution scheduleFunction(java.lang.String resourcePath, ODataRequestListener listener, java.util.Map<java.lang.String,java.lang.String> options) throws ODataException
resourcePath
- resource path of the function to be called. MUST be non-null, otherwise NullPointerException is thrownlistener
- the listener to invoke at key events of the operation. MUST be non-null, otherwise NullPointerException is thrownoptions
- the options set for this requestODataException
- in case of error. E.g. the store is closed, missing resource path.java.lang.NullPointerException
- if resourcePath or listener is nullODataDownloadMediaExecution scheduleMediaDownload(java.net.URL url, ODataDownloadMediaListener listener) throws ODataException
url
- URL of media content. MUST be non-null. See ODataEntity.getMediaLink() ODataEntity
listener
- the listener to invoke at key events of the operation. MUST be non-null ODataDownloadMediaListener
ODataDownloadMediaExecution
ODataException