Fix service csar with model download failure 07/123507/3
authorMichaelMorris <michael.morris@est.tech>
Tue, 24 Aug 2021 11:58:48 +0000 (12:58 +0100)
committerAndr� Schmid <andre.schmid@est.tech>
Wed, 25 Aug 2021 11:01:25 +0000 (11:01 +0000)
Signed-off-by: MichaelMorris <michael.morris@est.tech>
Issue-ID: SDC-3681
Change-Id: I824b38de5d0669db8aa3d47530fa02dcdf0d4871

catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java

index 0e08be5..c291c57 100644 (file)
@@ -3372,9 +3372,10 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
         if (nodeNamespaceMap.containsKey(uploadComponentInstanceInfo.getType())) {
             refResource = nodeNamespaceMap.get(uploadComponentInstanceInfo.getType());
         } else {
-            Either<Resource, StorageOperationStatus> findResourceEither = toscaOperationFacade
-                .getByToscaResourceNameMatchingVendorRelease(uploadComponentInstanceInfo.getType(),
-                    ((ResourceMetadataDataDefinition) resource.getComponentMetadataDefinition().getMetadataDataDefinition()).getVendorRelease());
+            Either<Resource, StorageOperationStatus> 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());
index cfbd633..542b142 100644 (file)
@@ -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);