summaryrefslogtreecommitdiffstats
path: root/catalog-model
diff options
context:
space:
mode:
authorfranciscovila <javier.paradela.vila@est.tech>2022-01-13 19:31:25 +0000
committerFrancisco Javier Paradela Vila <javier.paradela.vila@est.tech>2022-01-13 19:36:15 +0000
commit5ea7aeab94051f17d9e5e31b53302eef912b9c6a (patch)
treeface9e7e782860a8e394fef07024b5f7d0457ef6 /catalog-model
parent0fbe309f797b4cdac9d507a6f3dfd193644aa224 (diff)
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 <javier.paradela.vila@est.tech> Change-Id: I411f7d70a0016f0632e6e0daa315dfa70ffe8de9
Diffstat (limited to 'catalog-model')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java11
1 files 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<String, Object> getConfig = (Map<String, Object>) ConfigurationManager.getConfigurationManager().getConfiguration().getToscaArtifacts()
- .entrySet().stream().filter(p -> p.getKey().equalsIgnoreCase(artifactInfo.getArtifactLabel())).findAny().get().getValue();
- artifactInfo.setArtifactName(componentType + "-" + componentName + getConfig.get("artifactName"));
+ Optional<Entry<String, Object>> oConfig = ConfigurationManager.getConfigurationManager().getConfiguration().getToscaArtifacts()
+ .entrySet().stream().filter(p -> p.getKey().equalsIgnoreCase(artifactInfo.getArtifactLabel())).findAny();
+ if (oConfig.isPresent()) {
+ artifactInfo.setArtifactName(componentType + "-" + componentName + ((Map<String, Object>)oConfig.get().getValue()).get("artifactName"));
+ }
+ else {
+ artifactInfo.setArtifactName(componentType + "-" + componentName);
+ }
}
protected <T extends ToscaElement> StorageOperationStatus validateResourceCategory(T toscaElementToUpdate, GraphVertex elementV) {