aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java19
1 files changed, 18 insertions, 1 deletions
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 bf0f1b2812..ab43b4329e 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
@@ -68,6 +68,7 @@ import org.openecomp.sdc.be.dao.janusgraph.JanusGraphDao;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.datamodel.utils.ArtifactUtils;
import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.CustomYamlFunction;
import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
@@ -1893,7 +1894,19 @@ public class ServiceImportBusinessLogic {
final var property = new ComponentInstanceProperty(curPropertyDef, value, null);
String validatePropValue = serviceBusinessLogic.validatePropValueBeforeCreate(property, value, isValidate, allDataTypes);
property.setValue(validatePropValue);
- property.setToscaFunction(propertyInfo.getToscaFunction());
+
+ if (tryHandlingAsYamlToscaFunction(validatePropValue, value, propertyInfo)) {
+ try {
+ final Object yamlValue = new Yaml().loadAs(value, Object.class);
+ CustomYamlFunction toscaFunction = new CustomYamlFunction();
+ toscaFunction.setYamlValue(yamlValue);
+ property.setToscaFunction(toscaFunction);
+ } catch (Exception exception) {
+ log.info("Cannot create YAML value for {}", propName);
+ }
+ } else {
+ property.setToscaFunction(propertyInfo.getToscaFunction());
+ }
if (!getInputs.isEmpty()) {
final List<GetInputValueDataDefinition> getInputValues = new ArrayList<>();
for (final GetInputValueDataDefinition getInput : getInputs) {
@@ -1927,6 +1940,10 @@ public class ServiceImportBusinessLogic {
instProperties.put(currentCompInstance.getUniqueId(), instPropList);
return componentsUtils.getResponseFormat(ActionStatus.OK);
}
+
+ private boolean tryHandlingAsYamlToscaFunction(String validatePropValue, String value, UploadPropInfo propertyInfo) {
+ return StringUtils.isEmpty(validatePropValue) && StringUtils.isNotEmpty(value) && propertyInfo.getToscaFunction() == null;
+ }
protected ResponseFormat addInterfaceValuesToRi(
UploadComponentInstanceInfo uploadComponentInstanceInfo,