--- a/src/main/java/net/timbusproject/extractors/modules/tavernaextractor/TavernaExtractor.java
+++ b/src/main/java/net/timbusproject/extractors/modules/tavernaextractor/TavernaExtractor.java
@@ -2179,7 +2179,7 @@
}
- private Dataflow getDataflowRemote() throws EditException, OpenDataflowException, MalformedURLException, DeserializationException{
+ private Dataflow getDataflowRemote() throws TavernaExtractorException {
try {
@@ -2190,6 +2190,7 @@
}
catch(SSHManagerException e){
e.printStackTrace();
+ throw new TavernaExtractorException(e.getLocalizedMessage());
}
if (tavernaFile.exists()) {
@@ -2198,9 +2199,9 @@
LOGGER.info( "Reading workflow from " + workflowURL);
return openDataflow(workflowURL);
- } catch (NullPointerException npe) {
- npe.printStackTrace();
- LOGGER.error( "ERROR reading workflow from [" + inputFileName + "]." + npe.getMessage());
+ } catch (NullPointerException | EditException | OpenDataflowException | MalformedURLException | DeserializationException e) {
+ e.printStackTrace();
+ LOGGER.error( "ERROR reading workflow from [" + inputFileName + "]." + e.getMessage());
}
return null;
}
@@ -2226,7 +2227,7 @@
}
- private void saveRemote(IArchimateModel model) throws IOException{
+ private void saveRemote(IArchimateModel model) throws TavernaExtractorException {
// Set new file
File outFile = TavernaExtractor.getArchimateOutputPath().toFile();
@@ -2236,14 +2237,21 @@
model.setVersion(ModelVersion.VERSION);
//create tmp file
- Path outputTmp = Files.createTempFile("tavernaExtractor-",".output");
-
- // Adapted from {@link ArchiveManager#saveModelToXMLFile}
- ResourceSet resourceSet = ArchimateResourceFactory.createResourceSet();
- Resource resource = resourceSet.createResource(URI.createFileURI(outputTmp.toAbsolutePath().toString()));
-
- resource.getContents().add(model);
- resource.save(null);
+ Path outputTmp = null;
+ try{
+ outputTmp = Files.createTempFile("tavernaExtractor-",".output");
+
+ // Adapted from {@link ArchiveManager#saveModelToXMLFile}
+ ResourceSet resourceSet = ArchimateResourceFactory.createResourceSet();
+ Resource resource = resourceSet.createResource(URI.createFileURI(outputTmp.toAbsolutePath().toString()));
+
+ resource.getContents().add(model);
+ resource.save(null);
+ }
+ catch(IOException e){
+ e.printStackTrace();
+ throw new TavernaExtractorException(e.getLocalizedMessage());
+ }
LOGGER.info( "Wrote model successfully to " + outFile.getAbsolutePath());
@@ -2254,14 +2262,21 @@
}
catch(SSHManagerException e){
e.printStackTrace();
- }
-
- //for the testbed, return file content as string representation
- convertedFileAsString = new String(Files.readAllBytes(outputTmp), StandardCharsets.UTF_8);
-
- // remove both temp files.
- Files.deleteIfExists(outputTmp);
- Files.deleteIfExists(tavernaFile.toPath());
+ throw new TavernaExtractorException(e.getLocalizedMessage());
+ }
+
+ try {
+ //for the testbed, return file content as string representation
+ convertedFileAsString = new String(Files.readAllBytes(outputTmp), StandardCharsets.UTF_8);
+
+ // remove both temp files.
+ Files.deleteIfExists(outputTmp);
+ Files.deleteIfExists(tavernaFile.toPath());
+ }
+ catch(IOException e){
+ e.printStackTrace();
+ throw new TavernaExtractorException(e.getLocalizedMessage());
+ }
}
private void saveLocal(IArchimateModel model) throws IOException{