X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.core%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fcore%2Fexecution%2FFileExecutionResources.java;h=0f3a8dc5841051cca98785f68c2967e8280ea66b;hb=c092f2c4564f7238f2960bc005c5a2202732f44e;hp=361cede76ee3e17979433316a748e0495e056ef6;hpb=ee6c3543a0ff9403420ce6a9c647723269f14331;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/FileExecutionResources.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/FileExecutionResources.java index 361cede76..0f3a8dc58 100644 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/FileExecutionResources.java +++ b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/FileExecutionResources.java @@ -80,17 +80,17 @@ public class FileExecutionResources implements ExecutionResources { } public String getAsOsPath(Resource resource, Boolean overwrite) { - File file = null; - try { - file = resource.getFile(); - return file.getCanonicalPath(); - } catch (IOException e) { - if (log.isTraceEnabled()) - log - .trace("Resource " - + resource - + " is not available on the file system. Retrieving it..."); - } + File file = fileFromResource(resource); + if (file != null) + try { + return file.getCanonicalPath(); + } catch (IOException e1) { + // silent + } + + if (log.isTraceEnabled()) + log.trace("Resource " + resource + + " is not available on the file system. Retrieving it..."); InputStream in = null; OutputStream out = null; @@ -116,12 +116,30 @@ public class FileExecutionResources implements ExecutionResources { } } + /** + * Extract the underlying file from the resource. + * + * @return the file or null if no files support this resource. + */ + protected File fileFromResource(Resource resource) { + try { + return resource.getFile(); + } catch (IOException e) { + return null; + } + + } + public File getFile(String relativePath) { if (withExecutionSubdirectory) { Assert.notNull(executionContext, "execution context is null"); - String path = baseDir.getPath() + File.separator - + sdf().format(executionContext.getCreationDate()) + String path = baseDir.getPath() + + File.separator + + sdf() + .format( + executionContext + .getVariable(ExecutionContext.VAR_EXECUTION_CONTEXT_CREATION_DATE)) + executionContext.getUuid(); File executionDir = new File(path);