diff options
author | andre.schmid <andre.schmid@est.tech> | 2021-11-26 10:29:09 +0000 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2023-02-09 11:39:31 +0000 |
commit | be850f6e83cbaa5c16f79c2c8732583f42e55429 (patch) | |
tree | 3b36e783c5018ffe79e309397a88ca70721ede6e /catalog-be/src/main/java | |
parent | e2a9c9c4d6c76bf4c70953a9e5289777bc63c1f5 (diff) |
Consider model in generic substitution type query
Change-Id: I9905b5f6b1bd658befb88b2dbb6903dfaa1f0f8a
Issue-ID: SDC-3794
Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'catalog-be/src/main/java')
-rw-r--r-- | catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/generic/GenericTypeBusinessLogic.java | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/generic/GenericTypeBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/generic/GenericTypeBusinessLogic.java index 600f7fa3eb..52ae99e390 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/generic/GenericTypeBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/generic/GenericTypeBusinessLogic.java @@ -19,6 +19,8 @@ */ package org.openecomp.sdc.be.components.impl.generic; +import static org.openecomp.sdc.common.api.Constants.ABSTRACT; + import fj.data.Either; import java.util.ArrayList; import java.util.List; @@ -68,24 +70,35 @@ public class GenericTypeBusinessLogic { return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR)); } Either<Resource, StorageOperationStatus> genericType; - if (StringUtils.isEmpty(component.getDerivedFromGenericVersion())){ - genericType = toscaOperationFacade - .getLatestCertifiedNodeTypeByToscaResourceName(genericTypeToscaName); + if (StringUtils.isEmpty(component.getDerivedFromGenericVersion())) { + genericType = toscaOperationFacade.getLatestByToscaResourceNameAndModel(genericTypeToscaName, component.getModel()); if (genericType.isRight()) { - log.debug("Failed to fetch certified node type by tosca resource name {}", genericTypeToscaName); - return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERIC_TYPE_NOT_FOUND, component.assetType(), genericTypeToscaName)); + if (genericTypeToscaName.contains(ABSTRACT)) { + genericType = toscaOperationFacade.getLatestCertifiedNodeTypeByToscaResourceName(genericTypeToscaName); + if (genericType.isRight()) { + log.debug("Failed to fetch certified node type by tosca resource name {}", genericTypeToscaName); + return Either.right( + componentsUtils.getResponseFormat(ActionStatus.GENERIC_TYPE_NOT_FOUND, component.assetType(), genericTypeToscaName)); + } + } else { + log.debug("Failed to fetch latest node type by tosca resource name {} and model {}", genericTypeToscaName, component.getModel()); + return Either.right( + componentsUtils.getResponseFormat(ActionStatus.GENERIC_TYPE_NOT_FOUND, component.assetType(), genericTypeToscaName)); + } } } else { - genericType = toscaOperationFacade.getByToscaResourceNameAndVersion(genericTypeToscaName, component.getDerivedFromGenericVersion(), component.getModel()); + genericType = toscaOperationFacade.getByToscaResourceNameAndVersion(genericTypeToscaName, component.getDerivedFromGenericVersion(), + component.getModel()); } Resource genericTypeResource = genericType.left().value(); return Either.left(genericTypeResource); } - + public Either<Resource, ResponseFormat> fetchDerivedFromGenericType(final Component component, final String toscaType) { if (StringUtils.isNotEmpty(toscaType)) { - final Either<Resource, StorageOperationStatus> genericType = toscaOperationFacade.getLatestByToscaResourceNameAndModel(toscaType, component.getModel()); + final Either<Resource, StorageOperationStatus> genericType = toscaOperationFacade.getLatestByToscaResourceNameAndModel(toscaType, + component.getModel()); if (genericType.isRight()) { log.debug("Failed to fetch certified node type by tosca resource name {}", toscaType); return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERIC_TYPE_NOT_FOUND, component.assetType(), toscaType)); |