summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2022-08-15 17:14:13 +0100
committerMichaelMorris <michael.morris@est.tech>2022-08-15 17:17:17 +0100
commitfbfa96e29315ede4e41d43f6009367282ee46115 (patch)
treeee732fc991b730c5b5e5090511df8faf8e3becc9
parent4078ce4a2c2b3c660a22f6f908e975126219a064 (diff)
Fix ClassCastException in import
Signed-off-by: MichaelMorris <michael.morris@est.tech> Issue-ID: SDC-4133 Change-Id: Ic7ac38dac39ed9b962691390818e18b753f9378e
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java54
1 files changed, 30 insertions, 24 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
index ee31112253..01b62595b8 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
@@ -1255,31 +1255,37 @@ public class YamlTemplateParsingHandler {
final ArtifactDataDefinition artifactDataDefinition = new ArtifactDataDefinition();
if (operationDefinitionMap.get(IMPLEMENTATION.getElementName()) instanceof Map &&
((Map)operationDefinitionMap.get(IMPLEMENTATION.getElementName())).containsKey("primary")) {
- Map<String, Object> implDetails = (Map) ((Map)operationDefinitionMap.get(IMPLEMENTATION.getElementName())).get("primary");
-
- if (implDetails.get("file") != null) {
- final String file = implDetails.get("file").toString();
- artifactDataDefinition.setArtifactName(generateArtifactName(file));
- }
- if (implDetails.get("type") != null) {
- artifactDataDefinition.setArtifactType(implDetails.get("type").toString());
- }
- if (implDetails.get("artifact_version") != null) {
- artifactDataDefinition.setArtifactVersion(implDetails.get("artifact_version").toString());
- }
+
+ final Object primary = ((Map)operationDefinitionMap.get(IMPLEMENTATION.getElementName())).get("primary");
+ if(primary instanceof Map) {
+ Map<String, Object> implDetails = (Map) primary;
+
+ if (implDetails.get("file") != null) {
+ final String file = implDetails.get("file").toString();
+ artifactDataDefinition.setArtifactName(generateArtifactName(file));
+ }
+ if (implDetails.get("type") != null) {
+ artifactDataDefinition.setArtifactType(implDetails.get("type").toString());
+ }
+ if (implDetails.get("artifact_version") != null) {
+ artifactDataDefinition.setArtifactVersion(implDetails.get("artifact_version").toString());
+ }
- if(implDetails.get("properties") instanceof Map) {
- List<PropertyDataDefinition> operationProperties = artifactDataDefinition.getProperties() == null ? new ArrayList<>() : artifactDataDefinition.getProperties();
- Map<String, Object> properties = (Map<String, Object>) implDetails.get("properties");
- properties.forEach((k,v) -> {
- ToscaPropertyType type = getTypeFromObject(v);
- if (type != null) {
- PropertyDataDefinition propertyDef = new PropertyDataDefinition();
- propertyDef.setName(k);
- propertyDef.setValue(v.toString());
- artifactDataDefinition.addProperty(propertyDef);
- }
- });
+ if(implDetails.get("properties") instanceof Map) {
+ List<PropertyDataDefinition> operationProperties = artifactDataDefinition.getProperties() == null ? new ArrayList<>() : artifactDataDefinition.getProperties();
+ Map<String, Object> properties = (Map<String, Object>) implDetails.get("properties");
+ properties.forEach((k,v) -> {
+ ToscaPropertyType type = getTypeFromObject(v);
+ if (type != null) {
+ PropertyDataDefinition propertyDef = new PropertyDataDefinition();
+ propertyDef.setName(k);
+ propertyDef.setValue(v.toString());
+ artifactDataDefinition.addProperty(propertyDef);
+ }
+ });
+ }
+ } else {
+ artifactDataDefinition.setArtifactName(generateArtifactName(primary.toString()));
}
}
if (operationDefinitionMap.get(IMPLEMENTATION.getElementName()) instanceof String) {