Class CDORestRequest

java.lang.Object
org.eclipse.emf.cdo.server.rest.CDORestRequest

public final class CDORestRequest extends Object
Describes one HTTP request at the transport-neutral REST service boundary. The path is the raw encoded path relative to the adapter's configured mount point; the query string remains in its encoded HTTP form so that the service can reject malformed escapes consistently. Request headers are copied into an immutable, case-insensitive map so transport-neutral extensions can inspect the original HTTP request metadata.
Author:
Eike Stepper
  • Constructor Details

    • CDORestRequest

      public CDORestRequest(String method, String path, String queryString, String contentType, InputStream body)
      Creates a request description for a single service invocation.
      Parameters:
      method - the HTTP method, such as GET or POST; it is normalized to upper case
      path - the raw encoded path relative to the service mount, beginning with a slash
      queryString - the raw query string, or null when no query was supplied
      contentType - the request media type, or null when the request has no body
      body - the body stream, or null when the request has no body
    • CDORestRequest

      public CDORestRequest(String method, String path, String queryString, String contentType, InputStream body, Map<String, ? extends List<String>> headers)
      Creates a request description including its HTTP headers.

      Header names are matched without regard to case, and both the map and its value lists are copied and made immutable. Header values are retained in their supplied order. Header metadata is untrusted unless an authenticator validates it.

      Parameters:
      method - the HTTP method, such as GET or POST; it is normalized to upper case
      path - the raw encoded path relative to the service mount, beginning with a slash
      queryString - the raw query string, or null when no query was supplied
      contentType - the request media type, or null when the request has no body
      body - the body stream, or null when the request has no body
      headers - the HTTP header names and values supplied by the transport
      Throws:
      NullPointerException - if a required request field, header name, or header value list is null
    • CDORestRequest

      public CDORestRequest(String method, String path, String queryString, String contentType, InputStream body, Map<String, ? extends List<String>> headers, Principal principal)
      Creates a request description including headers and a principal asserted by a trusted transport integration.

      The principal must come from a transport's standard authenticated-principal mechanism, such as a Jakarta Servlet container. A header that merely names a user must never be supplied as this value.

      Parameters:
      method - the HTTP method, such as GET or POST; it is normalized to upper case
      path - the raw encoded path relative to the service mount, beginning with a slash
      queryString - the raw query string, or null when no query was supplied
      contentType - the request media type, or null when the request has no body
      body - the body stream, or null when the request has no body
      headers - the HTTP header names and values supplied by the transport
      principal - an optional principal supplied by a trusted transport, or null
      Throws:
      NullPointerException - if a required request field, header name, or header value list is null
  • Method Details

    • getMethod

      public String getMethod()
      Returns the normalized HTTP method used for route selection.
      Returns:
      the upper-case HTTP method
    • getPath

      public String getPath()
      Returns the raw encoded path relative to the configured mount point.
      Returns:
      a path beginning with a slash
    • getQueryString

      public String getQueryString()
      Returns the raw encoded query string so the REST service can apply consistent validation and decoding.
      Returns:
      the query string, or null when absent
    • getContentType

      public String getContentType()
      Returns the media type supplied by the caller.
      Returns:
      the content type, or null when absent
    • getHeaders

      public Map<String, List<String>> getHeaders()
      Returns an immutable copy of all supplied HTTP headers. The returned map uses case-insensitive header-name lookup.
      Returns:
      an immutable map from header names to their ordered values
    • getPrincipal

      public Principal getPrincipal()
      Returns the optional principal supplied by a trusted transport integration.
      Returns:
      the trusted principal, or null when the transport has not asserted one
    • getHeaderValues

      public List<String> getHeaderValues(String name)
      Returns the values of one supplied HTTP header, matching its name without regard to case.
      Parameters:
      name - the header name to find
      Returns:
      the ordered header values, or an empty list if the header was not supplied
      Throws:
      NullPointerException - if name is null
    • getBody

      public InputStream getBody()
      Returns the caller-owned request body stream. The service reads at most its configured request-size limit and does not close the stream.
      Returns:
      the request body, or null when absent