diff options
author | MichaelMorris <michael.morris@est.tech> | 2022-09-07 15:28:21 +0100 |
---|---|---|
committer | MichaelMorris <michael.morris@est.tech> | 2022-09-09 13:02:10 +0100 |
commit | 9699b67917b34c1a10536d353cef09d8904354a6 (patch) | |
tree | c050c27ef902ab8624fa3c91cf437357cfd9ab66 /catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java | |
parent | 92b18f188105d5ba4b2c469cdfaedc7d2953d593 (diff) |
Import services with sub prop tosca functions
Includes fix for setting sub properties to yaml values other than maps
Signed-off-by: MichaelMorris <michael.morris@est.tech>
Issue-ID: SDC-4168
Change-Id: I15e3c450c10d4603f882c20f2da80cb7b5d80bb6
Diffstat (limited to 'catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java')
-rw-r--r-- | catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java index 684645a7b2..9e04572075 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java @@ -145,6 +145,7 @@ import org.openecomp.sdc.common.log.wrappers.Logger; import org.openecomp.sdc.common.util.ValidationUtils; import org.openecomp.sdc.exception.ResponseFormat; import org.springframework.beans.factory.annotation.Autowired; +import org.yaml.snakeyaml.Yaml; @org.springframework.stereotype.Component public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { @@ -1968,6 +1969,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { toscaFunctionValidator.validate(property, containerComponent); property.setValue(property.getToscaFunction().getValue()); } + if (CollectionUtils.isNotEmpty(property.getSubPropertyToscaFunctions())){ final JSONObject jObject = property.getValue() == null ? new JSONObject() : new JSONObject(property.getValue()); property.getSubPropertyToscaFunctions().stream().forEach(subToscaFunction -> { @@ -2022,11 +2024,8 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { private void setJsonObjectForSubProperty(final JSONObject jObject, final List<String> path, String value) { if (path.size() == 1) { - if (!value.startsWith("{")) { - value = new StringBuilder("{").append(value).append("}").toString(); - } - final JSONObject jObjectSub = new JSONObject(value); - jObject.put(path.get(0), jObjectSub); + Object valueAsObject = new Yaml().loadAs(value, Object.class); + jObject.put(path.get(0), valueAsObject); } else { if (!jObject.has(path.get(0))) { jObject.put(path.get(0), new JSONObject()); |