From be850f6e83cbaa5c16f79c2c8732583f42e55429 Mon Sep 17 00:00:00 2001 From: "andre.schmid" Date: Fri, 26 Nov 2021 10:29:09 +0000 Subject: Consider model in generic substitution type query Change-Id: I9905b5f6b1bd658befb88b2dbb6903dfaa1f0f8a Issue-ID: SDC-3794 Signed-off-by: andre.schmid --- .../impl/generic/GenericTypeBusinessLogic.java | 29 ++++++++++++++++------ 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'catalog-be/src/main/java/org') 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 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 fetchDerivedFromGenericType(final Component component, final String toscaType) { if (StringUtils.isNotEmpty(toscaType)) { - final Either genericType = toscaOperationFacade.getLatestByToscaResourceNameAndModel(toscaType, component.getModel()); + final Either 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)); -- cgit 1.2.3-korg