diff options
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation')
13 files changed, 83 insertions, 181 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/CsarSecurityValidator.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/CsarSecurityValidator.java index 0efe65b3b6..81a17f333b 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/CsarSecurityValidator.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/CsarSecurityValidator.java @@ -16,7 +16,6 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation; import java.util.Optional; @@ -55,7 +54,6 @@ public class CsarSecurityValidator { if (certificateFilePath.isPresent()) { certificateBytes = fileContentHandler.getFileContent(certificateFilePath.get()); } - return securityManager.verifySignedData(signatureBytes, certificateBytes, archiveBytes); } } diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ManifestBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ManifestBuilder.java index eff1fb31cd..ee708b4176 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ManifestBuilder.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ManifestBuilder.java @@ -16,7 +16,6 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation; import static org.openecomp.sdc.tosca.csar.ManifestTokenType.ALGORITHM; @@ -36,19 +35,18 @@ import java.util.TreeMap; */ public class ManifestBuilder { + private static final String PROPERTY_FORMAT = "%s: %s%n"; + private static final String SECTION_FORMAT = "%s:%n"; private final Map<String, Map<String, String>> sourceWithPropertiesMap = new TreeMap<>(); private final Map<String, List<String>> nonManoArtifactMap = new TreeMap<>(); private final Map<String, String> metadataMap = new TreeMap<>(); - private static final String PROPERTY_FORMAT = "%s: %s%n"; - private static final String SECTION_FORMAT = "%s:%n"; /** * Adds a metadata property. * - * @param metadataProperty the property name - * @param value the property value - * @return - * a reference to this object. + * @param metadataProperty the property name + * @param value the property value + * @return a reference to this object. */ public ManifestBuilder withMetaData(final String metadataProperty, final String value) { metadataMap.put(metadataProperty, value); @@ -58,9 +56,8 @@ public class ManifestBuilder { /** * Adds a manifest source path. * - * @param sourcePath The source path - * @return - * a reference to this object. + * @param sourcePath The source path + * @return a reference to this object. */ public ManifestBuilder withSource(final String sourcePath) { sourceWithPropertiesMap.put(sourcePath, null); @@ -71,10 +68,9 @@ public class ManifestBuilder { * Adds a manifest source path with the source sign. * * @param sourcePath The source path - * @param hashAlgorithm The hash algorithm + * @param hashAlgorithm The hash algorithm * @param hash The hash representing the sign - * @return - * a reference to this object. + * @return a reference to this object. */ public ManifestBuilder withSignedSource(final String sourcePath, final String hashAlgorithm, final String hash) { TreeMap<String, String> sourcePropertiesMap = new TreeMap<>(); @@ -87,10 +83,9 @@ public class ManifestBuilder { /** * Adds a non mano artifact. * - * @param artifactType the artifact type - * @param sourcePath the artifact source path - * @return - * a reference to this object. + * @param artifactType the artifact type + * @param sourcePath the artifact source path + * @return a reference to this object. */ public ManifestBuilder withNonManoArtifact(final String artifactType, final String sourcePath) { nonManoArtifactMap.putIfAbsent(artifactType, new ArrayList<>()); @@ -98,27 +93,22 @@ public class ManifestBuilder { return this; } - /** * Builds the String representing the manifest file. - * @return - * The manifest file as String + * + * @return The manifest file as String */ public String build() { final StringBuilder stringBuilder = new StringBuilder(); - if (!metadataMap.isEmpty()) { stringBuilder.append(buildMetadata()); } - if (!sourceWithPropertiesMap.isEmpty()) { stringBuilder.append(buildSource()); } - if (!nonManoArtifactMap.isEmpty()) { stringBuilder.append(buildNonManoArtifact()); } - return stringBuilder.toString(); } @@ -143,7 +133,6 @@ public class ManifestBuilder { if (algorithm != null) { stringBuilder.append(String.format(PROPERTY_FORMAT, ALGORITHM.getToken(), algorithm)); } - final String hash = propertiesMap.get(HASH.getToken()); if (hash != null) { stringBuilder.append(String.format(PROPERTY_FORMAT, HASH.getToken(), hash)); @@ -167,5 +156,4 @@ public class ManifestBuilder { } return stringBuilder.toString(); } - } 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 0d5aef58ac..486970451f 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 @@ -17,7 +17,6 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation; import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters; @@ -51,7 +50,6 @@ import org.openecomp.sdc.tosca.csar.ToscaMetadata; class ONAPCsarValidator implements Validator { private static Logger logger = LoggerFactory.getLogger(ONAPCsarValidator.class); - private List<ErrorMessage> uploadFileErrors = new ArrayList<>(); @Override @@ -61,30 +59,26 @@ class ONAPCsarValidator implements Validator { validateMetadata(contentHandler); validateNoExtraFiles(contentHandler); validateFolders(contentHandler.getFolderList()); - - if(uploadFileErrors == null || uploadFileErrors.isEmpty()){ + if (uploadFileErrors == null || uploadFileErrors.isEmpty()) { return errors; } errors.put(SdcCommon.UPLOAD_FILE, uploadFileErrors); return errors; } - private void validateMetadata(FileContentHandler contentMap){ + private void validateMetadata(FileContentHandler contentMap) { if (!validateTOSCAYamlFileInRootExist(contentMap, MAIN_SERVICE_TEMPLATE_YAML_FILE_NAME)) { try (InputStream metaFileContent = contentMap.getFileContentAsStream(TOSCA_META_PATH_FILE_NAME)) { - ToscaMetadata onboardingToscaMetadata = OnboardingToscaMetadata.parseToscaMetadataFile(metaFileContent); String entryDefinitionsPath = onboardingToscaMetadata.getMetaEntries().get(ENTRY_DEFINITIONS.getName()); if (entryDefinitionsPath != null) { validateFileExist(contentMap, entryDefinitionsPath); } else { - uploadFileErrors.add(new ErrorMessage(ErrorLevel.ERROR, - Messages.METADATA_NO_ENTRY_DEFINITIONS.getErrorMessage())); + uploadFileErrors.add(new ErrorMessage(ErrorLevel.ERROR, Messages.METADATA_NO_ENTRY_DEFINITIONS.getErrorMessage())); } } catch (IOException exception) { logger.error(exception.getMessage(), exception); - uploadFileErrors.add(new ErrorMessage(ErrorLevel.ERROR, - Messages.FAILED_TO_VALIDATE_METADATA.getErrorMessage())); + uploadFileErrors.add(new ErrorMessage(ErrorLevel.ERROR, Messages.FAILED_TO_VALIDATE_METADATA.getErrorMessage())); } } else { validateFileExist(contentMap, MAIN_SERVICE_TEMPLATE_YAML_FILE_NAME); @@ -95,40 +89,32 @@ class ONAPCsarValidator implements Validator { if (!validateFileExist(contentMap, MAIN_SERVICE_TEMPLATE_MF_FILE_NAME)) { return; } - try (final InputStream fileContent = contentMap.getFileContentAsStream(MAIN_SERVICE_TEMPLATE_MF_FILE_NAME)) { final Manifest onboardingManifest = new ONAPManifestOnboarding(); onboardingManifest.parse(fileContent); if (!onboardingManifest.isValid()) { - onboardingManifest.getErrors() - .forEach(error -> uploadFileErrors.add(new ErrorMessage(ErrorLevel.ERROR, error))); + onboardingManifest.getErrors().forEach(error -> uploadFileErrors.add(new ErrorMessage(ErrorLevel.ERROR, error))); } } catch (final IOException ex) { - final String errorMessage = - Messages.MANIFEST_UNEXPECTED_ERROR.formatMessage(MAIN_SERVICE_TEMPLATE_MF_FILE_NAME, ex.getMessage()); + final String errorMessage = Messages.MANIFEST_UNEXPECTED_ERROR.formatMessage(MAIN_SERVICE_TEMPLATE_MF_FILE_NAME, ex.getMessage()); uploadFileErrors.add(new ErrorMessage(ErrorLevel.ERROR, errorMessage)); logger.error(errorMessage, ex); } } private void validateNoExtraFiles(FileContentHandler contentMap) { - List<String> unwantedFiles = contentMap.getFileList().stream() - .filter(this::filterFiles).collect(Collectors.toList()); + List<String> unwantedFiles = contentMap.getFileList().stream().filter(this::filterFiles).collect(Collectors.toList()); if (!unwantedFiles.isEmpty()) { - unwantedFiles.stream().filter(this::filterFiles).forEach(unwantedFile -> - uploadFileErrors.add(new ErrorMessage(ErrorLevel.ERROR, - getErrorWithParameters(Messages.CSAR_FILES_NOT_ALLOWED.getErrorMessage(), unwantedFile)))); + unwantedFiles.stream().filter(this::filterFiles).forEach(unwantedFile -> uploadFileErrors + .add(new ErrorMessage(ErrorLevel.ERROR, getErrorWithParameters(Messages.CSAR_FILES_NOT_ALLOWED.getErrorMessage(), unwantedFile)))); } } private void validateFolders(Set<String> folderList) { - List<String> filterResult = - folderList.stream().filter(this::filterFolders).collect(Collectors.toList()); + List<String> filterResult = folderList.stream().filter(this::filterFolders).collect(Collectors.toList()); if (!filterResult.isEmpty()) { - folderList.stream().filter(this::filterFolders).forEach(unwantedFolder -> - uploadFileErrors.add(new ErrorMessage(ErrorLevel.ERROR, - getErrorWithParameters(Messages.CSAR_DIRECTORIES_NOT_ALLOWED.getErrorMessage(), - unwantedFolder)))); + folderList.stream().filter(this::filterFolders).forEach(unwantedFolder -> uploadFileErrors.add( + new ErrorMessage(ErrorLevel.ERROR, getErrorWithParameters(Messages.CSAR_DIRECTORIES_NOT_ALLOWED.getErrorMessage(), unwantedFolder)))); } } @@ -146,11 +132,10 @@ class ONAPCsarValidator implements Validator { } private boolean validateFileExist(FileContentHandler contentMap, String fileName) { - boolean containsFile = contentMap.containsFile(fileName); if (!containsFile) { - uploadFileErrors.add(new ErrorMessage(ErrorLevel.ERROR, - getErrorWithParameters(Messages.CSAR_FILE_NOT_FOUND.getErrorMessage(), fileName))); + uploadFileErrors + .add(new ErrorMessage(ErrorLevel.ERROR, getErrorWithParameters(Messages.CSAR_FILE_NOT_FOUND.getErrorMessage(), fileName))); } return containsFile; } diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/PMDictionaryValidator.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/PMDictionaryValidator.java index 90270c2f7e..77c7347e49 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/PMDictionaryValidator.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/PMDictionaryValidator.java @@ -30,19 +30,14 @@ import org.onap.validation.yaml.error.YamlDocumentValidationError; public class PMDictionaryValidator { public void validate(Stream<byte[]> pmDictionaryFiles, Consumer<String> errorReporter) { - pmDictionaryFiles - .map(this::validate) - .flatMap(Collection::stream) - .forEach(errorReporter); + pmDictionaryFiles.map(this::validate).flatMap(Collection::stream).forEach(errorReporter); } private List<String> validate(byte[] fileContent) { List<String> errors = new ArrayList<>(); try { List<YamlDocumentValidationError> validationErrors = new YamlContentValidator().validate(fileContent); - validationErrors.stream() - .map(this::formatErrorMessage) - .forEach(errors::add); + validationErrors.stream().map(this::formatErrorMessage).forEach(errors::add); } catch (Exception e) { errors.add(e.getMessage()); } @@ -50,9 +45,6 @@ public class PMDictionaryValidator { } private String formatErrorMessage(YamlDocumentValidationError error) { - return String.format("Document number: %d, Path: %s, Message: %s", - error.getYamlDocumentNumber(), - error.getPath(), - error.getMessage()); + return String.format("Document number: %d, Path: %s, Message: %s", error.getYamlDocumentNumber(), error.getPath(), error.getMessage()); } } 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 22ab4f45a6..d99848ddb8 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 @@ -19,10 +19,8 @@ * * Modifications copyright (c) 2020 Nokia * ================================================================================ */ - 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; @@ -44,6 +42,7 @@ import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.TOSCA_META_FILE_VERSIO 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.util.ArrayList; @@ -57,8 +56,6 @@ import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; import java.util.stream.Collectors; import java.util.stream.Stream; - -import com.google.common.collect.ImmutableSet; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.io.FilenameUtils; import org.openecomp.core.impl.ToscaDefinitionImportHandler; @@ -89,22 +86,21 @@ import org.openecomp.sdc.vendorsoftwareproduct.security.SecurityManagerException 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. + * 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 { private static final Logger LOGGER = LoggerFactory.getLogger(SOL004MetaDirectoryValidator.class); - private static final String MANIFEST_SOURCE = "Source"; private static final String MANIFEST_NON_MANO_SOURCE = "Non-MANO Source"; + protected final ValidatorUtils validatorUtils = new ValidatorUtils(); private final List<ErrorMessage> errorsByFile = new CopyOnWriteArrayList<>(); private final SecurityManager securityManager; + private final InternalFilesFilter internalFilesFilter = new InternalFilesFilter(); private OnboardingPackageContentHandler contentHandler; private Set<String> folderList; private ToscaMetadata toscaMetadata; - private final InternalFilesFilter internalFilesFilter = new InternalFilesFilter(); - protected final ValidatorUtils validatorUtils = new ValidatorUtils(); public SOL004MetaDirectoryValidator() { securityManager = SecurityManager.getInstance(); @@ -121,7 +117,6 @@ class SOL004MetaDirectoryValidator implements Validator { this.folderList = contentHandler.getFolderList(); parseToscaMetadata(); verifyMetadataFile(); - if (packageHasCertificate()) { verifySignedFiles(); } @@ -143,9 +138,7 @@ class SOL004MetaDirectoryValidator implements Validator { */ private void parseToscaMetadata() { try { - toscaMetadata = - OnboardingToscaMetadata - .parseToscaMetadataFile(contentHandler.getFileContentAsStream(TOSCA_META_PATH_FILE_NAME)); + toscaMetadata = OnboardingToscaMetadata.parseToscaMetadataFile(contentHandler.getFileContentAsStream(TOSCA_META_PATH_FILE_NAME)); } catch (final IOException e) { reportError(ErrorLevel.ERROR, Messages.METADATA_PARSER_INTERNAL.getErrorMessage()); LOGGER.error(Messages.METADATA_PARSER_INTERNAL.getErrorMessage(), e.getMessage(), e); @@ -175,12 +168,11 @@ class SOL004MetaDirectoryValidator implements Validator { final byte[] fileSignatureBytes = contentHandler.getFileContent(fileSignaturePath); try { if (!securityManager.verifySignedData(fileSignatureBytes, packageCert, fileBytes)) { - reportError(ErrorLevel.ERROR, - Messages.ARTIFACT_INVALID_SIGNATURE.formatMessage(fileSignaturePath, filePath)); + reportError(ErrorLevel.ERROR, Messages.ARTIFACT_INVALID_SIGNATURE.formatMessage(fileSignaturePath, filePath)); } } catch (final SecurityManagerException e) { final String errorMessage = Messages.ARTIFACT_SIGNATURE_VALIDATION_ERROR - .formatMessage(fileSignaturePath, filePath, packageCertificatePath, e.getMessage()); + .formatMessage(fileSignaturePath, filePath, packageCertificatePath, e.getMessage()); reportError(ErrorLevel.ERROR, errorMessage); LOGGER.error(errorMessage, e); } @@ -196,8 +188,7 @@ class SOL004MetaDirectoryValidator implements Validator { reportError(ErrorLevel.ERROR, Messages.MANIFEST_INVALID_EXT.getErrorMessage()); } if (!mainDefinitionFileName.equals(manifestFileName)) { - reportError(ErrorLevel.ERROR, String.format(Messages.MANIFEST_INVALID_NAME.getErrorMessage(), - manifestFileName, mainDefinitionFileName)); + reportError(ErrorLevel.ERROR, String.format(Messages.MANIFEST_INVALID_NAME.getErrorMessage(), manifestFileName, mainDefinitionFileName)); } } @@ -211,15 +202,13 @@ class SOL004MetaDirectoryValidator implements Validator { private boolean hasETSIMetadata() { final Map<String, String> entries = toscaMetadata.getMetaEntries(); - return hasEntry(entries, TOSCA_META_FILE_VERSION_ENTRY.getName()) - && hasEntry(entries, CSAR_VERSION_ENTRY.getName()) - && hasEntry(entries, CREATED_BY_ENTRY.getName()); + return hasEntry(entries, TOSCA_META_FILE_VERSION_ENTRY.getName()) && hasEntry(entries, CSAR_VERSION_ENTRY.getName()) && hasEntry(entries, + CREATED_BY_ENTRY.getName()); } private boolean hasEntry(final Map<String, String> entries, final String mandatoryEntry) { if (!entries.containsKey(mandatoryEntry)) { - reportError(ErrorLevel.ERROR, - String.format(Messages.METADATA_MISSING_ENTRY.getErrorMessage(), mandatoryEntry)); + reportError(ErrorLevel.ERROR, String.format(Messages.METADATA_MISSING_ENTRY.getErrorMessage(), mandatoryEntry)); return false; } return true; @@ -237,7 +226,6 @@ class SOL004MetaDirectoryValidator implements Validator { return; } final String value = entry.getValue(); - switch (toscaMetaEntry) { case TOSCA_META_FILE_VERSION_ENTRY: case CSAR_VERSION_ENTRY: @@ -277,18 +265,14 @@ class SOL004MetaDirectoryValidator implements Validator { validateOtherEntries(value); } else { final String key = (String) entry.getKey(); - reportError(ErrorLevel.ERROR, - String.format(Messages.MANIFEST_INVALID_PNF_METADATA.getErrorMessage(), key)); + reportError(ErrorLevel.ERROR, String.format(Messages.MANIFEST_INVALID_PNF_METADATA.getErrorMessage(), key)); } - } } private 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))); + 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); } } @@ -298,16 +282,13 @@ class SOL004MetaDirectoryValidator implements Validator { } private boolean isValidCSARVersion(final String value, final String version) { - return CSAR_VERSION_ENTRY.getName().equals(value) && (CSAR_VERSION_1_1.equals(version) - || CSAR_VERSION_1_0.equals(version)); + return CSAR_VERSION_ENTRY.getName().equals(value) && (CSAR_VERSION_1_1.equals(version) || CSAR_VERSION_1_0.equals(version)); } 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 ToscaDefinitionImportHandler toscaDefinitionImportHandler = new ToscaDefinitionImportHandler(contentHandler.getFiles(), filePath); final List<ErrorMessage> validationErrorList = toscaDefinitionImportHandler.getErrors(); if (CollectionUtils.isNotEmpty(validationErrorList)) { errorsByFile.addAll(validationErrorList); @@ -345,31 +326,23 @@ class SOL004MetaDirectoryValidator implements Validator { private void verifyManifestMetadata(final Map<String, String> metadata) { if (!validMetaLimit(metadata)) { - reportError(ErrorLevel.ERROR, - String.format(Messages.MANIFEST_METADATA_DOES_NOT_MATCH_LIMIT.getErrorMessage(), - MANIFEST_METADATA_LIMIT)); + reportError(ErrorLevel.ERROR, String.format(Messages.MANIFEST_METADATA_DOES_NOT_MATCH_LIMIT.getErrorMessage(), MANIFEST_METADATA_LIMIT)); } handleMetadataEntries(metadata); } protected boolean isPnfMetadata(final Map<String, String> metadata) { final String firstMetadataDefinition = metadata.keySet().iterator().next(); - final String expectedMetadataType = - firstMetadataDefinition.contains(TOSCA_TYPE_PNF) ? TOSCA_TYPE_PNF : TOSCA_TYPE_VNF; - if (metadata.keySet().stream() - .anyMatch((final String metadataEntry) -> !metadataEntry.contains(expectedMetadataType))) { + final String expectedMetadataType = firstMetadataDefinition.contains(TOSCA_TYPE_PNF) ? TOSCA_TYPE_PNF : TOSCA_TYPE_VNF; + if (metadata.keySet().stream().anyMatch((final String metadataEntry) -> !metadataEntry.contains(expectedMetadataType))) { throw new InvalidManifestMetadataException(Messages.MANIFEST_METADATA_INVALID_ENTRY.getErrorMessage()); } - return TOSCA_TYPE_PNF.equals(expectedMetadataType); } private void handleMetadataEntries(final Map<String, String> metadata) { - getManifestMetadata(metadata).stream() - .filter(requiredEntry -> !metadata.containsKey(requiredEntry)) - .forEach(requiredEntry -> - reportError(ErrorLevel.ERROR, - String.format(Messages.MANIFEST_METADATA_MISSING_ENTRY.getErrorMessage(), requiredEntry))); + getManifestMetadata(metadata).stream().filter(requiredEntry -> !metadata.containsKey(requiredEntry)).forEach( + requiredEntry -> reportError(ErrorLevel.ERROR, String.format(Messages.MANIFEST_METADATA_MISSING_ENTRY.getErrorMessage(), requiredEntry))); } /** @@ -381,9 +354,7 @@ class SOL004MetaDirectoryValidator implements Validator { final Set<String> packageFiles = contentHandler.getFileList(); final List<String> sources = internalFilesFilter.filter(onboardingManifest.getSources()); verifyFilesExist(packageFiles, sources, MANIFEST_SOURCE); - final Map<String, List<String>> nonManoArtifacts = onboardingManifest.getNonManoSources(); - final List<String> nonManoValidFilePaths = new ArrayList<>(); nonManoArtifacts.forEach((nonManoType, files) -> { final List<String> internalNonManoFileList = internalFilesFilter.filter(files); @@ -397,9 +368,7 @@ class SOL004MetaDirectoryValidator implements Validator { validateOnapCnfHelmNonManoEntry(files); } }); - verifyFilesExist(packageFiles, nonManoValidFilePaths, MANIFEST_NON_MANO_SOURCE); - final Set<String> allReferredFiles = new HashSet<>(); allReferredFiles.addAll(sources); allReferredFiles.addAll(nonManoValidFilePaths); @@ -412,32 +381,25 @@ class SOL004MetaDirectoryValidator implements Validator { return; } if (files.size() != 1) { - final String formattedFileList = files.stream() - .map(filePath -> String.format("'%s'", filePath)) - .collect(Collectors.joining(", ")); - reportError(ErrorLevel.ERROR, - Messages.UNIQUE_SW_INFORMATION_NON_MANO_ERROR.formatMessage(formattedFileList)); + final String formattedFileList = files.stream().map(filePath -> String.format("'%s'", filePath)).collect(Collectors.joining(", ")); + reportError(ErrorLevel.ERROR, Messages.UNIQUE_SW_INFORMATION_NON_MANO_ERROR.formatMessage(formattedFileList)); return; } final String swInformationFilePath = files.get(0); final byte[] swInformationYaml = contentHandler.getFileContent(swInformationFilePath); - final Optional<PnfSoftwareInformation> parsedYaml = SoftwareInformationArtifactYamlParser - .parse(swInformationYaml); + final Optional<PnfSoftwareInformation> parsedYaml = SoftwareInformationArtifactYamlParser.parse(swInformationYaml); if (!parsedYaml.isPresent()) { - reportError(ErrorLevel.ERROR, - Messages.INVALID_SW_INFORMATION_NON_MANO_ERROR.formatMessage(swInformationFilePath)); + reportError(ErrorLevel.ERROR, Messages.INVALID_SW_INFORMATION_NON_MANO_ERROR.formatMessage(swInformationFilePath)); } else { final PnfSoftwareInformation pnfSoftwareInformation = parsedYaml.get(); if (!pnfSoftwareInformation.isValid()) { - reportError(ErrorLevel.ERROR, - Messages.INCORRECT_SW_INFORMATION_NON_MANO_ERROR.formatMessage(swInformationFilePath)); + reportError(ErrorLevel.ERROR, Messages.INCORRECT_SW_INFORMATION_NON_MANO_ERROR.formatMessage(swInformationFilePath)); } } } /** - * Validates if a YAML file has the correct extension, is not empty and the content is a valid YAML. Reports each - * error found. + * Validates if a YAML file has the correct extension, is not empty and the content is a valid YAML. Reports each error found. * * @param filePath the file path inside the package */ @@ -450,7 +412,6 @@ class SOL004MetaDirectoryValidator implements Validator { reportError(ErrorLevel.ERROR, Messages.INVALID_YAML_EXTENSION.formatMessage(filePath)); return; } - try (final InputStream fileContent = contentHandler.getFileContentAsStream(filePath)) { if (fileContent == null) { reportError(ErrorLevel.ERROR, Messages.EMPTY_YAML_FILE_1.formatMessage(filePath)); @@ -477,8 +438,7 @@ class SOL004MetaDirectoryValidator implements Validator { private void verifyFilesBeingReferred(final Set<String> referredFileSet, final Set<String> packageFileSet) { packageFileSet.forEach(filePath -> { if (!isManifestFile(filePath) && !referredFileSet.contains(filePath)) { - reportError(ErrorLevel.ERROR, - String.format(Messages.MISSING_MANIFEST_REFERENCE.getErrorMessage(), filePath)); + reportError(ErrorLevel.ERROR, String.format(Messages.MISSING_MANIFEST_REFERENCE.getErrorMessage(), filePath)); } }); } @@ -489,16 +449,14 @@ class SOL004MetaDirectoryValidator implements Validator { private void validateOtherEntries(final String folderPath) { if (!verifyFoldersExist(folderList, folderPath)) { - reportError(ErrorLevel.ERROR, String.format(Messages.METADATA_MISSING_OPTIONAL_FOLDERS.getErrorMessage(), - folderPath)); + reportError(ErrorLevel.ERROR, String.format(Messages.METADATA_MISSING_OPTIONAL_FOLDERS.getErrorMessage(), folderPath)); } } private 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)); + reportError(ErrorLevel.ERROR, String.format(Messages.MISSING_METADATA_FILES.getErrorMessage(), file, file)); } } @@ -509,8 +467,7 @@ class SOL004MetaDirectoryValidator implements Validator { private void verifyFilesExist(final Set<String> existingFiles, final List<String> sources, final String type) { sources.forEach(file -> { if (!existingFiles.contains(file)) { - reportError(ErrorLevel.ERROR, - String.format(Messages.MISSING_MANIFEST_SOURCE.getErrorMessage(), type, file)); + reportError(ErrorLevel.ERROR, String.format(Messages.MISSING_MANIFEST_SOURCE.getErrorMessage(), type, file)); } }); } @@ -552,10 +509,8 @@ class SOL004MetaDirectoryValidator implements Validator { } private void validatePmDictionaryContentsAgainstSchema() { - final Stream<byte[]> pmDictionaryFiles = new FileExtractor(getEtsiEntryManifestPath(), contentHandler) - .findFiles(ONAP_PM_DICTIONARY); - new PMDictionaryValidator() - .validate(pmDictionaryFiles, (String message) -> reportError(ErrorLevel.ERROR, message)); + final Stream<byte[]> pmDictionaryFiles = new FileExtractor(getEtsiEntryManifestPath(), contentHandler).findFiles(ONAP_PM_DICTIONARY); + new PMDictionaryValidator().validate(pmDictionaryFiles, (String message) -> reportError(ErrorLevel.ERROR, message)); } private String getEtsiEntryManifestPath() { @@ -564,6 +519,7 @@ class SOL004MetaDirectoryValidator implements Validator { /** * Validates if onap_cnf_helm non_mano type points to a file + * * @param files */ private void validateOnapCnfHelmNonManoEntry(final List<String> files) { @@ -572,11 +528,8 @@ class SOL004MetaDirectoryValidator implements Validator { 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)); + 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 9e380a355c..12d5ecfff9 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 @@ -36,8 +36,8 @@ 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. + * 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. */ class SOL004Version3MetaDirectoryValidator extends SOL004MetaDirectoryValidator { @@ -56,8 +56,9 @@ class SOL004Version3MetaDirectoryValidator extends SOL004MetaDirectoryValidator 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 + } else { validateDefinitionFile(entry.getValue()); + } } @Override 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 701abfc677..31c19d7794 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 @@ -36,8 +36,8 @@ 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 + * 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 { @@ -78,5 +78,4 @@ class SOL004Version4MetaDirectoryValidator extends SOL004MetaDirectoryValidator 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/Validator.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/Validator.java index 34386b6d29..e8f88c7eba 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/Validator.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/Validator.java @@ -17,22 +17,19 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation; -import org.openecomp.core.utilities.file.FileContentHandler; -import org.openecomp.sdc.datatypes.error.ErrorMessage; import java.util.List; import java.util.Map; +import org.openecomp.core.utilities.file.FileContentHandler; +import org.openecomp.sdc.datatypes.error.ErrorMessage; /** * Validates the contents of the CSAR package uploaded in SDC. */ - public interface Validator { /** - * * @param contentHandler contains file and its data * @return errors Map of errors that occur */ 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 9d218190d8..27a1852644 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 @@ -17,7 +17,6 @@ * 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.ETSI_VERSION_2_7_1; @@ -29,8 +28,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.services.impl.etsi.ETSIServiceImp public class ValidatorFactory { - private ValidatorFactory(){ - + private ValidatorFactory() { } /** @@ -45,7 +43,7 @@ public class ValidatorFactory { if (!etsiService.isSol004WithToscaMetaDirectory(fileContentHandler)) { return new ONAPCsarValidator(); } - if (!etsiService.getHighestCompatibleSpecificationVersion(fileContentHandler).isLowerThan(ETSI_VERSION_2_7_1)){ + if (!etsiService.getHighestCompatibleSpecificationVersion(fileContentHandler).isLowerThan(ETSI_VERSION_2_7_1)) { if (etsiService.hasCnfEnhancements(fileContentHandler)) { return new SOL004Version4MetaDirectoryValidator(); } diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/exception/MissingCertificateException.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/exception/MissingCertificateException.java index 620ff345ad..e3d91e01df 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/exception/MissingCertificateException.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/exception/MissingCertificateException.java @@ -16,7 +16,6 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.exception; public class MissingCertificateException extends RuntimeException { diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/utils/FileExtractor.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/utils/FileExtractor.java index c6d7d637fa..bfef0b4471 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/utils/FileExtractor.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/utils/FileExtractor.java @@ -48,8 +48,7 @@ public class FileExtractor { Map<String, List<String>> nonManoSources = extractNonManoSources(); List<String> pathsToSources = nonManoSources.getOrDefault(fileType.getType(), new ArrayList<>()); List<String> pathsToLocalFiles = internalFilesFilter.filter(pathsToSources); - return pathsToLocalFiles.stream() - .map(contentHandler::getFileContent); + return pathsToLocalFiles.stream().map(contentHandler::getFileContent); } private Map<String, List<String>> extractNonManoSources() { diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/utils/InternalFilesFilter.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/utils/InternalFilesFilter.java index 50dcd0ce29..ce119f6a6f 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/utils/InternalFilesFilter.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/utils/InternalFilesFilter.java @@ -25,9 +25,7 @@ import java.util.stream.Collectors; public class InternalFilesFilter { public List<String> filter(final List<String> sources) { - return sources.stream() - .filter(this::isInternalFile) - .collect(Collectors.toList()); + return sources.stream().filter(this::isInternalFile).collect(Collectors.toList()); } private boolean isInternalFile(final String filePath) { 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 index cfdd53774f..d260b1272b 100644 --- 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 @@ -17,7 +17,6 @@ * 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; @@ -32,15 +31,11 @@ import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.exceptions.Inv 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))) { + 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); } - } |