From e4a10c8950c35f21fd192f54c8a293af2dd02b1a Mon Sep 17 00:00:00 2001 From: vasraz Date: Fri, 26 Aug 2022 13:59:23 +0100 Subject: Fix 'Optional license in onboarding'-bug Signed-off-by: Vasyl Razinkov Change-Id: I6b63629e834b8a5002372d6af59ae0a3a9460542 Issue-ID: SDC-3601 --- .../impl/VendorSoftwareProductManagerImpl.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager') diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java index 234ee43f05..001c6c7e37 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java @@ -99,6 +99,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.LicenseType; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OnboardingMethod; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity; @@ -142,7 +143,7 @@ import org.openecomp.sdc.versioning.dao.types.Version; public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductManager { - private static final Logger LOGGER = LoggerFactory.getLogger(VendorSoftwareProductManager.class); + private static final Logger LOGGER = LoggerFactory.getLogger(VendorSoftwareProductManagerImpl.class); private VspMergeDao vspMergeDao; private OrchestrationTemplateDao orchestrationTemplateDao; private OrchestrationTemplateCandidateManager orchestrationTemplateCandidateManager; @@ -386,7 +387,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa private Map> compile(String vendorSoftwareProductId, Version version, ToscaServiceModel serviceModel) { if (isServiceModelMissing(serviceModel)) { - return null; + return Collections.emptyMap(); } enrichedServiceModelDao.deleteAll(vendorSoftwareProductId, version); if (CollectionUtils.isNotEmpty(serviceModel.getModelList())) { @@ -552,9 +553,8 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa populateVersionsForVlm(vspDetails.getVendorId(), vlmVersion); } final PackageInfo packageInfo = createPackageInfo(vspDetails); - final ToscaFileOutputServiceCsarImpl toscaServiceTemplateServiceCsar = new ToscaFileOutputServiceCsarImpl(new AsdPackageHelper(new ManifestUtils())); - final FileContentHandler licenseArtifacts = licenseArtifactsService - .createLicenseArtifacts(vspDetails.getId(), vspDetails.getVendorId(), vlmVersion, vspDetails.getFeatureGroups()); + final ToscaFileOutputServiceCsarImpl toscaServiceTemplateServiceCsar = new ToscaFileOutputServiceCsarImpl( + new AsdPackageHelper(new ManifestUtils())); final ETSIService etsiService = new ETSIServiceImpl(); if (etsiService.hasEtsiSol261Metadata(toscaServiceModel.getArtifactFiles())) { final FileContentHandler handler = toscaServiceModel.getArtifactFiles(); @@ -566,6 +566,11 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa packageInfo.setVendorRelease(etsiService.getHighestCompatibleSpecificationVersion(handler).getOriginalValue()); } } + FileContentHandler licenseArtifacts = null; + if (!LicenseType.EXTERNAL.name().equals(vspDetails.getLicenseType())) { + licenseArtifacts = licenseArtifactsService + .createLicenseArtifacts(vspDetails.getId(), vspDetails.getVendorId(), vlmVersion, vspDetails.getFeatureGroups()); + } packageInfo.setTranslatedFile(ByteBuffer.wrap(toscaServiceTemplateServiceCsar.createOutputFile(toscaServiceModel, licenseArtifacts))); packageInfoDao.create(packageInfo); return packageInfo; @@ -613,7 +618,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa private Map> validateOrchestrationTemplate(OrchestrationTemplateEntity orchestrationTemplate) throws IOException { if (isOrchestrationTemplateMissing(orchestrationTemplate)) { - return null; + return Collections.emptyMap(); } Map> validationErrors = new HashMap<>(); FileContentHandler fileContentMap = CommonUtil -- cgit 1.2.3-korg