public interface EntityRESTProvider
| Modifier and Type | Method and Description |
|---|---|
Map<String,Object> |
decodeData(String data,
String format)
Decode a string of a specified format into a java map of simple objects
Returned map can be fed into #populate(Object, Map) if you want to convert it
into a known object type Types are likely to require conversion as guesses are made about the right formats, use of the #convert(Object, Class) method is recommended |
String |
encodeData(Object data,
String format,
String name,
Map<String,Object> properties)
Encode data into a given format, can handle any java object,
note that unsupported formats and invalid data will result in an exception
|
void |
formatAndOutputEntity(EntityReference ref,
String format,
List<EntityData> entities,
OutputStream outputStream,
Map<String,Object> params)
Format and output an entity or collection included or referred to by this entity ref object
into output according to the format string provided,
Should take into account the reference when determining what the entities are
and how to encode them
(This is basically a copy of the code in EntityHandlerImpl with stuff removed)
|
ActionReturn |
handleCustomActionExecution(ActionsExecutable actionProvider,
EntityReference ref,
String action,
Map<String,Object> actionParams,
OutputStream outputStream,
EntityView view,
Map<String,Object> searchParams)
This will execute a custom action for an entity or space/collection of entities
This is meant for specialized usage as custom actions are typically meant to be executed by REST calls only |
EntityResponse |
handleEntityRequest(String reference,
String viewKey,
String format,
Map<String,String> params,
Object entity)
Processes and handles an entity request without requiring servlet processing
and a request/response round trip
|
Object |
translateInputToEntity(EntityReference ref,
String format,
InputStream inputStream,
Map<String,Object> params)
Translates the input data stream in the supplied format into an entity object for this reference
|
EntityResponse handleEntityRequest(String reference, String viewKey, String format, Map<String,String> params, Object entity)
reference - a globally unique reference to an entity,
consists of the entity prefix and optionally the local id,
cannot be null or emptyviewKey - specifies what kind of request this is (create, read/show, etc.),
must correspond to the VIEW constants in EntityView, example: EntityView.VIEW_SHOWformat - (optional) this is the format for this request (from Formats, e.g. XML),
if nothing is specified then the default will be used: Formats.HTMLparams - (optional) any params you want to send along with the request should
be included here, they will be placed into the query string or the request body
depending on the type of request this isentity - (optional) leave this null in most cases,
if you supply an entity object here it will be encoded based on the supplied format
(only if the entity supports output formatting) and then decoded on the other end
(only if the entity supports input translation), in most cases it is better to supply
the entity values in the paramsIllegalArgumentException - if the inputs are invalidRuntimeException - if the http request has an unrecoverable failure or an encoding failure occursvoid formatAndOutputEntity(EntityReference ref, String format, List<EntityData> entities, OutputStream outputStream, Map<String,Object> params)
ref - a globally unique reference to an entity,
consists of the entity prefix and optional segmentsformat - a string constant indicating the format (from Formats)
for output, (example: #XML)entities - (optional) a list of entities to create formatted output for,
if this is null then the entities should be retrieved based on the reference,
if this contains only a single item AND the ref refers to a single entity
then the entity should be extracted from the list and encoded without the indication
that it is a collection, for all other cases the encoding should include an indication that
this is a list of entitiesoutputStream - the output stream to place the formatted data in,
should be UTF-8 encoded if there is char dataFormatUnsupportedException - if you do not handle this format type (passes control to the internal handlers)EntityEncodingException - if you cannot encode the received data into an entityIllegalArgumentException - if any of the arguments are invalidIllegalStateException - for all other failuresObject translateInputToEntity(EntityReference ref, String format, InputStream inputStream, Map<String,Object> params)
ref - a globally unique reference to an entity,
consists of the entity prefix and optional segmentsformat - a string constant indicating the format (from Formats)
of the input, (example: #XML)input - a stream which contains the data to make up this entity,
you may assume this is UTF-8 encoded if you don't know anything else about itFormatUnsupportedException - if you do not handle this format type (passes control to the internal handlers)EntityEncodingException - if you cannot encode the received data into an entityIllegalArgumentException - if any of the arguments are invalidIllegalStateException - for all other failuresActionReturn handleCustomActionExecution(ActionsExecutable actionProvider, EntityReference ref, String action, Map<String,Object> actionParams, OutputStream outputStream, EntityView view, Map<String,Object> searchParams)
actionProvider - the action provider which has declared itself as the handler for this action and prefixref - a globally unique reference to an entity,
consists of the entity prefix and optional segmentsaction - key which will be used to trigger the action (e.g. promote, double, photo),
can be triggered by a URL like so: /user/aaronz/promoteactionParams - (optional) an optional set of params to pass along with this custom action request,
typically used to provide information about the request, may be left null if not neededoutputStream - (optional) an OutputStream to place binary or long text data into,
if this is used for binary data then the ActionReturn should be returned with the correct encoding information
and the output variable set to the OutputStream, may be left null if this custom action does not deal with binary streamsview - the entity view corresponding to all data sent in the URL for this action viewsearchParams - any search params which were included in the requestActionReturn which contains entity data or binary/string data OR null if there is no return for this actionUnsupportedOperationException - if there is no action with this key for this entityIllegalArgumentException - if there are required params that are missing or invalidIllegalStateException - if the action cannot be performed for some reasonString encodeData(Object data, String format, String name, Map<String,Object> properties)
data - the data to encodeformat - the format to use for output (from Formats)name - (optional) the name to use for the encoded data (e.g. root node for XML)properties - (optional) extra properties to add into the encoding, ignored if encoded object is not a map or beanUnsupportedOperationException - if the data cannot be encodedIllegalArgumentException - if the format requested cannot be encoded because there is no encoderMap<String,Object> decodeData(String data, String format)
#populate(Object, Map) if you want to convert it
into a known object type #convert(Object, Class) method is recommended data - encoded dataformat - the format of the encoded data (from Formats)UnsupportedOperationException - if the data cannot be decodedIllegalArgumentException - if the data cannot be decoded because there is no decoder for that formatCopyright © 2003–2021 Sakai Project. All rights reserved.