Class WebResourceUri


  • public class WebResourceUri
    extends Object
    URI of the current web resource, that is the web resource being in execution and whose execution was triggered by an incoming HTTP request; the request URI. It is defined to replace the use of UriInfo as it takes care of the Silverpeas settings in regard to the URL, host and web context definitions and as it is dedicated to compute more easily the URI of the Web entities involved by the incoming HTTP requests.

    The different properties of such a running web resource URI are explained by an example here. For the following request URI:

    http://localhost:8000/silverpeas/services/toto/kmelia32/content/bidule?p=3&u=10
    • The base URI is http://localhost:8000/silverpeas/services
    • The request URI is http://localhost:8000/silverpeas/services/toto/kmelia32/content/bidule?p=3&u=10
    • The absolute web resource path is http://localhost:8000/silverpeas/services/toto/kmelia32
    • The web resource path is /silverpeas/services/toto/kmelia32
    • The absolute path is http://localhost:8000/silverpeas/services/toto/kmelia32/content/bidule
    • The path is /silverpeas/services/toto/kmelia32/content/bidule
    • The query parameters are taken from the parsing of ?p=3&u=10
    • The path parameters are all nodes in the URI that matches with an parameter in the Path annotations of the web resource
    Author:
    mmoquillon
    • Constructor Detail

      • WebResourceUri

        public WebResourceUri​(String webResourcePath,
                              javax.servlet.http.HttpServletRequest request,
                              javax.ws.rs.core.UriInfo uriInfo)
      • WebResourceUri

        public WebResourceUri​(String webResourcePath,
                              javax.servlet.http.HttpServletRequest request)
    • Method Detail

      • getHttpRequest

        public javax.servlet.http.HttpServletRequest getHttpRequest()
        Gets the current HTTP request targeting this URI.
        Returns:
        the current HTTP request
      • getWebResourcePath

        public URI getWebResourcePath()
        Gets the base path of the current web resource relative to the root path of the Silverpeas URI. If the web resource targeted by the current request is related to a given component instance, then the identifier of the component instance is also referred in the returned path. All sequences of escaped octets are decoded.
        Returns:
        the base path of the requested web resource.
      • getWebResourcePathBuilder

        public javax.ws.rs.core.UriBuilder getWebResourcePathBuilder()
        Gets the path of the current web resource relative to the root path of the Silverpeas URI in the form of a UriBuilder. If the web resource targeted by the current request is related to a given component instance, then the identifier of the component instance is also referred in the returned path.

        The returned UriBuilder gives possibility to enrich the path to build a customized URI for a web entity.

        Returns:
        the UriBuilder initialized with the base path of the requested web resource.
      • getAbsoluteWebResourcePath

        public URI getAbsoluteWebResourcePath()
        Gets the absolute base path of the current web resource. This includes everything preceding the path (host, port, etc). If the web resource targeted by the current request is related to a given component instance, then the identifier of the component instance is also referred in the returned path. All sequences of escaped octets are decoded.
        Returns:
        the absolute base path of the requested web resource.
      • getAbsoluteWebResourcePathBuilder

        public javax.ws.rs.core.UriBuilder getAbsoluteWebResourcePathBuilder()
        Gets the absolute path of the current web resource in the form of a UriBuilder. This includes everything preceding the path (host, port, etc). If the web resource targeted by the current request is related to a given component instance, then the identifier of the component instance is also referred in the returned path.

        The returned UriBuilder gives possibility to enrich the path to build a customized URI for a web entity.

        Returns:
        the UriBuilder initialized with the absolute base path of the requested web resource.
      • getPath

        public URI getPath()
        Gets the path of the current request relative to the root path of the Silverpeas URI. All sequences of escaped octets are decoded.
        Returns:
        the path of the requested URI.
      • getPathBuilder

        public javax.ws.rs.core.UriBuilder getPathBuilder()
        Gets the path of the current request relative to the root path of the Silverpeas URI in the form of a UriBuilder.

        The returned UriBuilder gives possibility to enrich the path to build a customized URI for a web entity.

        Returns:
        the UriBuilder initialized with the path of the requested URI.
      • getRequestUri

        public URI getRequestUri()
        Get the absolute request URI including any query parameters. It takes into account the Silverpeas settings about the application host and context definition.
        Returns:
        the absolute request URI.
      • getRequestUriBuilder

        public javax.ws.rs.core.UriBuilder getRequestUriBuilder()
        Get the absolute request URI including any query parameters in the form of a UriBuilder. It takes into account the Silverpeas settings about the application host and context definition.

        The returned UriBuilder gives possibility to enrich the path to build a customized URI for a web entity.

        Returns:
        the UriBuilder initialized with the absolute request URI.
      • getAbsolutePath

        public URI getAbsolutePath()
        Get the absolute path of the request. This includes everything preceding the path (host, port etc.) but excludes query parameters.
        Returns:
        the absolute path of the request.
      • getAbsolutePathBuilder

        public javax.ws.rs.core.UriBuilder getAbsolutePathBuilder()
        Get the absolute path of the request in the form of a UriBuilder. This includes everything preceding the path (host, port, etc.) but excludes query parameters.

        The returned UriBuilder gives possibility to enrich the path to build a customized URI for a web entity.

        Returns:
        the UriBuilder initialized with the absolute path of the request.
      • getBaseUri

        public URI getBaseUri()
        Get the base URI of all Web resources in Silverpeas. URIs of REST web services are all relative to this base URI.
        Returns:
        the base URI of all the web resources in Silverpeas (REST web services).
      • getBaseUriBuilder

        public javax.ws.rs.core.UriBuilder getBaseUriBuilder()
        Get the base URI of all Web resources in Silverpeas in the form of a UriBuilder. URIs of root REST web services are all relative to this base URI.
        Returns:
        the UriBuilder initialized with the base URI of all the web resources in Silverpeas (REST web services) as a URI builder.
      • getPathParameters

        public javax.ws.rs.core.MultivaluedMap<String,​String> getPathParameters()
        Get the values of any embedded URI template parameters. All sequences of escaped octets are decoded.
        Returns:
        an unmodifiable map of parameter names and values.
      • getQueryParameters

        public javax.ws.rs.core.MultivaluedMap<String,​String> getQueryParameters()
        Get the URI query parameters of the current request. The map keys are the names of the query parameters with any escaped characters decoded. All sequences of escaped octets in parameter names and values are decoded.
        Returns:
        an unmodifiable map of query parameter names and values.