]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/FileExecutionResources.java
Introduce local osgi resource edition
[gpl/argeo-slc.git] / runtime / org.argeo.slc.core / src / main / java / org / argeo / slc / core / execution / FileExecutionResources.java
index 0debe45fbd857da89c54fdf61c8f79b21935c4f4..0f3a8dc5841051cca98785f68c2967e8280ea66b 100644 (file)
@@ -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) {