From 0a1d82ac04a8ef78bfdcbcced4f5096c050edcfe Mon Sep 17 00:00:00 2001 From: "bilal.iqbal" Date: Sun, 10 Mar 2019 00:47:55 +0000 Subject: CSAR Package validation Change-Id: I11af8d93f5a2cd0566a5caf0dad0519d70bd57d7 Issue-ID: SDC-2147 Issue-ID: SDC-2148 Issue-ID: SDC-2149 Issue-ID: SDC-2150 Signed-off-by: bilal.iqbal --- .../org/openecomp/sdc/tosca/csar/CSARConstants.java | 18 +++++++++++++++++- .../openecomp/sdc/tosca/csar/OnboardingManifest.java | 3 ++- .../sdc/tosca/csar/OnboardingToscaMetadata.java | 3 +++ 3 files changed, 22 insertions(+), 2 deletions(-) (limited to 'openecomp-be/lib/openecomp-tosca-lib/src/main/java') 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 94786fe0df..97e7809828 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 @@ -1,5 +1,6 @@ /* * Copyright © 2016-2017 European Support Limited + * Copyright (C) 2019 Nordix Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,18 +28,33 @@ public class CSARConstants { public static final String MAIN_SERVICE_TEMPLATE_MF_FILE_NAME = "MainServiceTemplate.mf"; public static final String MAIN_SERVICE_TEMPLATE_YAML_FILE_NAME = "MainServiceTemplate.yaml"; public static final String TOSCA_META_PATH_FILE_NAME="TOSCA-Metadata/TOSCA.meta"; + public static final String TOSCA_META_FILE_VERSION_ENTRY = "TOSCA-Meta-File-Version"; + 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 ImmutableSet ELIGIBLE_FILES = of(MAIN_SERVICE_TEMPLATE_MF_FILE_NAME,MAIN_SERVICE_TEMPLATE_YAML_FILE_NAME); - + public static final ImmutableSet MANIFEST_PNF_METADATA = + of("pnf_provider_id", "pnf_product_name", "pnf_release_date_time", "pnf_package_version"); + public static final ImmutableSet MANIFEST_VNF_METADATA = + of("vnf_provider_id", "vnf_product_name", "vnf_release_date_time", "vnf_package_version"); + public static final int MANIFEST_METADATA_LIMIT = 4; public static final String METADATA_MF_ATTRIBUTE = "metadata"; public static final String SOURCE_MF_ATTRIBUTE = "Source"; public static final String SEPERATOR_MF_ATTRIBUTE = ":"; public static final String NON_MANO_MF_ATTRIBUTE = "non_mano_artifact_sets"; public static final String TOSCA_META_ORIG_PATH_FILE_NAME="TOSCA-Metadata/TOSCA.meta.original"; + public static final String TOSCA_META_FILE_VERSION = "1.0"; + public static final String CSAR_VERSION_1_0 = "1.0"; + public static final String CSAR_VERSION_1_1 = "1.1"; + public static final ImmutableSet NON_FILE_IMPORT_ATTRIBUTES = + ImmutableSet.of("repository", "namespace_uri", "namespace_prefix"); + private CSARConstants() { } diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/OnboardingManifest.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/OnboardingManifest.java index 8858128b38..efa7e0aa1a 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/OnboardingManifest.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/OnboardingManifest.java @@ -133,11 +133,12 @@ public class OnboardingManifest implements Manifest{ } String[] metaSplit = line.split(SEPERATOR_MF_ATTRIBUTE); if (metaSplit.length < 2){ + reportError(line); return; } if (!metaSplit[0].equals(SOURCE_MF_ATTRIBUTE) && !metaSplit[0].equals(NON_MANO_MF_ATTRIBUTE)){ String value = line.substring((metaSplit[0] + SEPERATOR_MF_ATTRIBUTE).length()).trim(); - metadata.put(metaSplit[0],value); + metadata.put(metaSplit[0].trim(),value.trim()); processMetadata(iterator); } else { diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/OnboardingToscaMetadata.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/OnboardingToscaMetadata.java index b4d7f84ca4..6dd6979751 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/OnboardingToscaMetadata.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/OnboardingToscaMetadata.java @@ -56,6 +56,9 @@ public class OnboardingToscaMetadata implements ToscaMetadata{ * @throws IOException */ public static ToscaMetadata parseToscaMetadataFile(InputStream st) throws IOException { + if(st == null) { + throw new IOException(Messages.METADATA_PARSER_INTERNAL.getErrorMessage()); + } OnboardingToscaMetadata meta = new OnboardingToscaMetadata(); List metadataLines = IOUtils.readLines(st, "utf-8"); for (String line : metadataLines) { -- cgit 1.2.3-korg