summaryrefslogtreecommitdiffstats
path: root/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main')
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java27
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004Version3MetaDirectoryValidator.java17
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004Version4MetaDirectoryValidator.java82
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactory.java15
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/utils/ValidatorUtils.java46
5 files changed, 163 insertions, 24 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java
index 5f81910417..22ab4f45a6 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java
@@ -23,6 +23,7 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation;
+import static org.openecomp.sdc.be.config.NonManoArtifactType.ONAP_CNF_HELM;
import static org.openecomp.sdc.be.config.NonManoArtifactType.ONAP_PM_DICTIONARY;
import static org.openecomp.sdc.be.config.NonManoArtifactType.ONAP_SW_INFORMATION;
import static org.openecomp.sdc.be.config.NonManoArtifactType.ONAP_VES_EVENTS;
@@ -81,6 +82,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.impl.onboarding.OnboardingPackage
import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.exception.MissingCertificateException;
import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.utils.FileExtractor;
import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.utils.InternalFilesFilter;
+import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.utils.ValidatorUtils;
import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.exceptions.InvalidManifestMetadataException;
import org.openecomp.sdc.vendorsoftwareproduct.security.SecurityManager;
import org.openecomp.sdc.vendorsoftwareproduct.security.SecurityManagerException;
@@ -102,6 +104,7 @@ class SOL004MetaDirectoryValidator implements Validator {
private Set<String> folderList;
private ToscaMetadata toscaMetadata;
private final InternalFilesFilter internalFilesFilter = new InternalFilesFilter();
+ protected final ValidatorUtils validatorUtils = new ValidatorUtils();
public SOL004MetaDirectoryValidator() {
securityManager = SecurityManager.getInstance();
@@ -122,7 +125,7 @@ class SOL004MetaDirectoryValidator implements Validator {
if (packageHasCertificate()) {
verifySignedFiles();
}
- validatePMDictionaryContentsAgainstSchema();
+ validatePmDictionaryContentsAgainstSchema();
return Collections.unmodifiableMap(getAnyValidationErrors());
}
@@ -390,6 +393,8 @@ class SOL004MetaDirectoryValidator implements Validator {
internalNonManoFileList.forEach(this::validateYaml);
} else if (nonManoArtifactType == ONAP_SW_INFORMATION) {
validateSoftwareInformationNonManoArtifact(files);
+ } else if (nonManoArtifactType == ONAP_CNF_HELM) {
+ validateOnapCnfHelmNonManoEntry(files);
}
});
@@ -546,7 +551,7 @@ class SOL004MetaDirectoryValidator implements Validator {
return errors;
}
- private void validatePMDictionaryContentsAgainstSchema() {
+ private void validatePmDictionaryContentsAgainstSchema() {
final Stream<byte[]> pmDictionaryFiles = new FileExtractor(getEtsiEntryManifestPath(), contentHandler)
.findFiles(ONAP_PM_DICTIONARY);
new PMDictionaryValidator()
@@ -556,4 +561,22 @@ class SOL004MetaDirectoryValidator implements Validator {
private String getEtsiEntryManifestPath() {
return toscaMetadata.getMetaEntries().get(ETSI_ENTRY_MANIFEST.getName());
}
+
+ /**
+ * Validates if onap_cnf_helm non_mano type points to a file
+ * @param files
+ */
+ private void validateOnapCnfHelmNonManoEntry(final List<String> files) {
+ if (CollectionUtils.isEmpty(files)) {
+ reportError(ErrorLevel.ERROR, Messages.EMPTY_ONAP_CNF_HELM_NON_MANO_ERROR.getErrorMessage());
+ return;
+ }
+ if (files.size() != 1) {
+ final String formattedFileList = files.stream()
+ .map(filePath -> String.format("'%s'", filePath))
+ .collect(Collectors.joining(", "));
+ reportError(ErrorLevel.ERROR,
+ Messages.UNIQUE_ONAP_CNF_HELM_NON_MANO_ERROR.formatMessage(formattedFileList));
+ }
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004Version3MetaDirectoryValidator.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004Version3MetaDirectoryValidator.java
index 473d68e49a..9e380a355c 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004Version3MetaDirectoryValidator.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004Version3MetaDirectoryValidator.java
@@ -23,24 +23,18 @@ import static org.openecomp.sdc.tosca.csar.CSARConstants.MANIFEST_PNF_METADATA_L
import static org.openecomp.sdc.tosca.csar.CSARConstants.MANIFEST_PNF_METADATA_VERSION_3;
import static org.openecomp.sdc.tosca.csar.CSARConstants.MANIFEST_VNF_METADATA_LIMIT_VERSION_3;
import static org.openecomp.sdc.tosca.csar.CSARConstants.MANIFEST_VNF_METADATA_VERSION_3;
-import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_TYPE_PNF;
-import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_TYPE_VNF;
-import static org.openecomp.sdc.tosca.csar.ManifestTokenType.COMPATIBLE_SPECIFICATION_VERSIONS;
+import com.google.common.collect.ImmutableSet;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
-
import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.csar.ToscaMetaEntry;
-import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.exceptions.InvalidManifestMetadataException;
import org.openecomp.sdc.vendorsoftwareproduct.security.SecurityManager;
-import com.google.common.collect.ImmutableSet;
-
/**
* Validates the contents of the package to ensure it complies with the "CSAR with TOSCA-Metadata directory" structure
* as defined in ETSI GS NFV-SOL 004 v3.3.1.
@@ -81,13 +75,6 @@ class SOL004Version3MetaDirectoryValidator extends SOL004MetaDirectoryValidator
protected boolean isPnfMetadata(final Map<String, String> metadata) {
List<String> keys = metadata.keySet().stream().collect(Collectors.toList());
//Both VNF and PNF share this attribute
- keys.remove(COMPATIBLE_SPECIFICATION_VERSIONS.getToken());
- final String expectedMetadataType =
- keys.get(0).contains(TOSCA_TYPE_PNF) ? TOSCA_TYPE_PNF : TOSCA_TYPE_VNF;
- if (keys.stream()
- .anyMatch(k -> !k.contains(expectedMetadataType))) {
- throw new InvalidManifestMetadataException(Messages.MANIFEST_METADATA_INVALID_ENTRY.getErrorMessage());
- }
- return expectedMetadataType.equals(TOSCA_TYPE_PNF);
+ return validatorUtils.isPnfMetadata(keys);
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004Version4MetaDirectoryValidator.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004Version4MetaDirectoryValidator.java
new file mode 100644
index 0000000000..701abfc677
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004Version4MetaDirectoryValidator.java
@@ -0,0 +1,82 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation;
+
+import static org.openecomp.sdc.tosca.csar.CSARConstants.MANIFEST_PNF_METADATA_LIMIT_VERSION_3;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.MANIFEST_PNF_METADATA_VERSION_3;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.MANIFEST_VNF_METADATA_LIMIT_VERSION_3;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.MANIFEST_VNF_METADATA_VERSION_3;
+
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+import org.openecomp.sdc.common.errors.Messages;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+import org.openecomp.sdc.tosca.csar.ToscaMetaEntry;
+import org.openecomp.sdc.vendorsoftwareproduct.security.SecurityManager;
+
+/**
+ * Validates the contents of the package to ensure it complies with the "CSAR with TOSCA-Metadata directory" structure
+ * as defined in ETSI GS NFV-SOL 004 v3.3.1 with CNF Enhancements from ETSI GS NFV-SOL 004 v4.1.1
+ */
+class SOL004Version4MetaDirectoryValidator extends SOL004MetaDirectoryValidator {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(SOL004Version4MetaDirectoryValidator.class);
+
+ public SOL004Version4MetaDirectoryValidator() {
+ super();
+ }
+
+ SOL004Version4MetaDirectoryValidator(final SecurityManager securityManager) {
+ super(securityManager);
+ }
+
+ @Override
+ protected boolean validMetaLimit(Map<String, String> metadata) {
+ int maxAllowedEntries = isPnfMetadata(metadata) ? MANIFEST_PNF_METADATA_LIMIT_VERSION_3 : MANIFEST_VNF_METADATA_LIMIT_VERSION_3;
+ return metadata.size() == maxAllowedEntries;
+ }
+
+ @Override
+ protected ImmutableSet<String> getManifestMetadata(final Map<String, String> metadata) {
+ return isPnfMetadata(metadata) ? MANIFEST_PNF_METADATA_VERSION_3 : MANIFEST_VNF_METADATA_VERSION_3;
+ }
+
+ @Override
+ protected boolean isPnfMetadata(final Map<String, String> metadata) {
+ final List<String> keys = metadata.keySet().stream().collect(Collectors.toList());
+ //Both VNF and PNF share this attribute
+ return validatorUtils.isPnfMetadata(keys);
+ }
+
+ @Override
+ protected void handleOtherEntry(final Map.Entry<String, String> entry) {
+ if (!ToscaMetaEntry.OTHER_DEFINITIONS.getName().equals(entry.getKey())) {
+ reportError(ErrorLevel.ERROR, Messages.METADATA_UNSUPPORTED_ENTRY.formatMessage(entry.getKey()));
+ LOGGER.warn(Messages.METADATA_UNSUPPORTED_ENTRY.getErrorMessage(), entry.getKey());
+ } else {
+ validateDefinitionFile(entry.getValue());
+ }
+ }
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactory.java
index 38c28f88ec..9d218190d8 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactory.java
@@ -23,7 +23,6 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validati
import static org.openecomp.sdc.tosca.csar.CSARConstants.ETSI_VERSION_2_7_1;
import java.io.IOException;
-
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.sdc.vendorsoftwareproduct.services.impl.etsi.ETSIService;
import org.openecomp.sdc.vendorsoftwareproduct.services.impl.etsi.ETSIServiceImpl;
@@ -43,13 +42,15 @@ public class ValidatorFactory {
*/
public static Validator getValidator(final FileContentHandler fileContentHandler) throws IOException {
final ETSIService etsiService = new ETSIServiceImpl(null);
- if (etsiService.isSol004WithToscaMetaDirectory(fileContentHandler)) {
- if (!etsiService.getHighestCompatibleSpecificationVersion(fileContentHandler)
- .isLowerThan(ETSI_VERSION_2_7_1)){
- return new SOL004Version3MetaDirectoryValidator();
+ if (!etsiService.isSol004WithToscaMetaDirectory(fileContentHandler)) {
+ return new ONAPCsarValidator();
+ }
+ if (!etsiService.getHighestCompatibleSpecificationVersion(fileContentHandler).isLowerThan(ETSI_VERSION_2_7_1)){
+ if (etsiService.hasCnfEnhancements(fileContentHandler)) {
+ return new SOL004Version4MetaDirectoryValidator();
}
- return new SOL004MetaDirectoryValidator();
+ return new SOL004Version3MetaDirectoryValidator();
}
- return new ONAPCsarValidator();
+ return new SOL004MetaDirectoryValidator();
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/utils/ValidatorUtils.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/utils/ValidatorUtils.java
new file mode 100644
index 0000000000..cfdd53774f
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/utils/ValidatorUtils.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.utils;
+
+import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_TYPE_PNF;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_TYPE_VNF;
+import static org.openecomp.sdc.tosca.csar.ManifestTokenType.COMPATIBLE_SPECIFICATION_VERSIONS;
+
+import java.util.List;
+import java.util.stream.Collectors;
+import org.openecomp.sdc.common.errors.Messages;
+import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.exceptions.InvalidManifestMetadataException;
+
+public class ValidatorUtils {
+
+ public boolean isPnfMetadata(List<String> keys) {
+ keys = keys.stream().filter(key -> !COMPATIBLE_SPECIFICATION_VERSIONS.getToken().equals(key))
+ .collect(Collectors.toList());
+ final String expectedMetadataType =
+ keys.get(0).contains(TOSCA_TYPE_PNF) ? TOSCA_TYPE_PNF : TOSCA_TYPE_VNF;
+ if (keys.stream()
+ .anyMatch(k -> !k.startsWith(expectedMetadataType))) {
+ throw new InvalidManifestMetadataException(Messages.MANIFEST_METADATA_INVALID_ENTRY.getErrorMessage());
+ }
+ return expectedMetadataType.equals(TOSCA_TYPE_PNF);
+ }
+
+}