aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2022-09-05 18:30:04 +0100
committerVasyl Razinkov <vasyl.razinkov@est.tech>2022-09-08 10:49:57 +0000
commitc0c2637f201f488a74cb1916f05eece0cc207e9d (patch)
tree865d55822423eca85b389f65ec7d6a8e6087e680 /catalog-be/src
parent013779aedf93a6f6ff878c457de53e729540c252 (diff)
Support import service with yaml tosca function
Signed-off-by: MichaelMorris <michael.morris@est.tech> Issue-ID: SDC-4166 Change-Id: I3c0c3af3a36ccb02fbdd518de8e75175e9a42607
Diffstat (limited to 'catalog-be/src')
-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,