Class Command

java.lang.Object
com.google.refine.commands.Command
Direct Known Subclasses:
AnnotateOneRowCommand, ApplyOperationsCommand, CancelImportingJobCommand, CancelProcessesCommand, ComputeClustersCommand, ComputeFacetsCommand, CreateImportingJobCommand, CreateProjectCommand, DeleteProjectCommand, DenormalizeCommand, EditOneCellCommand, EngineDependentCommand, ExportProjectCommand, ExportRowsCommand, GetAllPreferencesCommand, GetAllProjectMetadataCommand, GetAllProjectTagsCommand, GetClusteringFunctionsAndDistancesCommand, GetColumnsInfoCommand, GetCSRFTokenCommand, GetExpressionHistoryCommand, GetExpressionLanguageInfoCommand, GetHistoryCommand, GetImportingConfigurationCommand, GetImportingJobStatusCommand, GetLanguagesCommand, GetModelsCommand, GetOperationsCommand, GetPreferenceCommand, GetProcessesCommand, GetProjectMetadataCommand, GetRowsCommand, GetScatterplotCommand, GetStarredExpressionsCommand, GetVersionCommand, GuessTypesOfColumnCommand, ImportingControllerCommand, ImportProjectCommand, JoinMultiValueCellsCommand, KeyValueColumnizeCommand, LoadLanguageCommand, LogExpressionCommand, MoveColumnCommand, OpenWorkspaceDirCommand, PreviewExpressionCommand, PreviewExtendDataCommand, ReconClearOneCellCommand, ReconJudgeOneCellCommand, RemoveColumnCommand, RenameColumnCommand, RenameProjectCommand, SetPreferenceCommand, SetProjectMetadataCommand, SetProjectTagsCommand, SplitMultiValueCellsCommand, ToggleStarredExpressionCommand, TransposeColumnsIntoRowsCommand, TransposeRowsIntoColumnsCommand, UndoRedoCommand

public abstract class Command extends Object
The super class of all calls that the client side can invoke, most of which are AJAX calls.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected static class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final CSRFTokenFactory
     
    protected static final org.slf4j.Logger
     
    protected RefineServlet
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    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
    doHead(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 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 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
     
    boolean
    Whether each request to this command should be logged.
    protected static void
    performProcessAndRespond(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Project project, Process process)
     
    protected static void
    redirect(javax.servlet.http.HttpServletResponse response, String url)
     
    protected static void
    respond(javax.servlet.http.HttpServletResponse response, String content)
     
    protected static void
    respond(javax.servlet.http.HttpServletResponse response, String status, String message)
     
    protected static void
    respondCSRFError(javax.servlet.http.HttpServletResponse response)
     
    protected static void
    respondException(javax.servlet.http.HttpServletResponse response, Exception e)
     
    static void
    respondJSON(javax.servlet.http.HttpServletResponse response, Object o)
     
    protected static void
    respondJSON(javax.servlet.http.HttpServletResponse response, Object o, Properties options)
     
    protected void
    respondWithErrorPage(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String message, Throwable e)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • logger

      protected static final org.slf4j.Logger logger
    • csrfFactory

      public static final CSRFTokenFactory csrfFactory
    • servlet

      protected RefineServlet servlet
  • Constructor Details

    • Command

      public Command()
  • Method Details

    • init

      public void init(RefineServlet servlet)
    • doPost

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

      public void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException
      Throws:
      javax.servlet.ServletException
      IOException
    • doHead

      public void doHead(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException
      Throws:
      javax.servlet.ServletException
      IOException
    • doPut

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

      public void doDelete(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException
      Throws:
      javax.servlet.ServletException
      IOException
    • 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.
      Parameters:
      request -
      Returns:
      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)
    • 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).
    • performProcessAndRespond

      protected static void performProcessAndRespond(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Project project, Process process) throws Exception
      Throws:
      Exception
    • respond

      protected static void respond(javax.servlet.http.HttpServletResponse response, String content) throws IOException, javax.servlet.ServletException
      Throws:
      IOException
      javax.servlet.ServletException
    • respond

      protected static void respond(javax.servlet.http.HttpServletResponse response, String status, String message) throws IOException
      Throws:
      IOException
    • respondJSON

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

      protected static void respondJSON(javax.servlet.http.HttpServletResponse response, Object o, Properties options) throws IOException
      Throws:
      IOException
    • respondCSRFError

      protected static void respondCSRFError(javax.servlet.http.HttpServletResponse response) throws IOException
      Throws:
      IOException
    • respondException

      protected static void respondException(javax.servlet.http.HttpServletResponse response, Exception e) throws IOException, javax.servlet.ServletException
      Throws:
      IOException
      javax.servlet.ServletException
    • respondWithErrorPage

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

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