From 3c33df0dc2d58d8e8bdbb52c0ca1ce8f93bce415 Mon Sep 17 00:00:00 2001 From: JvD_Ericsson Date: Tue, 18 Jan 2022 10:17:58 +0000 Subject: Support node template artifact properties Add properties variable to relevant classes and update functions to set these vaules Added properties to an artifact in ETSI-VNF-SAMPLE.csar Issue-ID: SDC-3847 Signed-off-by: JvD_Ericsson Change-Id: Id4f835826be7556cd97403da2018644c6dfea95b --- .../sdc/be/components/csar/YamlTemplateParsingHandler.java | 7 +++++++ .../openecomp/sdc/be/components/impl/ResourceBusinessLogic.java | 8 ++++++++ .../main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java | 1 + .../org/openecomp/sdc/be/tosca/model/ToscaTemplateArtifact.java | 3 +++ 4 files changed, 19 insertions(+) (limited to 'catalog-be/src/main/java') 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 a991f7e0d4..3faf750a73 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 @@ -832,6 +832,13 @@ public class YamlTemplateParsingHandler { if (nodeTemplateJsonMap.containsKey(FILE.getElementName())) { artifactTemplateInfo.setFile((String) nodeTemplateJsonMap.get(FILE.getElementName())); } + if (nodeTemplateJsonMap.containsKey(PROPERTIES.getElementName())) { + Map> props = buildPropModuleFromYaml(nodeTemplateJsonMap); + if (!props.isEmpty()) { + List properties = props.values().stream().flatMap(Collection::stream).collect(toList()); + artifactTemplateInfo.setProperties(properties); + } + } } @SuppressWarnings("unchecked") diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java index 666529986c..8c97a04a74 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java @@ -3409,6 +3409,14 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { ToscaArtifactDataDefinition to = new ToscaArtifactDataDefinition(); to.setFile(entry.getValue().getFile()); to.setType(entry.getValue().getType()); + if(isNotEmpty(entry.getValue().getProperties())) { + Map newPropertiesMap = new HashMap<>(); + List artifactPropsInfo = entry.getValue().getProperties(); + for(UploadPropInfo propInfo: artifactPropsInfo) { + newPropertiesMap.put(propInfo.getName(), propInfo.getValue()); + } + to.setProperties(newPropertiesMap); + } toscaArtifacts.put(entry.getKey(), to); } componentInstance.setToscaArtifacts(toscaArtifacts); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java index cdd5d60ed4..b6bd2a3967 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java @@ -1548,6 +1548,7 @@ public class ToscaExportHandler { ToscaTemplateArtifact artifact = new ToscaTemplateArtifact(); artifact.setFile(entry.getValue().getFile()); artifact.setType(entry.getValue().getType()); + artifact.setProperties(entry.getValue().getProperties()); arts.put(entry.getKey(), artifact); } return arts; diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateArtifact.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateArtifact.java index 894a806de0..9824552f6f 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateArtifact.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateArtifact.java @@ -22,10 +22,13 @@ package org.openecomp.sdc.be.tosca.model; import lombok.Getter; import lombok.Setter; +import java.util.Map; + @Getter @Setter public class ToscaTemplateArtifact { private String file; private String type; + private Map properties; } -- cgit 1.2.3-korg