Source:
<code>private Serializable execute(TaskContext taskContext, PrintStream output, PrintStream error, ScriptHandler scriptHandler, Map<String, String> thirdPartyCredentials, VariablesMap variables) throws Throwable { if (taskContext.getPreScript() != null) { Script<?> script = taskContext.getPreScript(); forkedTaskVariablesManager.replaceScriptParameters(script, thirdPartyCredentials, variables, error); Map<String, String> genericInfo = taskContext.getInitializer().getGenericInformation(); if (genericInfo != null && genericInfo.containsKey("PRE_SCRIPT_AS_FILE")) { String path = genericInfo.get("PRE_SCRIPT_AS_FILE"); ScriptEngineFactory factory = new ScriptEngineManager().getEngineByName(script.getEngineName()) .getFactory(); String extension = factory.getExtensions().get(0); String code = script.fetchScript().trim(); <START> try (FileWriter fw = new FileWriter(new File(path + "." + extension))) { <END> fw.write(code); fw.close(); } catch (IOException e) { e.printStackTrace(); } } else { ScriptResult preScriptResult = scriptHandler.handle(script, output, error); if (preScriptResult.errorOccured()) { throw new TaskException("Failed to execute pre script: " + preScriptResult.getException().getMessage(), preScriptResult.getException()); } } } Script<Serializable> script = ((ScriptExecutableContainer) taskContext.getExecutableContainer()).getScript(); forkedTaskVariablesManager.replaceScriptParameters(script, thirdPartyCredentials, variables, error); ScriptResult<Serializable> scriptResult = scriptHandler.handle(script, output, error); if (scriptResult.errorOccured()) { throw new TaskException("Failed to execute task: " + scriptResult.getException().getMessage(), scriptResult.getException()); } if (taskContext.getPostScript() != null) { forkedTaskVariablesManager.replaceScriptParameters(taskContext.getPostScript(), thirdPartyCredentials, variables, error); ScriptResult postScriptResult = scriptHandler.handle(taskContext.getPostScript(), output, error); if (postScriptResult.errorOccured()) { throw new TaskException("Failed to execute post script: " + postScriptResult.getException().getMessage(), postScriptResult.getException()); } } return scriptResult.getResult(); }</code><technical_language>check if provided path is relative absolute. If is relative, local space location store file</technical_language>

Target:
private Serializable execute(TaskContext taskContext, PrintStream output, PrintStream error, ScriptHandler scriptHandler, Map<String, String> thirdPartyCredentials, VariablesMap variables) throws Throwable { if (taskContext.getPreScript() != null) { Script<?> script = taskContext.getPreScript(); forkedTaskVariablesManager.replaceScriptParameters(script, thirdPartyCredentials, variables, error); Map<String, String> genericInfo = taskContext.getInitializer().getGenericInformation(); if (genericInfo != null && genericInfo.containsKey("PRE_SCRIPT_AS_FILE")) { String path = genericInfo.get("PRE_SCRIPT_AS_FILE"); saveScriptAsFile(path, script, taskContext); } else { ScriptResult preScriptResult = scriptHandler.handle(script, output, error); if (preScriptResult.errorOccured()) { throw new TaskException("Failed to execute pre script: " + preScriptResult.getException().getMessage(), preScriptResult.getException()); } } } Script<Serializable> script = ((ScriptExecutableContainer) taskContext.getExecutableContainer()).getScript(); forkedTaskVariablesManager.replaceScriptParameters(script, thirdPartyCredentials, variables, error); ScriptResult<Serializable> scriptResult = scriptHandler.handle(script, output, error); if (scriptResult.errorOccured()) { throw new TaskException("Failed to execute task: " + scriptResult.getException().getMessage(), scriptResult.getException()); } if (taskContext.getPostScript() != null) { forkedTaskVariablesManager.replaceScriptParameters(taskContext.getPostScript(), thirdPartyCredentials, variables, error); ScriptResult postScriptResult = scriptHandler.handle(taskContext.getPostScript(), output, error); if (postScriptResult.errorOccured()) { throw new TaskException("Failed to execute post script: " + postScriptResult.getException().getMessage(), postScriptResult.getException()); } } return scriptResult.getResult(); }