public class DefaultEntityHandler extends EntityHandler
Default handler for CRUD (create/read/update/delete) operations on entities.
Any entity operations that are not overridden will delegate to DefaultEntityHandler.dataService.
| Constructor and Description |
|---|
DefaultEntityHandler(DataServlet servlet,
DataService service)
Construct a new default entity handler.
|
| Modifier and Type | Method and Description |
|---|---|
void |
createEntity(EntityValue entity)
Handles the creation of an entity.
|
void |
createLink(EntityValue source,
Property sourceProperty,
EntityValue target)
Handles the creation of a link.
|
void |
createMedia(EntityValue entity,
ByteStream stream)
Handles the creation of a media entity.
|
void |
deleteEntity(EntityValue entity)
Handles the deletion of an entity.
|
void |
deleteLink(EntityValue source,
Property sourceProperty,
EntityValue target)
Handles the deletion of a link.
|
void |
deleteStream(EntityValue entity,
StreamLink link)
Handles the deletion of a stream property.
|
void |
downloadMedia(EntityValue entity,
ByteStream stream)
Handles the downloading of a media entity.
|
void |
downloadStream(EntityValue entity,
StreamLink link,
ByteStream stream)
Handles the downloading of a stream property.
|
DataValue |
executeQuery(DataQuery query)
Handles the execution of a query.
|
DataService |
getCacheDatabase()
Return cache database service, if available.
|
EntityValue |
getClientRegistration()
Return an entity value for the current client registration.
|
DataService |
getDataService()
Return data service, to which non-overridden entity operations will be delegated.
|
DataServlet |
getDataServlet()
Return data servlet, which receives and processes entity requests from the client.
|
java.lang.String |
getNameForMetrics()
Return component name for data metrics.
|
DataValue |
headerValue(EntityType entityType,
java.lang.String headerName)
Obtain the value of a structure property within an HTTP header in the current
DataServlet request. |
boolean |
isBackendHandler()
Return does this entity handler delegate to a backend system (as opposed to the main service database).
|
void |
refreshAfter(EntityHandler priorHandler,
EntitySet priorEntitySet,
EntitySet entitySet)
Register the cache refresh of an entity set to be scheduled after the refresh of a prior entity set.
|
void |
refreshCache(EntitySet entitySet,
boolean onDemand)
Refresh the database with changes from the corresponding backend system (if applicable).
|
void |
updateEntity(EntityValue entity)
Handles the updating of an entity.
|
void |
updateLink(EntityValue source,
Property sourceProperty,
EntityValue target)
Handles the updating of a link.
|
void |
uploadMedia(EntityValue entity,
ByteStream stream)
Handles the uploading of a media stream.
|
void |
uploadStream(EntityValue entity,
StreamLink link,
ByteStream stream)
Handles the uploading of a stream property.
|
allowUnused, loadAll, loadPartitionpublic DefaultEntityHandler(DataServlet servlet, DataService service)
Construct a new default entity handler.
servlet - Data servlet, which receives and processes entity requests from the client.service - Data service, to which non-overridden entity operations will be delegated.public void createEntity(EntityValue entity)
Handles the creation of an entity.
createEntity in class EntityHandlerentity - Entity value.public void createLink(EntityValue source, Property sourceProperty, EntityValue target)
Handles the creation of a link.
createLink in class EntityHandlersource - Source entity.sourceProperty - Source property.target - Target entity.public void createMedia(EntityValue entity, ByteStream stream)
Handles the creation of a media entity.
createMedia in class EntityHandlerentity - Media entity.stream - Input stream, to access uploaded content.public void deleteEntity(EntityValue entity)
Handles the deletion of an entity.
deleteEntity in class EntityHandlerentity - Entity value.public void deleteLink(EntityValue source, Property sourceProperty, EntityValue target)
Handles the deletion of a link.
deleteLink in class EntityHandlersource - Source entity.sourceProperty - Source property.target - Target entity.public void deleteStream(EntityValue entity, StreamLink link)
Handles the deletion of a stream property.
deleteStream in class EntityHandlerentity - Owning entity.link - Stream link, identifying the stream property the client is deleting.public void downloadMedia(EntityValue entity, ByteStream stream)
Handles the downloading of a media entity.
downloadMedia in class EntityHandlerentity - Media entity.stream - Output stream, to receive downloaded content.public void downloadStream(EntityValue entity, StreamLink link, ByteStream stream)
Handles the downloading of a stream property.
downloadStream in class EntityHandlerentity - Owning entity.link - Stream link, identifying the stream property the client is downloading.stream - Output stream, to receive downloaded content.public DataValue executeQuery(DataQuery query)
Handles the execution of a query.
executeQuery in class EntityHandlerquery - Data query.public DataService getCacheDatabase()
Return cache database service, if available.
public EntityValue getClientRegistration()
Return an entity value for the current client registration. Throw DataException if no registration is found.
Assumes that a ClientRegistration entity type exists in the service metadata, and Client-Instance-ID HTTP request parameter is available.
DataException if no registration is found.public DataService getDataService()
Return data service, to which non-overridden entity operations will be delegated.
public DataServlet getDataServlet()
Return data servlet, which receives and processes entity requests from the client.
public java.lang.String getNameForMetrics()
Return component name for data metrics.
getNameForMetrics in class EntityHandlerpublic DataValue headerValue(EntityType entityType, java.lang.String headerName)
Obtain the value of a structure property within an HTTP header in the current DataServlet request.
The header structure value should be encoded using OData JSON format wrapped as a data URI with media type "application/json" and base64-encoded data.
entityType - (nullable) Entity type, whose name (if provided) will be prefixed to the headerName name to determine the structure type for the header value.headerName - Header name, e.g. "CreateParameters.Reason" to obtain the "Reason" property value inside the entity value for HTTP header "X-Create-Parameters".public boolean isBackendHandler()
Return does this entity handler delegate to a backend system (as opposed to the main service database).
isBackendHandler in class EntityHandlerpublic void refreshAfter(EntityHandler priorHandler, EntitySet priorEntitySet, EntitySet entitySet)
Register the cache refresh of an entity set to be scheduled after the refresh of a prior entity set.
refreshAfter in class EntityHandlerpriorHandler - Entity handler for refresh of the prior entity set.priorEntitySet - Prior entity set which entitySet will be refreshed after.entitySet - Entity set to be refreshed after priorEntitySet.public void refreshCache(EntitySet entitySet, boolean onDemand)
Refresh the database with changes from the corresponding backend system (if applicable).
refreshCache in class EntityHandlerentitySet - Entity set to be refreshed.onDemand - true for on-demand refresh, false for scheduled refresh.public void updateEntity(EntityValue entity)
Handles the updating of an entity.
updateEntity in class EntityHandlerentity - Entity value.public void updateLink(EntityValue source, Property sourceProperty, EntityValue target)
Handles the updating of a link.
updateLink in class EntityHandlersource - Source entity.sourceProperty - Source property.target - Target entity.public void uploadMedia(EntityValue entity, ByteStream stream)
Handles the uploading of a media stream.
uploadMedia in class EntityHandlerentity - Owning media entity.stream - Input stream, to access uploaded content.public void uploadStream(EntityValue entity, StreamLink link, ByteStream stream)
Handles the uploading of a stream property.
uploadStream in class EntityHandlerentity - Owning entity.link - Stream link, identifying the stream property the client is uploading.stream - Input stream, to access uploaded content.