|
|
@ -80,22 +80,29 @@ public class TaskExecutionContextUtils { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void createProcessLocalPathIfAbsent(TaskExecutionContext taskExecutionContext) throws TaskException { |
|
|
|
public static void createTaskInstanceWorkingDirectory(TaskExecutionContext taskExecutionContext) throws TaskException { |
|
|
|
try { |
|
|
|
|
|
|
|
// local execute path
|
|
|
|
// local execute path
|
|
|
|
String execLocalPath = FileUtils.getProcessExecDir( |
|
|
|
String taskInstanceWorkingDirectory = FileUtils.getProcessExecDir( |
|
|
|
taskExecutionContext.getTenantCode(), |
|
|
|
taskExecutionContext.getTenantCode(), |
|
|
|
taskExecutionContext.getProjectCode(), |
|
|
|
taskExecutionContext.getProjectCode(), |
|
|
|
taskExecutionContext.getProcessDefineCode(), |
|
|
|
taskExecutionContext.getProcessDefineCode(), |
|
|
|
taskExecutionContext.getProcessDefineVersion(), |
|
|
|
taskExecutionContext.getProcessDefineVersion(), |
|
|
|
taskExecutionContext.getProcessInstanceId(), |
|
|
|
taskExecutionContext.getProcessInstanceId(), |
|
|
|
taskExecutionContext.getTaskInstanceId()); |
|
|
|
taskExecutionContext.getTaskInstanceId()); |
|
|
|
taskExecutionContext.setExecutePath(execLocalPath); |
|
|
|
try { |
|
|
|
taskExecutionContext.setAppInfoPath(FileUtils.getAppInfoPath(execLocalPath)); |
|
|
|
Path path = Paths.get(taskInstanceWorkingDirectory); |
|
|
|
Path executePath = Paths.get(taskExecutionContext.getExecutePath()); |
|
|
|
if (Files.deleteIfExists(path)) { |
|
|
|
FileUtils.createDirectoryIfNotPresent(executePath); |
|
|
|
log.warn("The TaskInstance WorkingDirectory: {} is exist, will recreate again", |
|
|
|
|
|
|
|
taskInstanceWorkingDirectory); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Files.createDirectories(path); |
|
|
|
|
|
|
|
taskExecutionContext.setExecutePath(taskInstanceWorkingDirectory); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
taskExecutionContext.setExecutePath(taskInstanceWorkingDirectory); |
|
|
|
|
|
|
|
taskExecutionContext.setAppInfoPath(FileUtils.getAppInfoPath(taskInstanceWorkingDirectory)); |
|
|
|
} catch (Throwable ex) { |
|
|
|
} catch (Throwable ex) { |
|
|
|
throw new TaskException("Cannot create process execute dir", ex); |
|
|
|
throw new TaskException( |
|
|
|
|
|
|
|
"Cannot create TaskInstance WorkingDirectory: " + taskInstanceWorkingDirectory + " failed", ex); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|