Interface CollectionResourceProvider
-
- All Known Implementing Classes:
DropwizardMetricsCollectionResourceProvider,MemoryBackend,ThingsResource,UserUpdateService
public interface CollectionResourceProviderAn implementation interface for resource providers which exposes a collection of resource instances. The resource collection supports the following operations:- action
- create - with an optional client provided resource ID as part of the request itself
- query
- action
- delete
- patch
- read
- update
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>actionCollection(Context context, ActionRequest request)Performs the providedactionagainst the resource collection.default Promise<ActionResponse,ResourceException>actionInstance(Context context, String resourceId, ActionRequest request)Performs the providedactionagainst a resource within the collection.default Promise<ResourceResponse,ResourceException>createInstance(Context context, CreateRequest request)Addsa new resource instance to the collection.default Promise<ResourceResponse,ResourceException>deleteInstance(Context context, String resourceId, DeleteRequest request)Removesa resource instance from the collection.default Promise<ResourceResponse,ResourceException>patchInstance(Context context, String resourceId, PatchRequest request)Patchesan existing resource within the collection.default Promise<QueryResponse,ResourceException>queryCollection(Context context, QueryRequest request, QueryResourceHandler handler)Searchesthe collection for all resources which match the query request criteria.default Promise<ResourceResponse,ResourceException>readInstance(Context context, String resourceId, ReadRequest request)Readsan existing resource within the collection.default Promise<ResourceResponse,ResourceException>updateInstance(Context context, String resourceId, UpdateRequest request)Updatesan existing resource within the collection.
-
-
-
Method Detail
-
actionCollection
default Promise<ActionResponse,ResourceException> actionCollection(Context context, ActionRequest request)
Performs the providedactionagainst the resource collection.- Parameters:
context- The request server context.request- The action request.- Returns:
- A
Promisecontaining the result of the operation. - See Also:
RequestHandler.handleAction(Context, ActionRequest)
-
actionInstance
default Promise<ActionResponse,ResourceException> actionInstance(Context context, String resourceId, ActionRequest request)
Performs the providedactionagainst a resource within the collection.- Parameters:
context- The request server context.resourceId- The ID of the targeted resource within the collection.request- The action request.- Returns:
- A
Promisecontaining the result of the operation. - See Also:
RequestHandler.handleAction(Context, ActionRequest)
-
createInstance
default Promise<ResourceResponse,ResourceException> createInstance(Context context, CreateRequest request)
Addsa new resource instance to the collection.Create requests are targeted at the collection itself and may include a user-provided resource ID for the new resource as part of the request itself. The user-provider resource ID may be accessed using the method
CreateRequest.getNewResourceId().- Parameters:
context- The request server context.request- The create request.- Returns:
- A
Promisecontaining the result of the operation. - See Also:
RequestHandler.handleCreate(Context, CreateRequest),CreateRequest.getNewResourceId()
-
deleteInstance
default Promise<ResourceResponse,ResourceException> deleteInstance(Context context, String resourceId, DeleteRequest request)
Removesa resource instance from the collection.- Parameters:
context- The request server context.resourceId- The ID of the targeted resource within the collection.request- The delete request.- Returns:
- A
Promisecontaining the result of the operation. - See Also:
RequestHandler.handleDelete(Context, DeleteRequest)
-
patchInstance
default Promise<ResourceResponse,ResourceException> patchInstance(Context context, String resourceId, PatchRequest request)
Patchesan existing resource within the collection.- Parameters:
context- The request server context.resourceId- The ID of the targeted resource within the collection.request- The patch request.- Returns:
- A
Promisecontaining the result of the operation. - See Also:
RequestHandler.handlePatch(Context, PatchRequest)
-
queryCollection
default Promise<QueryResponse,ResourceException> queryCollection(Context context, QueryRequest request, QueryResourceHandler handler)
Searchesthe collection for all resources which match the query request criteria.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).- Parameters:
context- The request server context.request- The query request.handler- The query resource handler to be notified for each matching resource.- Returns:
- A
Promisecontaining the result of the operation. - See Also:
RequestHandler.handleQuery(Context, QueryRequest, QueryResourceHandler)
-
readInstance
default Promise<ResourceResponse,ResourceException> readInstance(Context context, String resourceId, ReadRequest request)
Readsan existing resource within the collection.- Parameters:
context- The request server context.resourceId- The ID of the targeted resource within the collection.request- The read request.- Returns:
- A
Promisecontaining the result of the operation. - See Also:
RequestHandler.handleRead(Context, ReadRequest)
-
updateInstance
default Promise<ResourceResponse,ResourceException> updateInstance(Context context, String resourceId, UpdateRequest request)
Updatesan existing resource within the collection.- Parameters:
context- The request server context.resourceId- The ID of the targeted resource within the collection.request- The update request.- Returns:
- A
Promisecontaining the result of the operation. - See Also:
RequestHandler.handleUpdate(Context, UpdateRequest)
-
-