From 96908856dea9061161b2c324aa7b0eeb5d6e4fd5 Mon Sep 17 00:00:00 2001 From: "andre.schmid" Date: Thu, 29 Aug 2019 16:31:53 +0000 Subject: Fix artifacts references in main TOSCA descriptor During package conversion, artifacts can have their path changed. References for those artifacts inside the main TOSCA descriptor must be updated accordingly. Change-Id: Idcffb0724c20875ff1decebfec7c47605bfe20dc Issue-ID: SDC-2540 Signed-off-by: andre.schmid --- .../impl/VendorSoftwareProductManagerImpl.java | 76 +++++++++++----------- 1 file changed, 39 insertions(+), 37 deletions(-) (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main') 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 5d2fd518fa..4a44076e46 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 @@ -16,6 +16,31 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl; +import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductInvalidErrorBuilder.candidateDataNotProcessedOrAbortedErrorBuilder; +import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductInvalidErrorBuilder.invalidProcessedCandidate; +import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductInvalidErrorBuilder.vspMissingDeploymentFlavorErrorBuilder; + +import java.io.BufferedOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.nio.ByteBuffer; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.zip.ZipInputStream; +import java.util.zip.ZipOutputStream; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.tuple.ImmutablePair; @@ -108,31 +133,6 @@ import org.openecomp.sdc.versioning.VersioningManagerFactory; import org.openecomp.sdc.versioning.VersioningUtil; import org.openecomp.sdc.versioning.dao.types.Version; -import java.io.BufferedOutputStream; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; -import java.util.zip.ZipInputStream; -import java.util.zip.ZipOutputStream; - -import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductInvalidErrorBuilder.candidateDataNotProcessedOrAbortedErrorBuilder; -import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductInvalidErrorBuilder.invalidProcessedCandidate; -import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductInvalidErrorBuilder.vspMissingDeploymentFlavorErrorBuilder; - public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductManager { private VspMergeDao vspMergeDao; @@ -610,26 +610,28 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa } @Override - public PackageInfo createPackage(String vspId, Version version) throws IOException { - ToscaServiceModel toscaServiceModel = enrichedServiceModelDao.getServiceModel(vspId, version); - VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version)); - Version vlmVersion = vspDetails.getVlmVersion(); + public PackageInfo createPackage(final String vspId, final Version version) throws IOException { + final ToscaServiceModel toscaServiceModel = enrichedServiceModelDao.getServiceModel(vspId, version); + final VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version)); + final Version vlmVersion = vspDetails.getVlmVersion(); if (vlmVersion != null) { populateVersionsForVlm(vspDetails.getVendorId(), vlmVersion); } - PackageInfo packageInfo = createPackageInfo(vspDetails); + final PackageInfo packageInfo = createPackageInfo(vspDetails); - ToscaFileOutputServiceCsarImpl toscaServiceTemplateServiceCsar = + final ToscaFileOutputServiceCsarImpl toscaServiceTemplateServiceCsar = new ToscaFileOutputServiceCsarImpl(); - FileContentHandler licenseArtifacts = licenseArtifactsService + final FileContentHandler licenseArtifacts = licenseArtifactsService .createLicenseArtifacts(vspDetails.getId(), vspDetails.getVendorId(), vlmVersion, vspDetails.getFeatureGroups()); - ETSIService etsiService = new ETSIServiceImpl(); + final ETSIService etsiService = new ETSIServiceImpl(); if (etsiService.isSol004WithToscaMetaDirectory(toscaServiceModel.getArtifactFiles())) { - FileContentHandler handler = toscaServiceModel.getArtifactFiles(); - Manifest manifest = etsiService.getManifest(handler); - etsiService.moveNonManoFileToArtifactFolder(handler, manifest); - packageInfo.setResourceType(etsiService.getResourceType(manifest).name()); + final FileContentHandler handler = toscaServiceModel.getArtifactFiles(); + final Manifest manifest = etsiService.getManifest(handler); + final Optional> fromToMovedPaths = etsiService.moveNonManoFileToArtifactFolder(handler); + fromToMovedPaths + .ifPresent(it -> etsiService.updateMainDescriptorPaths(toscaServiceModel, it)); + packageInfo.setResourceType(etsiService.getResourceType(manifest).name()); } packageInfo.setTranslatedFile(ByteBuffer.wrap( toscaServiceTemplateServiceCsar.createOutputFile(toscaServiceModel, licenseArtifacts))); -- cgit 1.2.3-korg