diff options
author | franciscovila <javier.paradela.vila@est.tech> | 2022-01-11 11:02:57 +0000 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2022-01-13 09:34:24 +0000 |
commit | 9253465137072c13a7720bac1496b2f3c8655eb8 (patch) | |
tree | fba059ff94476645c105780637ee2263ac23c6e5 | |
parent | 5325a8ed571460b52d618963e37f5bda20fef727 (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
-rw-r--r-- | catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java | 8 |
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); } |