public class RecordProvider extends Object implements CollectionResourceProvider
Usage example:
// Persists { "key" : [ 42 ] } and returns the server-created ID to use for future references
requestHandler.handleCreate(context, newCreateRequest("record", json(object(field("key", array(42))))))
.then((response) -> {
System.out.println("Created resource with ID: " + response.getId());
});
Constructor and Description |
---|
RecordProvider(RecordService service)
Creates a new resource provider delegating to the given
service for storage. |
Modifier and Type | Method and Description |
---|---|
Promise<ActionResponse,ResourceException> |
actionCollection(Context context,
ActionRequest request)
Performs the provided
action
against the resource collection. |
Promise<ActionResponse,ResourceException> |
actionInstance(Context context,
String resourceId,
ActionRequest request)
Performs the provided
action against a resource within the collection. |
Promise<ResourceResponse,ResourceException> |
createInstance(Context context,
CreateRequest request)
Adds a new resource instance to the collection. |
Promise<ResourceResponse,ResourceException> |
deleteInstance(Context context,
String resourceId,
DeleteRequest request)
Removes a resource instance from the collection. |
Promise<ResourceResponse,ResourceException> |
patchInstance(Context context,
String resourceId,
PatchRequest request)
Patches an existing resource within the collection. |
Promise<QueryResponse,ResourceException> |
queryCollection(Context context,
QueryRequest request,
QueryResourceHandler resourceHandler)
Searches the collection for all resources which match the query request
criteria. |
Promise<ResourceResponse,ResourceException> |
readInstance(Context context,
String resourceId,
ReadRequest request)
Reads an existing resource within the collection. |
Promise<ResourceResponse,ResourceException> |
updateInstance(Context context,
String resourceId,
UpdateRequest request)
Updates an existing resource within the collection. |
public RecordProvider(RecordService service)
service
for storage.service
- storage servicepublic Promise<ActionResponse,ResourceException> actionCollection(Context context, ActionRequest request)
CollectionResourceProvider
action
against the resource collection.actionCollection
in interface CollectionResourceProvider
context
- The request server context.request
- The action request.Promise
containing the result of the operation.RequestHandler.handleAction(Context, ActionRequest)
public Promise<ActionResponse,ResourceException> actionInstance(Context context, String resourceId, ActionRequest request)
CollectionResourceProvider
action
against a resource within the collection.actionInstance
in interface CollectionResourceProvider
context
- The request server context.resourceId
- The ID of the targeted resource within the collection.request
- The action request.Promise
containing the result of the operation.RequestHandler.handleAction(Context, ActionRequest)
public Promise<ResourceResponse,ResourceException> createInstance(Context context, CreateRequest request)
CollectionResourceProvider
Adds
a 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()
.
createInstance
in interface CollectionResourceProvider
context
- The request server context.request
- The create request.Promise
containing the result of the operation.RequestHandler.handleCreate(Context, CreateRequest)
,
CreateRequest.getNewResourceId()
public Promise<ResourceResponse,ResourceException> deleteInstance(Context context, String resourceId, DeleteRequest request)
CollectionResourceProvider
Removes
a resource instance from the collection.deleteInstance
in interface CollectionResourceProvider
context
- The request server context.resourceId
- The ID of the targeted resource within the collection.request
- The delete request.Promise
containing the result of the operation.RequestHandler.handleDelete(Context, DeleteRequest)
public Promise<ResourceResponse,ResourceException> patchInstance(Context context, String resourceId, PatchRequest request)
CollectionResourceProvider
Patches
an existing resource within the collection.patchInstance
in interface CollectionResourceProvider
context
- The request server context.resourceId
- The ID of the targeted resource within the collection.request
- The patch request.Promise
containing the result of the operation.RequestHandler.handlePatch(Context, PatchRequest)
public Promise<QueryResponse,ResourceException> queryCollection(Context context, QueryRequest request, QueryResourceHandler resourceHandler)
CollectionResourceProvider
Searches
the 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 a
QueryResponse
if the query has completed successfully, or
ResourceException
if the query did not complete successfully
(even if some matching resources were returned).
queryCollection
in interface CollectionResourceProvider
context
- The request server context.request
- The query request.resourceHandler
- The query resource handler to be notified for each matching
resource.Promise
containing the result of the operation.RequestHandler.handleQuery(Context, QueryRequest, QueryResourceHandler)
public Promise<ResourceResponse,ResourceException> readInstance(Context context, String resourceId, ReadRequest request)
CollectionResourceProvider
Reads
an existing resource within the collection.readInstance
in interface CollectionResourceProvider
context
- The request server context.resourceId
- The ID of the targeted resource within the collection.request
- The read request.Promise
containing the result of the operation.RequestHandler.handleRead(Context, ReadRequest)
public Promise<ResourceResponse,ResourceException> updateInstance(Context context, String resourceId, UpdateRequest request)
CollectionResourceProvider
Updates
an existing resource within the collection.updateInstance
in interface CollectionResourceProvider
context
- The request server context.resourceId
- The ID of the targeted resource within the collection.request
- The update request.Promise
containing the result of the operation.RequestHandler.handleUpdate(Context, UpdateRequest)
Copyright 2011-2017 ForgeRock AS.