From 8220d912803cecb22af967173e228867569450c4 Mon Sep 17 00:00:00 2001 From: MichaelMorris Date: Wed, 19 Oct 2022 18:37:01 +0100 Subject: Fix import policy issues The following issues are addressed: When a service is imported containing polices, a new name for the policy is generated instead of using the name from the imported service When a service is imported containing policies with a string value set for a property of a policy, then the value is created in the new service surrounded with quotes NPE when service imported with no instances NPE when service imported with instances with no requirements Signed-off-by: MichaelMorris Issue-ID: SDC-4224 Change-Id: I8403c0564796a045816ae28e52961688ca7804db --- .../jsonjanusgraph/operations/TopologyTemplateOperation.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'catalog-model/src') diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java index c450457855..790499c0da 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java @@ -31,6 +31,7 @@ import java.util.Map.Entry; import java.util.Optional; import java.util.stream.Collectors; import org.apache.commons.collections.MapUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.tinkerpop.gremlin.structure.Direction; import org.apache.tinkerpop.gremlin.structure.Edge; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus; @@ -1585,9 +1586,12 @@ public class TopologyTemplateOperation extends ToscaElementOperation { } private void fillPolicyDefinition(GraphVertex componentV, PolicyDefinition policyDefinition, int counter) { - String policyName = buildSubComponentName((String) componentV.getJsonMetadataField(JsonPresentationFields.NAME), - policyDefinition.getPolicyTypeName(), counter); - policyDefinition.setName(policyName); + String policyName = policyDefinition.getName(); + if (StringUtils.isBlank(policyName)) { + policyName = buildSubComponentName((String) componentV.getJsonMetadataField(JsonPresentationFields.NAME), + policyDefinition.getPolicyTypeName(), counter); + policyDefinition.setName(policyName); + } policyDefinition.setInvariantName(policyName); policyDefinition.setComponentName((String) componentV.getJsonMetadataField(JsonPresentationFields.NAME)); policyDefinition.setUniqueId(UniqueIdBuilder.buildPolicyUniqueId(componentV.getUniqueId(), policyName)); -- cgit 1.2.3-korg