Package com.google.refine.commands
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
The super class of all calls that the client side can invoke, most of which are AJAX calls.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CSRFTokenFactoryprotected static final org.slf4j.Loggerprotected RefineServlet -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddoDelete(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) voiddoGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) voiddoHead(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) voiddoPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) voiddoPut(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) protected static EngineUtility function to reconstruct the browsing engine from the "engine" request parameter, most often in the POST body.protected static EngineConfiggetEngineConfig(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 intgetIntegerParameter(javax.servlet.http.HttpServletRequest request, String name, int def) protected ProjectgetProject(javax.servlet.http.HttpServletRequest request) Utility method for retrieving the Project object having the ID specified in the "project" URL parameter.protected ProjectMetadatagetProjectMetadata(javax.servlet.http.HttpServletRequest request) Utility method for retrieving the ProjectMetadata object having the ID specified in the "project" URL parameter.protected booleanhasValidCSRFToken(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 booleanhasValidCSRFTokenAsGET(javax.servlet.http.HttpServletRequest request) Checks the validity of a CSRF token, without reading the whole POST body.voidinit(RefineServlet servlet) booleanWhether each request to this command should be logged.protected static voidperformProcessAndRespond(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Project project, Process process) protected static voidprotected static voidprotected static voidprotected static voidrespondCSRFError(javax.servlet.http.HttpServletResponse response) protected static voidrespondException(javax.servlet.http.HttpServletResponse response, Exception e) static voidrespondJSON(javax.servlet.http.HttpServletResponse response, Object o) protected static voidrespondJSON(javax.servlet.http.HttpServletResponse response, Object o, Properties options) protected voidrespondWithErrorPage(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String message, Throwable e)
-
Field Details
-
logger
protected static final org.slf4j.Logger logger -
csrfFactory
-
servlet
-
-
Constructor Details
-
Command
public Command()
-
-
Method Details
-
init
-
doPost
public void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException - Throws:
javax.servlet.ServletExceptionIOException
-
doGet
public void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException - Throws:
javax.servlet.ServletExceptionIOException
-
doHead
public void doHead(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException - Throws:
javax.servlet.ServletExceptionIOException
-
doPut
public void doPut(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException - Throws:
javax.servlet.ServletExceptionIOException
-
doDelete
public void doDelete(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException - Throws:
javax.servlet.ServletExceptionIOException
-
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
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:
IOExceptionjavax.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:
IOExceptionjavax.servlet.ServletException
-
respondWithErrorPage
-
redirect
protected static void redirect(javax.servlet.http.HttpServletResponse response, String url) throws IOException - Throws:
IOException
-