Class RESTWebService.WebProcess<R>

  • Type Parameters:
    R - the type of the value returned by the web treatment.
    Enclosing class:
    RESTWebService

    protected final class RESTWebService.WebProcess<R>
    extends Object
    This class handles the execution of a RESTWebService.WebTreatment. It provides the centralization of exception catches and handles the lowest role access that must the user verify.
    • Constructor Detail

      • WebProcess

        protected WebProcess​(RESTWebService.WebTreatment<R> webTreatment)
        Default constructor.
        Parameters:
        webTreatment - a treatment to process.
    • Method Detail

      • lowestAccessRole

        public RESTWebService.WebProcess<R> lowestAccessRole​(SilverpeasRole lowestRoleAccess)
        Sets the lowest role access that the user behind the service call must verify.
        Parameters:
        lowestRoleAccess - the lowest role allowed to process a given web treatment.
        Returns:
        itself.
      • execute

        public R execute()
        This method calls the execute method of a .WebTreatment instance. One of the aim of this mechanism is to centralize the exception catching and also to avoid redundant coding around web exceptions. If a lowest role access is defined, the user must verify it. If the user isn't authenticated, a 401 HTTP code is returned. If a problem occurs when processing the request, a 503 HTTP code is returned.
        Returns:
        the value computed by the specified web treatment.