From d0031501cd81a9046396358f42657f168b5a58a8 Mon Sep 17 00:00:00 2001 From: kooper Date: Tue, 19 Mar 2019 13:31:54 +0000 Subject: Display PNF/VNF Type for PNF (backend) Change-Id: Ie3fabe2a91c1e9040939e2bfe97705cfee15b201 Issue-ID: SDC-2157 Signed-off-by: kooper --- .../impl/VendorSoftwareProductManagerImpl.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (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 36cd58dabf..5be982bede 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,7 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl; +import static org.openecomp.sdc.tosca.csar.CSARConstants.MANIFEST_PNF_METADATA; import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ENTRY_MANIFEST; import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ORIG_PATH_FILE_NAME; import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_PATH_FILE_NAME; @@ -62,6 +63,7 @@ import org.openecomp.core.utilities.json.JsonUtil; import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum; import org.openecomp.core.validation.api.ValidationManager; import org.openecomp.core.validation.util.MessageContainerUtil; +import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.common.errors.CoreException; import org.openecomp.sdc.common.errors.ErrorCode; import org.openecomp.sdc.common.errors.ValidationErrorBuilder; @@ -638,6 +640,8 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa Manifest onboardingManifest = new SOL004ManifestOnboarding(); onboardingManifest.parse(manifestInputStream); etsiService.moveNonManoFileToArtifactFolder(handler, onboardingManifest); + //VSP PNF resource type is supported only for sol004 csar for now, default VSP resource type is VF + packageInfo.setResourceType(getResourceType(onboardingManifest)); } } packageInfo.setTranslatedFile(ByteBuffer.wrap( @@ -647,6 +651,17 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa return packageInfo; } + private String getResourceType(Manifest onboardingManifest) { + //Valid manifest should contain whether vnf or pnf related metadata data exclusively in SOL004 standard, + // validation of manifest done during package upload stage + if(onboardingManifest != null && !onboardingManifest.getMetadata().isEmpty() + && MANIFEST_PNF_METADATA.stream().anyMatch(e -> onboardingManifest.getMetadata().containsKey(e))){ + return ResourceTypeEnum.PNF.name(); + } + //VNF is default resource type + return ResourceTypeEnum.VF.name(); + } + private InputStream getManifest(FileContentHandler handler) throws IOException { ToscaMetadata metadata = getMetadata(handler); return getManifestInputStream(handler, metadata.getMetaEntries().get(TOSCA_META_ENTRY_MANIFEST)); -- cgit 1.2.3-korg