summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/main/java/org')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogic.java18
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java12
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java10
3 files changed, 37 insertions, 3 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogic.java
index a85b5542a0..1d37efef28 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogic.java
@@ -164,7 +164,23 @@ public class CsarBusinessLogic extends BaseBusinessLogic {
CsarInfo csarInfo, String nodeName, Component component) {
return yamlHandler
.parseResourceInfoFromYAML(yamlName, topologyTemplateYaml, csarInfo.getCreatedNodesToscaResourceNames(), nodeTypesInfo, nodeName,
- component);
+ component, getInterfaceTemplateYaml(csarInfo).orElse(""));
+ }
+
+ private Optional<String> getInterfaceTemplateYaml(CsarInfo csarInfo) {
+ String[] yamlFile;
+ String interfaceTemplateYaml = "";
+ if (csarInfo.getMainTemplateName().contains(".yml")) {
+ yamlFile = csarInfo.getMainTemplateName().split(".yml");
+ interfaceTemplateYaml = yamlFile[0] + "-interface.yml";
+ } else if (csarInfo.getMainTemplateName().contains(".yaml")) {
+ yamlFile = csarInfo.getMainTemplateName().split(".yaml");
+ interfaceTemplateYaml = yamlFile[0] + "-interface.yaml";
+ }
+ if (csarInfo.getCsar().containsKey(interfaceTemplateYaml)) {
+ return Optional.of(new String(csarInfo.getCsar().get(interfaceTemplateYaml)));
+ }
+ return Optional.empty();
}
private String logAndThrowComponentException(ResponseFormat responseFormat, String logMessage, String... params) {
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 51794a3350..cb3057b49a 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
@@ -62,10 +62,10 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
+import java.util.Optional;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
-import java.util.stream.Stream;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
@@ -92,6 +92,7 @@ import org.openecomp.sdc.be.model.NodeTypeInfo;
import org.openecomp.sdc.be.model.ParsedToscaYamlInfo;
import org.openecomp.sdc.be.model.PolicyDefinition;
import org.openecomp.sdc.be.model.PolicyTypeDefinition;
+import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.UploadArtifactInfo;
import org.openecomp.sdc.be.model.UploadCapInfo;
@@ -130,7 +131,7 @@ public class YamlTemplateParsingHandler {
public ParsedToscaYamlInfo parseResourceInfoFromYAML(String fileName, String resourceYml, Map<String, String> createdNodesToscaResourceNames,
Map<String, NodeTypeInfo> nodeTypesInfo, String nodeName,
- org.openecomp.sdc.be.model.Component component) {
+ org.openecomp.sdc.be.model.Component component, String interfaceTemplateYaml) {
log.debug("#parseResourceInfoFromYAML - Going to parse yaml {} ", fileName);
Map<String, Object> mappedToscaTemplate = getMappedToscaTemplate(fileName, resourceYml, nodeTypesInfo, nodeName);
ParsedToscaYamlInfo parsedToscaYamlInfo = new ParsedToscaYamlInfo();
@@ -142,6 +143,9 @@ public class YamlTemplateParsingHandler {
parsedToscaYamlInfo.setPolicies(getPolicies(fileName, mappedToscaTemplate, component.getModel()));
}
if (getSubstitutionMappings(mappedToscaTemplate) != null) {
+ if (component.isService() && !interfaceTemplateYaml.isEmpty()) {
+ parsedToscaYamlInfo.setProperties(getProperties(loadYamlAsStrictMap(interfaceTemplateYaml)));
+ }
parsedToscaYamlInfo.setSubstitutionMappingNodeType((String) getSubstitutionMappings(mappedToscaTemplate).get(NODE_TYPE.getElementName()));
}
log.debug("#parseResourceInfoFromYAML - The yaml {} has been parsed ", fileName);
@@ -181,6 +185,10 @@ public class YamlTemplateParsingHandler {
return inputs;
}
+ private Map<String, PropertyDefinition> getProperties(Map<String, Object> toscaJson) {
+ return ImportUtils.getProperties(toscaJson).left().on(err -> new HashMap<>());
+ }
+
private Map<String, PolicyDefinition> getPolicies(String fileName, Map<String, Object> toscaJson, String model) {
Map<String, Object> foundPolicies = findFirstToscaMapElement(toscaJson, POLICIES).left().on(err -> logPoliciesNotFound(fileName));
if (MapUtils.isNotEmpty(foundPolicies)) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
index 8a855e0031..d3e7085e4f 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
@@ -291,6 +291,16 @@ public class ServiceImportBusinessLogic {
log.debug("name is locked {} status = {}", service.getSystemName(), lockResult);
}
try {
+ log.trace("************* Adding properties to service from interface yaml {}", yamlName);
+ Map<String, PropertyDefinition> properties = parsedToscaYamlInfo.getProperties();
+ if (properties != null && !properties.isEmpty()) {
+ final List<PropertyDefinition> propertiesList = new ArrayList<>();
+ properties.forEach((propertyName, propertyDefinition) -> {
+ propertyDefinition.setName(propertyName);
+ propertiesList.add(propertyDefinition);
+ });
+ service.setProperties(propertiesList);
+ }
log.trace("************* createResourceFromYaml before full create resource {}", yamlName);
service = serviceImportParseLogic.createServiceTransaction(service, csarInfo.getModifier(), isNormative);
log.trace("************* Going to add inputs from yaml {}", yamlName);