From 62f5ad6b806d0bda1bb918061a5aa4b5b4dbe8b8 Mon Sep 17 00:00:00 2001 From: "bilal.iqbal" Date: Mon, 25 Mar 2019 14:31:14 +0000 Subject: Change SOL004 baseline from v2.5.1 to v2.6.1 Change-Id: Ic524e25a5f0a9952dd0a2c578034c60e51c7a290 Issue-ID: SDC-2190 Signed-off-by: bilal.iqbal --- .../sdc/tosca/csar/AbstractOnboardingManifest.java | 18 ++++++++++++++++++ .../org/openecomp/sdc/tosca/csar/CSARConstants.java | 9 +++++---- .../java/org/openecomp/sdc/tosca/csar/Manifest.java | 8 ++++++++ .../sdc/tosca/csar/SOL004ManifestOnboarding.java | 2 +- 4 files changed, 32 insertions(+), 5 deletions(-) (limited to 'openecomp-be/lib/openecomp-tosca-lib/src/main') diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/AbstractOnboardingManifest.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/AbstractOnboardingManifest.java index 50c2c106ff..00eb46183a 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/AbstractOnboardingManifest.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/AbstractOnboardingManifest.java @@ -19,6 +19,7 @@ package org.openecomp.sdc.tosca.csar; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.common.errors.Messages; import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; @@ -33,18 +34,22 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Optional; import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters; +import static org.openecomp.sdc.tosca.csar.CSARConstants.MANIFEST_PNF_METADATA; import static org.openecomp.sdc.tosca.csar.CSARConstants.METADATA_MF_ATTRIBUTE; import static org.openecomp.sdc.tosca.csar.CSARConstants.SEPERATOR_MF_ATTRIBUTE; abstract class AbstractOnboardingManifest implements Manifest{ private static final Logger LOGGER = LoggerFactory.getLogger(AbstractOnboardingManifest.class); + private static final int MAX_ALLOWED_MANIFEST_META_ENTRIES = 4; protected Map metadata; protected List sources; protected List errors; protected Map> nonManoSources; + protected ResourceTypeEnum type; protected AbstractOnboardingManifest() { errors = new ArrayList<>(); @@ -53,6 +58,19 @@ import static org.openecomp.sdc.tosca.csar.CSARConstants.SEPERATOR_MF_ATTRIBUTE; nonManoSources = new HashMap<>(); } + @Override + public Optional getType(){ + if(errors.isEmpty() && !metadata.isEmpty() && metadata.size() == MAX_ALLOWED_MANIFEST_META_ENTRIES) { + for (String key : metadata.keySet()) { + if (MANIFEST_PNF_METADATA.stream().anyMatch(key::equals)) { + return Optional.of(ResourceTypeEnum.PNF); + } + return Optional.of(ResourceTypeEnum.VF); + } + } + return Optional.empty(); + } + @Override public void parse(InputStream is) { try { diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/CSARConstants.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/CSARConstants.java index 826a72b6fd..d7dd3d450f 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/CSARConstants.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/CSARConstants.java @@ -32,10 +32,11 @@ public class CSARConstants { public static final String TOSCA_META_CSAR_VERSION_ENTRY = "CSAR-Version"; public static final String TOSCA_META_CREATED_BY_ENTRY = "Created-by"; public static final String TOSCA_META_ENTRY_DEFINITIONS="Entry-Definitions"; - public static final String TOSCA_META_ENTRY_MANIFEST="Entry-Manifest"; - public static final String TOSCA_META_ENTRY_CHANGE_LOG="Entry-Change-Log"; - public static final String TOSCA_META_ENTRY_TESTS = "Entry-Tests"; - public static final String TOSCA_META_ENTRY_LICENSES= "Entry-Licenses"; + public static final String TOSCA_META_ETSI_ENTRY_MANIFEST ="ETSI-Entry-Manifest"; + public static final String TOSCA_META_ETSI_ENTRY_CHANGE_LOG ="ETSI-Entry-Change-Log"; + public static final String TOSCA_META_ETSI_ENTRY_TESTS = "ETSI-Entry-Tests"; + public static final String TOSCA_META_ETSI_ENTRY_LICENSES = "ETSI-Entry-Licenses"; + public static final String TOSCA_META_ETSI_ENTRY_CERTIFICATE = "ETSI-Entry-Certificate"; public static final ImmutableSet ELIGIBLE_FILES = of(MAIN_SERVICE_TEMPLATE_MF_FILE_NAME,MAIN_SERVICE_TEMPLATE_YAML_FILE_NAME); public static final ImmutableSet MANIFEST_PNF_METADATA = diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/Manifest.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/Manifest.java index 1a11ecf6f6..c11f4a3ddc 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/Manifest.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/Manifest.java @@ -20,9 +20,11 @@ package org.openecomp.sdc.tosca.csar; +import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import java.io.InputStream; import java.util.List; import java.util.Map; +import java.util.Optional; public interface Manifest { @@ -62,4 +64,10 @@ public interface Manifest { * @return */ Map> getNonManoSources(); + + /** + * Gets the type based on the metadata of manifest file (VF/PNF) + * @return enum for type values + */ + Optional getType(); } diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/SOL004ManifestOnboarding.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/SOL004ManifestOnboarding.java index 267729596b..1ee1c1b1ae 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/SOL004ManifestOnboarding.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/SOL004ManifestOnboarding.java @@ -32,7 +32,7 @@ import static org.openecomp.sdc.tosca.csar.CSARConstants.NON_MANO_MF_ATTRIBUTE; import static org.openecomp.sdc.tosca.csar.CSARConstants.SEPERATOR_MF_ATTRIBUTE; import static org.openecomp.sdc.tosca.csar.CSARConstants.SOURCE_MF_ATTRIBUTE; -public class SOL004ManifestOnboarding extends AbstractOnboardingManifest implements Manifest { +public class SOL004ManifestOnboarding extends AbstractOnboardingManifest { @Override protected void processMetadata(Iterator iterator) { -- cgit 1.2.3-korg