Package org.forgerock.openig.ui.record
Class RecordProvider
- java.lang.Object
-
- org.forgerock.openig.ui.record.RecordProvider
-
- All Implemented Interfaces:
CollectionResourceProvider
public class RecordProvider extends Object implements CollectionResourceProvider
CREST collection service dedicated to persist JSON objects (other types are not supported: arrays, primitives, and null).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 Summary
Constructors Constructor Description RecordProvider(RecordService service)
Creates a new resource provider delegating to the givenservice
for storage.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Promise<ActionResponse,ResourceException>
actionCollection(Context context, ActionRequest request)
Performs the providedaction
against the resource collection.Promise<ActionResponse,ResourceException>
actionInstance(Context context, String resourceId, ActionRequest request)
Performs the providedaction
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.
-
-
-
Constructor Detail
-
RecordProvider
public RecordProvider(RecordService service)
Creates a new resource provider delegating to the givenservice
for storage.- Parameters:
service
- storage service
-
-
Method Detail
-
actionCollection
public Promise<ActionResponse,ResourceException> actionCollection(Context context, ActionRequest request)
Description copied from interface:CollectionResourceProvider
Performs the providedaction
against the resource collection.- Specified by:
actionCollection
in interfaceCollectionResourceProvider
- Parameters:
context
- The request server context.request
- The action request.- Returns:
- A
Promise
containing the result of the operation. - See Also:
RequestHandler.handleAction(Context, ActionRequest)
-
actionInstance
public Promise<ActionResponse,ResourceException> actionInstance(Context context, String resourceId, ActionRequest request)
Description copied from interface:CollectionResourceProvider
Performs the providedaction
against a resource within the collection.- Specified by:
actionInstance
in interfaceCollectionResourceProvider
- Parameters:
context
- The request server context.resourceId
- The ID of the targeted resource within the collection.request
- The action request.- Returns:
- A
Promise
containing the result of the operation. - See Also:
RequestHandler.handleAction(Context, ActionRequest)
-
createInstance
public Promise<ResourceResponse,ResourceException> createInstance(Context context, CreateRequest request)
Description copied from interface: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()
.- Specified by:
createInstance
in interfaceCollectionResourceProvider
- Parameters:
context
- The request server context.request
- The create request.- Returns:
- A
Promise
containing the result of the operation. - See Also:
RequestHandler.handleCreate(Context, CreateRequest)
,CreateRequest.getNewResourceId()
-
deleteInstance
public Promise<ResourceResponse,ResourceException> deleteInstance(Context context, String resourceId, DeleteRequest request)
Description copied from interface:CollectionResourceProvider
Removes
a resource instance from the collection.- Specified by:
deleteInstance
in interfaceCollectionResourceProvider
- Parameters:
context
- The request server context.resourceId
- The ID of the targeted resource within the collection.request
- The delete request.- Returns:
- A
Promise
containing the result of the operation. - See Also:
RequestHandler.handleDelete(Context, DeleteRequest)
-
patchInstance
public Promise<ResourceResponse,ResourceException> patchInstance(Context context, String resourceId, PatchRequest request)
Description copied from interface:CollectionResourceProvider
Patches
an existing resource within the collection.- Specified by:
patchInstance
in interfaceCollectionResourceProvider
- Parameters:
context
- The request server context.resourceId
- The ID of the targeted resource within the collection.request
- The patch request.- Returns:
- A
Promise
containing the result of the operation. - See Also:
RequestHandler.handlePatch(Context, PatchRequest)
-
queryCollection
public Promise<QueryResponse,ResourceException> queryCollection(Context context, QueryRequest request, QueryResourceHandler resourceHandler)
Description copied from interface: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 aQueryResponse
if the query has completed successfully, orResourceException
if the query did not complete successfully (even if some matching resources were returned).- Specified by:
queryCollection
in interfaceCollectionResourceProvider
- Parameters:
context
- The request server context.request
- The query request.resourceHandler
- The query resource handler to be notified for each matching resource.- Returns:
- A
Promise
containing the result of the operation. - See Also:
RequestHandler.handleQuery(Context, QueryRequest, QueryResourceHandler)
-
readInstance
public Promise<ResourceResponse,ResourceException> readInstance(Context context, String resourceId, ReadRequest request)
Description copied from interface:CollectionResourceProvider
Reads
an existing resource within the collection.- Specified by:
readInstance
in interfaceCollectionResourceProvider
- Parameters:
context
- The request server context.resourceId
- The ID of the targeted resource within the collection.request
- The read request.- Returns:
- A
Promise
containing the result of the operation. - See Also:
RequestHandler.handleRead(Context, ReadRequest)
-
updateInstance
public Promise<ResourceResponse,ResourceException> updateInstance(Context context, String resourceId, UpdateRequest request)
Description copied from interface:CollectionResourceProvider
Updates
an existing resource within the collection.- Specified by:
updateInstance
in interfaceCollectionResourceProvider
- Parameters:
context
- The request server context.resourceId
- The ID of the targeted resource within the collection.request
- The update request.- Returns:
- A
Promise
containing the result of the operation. - See Also:
RequestHandler.handleUpdate(Context, UpdateRequest)
-
-