public OperationResult invokeOperation(String name, Configuration params) throws Exception {
if (name.equals(EXECUTE_OPERATION)) {
OperationResult operationResult = new OperationResult();
File scriptFile = getScriptFile();
SystemInfo systemInfo = this.resourceContext.getSystemInformation();
ProcessExecution processExecution = ProcessExecutionUtility.createProcessExecution(scriptFile);
processExecution.setWaitForCompletion(1000L * 60 * 60); // 1 hour
processExecution.setCaptureOutput(true);
// TODO: Make the script's cwd configurable, but default it to the
// directory containing the script.
processExecution.setWorkingDirectory(scriptFile.getParent());
setEnvironmentVariables(processExecution);
setCommandLineArguments(params, processExecution);
if (log.isDebugEnabled()) {
log.debug(processExecution);
}
ProcessExecutionResults processExecutionResults = systemInfo.executeProcess(processExecution);
if (processExecutionResults.getError() != null) {
throw new Exception(processExecutionResults.getError());
}
Integer exitCode = processExecutionResults.getExitCode();