From 35841a655443834474b48d94ae8b124d6f0896ff Mon Sep 17 00:00:00 2001 From: MichaelMorris Date: Tue, 24 Aug 2021 12:58:48 +0100 Subject: Fix service csar with model download failure Signed-off-by: MichaelMorris Issue-ID: SDC-3681 Change-Id: I824b38de5d0669db8aa3d47530fa02dcdf0d4871 --- .../openecomp/sdc/be/components/impl/ResourceBusinessLogic.java | 7 ++++--- .../sdc/be/components/impl/ResourceBusinessLogicTest.java | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java index 0e08be5d7a..c291c571d7 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java @@ -3372,9 +3372,10 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { if (nodeNamespaceMap.containsKey(uploadComponentInstanceInfo.getType())) { refResource = nodeNamespaceMap.get(uploadComponentInstanceInfo.getType()); } else { - Either findResourceEither = toscaOperationFacade - .getByToscaResourceNameMatchingVendorRelease(uploadComponentInstanceInfo.getType(), - ((ResourceMetadataDataDefinition) resource.getComponentMetadataDefinition().getMetadataDataDefinition()).getVendorRelease()); + Either findResourceEither = StringUtils.isEmpty(resource.getModel()) ? + toscaOperationFacade.getByToscaResourceNameMatchingVendorRelease(uploadComponentInstanceInfo.getType(), + ((ResourceMetadataDataDefinition) resource.getComponentMetadataDefinition().getMetadataDataDefinition()).getVendorRelease()): + toscaOperationFacade.getLatestByToscaResourceNameAndModel(uploadComponentInstanceInfo.getType(), resource.getModel()); if (findResourceEither.isRight()) { log.debug("validateResourceInstanceBeforeCreate - not found latest version for resource instance with name {} and type {}", uploadComponentInstanceInfo.getName(), uploadComponentInstanceInfo.getType()); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java index cfbd63363a..542b142c21 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java @@ -1489,7 +1489,7 @@ public class ResourceBusinessLogicTest { roleProp.setName("role"); roleProp.setType("string"); vduCp.getProperties().add(roleProp); - when(toscaOperationFacade.getByToscaResourceNameMatchingVendorRelease("tosca.nodes.nfv.VduCp", "1.0.0")).thenReturn(Either.left(vduCp)); + when(toscaOperationFacade.getLatestByToscaResourceNameAndModel("tosca.nodes.nfv.VduCp", "testModel")).thenReturn(Either.left(vduCp)); when(yamlTemplateParsingHandler.parseResourceInfoFromYAML(any(), any(), any(), any(), any(), any())).thenReturn(parsedToscaYamlInfo); -- cgit 1.2.3-korg