Fix use of Optional in ComponentBusinessLogic
[sdc.git] / catalog-be / src / main / java / org / openecomp / sdc / be / components / impl / ComponentBusinessLogic.java
index 7d4ba3b..6625d72 100644 (file)
@@ -423,16 +423,17 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
         }
     }
 
-    public Either<List<Component>, ResponseFormat> getLatestVersionNotAbstractComponentsMetadata(boolean isAbstractAbstract,
-                                                                                                 HighestFilterEnum highestFilter,
-                                                                                                 ComponentTypeEnum componentTypeEnum,
-                                                                                                 String internalComponentType, String userId,
-                                                                                                 String modelName) {
+    public Either<List<Component>, ResponseFormat> getLatestVersionNotAbstractComponentsMetadata(final boolean isAbstractAbstract,
+                                                                                                 final HighestFilterEnum highestFilter,
+                                                                                                 final ComponentTypeEnum componentTypeEnum,
+                                                                                                 final String internalComponentType, String userId,
+                                                                                                 final String modelName,
+                                                                                                 final boolean includeNormativeExtensionModels) {
         Either<List<Component>, StorageOperationStatus> nonCheckoutCompResponse = null;
         try {
             validateUserExists(userId);
            nonCheckoutCompResponse = toscaOperationFacade
-                .getLatestVersionNotAbstractMetadataOnly(isAbstractAbstract, componentTypeEnum, internalComponentType, modelName);
+                .getLatestVersionNotAbstractMetadataOnly(isAbstractAbstract, componentTypeEnum, internalComponentType, modelName, includeNormativeExtensionModels);
             if (nonCheckoutCompResponse.isLeft()) {
                 log.debug("Retrieved Resource successfully.");
                 return Either.left(nonCheckoutCompResponse.left().value());
@@ -542,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);
     }