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=0debe45fbd857da89c54fdf61c8f79b21935c4f4;hpb=08aa02f96eb32a6e1f0cc001113df9311a618eb9;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 0debe45fb..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,6 +116,20 @@ 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) {