Class Command

    • Constructor Summary

      Constructors 
      Constructor Description
      Command()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      protected static void addHistoryEntryAndRespond​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Project project, Operation operation)  
      void doDelete​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)  
      void doGet​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)  
      void doPost​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)  
      void doPut​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)  
      protected static Engine getEngine​(javax.servlet.http.HttpServletRequest request, Project project)
      Utility function to reconstruct the browsing engine from the "engine" request parameter, most often in the POST body.
      protected static EngineConfig getEngineConfig​(javax.servlet.http.HttpServletRequest request)
      Utility function to get the browsing engine's configuration as a JSON object from the "engine" request parameter, most often in the POST body.
      protected static int getIntegerParameter​(javax.servlet.http.HttpServletRequest request, String name, int def)  
      protected static long getLongParameter​(javax.servlet.http.HttpServletRequest request, String name, long def)  
      protected Project getProject​(javax.servlet.http.HttpServletRequest request)
      Utility method for retrieving the Project object having the ID specified in the "project" URL parameter.
      protected ProjectMetadata getProjectMetadata​(javax.servlet.http.HttpServletRequest request)
      Utility method for retrieving the ProjectMetadata object having the ID specified in the "project" URL parameter.
      protected SortingConfig getSortingConfig​(javax.servlet.http.HttpServletRequest request)  
      protected boolean hasValidCSRFToken​(javax.servlet.http.HttpServletRequest request)
      Utility method for retrieving the CSRF token stored in the "csrf_token" parameter of the request, and checking that it is valid.
      protected boolean hasValidCSRFTokenAsGET​(javax.servlet.http.HttpServletRequest request)
      Checks the validity of a CSRF token, without reading the whole POST body.
      void init​(RefineServlet servlet)  
      boolean logRequests()
      Whether each request to this command should be logged.
      protected static void redirect​(javax.servlet.http.HttpServletResponse response, String url)  
      static void respondCSRFError​(javax.servlet.http.HttpServletResponse response)  
      static void respondError​(javax.servlet.http.HttpServletResponse response, int status, String errorMessage)
      Helper introduced to ease returning error messages from a response.
      static void respondError​(javax.servlet.http.HttpServletResponse response, String errorMessage)
      Helper introduced to ease returning error messages from a response, with a default 400 status code.
      static void respondJSON​(javax.servlet.http.HttpServletResponse response, int status, Object o)  
      protected static void respondJSON​(javax.servlet.http.HttpServletResponse response, Object o)
      Deprecated.
      use respondJSON(HttpServletResponse, int, Object) to make sure an HTTP status code is set
      static void respondOK​(javax.servlet.http.HttpServletResponse response)  
      protected void respondWithErrorPage​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String message, Throwable e)  
    • Field Detail

      • logger

        protected static final org.slf4j.Logger logger
    • Constructor Detail

      • Command

        public Command()
    • Method Detail

      • doPost

        public void doPost​(javax.servlet.http.HttpServletRequest request,
                           javax.servlet.http.HttpServletResponse response)
                    throws Exception
        Throws:
        Exception
      • doGet

        public void doGet​(javax.servlet.http.HttpServletRequest request,
                          javax.servlet.http.HttpServletResponse response)
                   throws Exception
        Throws:
        Exception
      • doPut

        public void doPut​(javax.servlet.http.HttpServletRequest request,
                          javax.servlet.http.HttpServletResponse response)
                   throws Exception
        Throws:
        Exception
      • doDelete

        public void doDelete​(javax.servlet.http.HttpServletRequest request,
                             javax.servlet.http.HttpServletResponse response)
                      throws Exception
        Throws:
        Exception
      • logRequests

        public boolean logRequests()
        Whether each request to this command should be logged. For some commands that can get called too frequently, such as GetProcessesCommand, logging is very distracting.
      • getEngineConfig

        protected static EngineConfig getEngineConfig​(javax.servlet.http.HttpServletRequest request)
        Utility function to get the browsing engine's configuration as a JSON object from the "engine" request parameter, most often in the POST body.
        Parameters:
        request -
        Returns:
      • getEngine

        protected static Engine getEngine​(javax.servlet.http.HttpServletRequest request,
                                          Project project)
                                   throws Exception
        Utility function to reconstruct the browsing engine from the "engine" request parameter, most often in the POST body.
        Parameters:
        request -
        project -
        Returns:
        Throws:
        Exception
      • getProject

        protected Project getProject​(javax.servlet.http.HttpServletRequest request)
                              throws javax.servlet.ServletException
        Utility method for retrieving the Project object having the ID specified in the "project" URL parameter.
        Throws:
        javax.servlet.ServletException
      • getProjectMetadata

        protected ProjectMetadata getProjectMetadata​(javax.servlet.http.HttpServletRequest request)
                                              throws javax.servlet.ServletException
        Utility method for retrieving the ProjectMetadata object having the ID specified in the "project" URL parameter.
        Parameters:
        request -
        Returns:
        Throws:
        javax.servlet.ServletException
      • getIntegerParameter

        protected static int getIntegerParameter​(javax.servlet.http.HttpServletRequest request,
                                                 String name,
                                                 int def)
      • getLongParameter

        protected static long getLongParameter​(javax.servlet.http.HttpServletRequest request,
                                               String name,
                                               long def)
      • hasValidCSRFToken

        protected boolean hasValidCSRFToken​(javax.servlet.http.HttpServletRequest request)
                                     throws javax.servlet.ServletException
        Utility method for retrieving the CSRF token stored in the "csrf_token" parameter of the request, and checking that it is valid.
        Parameters:
        request -
        Returns:
        Throws:
        javax.servlet.ServletException
      • hasValidCSRFTokenAsGET

        protected boolean hasValidCSRFTokenAsGET​(javax.servlet.http.HttpServletRequest request)
        Checks the validity of a CSRF token, without reading the whole POST body. Useful when we need to control how the POST body is read (for instance if it contains files).
      • addHistoryEntryAndRespond

        protected static void addHistoryEntryAndRespond​(javax.servlet.http.HttpServletRequest request,
                                                        javax.servlet.http.HttpServletResponse response,
                                                        Project project,
                                                        Operation operation)
                                                 throws Exception
        Throws:
        Exception
      • respondJSON

        public static void respondJSON​(javax.servlet.http.HttpServletResponse response,
                                       int status,
                                       Object o)
                                throws IOException
        Throws:
        IOException
      • respondCSRFError

        public static void respondCSRFError​(javax.servlet.http.HttpServletResponse response)
                                     throws IOException
        Throws:
        IOException
      • respondError

        public static void respondError​(javax.servlet.http.HttpServletResponse response,
                                        String errorMessage)
                                 throws IOException
        Helper introduced to ease returning error messages from a response, with a default 400 status code.
        Throws:
        IOException
      • respondError

        public static void respondError​(javax.servlet.http.HttpServletResponse response,
                                        int status,
                                        String errorMessage)
                                 throws IOException
        Helper introduced to ease returning error messages from a response.
        Throws:
        IOException
      • respondOK

        public static void respondOK​(javax.servlet.http.HttpServletResponse response)
                              throws IOException
        Throws:
        IOException
      • respondWithErrorPage

        protected void respondWithErrorPage​(javax.servlet.http.HttpServletRequest request,
                                            javax.servlet.http.HttpServletResponse response,
                                            String message,
                                            Throwable e)
      • getSortingConfig

        protected SortingConfig getSortingConfig​(javax.servlet.http.HttpServletRequest request)
      • redirect

        protected static void redirect​(javax.servlet.http.HttpServletResponse response,
                                       String url)
                                throws IOException
        Throws:
        IOException