Switch to side-by-side view

--- a/src/main/java/net/timbusproject/extractors/modules/tavernaextractor/TavernaExtractorOSGi.java
+++ b/src/main/java/net/timbusproject/extractors/modules/tavernaextractor/TavernaExtractorOSGi.java
@@ -2,6 +2,7 @@
 
 import net.timbusproject.extractors.core.*;
 import net.timbusproject.extractors.modules.tavernaextractor.utils.SSHManager;
+import org.codehaus.jettison.json.JSONObject;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Version;
 import org.slf4j.Logger;
@@ -71,14 +72,24 @@
                 ,new Integer(endpoint.getProperty("port")),
                 endpoint.getProperty("user"),
                 endpoint.getProperty("password"));
-        TavernaExtractor extractor = new TavernaExtractor(_sshManager);
-        TavernaExtractor.setTavernaHome(Paths.get(tavernaHome));
-        TavernaExtractor.setArchimateOutputPath(Paths.get(archimateOutputPath));
-        TavernaExtractor.setInputFileName(Paths.get(inputFileName));
 
-        // starts the execution
-        extractor.process(true); //true = remote execution
+        try {
+            TavernaExtractor extractor = new TavernaExtractor(_sshManager);
+            TavernaExtractor.setTavernaHome(Paths.get(tavernaHome));
+            TavernaExtractor.setArchimateOutputPath(Paths.get(archimateOutputPath));
+            TavernaExtractor.setInputFileName(Paths.get(inputFileName));
 
-        return "Result is available at "+archimateOutputPath;
+            // starts the execution
+            extractor.process(true); //true = remote execution
+
+            // inform user about the result of the extraction
+            String fileContent = extractor.getConvertedFileAsString();
+            return new JSONObject().put("DONE", "Extraction was successfully!").put("Archimate file is available at ", endpoint.getProperty("fqdn") + archimateOutputPath).put("file content",fileContent).toString();
+        }
+
+        // !STUPID! But in the current TIMBUS testbed, error infos can not be broadcasted via user interface other than that.
+        catch(Exception e){
+            return new JSONObject().put("ERROR", e.getLocalizedMessage()).toString();
+        }
     }
 }