From 5ea7aeab94051f17d9e5e31b53302eef912b9c6a Mon Sep 17 00:00:00 2001 From: franciscovila Date: Thu, 13 Jan 2022 19:31:25 +0000 Subject: Fix use of Optional in ToscaElementOperation Checking the Optionals are present before getting their values in the ToscaElementOperation class Issue-ID: SDC-3831 Signed-off-by: franciscovila Change-Id: I411f7d70a0016f0632e6e0daa315dfa70ffe8de9 --- .../jsonjanusgraph/operations/ToscaElementOperation.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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 2ff3b49a00..9e9b944fae 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 @@ -1232,9 +1232,14 @@ public abstract class ToscaElementOperation extends BaseOperation { } private void generateNewToscaFileName(String componentType, String componentName, ArtifactDataDefinition artifactInfo) { - Map getConfig = (Map) ConfigurationManager.getConfigurationManager().getConfiguration().getToscaArtifacts() - .entrySet().stream().filter(p -> p.getKey().equalsIgnoreCase(artifactInfo.getArtifactLabel())).findAny().get().getValue(); - artifactInfo.setArtifactName(componentType + "-" + componentName + getConfig.get("artifactName")); + Optional> oConfig = ConfigurationManager.getConfigurationManager().getConfiguration().getToscaArtifacts() + .entrySet().stream().filter(p -> p.getKey().equalsIgnoreCase(artifactInfo.getArtifactLabel())).findAny(); + if (oConfig.isPresent()) { + artifactInfo.setArtifactName(componentType + "-" + componentName + ((Map)oConfig.get().getValue()).get("artifactName")); + } + else { + artifactInfo.setArtifactName(componentType + "-" + componentName); + } } protected StorageOperationStatus validateResourceCategory(T toscaElementToUpdate, GraphVertex elementV) { -- cgit 1.2.3-korg