Class RESTWebService

    • Field Detail

      • RESPONSE_HEADER_ARRAYSIZE

        public static final String RESPONSE_HEADER_ARRAYSIZE
        The HTTP header parameter that provides the real size of an array of resources. It is for client side when a pagination mechanism is used in order to calculate the number of pages.
        See Also:
        Constant Field Values
    • Constructor Detail

      • RESTWebService

        public RESTWebService()
    • Method Detail

      • initContext

        @PostConstruct
        protected void initContext()
      • initWebResourceUri

        protected WebResourceUri initWebResourceUri()
        Default initialization of WebResourceUri instance for all WEB services extending RESTWebService class.

        This method can be overrated in case the default initialization is not satisfying a right behavior.

        In any case, the WebResourceUri is computed one time (and only one) per request and the result of computation is provided by getUri() method.

        Returns:
        a WebResourceUri instance.
      • getResourceBasePath

        protected abstract String getResourceBasePath()
        Gets the base path of the web resource relative to the root path of all of the web resources in Silverpeas as given by SilverpeasWebResource.getBasePath().
        Returns:
        the relative path that identifies this REST web service among all other REST web services.
      • getHttpServletRequest

        public javax.servlet.http.HttpServletRequest getHttpServletRequest()
        Gets the HTTP servlet request mapped with the execution context of this web service.
        Returns:
        the HTTP servlet request.
      • getHttpServletResponse

        public javax.servlet.http.HttpServletResponse getHttpServletResponse()
        Gets the HTTP servlet response mapped with the execution context of this web service.
        Returns:
        the HTTP servlet response.
      • isUserDefined

        protected boolean isUserDefined()
        Is the user behind the request is well-defined in Silverpeas? In the case of an anonymous or public request, the user isn't identified in Silverpeas and therefore this method returns false.
        Returns:
        true if the user behind the request is well identified, false otherwise.
      • getUser

        protected User getUser()
        Gets the detail about the user that has called this web service. If the user isn't already identified by this web service, then null is returned.
        Returns:
        the detail about the user.
      • getUserPreferences

        protected UserPreferences getUserPreferences()
        Gets the preference of the user that requested the resource backed by this web service. If the user isn't already identified by this web service, then an identification is performed before through an authentication operation followed by an authorization validation. If the identification or the authorization fails, then a WebApplicationException is thrown with respectively a HTTP status code UNAUTHORIZED (401) or FORBIDEN (403). If the preferences can be retrieved, then null is returned.
        Returns:
        the user preference or null if its preferences can be retrieved.
      • getOrganisationController

        protected OrganizationController getOrganisationController()
        Gets the organization controller.
        Returns:
        an OrganizationController instance.
      • getBundleLocation

        protected String getBundleLocation()
        Gets the location of the bundle to use.
        Returns:
      • getHighestUserRole

        public SilverpeasRole getHighestUserRole()
        Gets the highest role of the user behind the service call.
        Returns:
      • identifiedBy

        protected URI identifiedBy​(String... id)
        Convenient method to build an URI from the request's absolute path and the specified identifiers. Each identifier will be added to the absolute path as a path node in the returned URI.
        Parameters:
        id - one or more identifiers identifying uniquely the current requested web resource.
        Returns:
        an URI identifying uniquely in the Web the current requested resource.
      • identifiedBy

        protected URI identifiedBy​(javax.ws.rs.core.UriBuilder base,
                                   String... id)
        Convenient method to build an URI from the a base URI represented by the specified UriBuilder and from the specified identifiers. Each identifier will be added to the base URI as a path node in the returned URI.
        Parameters:
        base - a UriBuilder instance representing the base URI from which the resulted URI will be computed.
        id - one or more identifiers identifying the uniquely the current requested web resource.
        Returns:
        an URI identifying uniquely in the Web the current requested resource.
      • fromPage

        protected PaginationPage fromPage​(String page)
        Computes the PaginationPage according to the given asked page data.

        Page data is a String composed of two values separated by a semicolon :

        • Left value represents the page number. First page is '1'.
        • Right value represents the number of data per page.

        Parameters:
        page - the page information.
        Returns:
        the initialized PaginationPage.