Class ConfigContexts

java.lang.Object
com.sodius.oslc.server.config.ConfigContexts

public class ConfigContexts extends Object
Determines the configuration context of a request. The configuration context controls which version of a resource is desired. The context may be empty, in which case the request is not made for a particular configuration and it's up to the server to determine which version of the resource to return
Since:
3.0.0
  • Method Details

    • of

      public static ConfigContext of(HttpServletRequest request, HttpServletResponse response)
      Creates a context as specified in the provided servlet request.

      The configuration can be set in one of two ways:

      • Using an oslc_config.context query parameter.
        The configuration URI is expected to be angle bracket-delimited (e.g. <http://myServer.myConfiguration>)
         
      • Using a Configuration-Context header.
        In this case this method adds a Vary=Configuration-Context header in the servlet response, so that the client does not cache the request based only on the request URL.
      Parameters:
      request - the servlet request.
      response - the servlet response.
      Returns:
      the configuration context wrapping the configuration specified in the request, or an empty context if not configuration is set.
      Throws:
      WebApplicationException - if the configuration set is not a valid URI or if both oslc_config.context query parameter and Configuration-Context header are referencing different configurations.
    • of

      public static ConfigContext of(HttpServletRequest request)
      Equivalent to of(HttpServletRequest, HttpServletResponse) but without support to set the Vary header.

      Callers must prefer to use the overload with the response when available so the clients do not cache the request.

      Parameters:
      request - the servlet request.
      Returns:
      the configuration context wrapping the configuration specified in the request, or an empty context if not configuration is set.
      Throws:
      WebApplicationException - if the configuration set is not a valid URI or if both oslc_config.context query parameter and Configuration-Context header are referencing different configurations.
      Since:
      4.0.0