ServerSideScriptingCaller#

public class ServerSideScriptingCaller#

Calls server-side scripting scripts.

The script are started in a unique directory, they are provided with an authentication token and a special shared directory where they may temporarily store files for download by the user.

Fields#

STARTED#

public static final Integer STARTED#

UPLOAD_FILES_DIR#

public static final String UPLOAD_FILES_DIR#

Constructors#

ServerSideScriptingCaller#

public ServerSideScriptingCaller(String[] commandLine, Integer timeoutMs, List<FileProperties> files, Object authToken)#

ServerSideScriptingCaller#

public ServerSideScriptingCaller(String[] commandLine, Integer timeoutMs, List<FileProperties> files, Object authToken, Map<String, String> env)#

ServerSideScriptingCaller#

public ServerSideScriptingCaller(String[] commandLine, Integer timeoutMs, List<FileProperties> files, Object authToken, Map<String, String> env, ScriptingUtils utils)#

ServerSideScriptingCaller#

public ServerSideScriptingCaller(String[] commandLine, Integer timeoutMs, List<FileProperties> files, Object authToken, Map<String, String> env, ScriptingUtils utils, File workingDir)#

Methods#

callScript#

int callScript(String absoluteScriptPath, String[] commandLine, Object authToken, Map<String, String> env)#

Call the script.

The absoluteScriptPath is called with all remaining parameters from the commandLine arrays, an optional additional authToken and environment variables.

Parameters:
  • absoluteScriptPath

  • commandLine

  • authToken

  • env

    • environment variables

Throws:
Returns:

the exit code of the script call

cleanup#

void cleanup()#

createSharedDir#

void createSharedDir()#

Creates a temporary directory for sharing by the script and sets sharedDir accordingly.

createTmpHomeDir#

void createTmpHomeDir()#

Create a writable “home like” directory, needed for some Python libs, e.g. caosdb-pylib.

The temporary working directory must exist when this method is called.

createWorkingDir#

void createWorkingDir()#

deleteWorkingDir#

void deleteWorkingDir(File pwd)#

getAbsoluteScriptPath#

String getAbsoluteScriptPath(String[] commandLine)#

Returns the absolute script path.

Throws Message when the script does not exist or when the script is not executable.

Parameters:
  • commandLine

Throws:
Returns:

The absolute script path.

getCode#

public Integer getCode()#

getCommandLine#

public String[] getCommandLine()#

getSharedDir#

File getSharedDir()#

getStdErr#

public String getStdErr()#

getStdErrFile#

public File getStdErrFile()#

getStdOut#

public String getStdOut()#

getStdOutFile#

public File getStdOutFile()#

getTimeoutMs#

int getTimeoutMs()#

getTmpHomeDir#

File getTmpHomeDir()#

getTmpWorkingDir#

File getTmpWorkingDir()#

getUploadFilesDir#

File getUploadFilesDir()#

injectAuthToken#

String[] injectAuthToken(String[] commandLine)#

invoke#

public int invoke()#

Does some final preparation, then calls the script and cleans up.

putFilesInWorkingDir#

void putFilesInWorkingDir(Collection<FileProperties> files)#

updateEnvironment#

void updateEnvironment()#

Sets environment variables for the script, according to the current state of the caller.