Skip to content

Commit a9ee074

Browse files
committed
Report properly on errors during CSAR generation
1 parent 18f82b1 commit a9ee074

File tree

7 files changed

+64
-5
lines changed

7 files changed

+64
-5
lines changed
-2.67 KB
Binary file not shown.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
tosca_definitions_version: tosca_simple_yaml_1_3
2+
3+
4+
5+
topology_template:
6+
7+
node_templates:
8+
Myrtus_Workstation_1:
9+
type: example.eu.myrtus.nodetypes.Myrtus-Workstation
10+
11+
12+
13+
14+
MyrtusFaceDetectionService_0:
15+
type: example.eu.myrtus.nodetypes.MyrtusFaceDetectionService
16+
17+
properties:
18+
dockerImage: "thebigpotatoe/face-recognition-docker"
19+
20+
21+
MyrtusCameraFeed_0:
22+
type: example.eu.myrtus.nodetypes.MyrtusCameraFeed
23+
24+
properties:
25+
dockerImage: "ci.hesi.energy:5000/myrtus/examples/myrtusface/camera_feed:web"
26+
27+
28+
Myrtus_Proxy_0:
29+
type: example.eu.myrtus.nodetypes.MyrtusProxy
30+
31+
properties:
32+
dockerImage: "nginx:alpine"
33+
port: "443"
34+
35+
36+
37+
relationship_templates:
38+
hostedOn:
39+
type: hostedOn
40+
hostedOn:
41+
type: hostedOn
42+
hostedOn:
43+
type: hostedOn
44+
connectsOn:
45+
type: hostedOn
46+
connectsOn:
47+
type: hostedOn

ToscaDesigner/src/main/java/fr/softeam/toscadesigner/export/AbstractToscaFileGenerator.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828

2929
import fr.softeam.toscadesigner.api.tosca.standard.association.TRelationshipTemplate;
3030
import fr.softeam.toscadesigner.api.tosca.standard.attribute.TCapabilityDefinition;
31+
import fr.softeam.toscadesigner.api.tosca.standard.class_.CapabilityStereotype;
32+
import fr.softeam.toscadesigner.api.tosca.standard.class_.TCapabilityType;
3133
import fr.softeam.toscadesigner.api.tosca.standard.class_.TNodeTemplate;
3234
import fr.softeam.toscadesigner.api.tosca.standard.class_.TNodeType;
3335
import fr.softeam.toscadesigner.api.tosca.standard.class_.TRelationshipType;
@@ -70,7 +72,7 @@ private Handlebars setupHandlebars() {
7072
TNodeTemplate node = tRequirement.getNode();
7173
propertyStringValue = node != null ? node.getName() : "''";
7274
} else if (searchedPropertyName.equals("capability")) {
73-
fr.softeam.toscadesigner.api.tosca.standard.class_.TCapabilityDefinition capability = tRequirement.getCapability();
75+
CapabilityStereotype capability = tRequirement.getCapability();
7476
propertyStringValue = capability != null ? capability.getElement().getName() : "";
7577
}
7678
} else if (stereotype.getName().equals("TRequirementDefinition")) {
@@ -80,7 +82,7 @@ private Handlebars setupHandlebars() {
8082
if (searchedPropertyName.equals("node")) {
8183
propertyStringValue = tRequirementDefinition.getNodeType().getName();
8284
} else if (searchedPropertyName.equals("capability")) {
83-
fr.softeam.toscadesigner.api.tosca.standard.class_.TCapabilityDefinition capability = tRequirementDefinition.getCapability();
85+
TCapabilityType capability = tRequirementDefinition.getCapability();
8486
propertyStringValue = capability.getElement().getName();
8587
} else if (searchedPropertyName.equals("relationshipType")) {
8688
propertyStringValue = tRequirementDefinition.getRelationshipType().getElement().getName();

ToscaDesigner/src/main/java/fr/softeam/toscadesigner/export/CsarFileGenerator.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import org.modelio.metamodel.uml.infrastructure.ModelTree;
1212
import org.modelio.vcore.smkernel.mapi.MObject;
1313

14+
import com.github.jknack.handlebars.HandlebarsException;
15+
1416
public class CsarFileGenerator extends AbstractToscaFileGenerator {
1517

1618
private static final String[] CSAR_FILE_EXTENSIONS = { "*.csar" };
@@ -67,7 +69,15 @@ public void generateContent(MObject toscaModel) throws IOException {
6769
logger.error(e);
6870
MessageDialog.openError(Display.getCurrent().getActiveShell(), "CSAR export error",
6971
e.getLocalizedMessage());
70-
}
72+
} catch (HandlebarsException ex) {
73+
logger.error(ex);
74+
MessageDialog.openError(Display.getCurrent().getActiveShell(), "Handlebars Error",
75+
"An error occurred while rendering the Handlebars template: " + ex.getMessage());
76+
} catch (NullPointerException ex) {
77+
logger.error(ex);
78+
MessageDialog.openError(Display.getCurrent().getActiveShell(), "NullPointerException",
79+
ex.getStackTrace().toString());
80+
}
7181
}
7282

7383
private void addToscaMetadata(ZipOutputStream zos) throws IOException {

ToscaDesigner/src/main/resources/fr/softeam/templates/TNodeType.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ node_types:
77
targetNamespace: "{{getProperty this "targetNamespace"}}"
88
abstract: "{{getProperty this "abstract"}}"
99
final: "{{getProperty this "final"}}"
10-
{{#unless (noStereotypeApplications this "TRequirementDefinitionType")}}requirements:{{/unless}}
11-
{{#each ownedElement}}{{#extension}}{{#eq name "TRequirementDefinitionType"}}{{#each ../ownedAttribute}}{{#extension}}{{#eq name "TRequirementDefinition"}}
10+
{{#unless (noStereotypeApplications this "RequirementDefinitionType")}}requirements:{{/unless}}
11+
{{#each ownedElement}}{{#extension}}{{#eq name "RequirementDefinitionType"}}{{#each ../ownedAttribute}}{{#extension}}{{#eq name "TRequirementDefinition"}}
1212
- {{../name}}:
1313
capability: {{getProperty ../this "capability"}}
1414
relationship: {{getProperty ../this "relationshipType"}}
13 KB
Binary file not shown.
-776 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)