aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src
diff options
context:
space:
mode:
authorfranciscovila <javier.paradela.vila@est.tech>2022-01-11 11:02:57 +0000
committerMichael Morris <michael.morris@est.tech>2022-01-13 09:34:24 +0000
commit9253465137072c13a7720bac1496b2f3c8655eb8 (patch)
treefba059ff94476645c105780637ee2263ac23c6e5 /catalog-be/src
parent5325a8ed571460b52d618963e37f5bda20fef727 (diff)
Fix use of Optional in ComponentBusinessLogic
Checking the Optionals are present before getting their values in the ComponentBusinessLogic class Issue-ID: SDC-3829 Signed-off-by: franciscovila <javier.paradela.vila@est.tech> Change-Id: I9ec1825dfa0489875933728fa708fc79f0991751
Diffstat (limited to 'catalog-be/src')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java8
1 files changed, 6 insertions, 2 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
index 8d202092b5..6625d72bcf 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
@@ -543,8 +543,12 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
throw new ByResponseFormatComponentException(
componentsUtils.getResponseFormat(ActionStatus.ARTIFACT_NOT_FOUND, ArtifactTypeEnum.TOSCA_CSAR.name()));
}
- ArtifactDefinition csarArtifact = component.getToscaArtifacts().values().stream()
- .filter(p -> p.getArtifactType().equals(ArtifactTypeEnum.TOSCA_CSAR.getType())).findAny().get();
+
+ final ArtifactDefinition csarArtifact = component.getToscaArtifacts().values().stream()
+ .filter(p -> p.getArtifactType().equals(ArtifactTypeEnum.TOSCA_CSAR.getType())).findAny().orElseThrow(() -> {
+ throw new ByResponseFormatComponentException(
+ componentsUtils.getResponseFormat(ActionStatus.ARTIFACT_NOT_FOUND, ArtifactTypeEnum.TOSCA_CSAR.name()));
+ });
return artifactsBusinessLogic.handleDownloadToscaModelRequest(component, csarArtifact);
}