diff options
author | 2021-08-25 18:28:10 +0100 | |
---|---|---|
committer | 2021-08-27 10:33:32 +0000 | |
commit | d61ccd1c131af3de8119645e183761d3afabb549 (patch) | |
tree | 9b6dc682a705c79a7804c8f42583c64115c47c7e /openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp | |
parent | a5e32b3d20bc078482cb08645c38ffb685c0f145 (diff) |
Add a CSAR validator for model ETSI SOL001 2.5.1
Change-Id: I8e67b46f95bb45e0dd91d29eef6be7a0a8d645be
Issue-ID: SDC-3686
Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp')
6 files changed, 186 insertions, 65 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java index 5a3518135a..d8544ffa8e 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java @@ -93,6 +93,8 @@ public class OrchestrationTemplateCSARHandler extends BaseOrchestrationTemplateH } catch (final CoreException coreException) { logger.error(coreException.getMessage(), coreException); uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR, coreException.getMessage())); + } catch (final Exception ex) { + logger.error(ex.getMessage(), ex); } return uploadFileResponse; } diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/EtsiSol004Version251Validator.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/EtsiSol004Version251Validator.java new file mode 100644 index 0000000000..3e4edd6e87 --- /dev/null +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/EtsiSol004Version251Validator.java @@ -0,0 +1,113 @@ +/* + * - + * ============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.TOSCA_MANIFEST_FILE_EXT; +import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion251.ENTRY_CERTIFICATE; +import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion251.ENTRY_DEFINITIONS; +import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion251.ENTRY_MANIFEST; + +import java.util.Map; +import java.util.Optional; +import lombok.NoArgsConstructor; +import org.openecomp.sdc.common.errors.Messages; +import org.openecomp.sdc.datatypes.error.ErrorLevel; +import org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion251; + +/** + * 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 v2.5.1. + */ +@NoArgsConstructor +public class EtsiSol004Version251Validator extends SOL004MetaDirectoryValidator { + + @Override + public boolean appliesTo(final String model) { + return "ETSI SOL001 v2.5.1".equals(model); + } + + @Override + public int getOrder() { + return 0; + } + + @Override + protected Optional<String> getCertificatePath() { + return getToscaMetadata().getEntry(ENTRY_CERTIFICATE); + } + + @Override + protected void handleEntry(final Map.Entry<String, String> entry) { + final String key = entry.getKey(); + final var toscaMetaEntry = ToscaMetaEntryVersion251.parse(entry.getKey()).orElse(null); + // allows any other unknown entry + if (toscaMetaEntry == null) { + return; + } + final String value = entry.getValue(); + switch (toscaMetaEntry) { + case TOSCA_META_FILE_VERSION_ENTRY: + case CSAR_VERSION_ENTRY: + case CREATED_BY_ENTRY: + verifyMetadataEntryVersions(key, value); + break; + case ENTRY_DEFINITIONS: + validateDefinitionFile(value); + break; + case ENTRY_MANIFEST: + validateManifestFile(value); + break; + case ENTRY_CHANGE_LOG: + validateChangeLog(value); + break; + case ENTRY_TESTS: + case ENTRY_LICENSES: + validateOtherEntries(entry); + break; + case ENTRY_CERTIFICATE: + validateCertificate(value); + break; + default: + handleOtherEntry(entry); + break; + } + } + + @Override + protected String getManifestFilePath() { + return getToscaMetadata().getMetaEntries().get(ENTRY_MANIFEST.getName()); + } + + @Override + protected void verifyManifestNameAndExtension() { + final Map<String, String> entries = getToscaMetadata().getMetaEntries(); + final String manifestFileName = getFileName(entries.get(ENTRY_MANIFEST.getName())); + final String manifestExtension = getFileExtension(entries.get(ENTRY_MANIFEST.getName())); + final String mainDefinitionFileName = getFileName(entries.get(ENTRY_DEFINITIONS.getName())); + if (!(TOSCA_MANIFEST_FILE_EXT).equals(manifestExtension)) { + reportError(ErrorLevel.ERROR, Messages.MANIFEST_INVALID_EXT.getErrorMessage()); + } + if (!mainDefinitionFileName.equals(manifestFileName)) { + reportError(ErrorLevel.ERROR, String.format(Messages.MANIFEST_INVALID_NAME.getErrorMessage(), manifestFileName, mainDefinitionFileName)); + } + } + +} diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ONAPCsarValidator.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ONAPCsarValidator.java index 12901abde5..f86cd4c79c 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ONAPCsarValidator.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ONAPCsarValidator.java @@ -24,7 +24,7 @@ import static org.openecomp.sdc.tosca.csar.CSARConstants.ELIGBLE_FOLDERS; import static org.openecomp.sdc.tosca.csar.CSARConstants.ELIGIBLE_FILES; import static org.openecomp.sdc.tosca.csar.CSARConstants.MAIN_SERVICE_TEMPLATE_MF_FILE_NAME; import static org.openecomp.sdc.tosca.csar.CSARConstants.MAIN_SERVICE_TEMPLATE_YAML_FILE_NAME; -import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ENTRY_DEFINITIONS; +import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion261.ENTRY_DEFINITIONS; import static org.openecomp.sdc.tosca.csar.ToscaMetadataFileInfo.TOSCA_META_PATH_FILE_NAME; import java.io.IOException; 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 7416339b87..fde0565a3e 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 @@ -33,21 +33,20 @@ import static org.openecomp.sdc.tosca.csar.CSARConstants.MANIFEST_VNF_METADATA; import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_MANIFEST_FILE_EXT; 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.ToscaMetaEntry.CREATED_BY_ENTRY; -import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.CSAR_VERSION_ENTRY; -import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ENTRY_DEFINITIONS; -import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ETSI_ENTRY_CERTIFICATE; -import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ETSI_ENTRY_MANIFEST; -import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.TOSCA_META_FILE_VERSION_ENTRY; +import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion261.CREATED_BY_ENTRY; +import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion261.CSAR_VERSION_ENTRY; +import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion261.ENTRY_DEFINITIONS; +import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion261.ETSI_ENTRY_CERTIFICATE; +import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion261.ETSI_ENTRY_MANIFEST; +import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion261.TOSCA_META_FILE_VERSION_ENTRY; import static org.openecomp.sdc.tosca.csar.ToscaMetadataFileInfo.TOSCA_META_FILE_VERSION_1_0; import static org.openecomp.sdc.tosca.csar.ToscaMetadataFileInfo.TOSCA_META_PATH_FILE_NAME; import com.google.common.collect.ImmutableSet; import java.io.IOException; import java.io.InputStream; +import java.nio.file.Path; import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -56,6 +55,7 @@ import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; import java.util.stream.Collectors; import java.util.stream.Stream; +import lombok.Getter; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.io.FilenameUtils; import org.openecomp.core.impl.ToscaDefinitionImportHandler; @@ -65,7 +65,6 @@ import org.openecomp.sdc.be.csar.pnf.PnfSoftwareInformation; import org.openecomp.sdc.be.csar.pnf.SoftwareInformationArtifactYamlParser; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.common.errors.Messages; -import org.openecomp.sdc.common.utils.SdcCommon; import org.openecomp.sdc.datatypes.error.ErrorLevel; import org.openecomp.sdc.datatypes.error.ErrorMessage; import org.openecomp.sdc.logging.api.Logger; @@ -73,7 +72,7 @@ import org.openecomp.sdc.logging.api.LoggerFactory; import org.openecomp.sdc.tosca.csar.Manifest; import org.openecomp.sdc.tosca.csar.OnboardingToscaMetadata; import org.openecomp.sdc.tosca.csar.SOL004ManifestOnboarding; -import org.openecomp.sdc.tosca.csar.ToscaMetaEntry; +import org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion261; import org.openecomp.sdc.tosca.csar.ToscaMetadata; import org.openecomp.sdc.vendorsoftwareproduct.impl.onboarding.OnboardingPackageContentHandler; import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.exception.MissingCertificateException; @@ -89,7 +88,7 @@ import org.yaml.snakeyaml.Yaml; * 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 v2.6.1. */ -class SOL004MetaDirectoryValidator implements Validator { +public class SOL004MetaDirectoryValidator implements Validator { private static final Logger LOGGER = LoggerFactory.getLogger(SOL004MetaDirectoryValidator.class); private static final String MANIFEST_SOURCE = "Source"; @@ -100,6 +99,7 @@ class SOL004MetaDirectoryValidator implements Validator { private final InternalFilesFilter internalFilesFilter = new InternalFilesFilter(); private OnboardingPackageContentHandler contentHandler; private Set<String> folderList; + @Getter private ToscaMetadata toscaMetadata; public SOL004MetaDirectoryValidator() { @@ -111,19 +111,44 @@ class SOL004MetaDirectoryValidator implements Validator { this.securityManager = securityManager; } - private boolean packageHasCertificate() { + @Override + public ValidationResult validate(final FileContentHandler csarContent) { + this.contentHandler = (OnboardingPackageContentHandler) csarContent; + this.folderList = contentHandler.getFolderList(); + parseToscaMetadata(); + verifyMetadataFile(); + if (packageHasCertificate()) { + verifySignedFiles(); + } + validatePmDictionaryContentsAgainstSchema(); + final var csarValidationResult = new CsarValidationResult(); + errorsByFile.forEach(csarValidationResult::addError); + return csarValidationResult; + } + + @Override + public boolean appliesTo(final String model) { + return model == null; + } + + @Override + public int getOrder() { + return 0; + } + + protected boolean packageHasCertificate() { final String certificatePath = getCertificatePath().orElse(null); return contentHandler.containsFile(certificatePath); } - private Optional<String> getCertificatePath() { + protected Optional<String> getCertificatePath() { return toscaMetadata.getEntry(ETSI_ENTRY_CERTIFICATE); } /** * Parses the {@link org.openecomp.sdc.tosca.csar.ToscaMetadataFileInfo#TOSCA_META_PATH_FILE_NAME} file */ - private void parseToscaMetadata() { + protected void parseToscaMetadata() { try { toscaMetadata = OnboardingToscaMetadata.parseToscaMetadataFile(contentHandler.getFileContentAsStream(TOSCA_META_PATH_FILE_NAME)); } catch (final IOException e) { @@ -132,7 +157,7 @@ class SOL004MetaDirectoryValidator implements Validator { } } - private void verifyMetadataFile() { + protected void verifyMetadataFile() { if (toscaMetadata.isValid() && hasETSIMetadata()) { verifyManifestNameAndExtension(); handleMetadataEntries(); @@ -141,7 +166,7 @@ class SOL004MetaDirectoryValidator implements Validator { } } - private void verifySignedFiles() { + protected void verifySignedFiles() { final Map<String, String> signedFileMap = contentHandler.getFileAndSignaturePathMap(SecurityManager.ALLOWED_SIGNATURE_EXTENSIONS); final String packageCertificatePath = getCertificatePath().orElse(null); final byte[] packageCert = contentHandler.getFileContent(packageCertificatePath); @@ -166,7 +191,7 @@ class SOL004MetaDirectoryValidator implements Validator { }); } - private void verifyManifestNameAndExtension() { + protected void verifyManifestNameAndExtension() { final Map<String, String> entries = toscaMetadata.getMetaEntries(); final String manifestFileName = getFileName(entries.get(ETSI_ENTRY_MANIFEST.getName())); final String manifestExtension = getFileExtension(entries.get(ETSI_ENTRY_MANIFEST.getName())); @@ -179,11 +204,11 @@ class SOL004MetaDirectoryValidator implements Validator { } } - private String getFileExtension(final String filePath) { + protected String getFileExtension(final String filePath) { return FilenameUtils.getExtension(filePath); } - private String getFileName(final String filePath) { + protected String getFileName(final String filePath) { return FilenameUtils.getBaseName(filePath); } @@ -205,9 +230,9 @@ class SOL004MetaDirectoryValidator implements Validator { toscaMetadata.getMetaEntries().entrySet().parallelStream().forEach(this::handleEntry); } - private void handleEntry(final Map.Entry<String, String> entry) { + protected void handleEntry(final Map.Entry<String, String> entry) { final String key = entry.getKey(); - final ToscaMetaEntry toscaMetaEntry = ToscaMetaEntry.parse(entry.getKey()).orElse(null); + final var toscaMetaEntry = ToscaMetaEntryVersion261.parse(entry.getKey()).orElse(null); // allows any other unknown entry if (toscaMetaEntry == null) { return; @@ -241,23 +266,27 @@ class SOL004MetaDirectoryValidator implements Validator { } } - private void validateOtherEntries(final Map.Entry<String, String> entry) { - final String manifestFile = toscaMetadata.getMetaEntries().get(ETSI_ENTRY_MANIFEST.getName()); + protected void validateOtherEntries(final Map.Entry<String, String> entry) { + final String manifestFile = getManifestFilePath(); if (verifyFileExists(contentHandler.getFileList(), manifestFile)) { final Manifest onboardingManifest = new SOL004ManifestOnboarding(); onboardingManifest.parse(contentHandler.getFileContentAsStream(manifestFile)); final Optional<ResourceTypeEnum> resourceType = onboardingManifest.getType(); if (resourceType.isPresent() && resourceType.get() == ResourceTypeEnum.VF) { - final String value = (String) entry.getValue(); + final String value = entry.getValue(); validateOtherEntries(value); } else { - final String key = (String) entry.getKey(); + final String key = entry.getKey(); reportError(ErrorLevel.ERROR, String.format(Messages.MANIFEST_INVALID_PNF_METADATA.getErrorMessage(), key)); } } } - private void verifyMetadataEntryVersions(final String key, final String version) { + protected String getManifestFilePath() { + return toscaMetadata.getMetaEntries().get(ETSI_ENTRY_MANIFEST.getName()); + } + + protected void verifyMetadataEntryVersions(final String key, final String version) { if (!(isValidTOSCAVersion(key, version) || isValidCSARVersion(key, version) || CREATED_BY_ENTRY.getName().equals(key))) { errorsByFile.add(new ErrorMessage(ErrorLevel.ERROR, String.format(Messages.METADATA_INVALID_VERSION.getErrorMessage(), key, version))); LOGGER.error("{}: key {} - value {} ", Messages.METADATA_INVALID_VERSION.getErrorMessage(), key, version); @@ -275,7 +304,7 @@ class SOL004MetaDirectoryValidator implements Validator { protected void validateDefinitionFile(final String filePath) { final Set<String> existingFiles = contentHandler.getFileList(); if (verifyFileExists(existingFiles, filePath)) { - final ToscaDefinitionImportHandler toscaDefinitionImportHandler = new ToscaDefinitionImportHandler(contentHandler.getFiles(), filePath); + final var toscaDefinitionImportHandler = new ToscaDefinitionImportHandler(contentHandler.getFiles(), filePath); final List<ErrorMessage> validationErrorList = toscaDefinitionImportHandler.getErrors(); if (CollectionUtils.isNotEmpty(validationErrorList)) { errorsByFile.addAll(validationErrorList); @@ -289,7 +318,7 @@ class SOL004MetaDirectoryValidator implements Validator { return existingFiles.contains(filePath); } - private void validateManifestFile(final String filePath) { + protected void validateManifestFile(final String filePath) { final Set<String> existingFiles = contentHandler.getFileList(); if (verifyFileExists(existingFiles, filePath)) { final Manifest onboardingManifest = new SOL004ManifestOnboarding(); @@ -346,7 +375,7 @@ class SOL004MetaDirectoryValidator implements Validator { nonManoArtifacts.forEach((nonManoType, files) -> { final List<String> internalNonManoFileList = internalFilesFilter.filter(files); nonManoValidFilePaths.addAll(internalNonManoFileList); - final NonManoArtifactType nonManoArtifactType = NonManoArtifactType.parse(nonManoType).orElse(null); + final var nonManoArtifactType = NonManoArtifactType.parse(nonManoType).orElse(null); if (nonManoArtifactType == ONAP_PM_DICTIONARY || nonManoArtifactType == ONAP_VES_EVENTS) { internalNonManoFileList.forEach(this::validateYaml); } else if (nonManoArtifactType == ONAP_SW_INFORMATION) { @@ -375,10 +404,10 @@ class SOL004MetaDirectoryValidator implements Validator { final String swInformationFilePath = files.get(0); final byte[] swInformationYaml = contentHandler.getFileContent(swInformationFilePath); final Optional<PnfSoftwareInformation> parsedYaml = SoftwareInformationArtifactYamlParser.parse(swInformationYaml); - if (!parsedYaml.isPresent()) { + if (parsedYaml.isEmpty()) { reportError(ErrorLevel.ERROR, Messages.INVALID_SW_INFORMATION_NON_MANO_ERROR.formatMessage(swInformationFilePath)); } else { - final PnfSoftwareInformation pnfSoftwareInformation = parsedYaml.get(); + final var pnfSoftwareInformation = parsedYaml.get(); if (!pnfSoftwareInformation.isValid()) { reportError(ErrorLevel.ERROR, Messages.INCORRECT_SW_INFORMATION_NON_MANO_ERROR.formatMessage(swInformationFilePath)); } @@ -431,7 +460,7 @@ class SOL004MetaDirectoryValidator implements Validator { } private boolean isManifestFile(final String filePath) { - return filePath.equals(toscaMetadata.getMetaEntries().get(ETSI_ENTRY_MANIFEST.getName())); + return filePath.equals(getManifestFilePath()); } private void validateOtherEntries(final String folderPath) { @@ -440,7 +469,7 @@ class SOL004MetaDirectoryValidator implements Validator { } } - private void validateCertificate(final String file) { + protected void validateCertificate(final String file) { final Set<String> packageFiles = contentHandler.getFileList(); if (!verifyFileExist(packageFiles, file)) { reportError(ErrorLevel.ERROR, String.format(Messages.MISSING_METADATA_FILES.getErrorMessage(), file, file)); @@ -448,7 +477,8 @@ class SOL004MetaDirectoryValidator implements Validator { } private boolean verifyFoldersExist(final Set<String> folderList, final String folderPath) { - return folderList.contains(folderPath + "/"); + final var folderPath1 = Path.of(folderPath); + return folderList.stream().map(Path::of).anyMatch(path -> path.equals(folderPath1)); } private void verifyFilesExist(final Set<String> existingFiles, final List<String> sources, final String type) { @@ -463,7 +493,7 @@ class SOL004MetaDirectoryValidator implements Validator { return existingFiles.contains(file); } - private void validateChangeLog(final String filePath) { + protected void validateChangeLog(final String filePath) { if (!verifyFileExists(contentHandler.getFileList(), filePath)) { reportError(ErrorLevel.ERROR, String.format(Messages.MISSING_METADATA_FILES.getErrorMessage(), filePath)); } @@ -492,7 +522,7 @@ class SOL004MetaDirectoryValidator implements Validator { } private String getEtsiEntryManifestPath() { - return toscaMetadata.getMetaEntries().get(ETSI_ENTRY_MANIFEST.getName()); + return getManifestFilePath(); } /** @@ -511,28 +541,4 @@ class SOL004MetaDirectoryValidator implements Validator { } } - @Override - public ValidationResult validate(final FileContentHandler csarContent) { - this.contentHandler = (OnboardingPackageContentHandler) csarContent; - this.folderList = contentHandler.getFolderList(); - parseToscaMetadata(); - verifyMetadataFile(); - if (packageHasCertificate()) { - verifySignedFiles(); - } - validatePmDictionaryContentsAgainstSchema(); - final var csarValidationResult = new CsarValidationResult(); - errorsByFile.forEach(csarValidationResult::addError); - return csarValidationResult; - } - - @Override - public boolean appliesTo(final String model) { - return model == null; - } - - @Override - public int getOrder() { - return 0; - } } 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 12d5ecfff9..c815448155 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 @@ -32,7 +32,7 @@ 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.tosca.csar.ToscaMetaEntryVersion261; import org.openecomp.sdc.vendorsoftwareproduct.security.SecurityManager; /** @@ -53,7 +53,7 @@ class SOL004Version3MetaDirectoryValidator extends SOL004MetaDirectoryValidator @Override protected void handleOtherEntry(final Map.Entry<String, String> entry) { - if (!ToscaMetaEntry.OTHER_DEFINITIONS.getName().equals(entry.getKey())) { + if (!ToscaMetaEntryVersion261.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 { 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 index 31c19d7794..b142a01af4 100644 --- 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 @@ -32,7 +32,7 @@ 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.tosca.csar.ToscaMetaEntryVersion261; import org.openecomp.sdc.vendorsoftwareproduct.security.SecurityManager; /** @@ -71,7 +71,7 @@ class SOL004Version4MetaDirectoryValidator extends SOL004MetaDirectoryValidator @Override protected void handleOtherEntry(final Map.Entry<String, String> entry) { - if (!ToscaMetaEntry.OTHER_DEFINITIONS.getName().equals(entry.getKey())) { + if (!ToscaMetaEntryVersion261.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 { |