From 9253465137072c13a7720bac1496b2f3c8655eb8 Mon Sep 17 00:00:00 2001 From: franciscovila Date: Tue, 11 Jan 2022 11:02:57 +0000 Subject: 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 Change-Id: I9ec1825dfa0489875933728fa708fc79f0991751 --- .../openecomp/sdc/be/components/impl/ComponentBusinessLogic.java | 8 ++++++-- 1 file 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); } -- cgit 1.2.3-korg