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
*
*/
public class DropinsSCL {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(DropinsSCL.class);
public static void watchDropinsFolder() {
FileImportDropins.watchDropinsFolder();
public static void uploadToDropinsBase64(String base64, String fileName) {
// ensure that watcher is awake
FileImportDropins.watchDropinsFolder();
+ Path rootFolder = null;
try {
- Path rootFolder = Activator.getDropinsFolder();
+ rootFolder = Activator.getDropinsFolder();
Path newFile = rootFolder.resolve(fileName);
if (Files.exists(newFile)) {
newFile = findFreshFileName(rootFolder, fileName);
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);
}
}