Interface Request

All Known Subinterfaces:
ActionRequest, CreateRequest, DeleteRequest, PatchRequest, QueryRequest, ReadRequest, UpdateRequest

public interface Request
Common attributes of all JSON resource requests.
  • Field Details

    • FIELD_ADDITIONAL_PARAMETERS

      static final String FIELD_ADDITIONAL_PARAMETERS
      The name of the field which contains the additional query parameters in the JSON representation.
      See Also:
    • FIELD_FIELDS

      static final String FIELD_FIELDS
      The name of the field which contains the fields in the JSON representation.
      See Also:
    • FIELD_VALUE_ALL

      static final String FIELD_VALUE_ALL
      The value of the fields request parameter to request all fields.
      See Also:
    • FIELD_RESOURCE_PATH

      static final String FIELD_RESOURCE_PATH
      The name of the field which contains the resource name in the JSON representation.
      See Also:
  • Method Details

    • accept

      <R, P> R accept(RequestVisitor<R,P> v, P p)
      Applies a RequestVisitor to this Request.
      Type Parameters:
      R - The return type of the visitor's methods.
      P - The type of the additional parameters to the visitor's methods.
      Parameters:
      v - The request visitor.
      p - Optional additional visitor parameter.
      Returns:
      A result as specified by the visitor.
    • addField

      Request addField(JsonPointer... fields)
      Adds one or more fields which should be included with each JSON resource returned by this request.
      Parameters:
      fields - The fields which should be included with each JSON resource returned by this request.
      Returns:
      This request.
      Throws:
      UnsupportedOperationException - If this request does not permit changes to the fields.
    • addField

      Request addField(String... fields)
      Adds one or more fields which should be included with each JSON resource returned by this request.
      Parameters:
      fields - The fields which should be included with each JSON resource returned by this request.
      Returns:
      This request.
      Throws:
      IllegalArgumentException - If one or more of the provided field identifiers could not be parsed as a JSON pointer.
      UnsupportedOperationException - If this request does not permit changes to the fields.
    • getAdditionalParameter

      String getAdditionalParameter(String name)
      Returns the additional parameter which should be used to control the behavior of this action request.
      Parameters:
      name - The name of the additional parameter.
      Returns:
      The additional parameter which should be used to control the behavior of this action request
    • getAdditionalParameters

      Map<String,String> getAdditionalParameters()
      Returns the additional parameters which should be used to control the behavior of this action request. The returned map may be modified if permitted by this action request.
      Returns:
      The additional parameters which should be used to control the behavior of this action request (never null).
    • getFields

      List<JsonPointer> getFields()
      Returns the list of fields which should be included with each JSON resource returned by this request. The returned list may be modified if permitted by this query request. An empty list indicates that all fields should be included.

      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.

      Returns:
      The list of fields which should be included with each JSON resource returned by this request (never null).
    • getPreferredLocales

      PreferredLocales getPreferredLocales()
      Get the locale preference for the request.
      Returns:
      The PreferredLocales instance for the request.
    • getRequestType

      RequestType getRequestType()
      Returns the type of this request.
      Returns:
      The type of this request.
    • getResourcePath

      String getResourcePath()
      Returns the non-null path of the JSON resource to which this request should be targeted. The resource path is relative and never begins or ends with a forward slash, but may be empty.

      NOTE: for resource provider implementations the resource path is relative to the current resource being accessed. See the description of UriRouterContext for more information.

      Returns:
      The non-null path of the JSON resource to which this request should be targeted, which may be the empty string.
    • getResourcePathObject

      ResourcePath getResourcePathObject()
      Returns the non-null path of the JSON resource to which this request should be targeted. The resource path is relative and never begins or ends with a forward slash, but may be empty.

      NOTE: for resource provider implementations the resource path is relative to the current resource being accessed. See the description of UriRouterContext for more information.

      Returns:
      The non-null path of the JSON resource to which this request should be targeted, which may be the empty string.
    • getResourceVersion

      Version getResourceVersion()
      Gets the requested API version of the resource.
      Returns:
      The requested API version of the resource.
    • setAdditionalParameter

      Request setAdditionalParameter(String name, String value) throws BadRequestException
      Sets an additional parameter which should be used to control the behavior of this action request.
      Parameters:
      name - The name of the additional parameter.
      value - The additional parameter's value.
      Returns:
      This request.
      Throws:
      BadRequestException - If this request does not permit the additional parameter to be set.
      UnsupportedOperationException - If this request does not permit changes to the additional parameters.
    • setPreferredLocales

      Request setPreferredLocales(PreferredLocales preferredLocales)
      Set the locale preference for the request.
      Parameters:
      preferredLocales - The PreferredLocales instance for the request.
      Returns:
      This request.
    • setResourcePath

      Request setResourcePath(String path)
      Sets the non-null path of the JSON resource to which this request should be targeted. The resource path is relative and never begins or ends with a forward slash, but may be empty.

      NOTE: for resource provider implementations the resource path is relative to the current resource being accessed. See the description of UriRouterContext for more information.

      Parameters:
      path - The non-null path of the JSON resource to which this request should be targeted, which may be the empty string. The path should be URL-encoded.
      Returns:
      This request.
      Throws:
      UnsupportedOperationException - If this request does not permit changes to the JSON resource path.
    • setResourcePath

      Request setResourcePath(ResourcePath path)
      Sets the non-null path of the JSON resource to which this request should be targeted. The resource path is relative and never begins or ends with a forward slash, but may be empty.

      NOTE: for resource provider implementations the resource path is relative to the current resource being accessed. See the description of UriRouterContext for more information.

      Parameters:
      path - The non-null path of the JSON resource to which this request should be targeted, which may be the empty string.
      Returns:
      This request.
      Throws:
      UnsupportedOperationException - If this request does not permit changes to the JSON resource path.
    • setResourceVersion

      Request setResourceVersion(Version resourceVersion)
      Sets the requested API version of the resource.
      Parameters:
      resourceVersion - The requested API version of the resource.
      Returns:
      This request.
    • toJsonValue

      JsonValue toJsonValue()
      Return a JsonValue representation of this request.
      Returns:
      this request as a JsonValue