Class AbstractRequestHandler

java.lang.Object
org.forgerock.json.resource.AbstractRequestHandler
All Implemented Interfaces:
RequestHandler

public abstract class AbstractRequestHandler extends Object implements RequestHandler
An abstract base class from which request handlersmay be easily implemented. The default implementation of each method is to return a NotSupportedException.
  • Constructor Details

  • Method Details

    • handleAction

      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 returned Promise must be completed with the exception.

      Action expects failure exceptions as follows: ForbiddenException if access to the resource is forbidden. NotSupportedException if the requested functionality is not implemented/supported BadRequestException if the passed identifier, parameters or filter is invalid NotFoundException if the specified resource could not be found.

      The default implementation is to return a NotSupportedException.

      Specified by:
      handleAction in interface RequestHandler
      Parameters:
      context - The request server context, such as associated principal.
      request - The action request.
      Returns:
      A Promise containing the result of the operation.
    • handleCreate

      Adds a new JSON resource, returning a Promise that will be completed when the resource has been added.

      Create expects failure exceptions as follows:

      • ForbiddenException if access to the resource is forbidden.
      • NotSupportedException if the requested functionality is not implemented/supported
      • PreconditionFailedException if a resource with the same ID already exists
      • BadRequestException if the passed identifier or value is invalid
      • NotFoundException if the specified id could not be resolved, for example when an intermediate resource in the hierarchy does not exist.

      The default implementation is to return a NotSupportedException.

      Specified by:
      handleCreate in interface RequestHandler
      Parameters:
      context - The request server context, such as associated principal.
      request - The create request.
      Returns:
      A Promise containing the result of the operation.
    • handleDelete

      Deletes a JSON resource, returning a Promise that will be completed when the resource has been deleted.

      Delete expects failure exceptions as follows:

      • ForbiddenException if access to the resource is forbidden
      • NotSupportedException if the requested functionality is not implemented/supported
      • BadRequestException if the passed identifier is invalid
      • NotFoundException if the specified resource could not be found
      • PreconditionRequiredException if version is required, but is null
      • PreconditionFailedException if version did not match the existing resource.

      The default implementation is to return a NotSupportedException.

      Specified by:
      handleDelete in interface RequestHandler
      Parameters:
      context - The request server context, such as associated principal.
      request - The delete request.
      Returns:
      A Promise containing the result of the operation.
    • handlePatch

      Updates a JSON resource by applying a set of changes to its existing content, returning a Promise that will be completed when the resource has been updated.

      Patch expects failure exceptions as follows:

      • ForbiddenException if access to the resource is forbidden
      • NotSupportedException if the requested functionality is not implemented/supported
      • PreconditionRequiredException if version is required, but is null
      • PreconditionFailedException if version did not match the existing resource
      • BadRequestException if the passed identifier or filter is invalid
      • NotFoundException if the specified resource could not be found
      • ConflictException if patch could not be applied for the given resource state.

      The default implementation is to return a NotSupportedException.

      Specified by:
      handlePatch in interface RequestHandler
      Parameters:
      context - The request server context, such as associated principal.
      request - The patch request.
      Returns:
      A Promise containing the result of the operation.
    • handleQuery

      Searches for all JSON resources matching a user specified set of criteria, returning a Promise that 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 a QueryResponse if the query has completed successfully, or ResourceException if the query did not complete successfully (even if some matching resources were returned).

      Query expects failure exceptions as follows:

      • ForbiddenException if access to the resource is forbidden
      • NotSupportedException if the requested functionality is not implemented/supported
      • BadRequestException if the passed identifier, parameters or filter is invalid
      • NotFoundException if the specified resource could not be found

      The default implementation is to return a NotSupportedException.

      Specified by:
      handleQuery in interface RequestHandler
      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 Promise containing the result of the operation.
    • handleRead

      Reads a JSON resource, returning a Promise that will be completed when the resource has been read.

      Read expects failure exceptions as follows:

      • ForbiddenException if access to the resource is forbidden.
      • NotSupportedException if the requested functionality is not implemented/supported
      • BadRequestException if the passed identifier or filter is invalid
      • NotFoundException if the specified resource could not be found.

      The default implementation is to return a NotSupportedException.

      Specified by:
      handleRead in interface RequestHandler
      Parameters:
      context - The request server context, such as associated principal.
      request - The read request.
      Returns:
      A Promise containing the result of the operation.
    • handleUpdate

      Updates a JSON resource by replacing its existing content with new content, returning a Promise that will be completed when the resource has been updated.

      Update expects failure the following failure exceptions:

      • ForbiddenException if access to the resource is forbidden
      • NotSupportedException if the requested functionality is not implemented/supported
      • PreconditionRequiredException if version is required, but is null
      • PreconditionFailedException if version did not match the existing resource
      • BadRequestException if the passed identifier or filter is invalid
      • NotFoundException if the specified resource could not be found.

      The default implementation is to return a NotSupportedException.

      Specified by:
      handleUpdate in interface RequestHandler
      Parameters:
      context - The request server context, such as associated principal.
      request - The update request.
      Returns:
      A Promise containing the result of the operation.