]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.fileimport/src/org/simantics/fileimport/scl/DropinsSCL.java
Some fixes for FileImportService to throw exceptions forward
[simantics/platform.git] / bundles / org.simantics.fileimport / src / org / simantics / fileimport / scl / DropinsSCL.java
index 74d2a0322f45c426e0fffa1434e888641e69632c..50fd584466bedd5849d950b9c778f80b16441fa3 100644 (file)
@@ -21,6 +21,8 @@ import org.simantics.fileimport.FileImportService;
 import org.simantics.fileimport.dropins.FileImportDropins;
 import org.simantics.layer0.Layer0;
 import org.simantics.utils.FileUtils;
 import org.simantics.fileimport.dropins.FileImportDropins;
 import org.simantics.layer0.Layer0;
 import org.simantics.utils.FileUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * SCL interface for Simantics File Import Functionality
 
 /**
  * SCL interface for Simantics File Import Functionality
@@ -30,6 +32,8 @@ import org.simantics.utils.FileUtils;
  *
  */
 public class DropinsSCL {
  *
  */
 public class DropinsSCL {
+    
+    private static final Logger LOGGER = LoggerFactory.getLogger(DropinsSCL.class);
 
     public static void watchDropinsFolder() {
         FileImportDropins.watchDropinsFolder();
 
     public static void watchDropinsFolder() {
         FileImportDropins.watchDropinsFolder();
@@ -42,8 +46,9 @@ public class DropinsSCL {
     public static void uploadToDropinsBase64(String base64, String fileName) {
         // ensure that watcher is awake
         FileImportDropins.watchDropinsFolder();
     public static void uploadToDropinsBase64(String base64, String fileName) {
         // ensure that watcher is awake
         FileImportDropins.watchDropinsFolder();
+        Path rootFolder = null;
         try {
         try {
-            Path rootFolder = Activator.getDropinsFolder();
+            rootFolder = Activator.getDropinsFolder();
             Path newFile = rootFolder.resolve(fileName);
             if (Files.exists(newFile)) {
                 newFile = findFreshFileName(rootFolder, fileName);
             Path newFile = rootFolder.resolve(fileName);
             if (Files.exists(newFile)) {
                 newFile = findFreshFileName(rootFolder, fileName);
@@ -51,7 +56,7 @@ public class DropinsSCL {
             byte[] bytes = Base64.decode(base64);
             FileUtils.writeFile(newFile.toFile(), bytes);
         } catch (IOException e) {
             byte[] bytes = Base64.decode(base64);
             FileUtils.writeFile(newFile.toFile(), bytes);
         } catch (IOException e) {
-            e.printStackTrace();
+            LOGGER.error("Could not upload base64 to file " + (rootFolder != null ? rootFolder.resolve(fileName).toAbsolutePath() : ""), e);
         }
     }
 
         }
     }