Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBob Brodt2014-07-14 10:39:16 -0400
committerBob Brodt2014-07-14 10:39:16 -0400
commit9c749b7c8aa9ef772faad5f6f99ef520dc83c870 (patch)
treea1f9e136a6f961c99afc938794344bb857f246e6
parentf80bcad9f61f9b67d4c9a61fdd06d071527825ed (diff)
downloadorg.eclipse.bpmn2-modeler-9c749b7c8aa9ef772faad5f6f99ef520dc83c870.tar.gz
org.eclipse.bpmn2-modeler-9c749b7c8aa9ef772faad5f6f99ef520dc83c870.tar.xz
org.eclipse.bpmn2-modeler-9c749b7c8aa9ef772faad5f6f99ef520dc83c870.zip
Added check for unsupported importType
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/model/Bpmn2ModelerResourceImpl.java56
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/ImportUtil.java5
2 files changed, 47 insertions, 14 deletions
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/model/Bpmn2ModelerResourceImpl.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/model/Bpmn2ModelerResourceImpl.java
index 23673993..2111e580 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/model/Bpmn2ModelerResourceImpl.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/model/Bpmn2ModelerResourceImpl.java
@@ -72,6 +72,7 @@ import org.eclipse.dd.dc.Point;
import org.eclipse.dd.di.DiPackage;
import org.eclipse.dd.di.DiagramElement;
import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.util.BasicDiagnostic;
import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.ECollections;
import org.eclipse.emf.common.util.EList;
@@ -299,27 +300,29 @@ public class Bpmn2ModelerResourceImpl extends Bpmn2ResourceImpl {
super.load(resource, inputStream, options);
}
catch (Exception e) {
- DiagnosticWrappedException error = new DiagnosticWrappedException(e);
+ BPMNDiagnostic error = new BPMNDiagnostic(e.getMessage());
error.setLine(handler.getLineNumber());
error.setColumn(handler.getColumnNumber());
error.setLocation(handler.getLocation());
- resource.getErrors().add(error);
+ if (!resource.getErrors().contains(error))
+ resource.getErrors().add(error);
throw new IOException(e);
}
}
};
}
- class DiagnosticWrappedException extends WrappedException implements Resource.Diagnostic {
- private static final long serialVersionUID = 1L;
+ static class BPMNDiagnostic implements Resource.Diagnostic {
+
+ private String message;
private String location;
private int column;
private int line;
-
- public DiagnosticWrappedException(Exception exception) {
- super(exception);
- }
+ public BPMNDiagnostic(String message) {
+ this.message = message;
+ }
+
public void setLocation(String location) {
this.location = location;
}
@@ -343,6 +346,26 @@ public class Bpmn2ModelerResourceImpl extends Bpmn2ResourceImpl {
public int getLine() {
return line;
}
+
+ public String getMessage() {
+ return message;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof BPMNDiagnostic) {
+ BPMNDiagnostic that = (BPMNDiagnostic)obj;
+ return
+ this.message.equals(that.message) &&
+ this.line==that.line &&
+ this.column==that.column;
+ }
+ else if (obj instanceof Exception) {
+ String message = ((Exception)obj).getMessage();
+ return this.message.equals(message);
+ }
+ return super.equals(obj);
+ }
}
@Override
@@ -439,10 +462,19 @@ public class Bpmn2ModelerResourceImpl extends Bpmn2ResourceImpl {
}
// Load all of the Imports and generate Interfaces, Operations, Messages, Faults and ItemDefinitions
for (Import imp : definitions.getImports()) {
- Object importObject = importHandler.loadImport(imp);
- if (importObject!=null) {
- importHandler.addImportObjects(imp, importObject);
- }
+ try {
+ Object importObject = importHandler.loadImport(imp);
+ if (importObject!=null) {
+ importHandler.addImportObjects(imp, importObject);
+ }
+ }
+ catch (Exception e) {
+ BPMNDiagnostic error = new BPMNDiagnostic(e.getMessage());
+ error.setLine(getLineNumber());
+ error.setColumn(getColumnNumber());
+ error.setLocation(getLocation());
+ xmlResource.getErrors().add(error);
+ }
}
// Fix up the descriptions for BPMNDiagrams
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/ImportUtil.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/ImportUtil.java
index 528dfb08..dca11f55 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/ImportUtil.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/ImportUtil.java
@@ -98,8 +98,9 @@ public class ImportUtil {
kind = IMPORT_KIND_JAVA;
else if (IMPORT_TYPE_BPMN2.equals(type))
kind = "bpmn"; //$NON-NLS-1$
- else
- return null;
+ else {
+ throw new IllegalArgumentException("Unsupported Import type: "+type);
+ }
String location = imp.getLocation();
if (location==null) {
location = ""; //$NON-NLS-1$

Back to the top