Interface RequestHandler
-
- All Known Implementing Classes:
AbstractRequestHandler,AnonymousProcessService,DescribedSyncRequestHandlerAdapter,FilterChain,Router
public interface RequestHandlerRepresents the contract with a set of resources.The structure and depth of the (potentially nested) resource set it deals with is up to the implementation. It can choose to just deal with one level, and hand off to another resource implementation, or it can choose to handle multiple levels.
As an example, taking an id of level1/level2/leaf, and assuming that the resource implementation registers to handle level1 with the router; the implementation could choose to hand off processing to other implementations for level2 (or leaf) or it could handle all operations down to leaf.
Supports either synchronous or asynchronous internal processing, i.e. it does not have to block the request thread until a response becomes available.
For synchronous internal processing, immediately return a completed
Promise, e.g.return Promises.newResultPromise(result);
NOTE: field filtering alters the structure of a JSON resource and MUST only be performed once while processing a request. It is therefore the responsibility of front-end implementations (e.g. HTTP listeners, Servlets, etc) to perform field filtering. Request handler and resource provider implementations SHOULD NOT filter fields, but MAY choose to optimise their processing in order to return a resource containing only the fields targeted by the field filters.
-
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default Promise<ActionResponse,ResourceException>handleAction(Context context, ActionRequest request)Handles performing an action on a resource, and optionally returns an associated result.default Promise<ResourceResponse,ResourceException>handleCreate(Context context, CreateRequest request)Adds a new JSON resource, returning aPromisethat will be completed when the resource has been added.default Promise<ResourceResponse,ResourceException>handleDelete(Context context, DeleteRequest request)Deletes a JSON resource, returning aPromisethat will be completed when the resource has been deleted.default Promise<ResourceResponse,ResourceException>handlePatch(Context context, PatchRequest request)Updates a JSON resource by applying a set of changes to its existing content, returning aPromisethat will be completed when the resource has been updated.default Promise<QueryResponse,ResourceException>handleQuery(Context context, QueryRequest request, QueryResourceHandler handler)Searches for all JSON resources matching a user specified set of criteria, returning aPromisethat will be completed when the search has completed.default Promise<ResourceResponse,ResourceException>handleRead(Context context, ReadRequest request)Reads a JSON resource, returning aPromisethat will be completed when the resource has been read.default Promise<ResourceResponse,ResourceException>handleUpdate(Context context, UpdateRequest request)Updates a JSON resource by replacing its existing content with new content, returning aPromisethat will be completed when the resource has been updated.
-
-
-
Method Detail
-
handleAction
default Promise<ActionResponse,ResourceException> handleAction(Context context, ActionRequest request)
Handles performing an action on a resource, and optionally returns an associated result. The execution of an action is allowed to incur side effects.Actions are parametric; a set of named parameters is provided as input to the action. The action result is a JSON object structure composed of basic Java types; its overall structure is defined by a specific implementation.
On completion, the action result (or null) must be used to complete the returned
Promise. On failure, the returnedPromisemust be completed with the exception.Action expects failure exceptions as follows:
ForbiddenExceptionif access to the resource is forbidden.NotSupportedExceptionif the requested functionality is not implemented/supportedBadRequestExceptionif the passed identifier, parameters or filter is invalidNotFoundExceptionif the specified resource could not be found.- Parameters:
context- The request server context, such as associated principal.request- The action request.- Returns:
- A
Promisecontaining the result of the operation.
-
handleCreate
default Promise<ResourceResponse,ResourceException> handleCreate(Context context, CreateRequest request)
Adds a new JSON resource, returning aPromisethat will be completed when the resource has been added.Create expects failure exceptions as follows:
CreateNotSupportedExceptionif create is not implemented or supported by the RequestHandler.ForbiddenExceptionif access to the resource is forbidden.NotSupportedExceptionif the requested functionality is not implemented/supportedPreconditionFailedExceptionif a resource with the same ID already existsBadRequestExceptionif the passed identifier or value is invalidNotFoundExceptionif the specified id could not be resolved, for example when an intermediate resource in the hierarchy does not exist.
- Parameters:
context- The request server context, such as associated principal.request- The create request.- Returns:
- A
Promisecontaining the result of the operation.
-
handleDelete
default Promise<ResourceResponse,ResourceException> handleDelete(Context context, DeleteRequest request)
Deletes a JSON resource, returning aPromisethat will be completed when the resource has been deleted.Delete expects failure exceptions as follows:
ForbiddenExceptionif access to the resource is forbiddenNotSupportedExceptionif the requested functionality is not implemented/supportedBadRequestExceptionif the passed identifier is invalidNotFoundExceptionif the specified resource could not be foundPreconditionRequiredExceptionif version is required, but isnullPreconditionFailedExceptionif version did not match the existing resource.
- Parameters:
context- The request server context, such as associated principal.request- The delete request.- Returns:
- A
Promisecontaining the result of the operation.
-
handlePatch
default Promise<ResourceResponse,ResourceException> handlePatch(Context context, PatchRequest request)
Updates a JSON resource by applying a set of changes to its existing content, returning aPromisethat will be completed when the resource has been updated.Patch expects failure exceptions as follows:
ForbiddenExceptionif access to the resource is forbiddenNotSupportedExceptionif the requested functionality is not implemented/supportedPreconditionRequiredExceptionif version is required, but isnullPreconditionFailedExceptionif version did not match the existing resourceBadRequestExceptionif the passed identifier or filter is invalidNotFoundExceptionif the specified resource could not be foundConflictExceptionif patch could not be applied for the given resource state.
- Parameters:
context- The request server context, such as associated principal.request- The patch request.- Returns:
- A
Promisecontaining the result of the operation.
-
handleQuery
default Promise<QueryResponse,ResourceException> handleQuery(Context context, QueryRequest request, QueryResourceHandler handler)
Searches for all JSON resources matching a user specified set of criteria, returning aPromisethat will be completed when the search has completed.Implementations must invoke
QueryResourceHandler.handleResource(ResourceResponse)for each resource which matches the query criteria. Once all matching resources have been returned implementations are required to return either aQueryResponseif the query has completed successfully, orResourceExceptionif the query did not complete successfully (even if some matching resources were returned).Query expects failure exceptions as follows:
ForbiddenExceptionif access to the resource is forbiddenNotSupportedExceptionif the requested functionality is not implemented/supportedBadRequestExceptionif the passed identifier, parameters or filter is invalidNotFoundExceptionif the specified resource could not be found
- Parameters:
context- The request server context, such as associated principal.request- The query request.handler- The query resource handler to be notified for each matching resource.- Returns:
- A
Promisecontaining the result of the operation.
-
handleRead
default Promise<ResourceResponse,ResourceException> handleRead(Context context, ReadRequest request)
Reads a JSON resource, returning aPromisethat will be completed when the resource has been read.Read expects failure exceptions as follows:
ForbiddenExceptionif access to the resource is forbidden.NotSupportedExceptionif the requested functionality is not implemented/supportedBadRequestExceptionif the passed identifier or filter is invalidNotFoundExceptionif the specified resource could not be found.
- Parameters:
context- The request server context, such as associated principal.request- The read request.- Returns:
- A
Promisecontaining the result of the operation.
-
handleUpdate
default Promise<ResourceResponse,ResourceException> handleUpdate(Context context, UpdateRequest request)
Updates a JSON resource by replacing its existing content with new content, returning aPromisethat will be completed when the resource has been updated.Update expects failure the following failure exceptions:
ForbiddenExceptionif access to the resource is forbiddenNotSupportedExceptionif the requested functionality is not implemented/supportedPreconditionRequiredExceptionif version is required, but isnullPreconditionFailedExceptionif version did not match the existing resourceBadRequestExceptionif the passed identifier or filter is invalidNotFoundExceptionif the specified resource could not be found.
- Parameters:
context- The request server context, such as associated principal.request- The update request.- Returns:
- A
Promisecontaining the result of the operation.
-
-