diff options
author | Chris André <chris.andre@yoppworks.com> | 2020-04-21 21:26:12 -0400 |
---|---|---|
committer | Ofir Sonsino <ofir.sonsino@intl.att.com> | 2020-04-22 10:58:43 +0000 |
commit | 80a4b4a14a63509990bdbcb960538d30ae22a6e5 (patch) | |
tree | c9565ded67e69716431d9cb74fce98a155edc531 /catalog-model/src/main | |
parent | c39f8ff9e9436d974f9d0021be04b0a925d6745d (diff) |
Add null test in ArtifactsOperations
- Added if statement in `updateArtifactOnGraph` to account for the case where variable `artifactInst` has not been properly initialized
Issue-ID: SDC-2919
Signed-off-by: Chris Andre <chris.andre@yoppworks.com>
Change-Id: I73fe3b3bcef59e5797a0f7cfe7b6894816d0d3fb
Diffstat (limited to 'catalog-model/src/main')
-rw-r--r-- | catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java index 3c8e0ee5cf..30e76a8b79 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java @@ -686,22 +686,30 @@ public class ArtifactsOperations extends BaseOperation { List<String> pathKeys = new ArrayList<>(); pathKeys.add(instanceId); if (isNeedToClone) { - MapArtifactDataDefinition artifatcsOnInstance = artifactInst.get(instanceId); - if (artifatcsOnInstance != null) { - Map<String, ArtifactDataDefinition> mapToscaDataDefinition = artifatcsOnInstance.getMapToscaDataDefinition(); - ArtifactDataDefinition artifactDataDefinitionToUpdate = new ArtifactDataDefinition(artifactToUpdate); - mapToscaDataDefinition.put(artifactToUpdate.getArtifactLabel(), artifactDataDefinitionToUpdate); - } + if (artifactInst != null) { + MapArtifactDataDefinition artifatcsOnInstance = artifactInst.get(instanceId); + if (artifatcsOnInstance != null) { + Map<String, ArtifactDataDefinition> mapToscaDataDefinition = artifatcsOnInstance + .getMapToscaDataDefinition(); + ArtifactDataDefinition artifactDataDefinitionToUpdate = new ArtifactDataDefinition( + artifactToUpdate); + mapToscaDataDefinition.put(artifactToUpdate.getArtifactLabel(), artifactDataDefinitionToUpdate); + } - for (Entry<String, MapArtifactDataDefinition> e : artifactInst.entrySet()) { - List<ArtifactDataDefinition> toscaDataListPerInst = e.getValue().getMapToscaDataDefinition().values().stream().collect(Collectors.toList()); - List<String> pathKeysPerInst = new ArrayList<>(); - pathKeysPerInst.add(e.getKey()); - status = updateToscaDataDeepElementsOfToscaElement(componentId, edgeLabelEnum, vertexTypeEnum, toscaDataListPerInst, pathKeysPerInst, JsonPresentationFields.ARTIFACT_LABEL); - if (status != StorageOperationStatus.OK) { - log.debug("Failed to update atifacts group for instance {} in component {} edge type {} error {}", instanceId, componentId, edgeLabelEnum, status); - res = Either.right(status); - break; + for (Entry<String, MapArtifactDataDefinition> e : artifactInst.entrySet()) { + List<ArtifactDataDefinition> toscaDataListPerInst = e.getValue().getMapToscaDataDefinition() + .values().stream().collect(Collectors.toList()); + List<String> pathKeysPerInst = new ArrayList<>(); + pathKeysPerInst.add(e.getKey()); + status = updateToscaDataDeepElementsOfToscaElement(componentId, edgeLabelEnum, vertexTypeEnum, + toscaDataListPerInst, pathKeysPerInst, JsonPresentationFields.ARTIFACT_LABEL); + if (status != StorageOperationStatus.OK) { + log.debug( + "Failed to update atifacts group for instance {} in component {} edge type {} error {}", + instanceId, componentId, edgeLabelEnum, status); + res = Either.right(status); + break; + } } } } else { |