From 438650c3a958c9176db3720204ec1ff9af94fc3a Mon Sep 17 00:00:00 2001 From: vasraz Date: Tue, 29 Aug 2023 15:29:59 +0100 Subject: Improve handling 'empty'/null string in Service fields Signed-off-by: Vasyl Razinkov Change-Id: Ib301280fe1be2896e2d80e208349ac3c4ff763ec Issue-ID: SDC-4608 --- .../be/model/jsonjanusgraph/operations/NodeTemplateOperation.java | 2 +- .../be/model/jsonjanusgraph/operations/ToscaElementOperation.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'catalog-model') diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java index 22548dbf92..f75c7a6b06 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java @@ -1497,7 +1497,7 @@ public class NodeTemplateOperation extends BaseOperation { String instanceNewName, boolean generateUid, ToscaElement originToscaElement) { String ciOriginComponentUid = resourceInstance.getComponentUid(); - if (!ValidationUtils.validateStringNotEmpty(resourceInstance.getCustomizationUUID())) { + if (StringUtils.isEmpty(resourceInstance.getCustomizationUUID())) { resourceInstance.setCustomizationUUID(generateCustomizationUUID()); } ComponentInstanceDataDefinition dataDefinition = new ComponentInstanceDataDefinition(resourceInstance); diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java index 13729bf0b1..24e1e910d3 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java @@ -39,6 +39,7 @@ import java.util.Set; import java.util.stream.Collectors; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.tinkerpop.gremlin.structure.Direction; import org.apache.tinkerpop.gremlin.structure.Edge; import org.apache.tinkerpop.gremlin.structure.Vertex; @@ -475,10 +476,11 @@ public abstract class ToscaElementOperation extends BaseOperation { protected StorageOperationStatus associateComponentToModel(final GraphVertex nodeTypeVertex, final ToscaElement nodeType, final EdgeLabelEnum edgeLabelEnum) { - if (nodeType.getMetadataValue(JsonPresentationFields.MODEL) == null) { + Object metadataValue = nodeType.getMetadataValue(JsonPresentationFields.MODEL); + if (metadataValue == null || StringUtils.isEmpty((String) metadataValue)) { return StorageOperationStatus.OK; } - final String model = ((String) nodeType.getMetadataValue(JsonPresentationFields.MODEL)); + final String model = ((String) metadataValue); final JanusGraphOperationStatus createEdge = janusGraphDao.createEdge(getModelVertex(model), nodeTypeVertex, edgeLabelEnum, new HashMap<>()); if (createEdge != JanusGraphOperationStatus.OK) { log.trace("Failed to associate resource {} to model {}", nodeType.getUniqueId(), model); -- cgit 1.2.3-korg