.. java:import:: java.io File .. java:import:: java.io FileNotFoundException .. java:import:: java.io IOException .. java:import:: java.lang ProcessBuilder.Redirect .. java:import:: java.util Arrays .. java:import:: java.util Collection .. java:import:: java.util HashMap .. java:import:: java.util List .. java:import:: java.util Map .. java:import:: org.apache.commons.io FileUtils .. java:import:: org.caosdb.server CaosDBException .. java:import:: org.caosdb.server CaosDBServer .. java:import:: org.caosdb.server FileSystem .. java:import:: org.caosdb.server ServerProperties .. java:import:: org.caosdb.server.entity FileProperties .. java:import:: org.caosdb.server.entity Message .. java:import:: org.caosdb.server.utils ServerMessages ServerSideScriptingCaller ========================= .. java:package:: org.caosdb.server.scripting :noindex: .. java:type:: 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 ^^^^^^^ .. java:field:: public static final Integer STARTED :outertype: ServerSideScriptingCaller UPLOAD_FILES_DIR ^^^^^^^^^^^^^^^^ .. java:field:: public static final String UPLOAD_FILES_DIR :outertype: ServerSideScriptingCaller Constructors ------------ ServerSideScriptingCaller ^^^^^^^^^^^^^^^^^^^^^^^^^ .. java:constructor:: public ServerSideScriptingCaller(String[] commandLine, Integer timeoutMs, List files, Object authToken) :outertype: ServerSideScriptingCaller ServerSideScriptingCaller ^^^^^^^^^^^^^^^^^^^^^^^^^ .. java:constructor:: public ServerSideScriptingCaller(String[] commandLine, Integer timeoutMs, List files, Object authToken, Map env) :outertype: ServerSideScriptingCaller ServerSideScriptingCaller ^^^^^^^^^^^^^^^^^^^^^^^^^ .. java:constructor:: public ServerSideScriptingCaller(String[] commandLine, Integer timeoutMs, List files, Object authToken, Map env, ScriptingUtils utils) :outertype: ServerSideScriptingCaller ServerSideScriptingCaller ^^^^^^^^^^^^^^^^^^^^^^^^^ .. java:constructor:: public ServerSideScriptingCaller(String[] commandLine, Integer timeoutMs, List files, Object authToken, Map env, ScriptingUtils utils, File workingDir) :outertype: ServerSideScriptingCaller Methods ------- callScript ^^^^^^^^^^ .. java:method:: int callScript(String absoluteScriptPath, String[] commandLine, Object authToken, Map env) throws IOException, InterruptedException, TimeoutException :outertype: ServerSideScriptingCaller Call the script. The absoluteScriptPath is called with all remaining parameters from the commandLine arrays, an optional additional authToken and environment variables. :param absoluteScriptPath: :param commandLine: :param authToken: :param env: - environment variables :throws IOException: :throws InterruptedException: :throws TimeoutException: :return: the exit code of the script call cleanup ^^^^^^^ .. java:method:: void cleanup() :outertype: ServerSideScriptingCaller createSharedDir ^^^^^^^^^^^^^^^ .. java:method:: void createSharedDir() throws Exception :outertype: ServerSideScriptingCaller Creates a temporary directory for sharing by the script and sets `sharedDir` accordingly. createTmpHomeDir ^^^^^^^^^^^^^^^^ .. java:method:: void createTmpHomeDir() throws Exception, IOException :outertype: ServerSideScriptingCaller 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 ^^^^^^^^^^^^^^^^ .. java:method:: void createWorkingDir() throws Exception :outertype: ServerSideScriptingCaller deleteWorkingDir ^^^^^^^^^^^^^^^^ .. java:method:: void deleteWorkingDir(File pwd) throws IOException :outertype: ServerSideScriptingCaller getAbsoluteScriptPath ^^^^^^^^^^^^^^^^^^^^^ .. java:method:: String getAbsoluteScriptPath(String[] commandLine) throws Message :outertype: ServerSideScriptingCaller Returns the absolute script path. Throws Message when the script does not exist or when the script is not executable. :param commandLine: :throws Message: :return: The absolute script path. getCode ^^^^^^^ .. java:method:: public Integer getCode() :outertype: ServerSideScriptingCaller getCommandLine ^^^^^^^^^^^^^^ .. java:method:: public String[] getCommandLine() :outertype: ServerSideScriptingCaller getSharedDir ^^^^^^^^^^^^ .. java:method:: File getSharedDir() :outertype: ServerSideScriptingCaller getStdErr ^^^^^^^^^ .. java:method:: public String getStdErr() throws IOException :outertype: ServerSideScriptingCaller getStdErrFile ^^^^^^^^^^^^^ .. java:method:: public File getStdErrFile() :outertype: ServerSideScriptingCaller getStdOut ^^^^^^^^^ .. java:method:: public String getStdOut() throws IOException :outertype: ServerSideScriptingCaller getStdOutFile ^^^^^^^^^^^^^ .. java:method:: public File getStdOutFile() :outertype: ServerSideScriptingCaller getTimeoutMs ^^^^^^^^^^^^ .. java:method:: int getTimeoutMs() :outertype: ServerSideScriptingCaller getTmpHomeDir ^^^^^^^^^^^^^ .. java:method:: File getTmpHomeDir() :outertype: ServerSideScriptingCaller getTmpWorkingDir ^^^^^^^^^^^^^^^^ .. java:method:: File getTmpWorkingDir() :outertype: ServerSideScriptingCaller getUploadFilesDir ^^^^^^^^^^^^^^^^^ .. java:method:: File getUploadFilesDir() :outertype: ServerSideScriptingCaller injectAuthToken ^^^^^^^^^^^^^^^ .. java:method:: String[] injectAuthToken(String[] commandLine) :outertype: ServerSideScriptingCaller invoke ^^^^^^ .. java:method:: public int invoke() throws Message :outertype: ServerSideScriptingCaller Does some final preparation, then calls the script and cleans up. putFilesInWorkingDir ^^^^^^^^^^^^^^^^^^^^ .. java:method:: void putFilesInWorkingDir(Collection files) throws FileNotFoundException, CaosDBException :outertype: ServerSideScriptingCaller updateEnvironment ^^^^^^^^^^^^^^^^^ .. java:method:: void updateEnvironment() throws Exception :outertype: ServerSideScriptingCaller Sets environment variables for the script, according to the current state of the caller.