2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Nordix Foundation.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
19 * * Modifications copyright (c) 2020 Nokia
20 * ================================================================================
23 package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation;
26 import static org.openecomp.sdc.be.config.NonManoArtifactType.ONAP_PM_DICTIONARY;
27 import static org.openecomp.sdc.be.config.NonManoArtifactType.ONAP_SW_INFORMATION;
28 import static org.openecomp.sdc.be.config.NonManoArtifactType.ONAP_VES_EVENTS;
29 import static org.openecomp.sdc.tosca.csar.CSARConstants.CSAR_VERSION_1_0;
30 import static org.openecomp.sdc.tosca.csar.CSARConstants.CSAR_VERSION_1_1;
31 import static org.openecomp.sdc.tosca.csar.CSARConstants.MANIFEST_METADATA_LIMIT;
32 import static org.openecomp.sdc.tosca.csar.CSARConstants.MANIFEST_PNF_METADATA;
33 import static org.openecomp.sdc.tosca.csar.CSARConstants.MANIFEST_VNF_METADATA;
34 import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_MANIFEST_FILE_EXT;
35 import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_TYPE_PNF;
36 import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_TYPE_VNF;
37 import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.CREATED_BY_ENTRY;
38 import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.CSAR_VERSION_ENTRY;
39 import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ENTRY_DEFINITIONS;
40 import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ETSI_ENTRY_CERTIFICATE;
41 import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ETSI_ENTRY_MANIFEST;
42 import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.TOSCA_META_FILE_VERSION_ENTRY;
43 import static org.openecomp.sdc.tosca.csar.ToscaMetadataFileInfo.TOSCA_META_FILE_VERSION_1_0;
44 import static org.openecomp.sdc.tosca.csar.ToscaMetadataFileInfo.TOSCA_META_PATH_FILE_NAME;
46 import java.io.IOException;
47 import java.io.InputStream;
48 import java.util.ArrayList;
49 import java.util.Collections;
50 import java.util.HashMap;
51 import java.util.HashSet;
52 import java.util.List;
54 import java.util.Optional;
56 import java.util.concurrent.CopyOnWriteArrayList;
57 import java.util.stream.Collectors;
59 import java.util.stream.Stream;
60 import org.apache.commons.collections.CollectionUtils;
61 import org.apache.commons.io.FilenameUtils;
62 import org.openecomp.core.impl.ToscaDefinitionImportHandler;
63 import org.openecomp.core.utilities.file.FileContentHandler;
64 import org.openecomp.sdc.be.config.NonManoArtifactType;
65 import org.openecomp.sdc.be.csar.pnf.PnfSoftwareInformation;
66 import org.openecomp.sdc.be.csar.pnf.SoftwareInformationArtifactYamlParser;
67 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
68 import org.openecomp.sdc.common.errors.Messages;
69 import org.openecomp.sdc.common.utils.SdcCommon;
70 import org.openecomp.sdc.datatypes.error.ErrorLevel;
71 import org.openecomp.sdc.datatypes.error.ErrorMessage;
72 import org.openecomp.sdc.logging.api.Logger;
73 import org.openecomp.sdc.logging.api.LoggerFactory;
74 import org.openecomp.sdc.tosca.csar.Manifest;
75 import org.openecomp.sdc.tosca.csar.OnboardingToscaMetadata;
76 import org.openecomp.sdc.tosca.csar.SOL004ManifestOnboarding;
77 import org.openecomp.sdc.tosca.csar.ToscaMetaEntry;
78 import org.openecomp.sdc.tosca.csar.ToscaMetadata;
79 import org.openecomp.sdc.vendorsoftwareproduct.impl.onboarding.OnboardingPackageContentHandler;
80 import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.exception.MissingCertificateException;
81 import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.utils.FileExtractor;
82 import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.utils.InternalFilesFilter;
83 import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.exceptions.InvalidManifestMetadataException;
84 import org.openecomp.sdc.vendorsoftwareproduct.security.SecurityManager;
85 import org.openecomp.sdc.vendorsoftwareproduct.security.SecurityManagerException;
86 import org.yaml.snakeyaml.Yaml;
89 * Validates the contents of the package to ensure it complies with the "CSAR with TOSCA-Metadata directory" structure
90 * as defined in ETSI GS NFV-SOL 004 v2.6.1.
92 class SOL004MetaDirectoryValidator implements Validator {
94 private static final Logger LOGGER = LoggerFactory.getLogger(SOL004MetaDirectoryValidator.class);
96 private static final String MANIFEST_SOURCE = "Source";
97 private static final String MANIFEST_NON_MANO_SOURCE = "Non-MANO Source";
98 private final List<ErrorMessage> errorsByFile = new CopyOnWriteArrayList<>();
99 private final SecurityManager securityManager;
100 private OnboardingPackageContentHandler contentHandler;
101 private Set<String> folderList;
102 private ToscaMetadata toscaMetadata;
103 private final InternalFilesFilter internalFilesFilter = new InternalFilesFilter();
105 public SOL004MetaDirectoryValidator() {
106 securityManager = SecurityManager.getInstance();
110 SOL004MetaDirectoryValidator(final SecurityManager securityManager) {
111 this.securityManager = securityManager;
115 public Map<String, List<ErrorMessage>> validateContent(final FileContentHandler fileContentHandler) {
116 this.contentHandler = (OnboardingPackageContentHandler) fileContentHandler;
117 this.folderList = contentHandler.getFolderList();
118 parseToscaMetadata();
119 verifyMetadataFile();
121 if (packageHasCertificate()) {
124 validatePMDictionaryContentsAgainstSchema();
125 return Collections.unmodifiableMap(getAnyValidationErrors());
128 private boolean packageHasCertificate() {
129 final String certificatePath = getCertificatePath().orElse(null);
130 return contentHandler.containsFile(certificatePath);
133 private Optional<String> getCertificatePath() {
134 return toscaMetadata.getEntry(ETSI_ENTRY_CERTIFICATE);
138 * Parses the {@link org.openecomp.sdc.tosca.csar.ToscaMetadataFileInfo#TOSCA_META_PATH_FILE_NAME} file
140 private void parseToscaMetadata() {
143 OnboardingToscaMetadata
144 .parseToscaMetadataFile(contentHandler.getFileContentAsStream(TOSCA_META_PATH_FILE_NAME));
145 } catch (final IOException e) {
146 reportError(ErrorLevel.ERROR, Messages.METADATA_PARSER_INTERNAL.getErrorMessage());
147 LOGGER.error(Messages.METADATA_PARSER_INTERNAL.getErrorMessage(), e.getMessage(), e);
151 private void verifyMetadataFile() {
152 if (toscaMetadata.isValid() && hasETSIMetadata()) {
153 verifyManifestNameAndExtension();
154 handleMetadataEntries();
156 errorsByFile.addAll(toscaMetadata.getErrors());
160 private void verifySignedFiles() {
161 final Map<String, String> signedFileMap = contentHandler.getFileAndSignaturePathMap(SecurityManager.ALLOWED_SIGNATURE_EXTENSIONS);
162 final String packageCertificatePath = getCertificatePath().orElse(null);
163 final byte[] packageCert = contentHandler.getFileContent(packageCertificatePath);
164 if (packageCert == null) {
165 throw new MissingCertificateException("Expected package certificate");
167 signedFileMap.entrySet().stream().filter(entry -> entry.getValue() != null).forEach(entry -> {
168 final String filePath = entry.getKey();
169 final String fileSignaturePath = entry.getValue();
170 final byte[] fileBytes = contentHandler.getFileContent(filePath);
171 final byte[] fileSignatureBytes = contentHandler.getFileContent(fileSignaturePath);
173 if (!securityManager.verifySignedData(fileSignatureBytes, packageCert, fileBytes)) {
174 reportError(ErrorLevel.ERROR,
175 Messages.ARTIFACT_INVALID_SIGNATURE.formatMessage(fileSignaturePath, filePath));
177 } catch (final SecurityManagerException e) {
178 final String errorMessage = Messages.ARTIFACT_SIGNATURE_VALIDATION_ERROR
179 .formatMessage(fileSignaturePath, filePath, packageCertificatePath, e.getMessage());
180 reportError(ErrorLevel.ERROR, errorMessage);
181 LOGGER.error(errorMessage, e);
186 private void verifyManifestNameAndExtension() {
187 final Map<String, String> entries = toscaMetadata.getMetaEntries();
188 final String manifestFileName = getFileName(entries.get(ETSI_ENTRY_MANIFEST.getName()));
189 final String manifestExtension = getFileExtension(entries.get(ETSI_ENTRY_MANIFEST.getName()));
190 final String mainDefinitionFileName = getFileName(entries.get(ENTRY_DEFINITIONS.getName()));
191 if (!(TOSCA_MANIFEST_FILE_EXT).equals(manifestExtension)) {
192 reportError(ErrorLevel.ERROR, Messages.MANIFEST_INVALID_EXT.getErrorMessage());
194 if (!mainDefinitionFileName.equals(manifestFileName)) {
195 reportError(ErrorLevel.ERROR, String.format(Messages.MANIFEST_INVALID_NAME.getErrorMessage(),
196 manifestFileName, mainDefinitionFileName));
200 private String getFileExtension(final String filePath) {
201 return FilenameUtils.getExtension(filePath);
204 private String getFileName(final String filePath) {
205 return FilenameUtils.getBaseName(filePath);
208 private boolean hasETSIMetadata() {
209 final Map<String, String> entries = toscaMetadata.getMetaEntries();
210 return hasEntry(entries, TOSCA_META_FILE_VERSION_ENTRY.getName())
211 && hasEntry(entries, CSAR_VERSION_ENTRY.getName())
212 && hasEntry(entries, CREATED_BY_ENTRY.getName());
215 private boolean hasEntry(final Map<String, String> entries, final String mandatoryEntry) {
216 if (!entries.containsKey(mandatoryEntry)) {
217 reportError(ErrorLevel.ERROR,
218 String.format(Messages.METADATA_MISSING_ENTRY.getErrorMessage(), mandatoryEntry));
224 private void handleMetadataEntries() {
225 toscaMetadata.getMetaEntries().entrySet().parallelStream().forEach(this::handleEntry);
228 private void handleEntry(final Map.Entry<String, String> entry) {
229 final String key = entry.getKey();
230 final ToscaMetaEntry toscaMetaEntry = ToscaMetaEntry.parse(entry.getKey()).orElse(null);
231 // allows any other unknown entry
232 if (toscaMetaEntry == null) {
235 final String value = entry.getValue();
237 switch (toscaMetaEntry) {
238 case TOSCA_META_FILE_VERSION_ENTRY:
239 case CSAR_VERSION_ENTRY:
240 case CREATED_BY_ENTRY:
241 verifyMetadataEntryVersions(key, value);
243 case ENTRY_DEFINITIONS:
244 validateDefinitionFile(value);
246 case ETSI_ENTRY_MANIFEST:
247 validateManifestFile(value);
249 case ETSI_ENTRY_CHANGE_LOG:
250 validateChangeLog(value);
252 case ETSI_ENTRY_TESTS:
253 case ETSI_ENTRY_LICENSES:
254 validateOtherEntries(entry);
256 case ETSI_ENTRY_CERTIFICATE:
257 validateCertificate(value);
260 reportError(ErrorLevel.ERROR, Messages.METADATA_UNSUPPORTED_ENTRY.formatMessage(key));
261 LOGGER.warn(Messages.METADATA_UNSUPPORTED_ENTRY.getErrorMessage(), key);
266 private void validateOtherEntries(final Map.Entry entry) {
267 final String manifestFile = toscaMetadata.getMetaEntries().get(ETSI_ENTRY_MANIFEST.getName());
268 if (verifyFileExists(contentHandler.getFileList(), manifestFile)) {
269 final Manifest onboardingManifest = new SOL004ManifestOnboarding();
270 onboardingManifest.parse(contentHandler.getFileContentAsStream(manifestFile));
271 final Optional<ResourceTypeEnum> resourceType = onboardingManifest.getType();
272 if (resourceType.isPresent() && resourceType.get() == ResourceTypeEnum.VF) {
273 final String value = (String) entry.getValue();
274 validateOtherEntries(value);
276 final String key = (String) entry.getKey();
277 reportError(ErrorLevel.ERROR,
278 String.format(Messages.MANIFEST_INVALID_PNF_METADATA.getErrorMessage(), key));
284 private void verifyMetadataEntryVersions(final String key, final String version) {
285 if (!(isValidTOSCAVersion(key, version) || isValidCSARVersion(key, version)
286 || CREATED_BY_ENTRY.getName().equals(key))) {
287 errorsByFile.add(new ErrorMessage(ErrorLevel.ERROR,
288 String.format(Messages.METADATA_INVALID_VERSION.getErrorMessage(), key, version)));
289 LOGGER.error("{}: key {} - value {} ", Messages.METADATA_INVALID_VERSION.getErrorMessage(), key, version);
293 private boolean isValidTOSCAVersion(final String key, final String version) {
294 return TOSCA_META_FILE_VERSION_ENTRY.getName().equals(key) && TOSCA_META_FILE_VERSION_1_0.equals(version);
297 private boolean isValidCSARVersion(final String value, final String version) {
298 return CSAR_VERSION_ENTRY.getName().equals(value) && (CSAR_VERSION_1_1.equals(version)
299 || CSAR_VERSION_1_0.equals(version));
302 private void validateDefinitionFile(final String filePath) {
303 final Set<String> existingFiles = contentHandler.getFileList();
305 if (verifyFileExists(existingFiles, filePath)) {
306 final ToscaDefinitionImportHandler toscaDefinitionImportHandler =
307 new ToscaDefinitionImportHandler(contentHandler.getFiles(), filePath);
308 final List<ErrorMessage> validationErrorList = toscaDefinitionImportHandler.getErrors();
309 if (CollectionUtils.isNotEmpty(validationErrorList)) {
310 errorsByFile.addAll(validationErrorList);
313 reportError(ErrorLevel.ERROR, String.format(Messages.MISSING_DEFINITION_FILE.getErrorMessage(), filePath));
317 private boolean verifyFileExists(final Set<String> existingFiles, final String filePath) {
318 return existingFiles.contains(filePath);
321 private void validateManifestFile(final String filePath) {
322 final Set<String> existingFiles = contentHandler.getFileList();
323 if (verifyFileExists(existingFiles, filePath)) {
324 final Manifest onboardingManifest = new SOL004ManifestOnboarding();
325 onboardingManifest.parse(contentHandler.getFileContentAsStream(filePath));
326 if (onboardingManifest.isValid()) {
328 verifyManifestMetadata(onboardingManifest.getMetadata());
329 } catch (final InvalidManifestMetadataException e) {
330 reportError(ErrorLevel.ERROR, e.getMessage());
331 LOGGER.error(e.getMessage(), e);
333 verifyManifestSources(onboardingManifest);
335 final List<String> manifestErrors = onboardingManifest.getErrors();
336 manifestErrors.forEach(error -> reportError(ErrorLevel.ERROR, error));
339 reportError(ErrorLevel.ERROR, String.format(Messages.MANIFEST_NOT_FOUND.getErrorMessage(), filePath));
343 private void verifyManifestMetadata(final Map<String, String> metadata) {
344 if (metadata.size() != MANIFEST_METADATA_LIMIT) {
345 reportError(ErrorLevel.ERROR,
346 String.format(Messages.MANIFEST_METADATA_DOES_NOT_MATCH_LIMIT.getErrorMessage(),
347 MANIFEST_METADATA_LIMIT));
349 if (isPnfMetadata(metadata)) {
350 handleMetadataEntries(metadata, MANIFEST_PNF_METADATA);
352 handleMetadataEntries(metadata, MANIFEST_VNF_METADATA);
356 private boolean isPnfMetadata(final Map<String, String> metadata) {
357 final String firstMetadataDefinition = metadata.keySet().iterator().next();
358 final String expectedMetadataType =
359 firstMetadataDefinition.contains(TOSCA_TYPE_PNF) ? TOSCA_TYPE_PNF : TOSCA_TYPE_VNF;
360 if (metadata.keySet().stream()
361 .anyMatch((final String metadataEntry) -> !metadataEntry.contains(expectedMetadataType))) {
362 throw new InvalidManifestMetadataException(Messages.MANIFEST_METADATA_INVALID_ENTRY.getErrorMessage());
365 return TOSCA_TYPE_PNF.equals(expectedMetadataType);
368 private void handleMetadataEntries(final Map<String, String> metadata, final Set<String> manifestMetadata) {
369 manifestMetadata.stream()
370 .filter(requiredEntry -> !metadata.containsKey(requiredEntry))
371 .forEach(requiredEntry ->
372 reportError(ErrorLevel.ERROR,
373 String.format(Messages.MANIFEST_METADATA_MISSING_ENTRY.getErrorMessage(), requiredEntry)));
377 * Checks if all manifest sources exists within the package and if all package files are being referred.
379 * @param onboardingManifest The manifest
381 private void verifyManifestSources(final Manifest onboardingManifest) {
382 final Set<String> packageFiles = contentHandler.getFileList();
383 final List<String> sources = internalFilesFilter.filter(onboardingManifest.getSources());
384 verifyFilesExist(packageFiles, sources, MANIFEST_SOURCE);
386 final Map<String, List<String>> nonManoArtifacts = onboardingManifest.getNonManoSources();
388 final List<String> nonManoValidFilePaths = new ArrayList<>();
389 nonManoArtifacts.forEach((nonManoType, files) -> {
390 final List<String> internalNonManoFileList = internalFilesFilter.filter(files);
391 nonManoValidFilePaths.addAll(internalNonManoFileList);
392 final NonManoArtifactType nonManoArtifactType = NonManoArtifactType.parse(nonManoType).orElse(null);
393 if (nonManoArtifactType == ONAP_PM_DICTIONARY || nonManoArtifactType == ONAP_VES_EVENTS) {
394 internalNonManoFileList.forEach(this::validateYaml);
395 } else if (nonManoArtifactType == ONAP_SW_INFORMATION) {
396 validateSoftwareInformationNonManoArtifact(files);
400 verifyFilesExist(packageFiles, nonManoValidFilePaths, MANIFEST_NON_MANO_SOURCE);
402 final Set<String> allReferredFiles = new HashSet<>();
403 allReferredFiles.addAll(sources);
404 allReferredFiles.addAll(nonManoValidFilePaths);
405 verifyFilesBeingReferred(allReferredFiles, packageFiles);
408 private void validateSoftwareInformationNonManoArtifact(final List<String> files) {
409 if (CollectionUtils.isEmpty(files)) {
410 reportError(ErrorLevel.ERROR, Messages.EMPTY_SW_INFORMATION_NON_MANO_ERROR.getErrorMessage());
413 if (files.size() != 1) {
414 final String formattedFileList = files.stream()
415 .map(filePath -> String.format("'%s'", filePath))
416 .collect(Collectors.joining(", "));
417 reportError(ErrorLevel.ERROR,
418 Messages.UNIQUE_SW_INFORMATION_NON_MANO_ERROR.formatMessage(formattedFileList));
421 final String swInformationFilePath = files.get(0);
422 final byte[] swInformationYaml = contentHandler.getFileContent(swInformationFilePath);
423 final Optional<PnfSoftwareInformation> parsedYaml = SoftwareInformationArtifactYamlParser
424 .parse(swInformationYaml);
425 if (!parsedYaml.isPresent()) {
426 reportError(ErrorLevel.ERROR,
427 Messages.INVALID_SW_INFORMATION_NON_MANO_ERROR.formatMessage(swInformationFilePath));
429 final PnfSoftwareInformation pnfSoftwareInformation = parsedYaml.get();
430 if (!pnfSoftwareInformation.isValid()) {
431 reportError(ErrorLevel.ERROR,
432 Messages.INCORRECT_SW_INFORMATION_NON_MANO_ERROR.formatMessage(swInformationFilePath));
438 * Validates if a YAML file has the correct extension, is not empty and the content is a valid YAML. Reports each
441 * @param filePath the file path inside the package
443 private void validateYaml(final String filePath) {
444 if (!contentHandler.containsFile(filePath)) {
447 final String fileExtension = getFileExtension(filePath);
448 if (!"yaml".equalsIgnoreCase(fileExtension) && !"yml".equalsIgnoreCase(fileExtension)) {
449 reportError(ErrorLevel.ERROR, Messages.INVALID_YAML_EXTENSION.formatMessage(filePath));
453 try (final InputStream fileContent = contentHandler.getFileContentAsStream(filePath)) {
454 if (fileContent == null) {
455 reportError(ErrorLevel.ERROR, Messages.EMPTY_YAML_FILE_1.formatMessage(filePath));
458 new Yaml().loadAll(fileContent).iterator().next();
459 } catch (final IOException e) {
460 final String errorMsg = Messages.FILE_LOAD_CONTENT_ERROR.formatMessage(filePath);
461 reportError(ErrorLevel.ERROR, errorMsg);
462 LOGGER.debug(errorMsg, e);
463 } catch (final Exception e) {
464 final String message = Messages.INVALID_YAML_FORMAT_1.formatMessage(filePath, e.getMessage());
465 LOGGER.debug(message, e);
466 reportError(ErrorLevel.ERROR, message);
471 * Checks if all package files are referred in manifest. Reports missing references.
473 * @param referredFileSet the list of referred files path
474 * @param packageFileSet the list of package file path
476 private void verifyFilesBeingReferred(final Set<String> referredFileSet, final Set<String> packageFileSet) {
477 packageFileSet.forEach(filePath -> {
478 if (!isManifestFile(filePath) && !referredFileSet.contains(filePath)) {
479 reportError(ErrorLevel.ERROR,
480 String.format(Messages.MISSING_MANIFEST_REFERENCE.getErrorMessage(), filePath));
485 private boolean isManifestFile(final String filePath) {
486 return filePath.equals(toscaMetadata.getMetaEntries().get(ETSI_ENTRY_MANIFEST.getName()));
489 private void validateOtherEntries(final String folderPath) {
490 if (!verifyFoldersExist(folderList, folderPath)) {
491 reportError(ErrorLevel.ERROR, String.format(Messages.METADATA_MISSING_OPTIONAL_FOLDERS.getErrorMessage(),
496 private void validateCertificate(final String file) {
497 final Set<String> packageFiles = contentHandler.getFileList();
498 if (!verifyFileExist(packageFiles, file)) {
499 reportError(ErrorLevel.ERROR,
500 String.format(Messages.MISSING_METADATA_FILES.getErrorMessage(), file, file));
504 private boolean verifyFoldersExist(final Set<String> folderList, final String folderPath) {
505 return folderList.contains(folderPath + "/");
508 private void verifyFilesExist(final Set<String> existingFiles, final List<String> sources, final String type) {
509 sources.forEach(file -> {
510 if (!existingFiles.contains(file)) {
511 reportError(ErrorLevel.ERROR,
512 String.format(Messages.MISSING_MANIFEST_SOURCE.getErrorMessage(), type, file));
517 private boolean verifyFileExist(final Set<String> existingFiles, final String file) {
518 return existingFiles.contains(file);
521 private void validateChangeLog(final String filePath) {
522 if (!verifyFileExists(contentHandler.getFileList(), filePath)) {
523 reportError(ErrorLevel.ERROR, String.format(Messages.MISSING_METADATA_FILES.getErrorMessage(), filePath));
527 private void reportError(final ErrorLevel errorLevel, final String errorMessage) {
528 errorsByFile.add(new ErrorMessage(errorLevel, errorMessage));
531 private Map<String, List<ErrorMessage>> getAnyValidationErrors() {
532 if (errorsByFile.isEmpty()) {
533 return Collections.emptyMap();
535 final Map<String, List<ErrorMessage>> errors = new HashMap<>();
536 errors.put(SdcCommon.UPLOAD_FILE, errorsByFile);
540 private void validatePMDictionaryContentsAgainstSchema() {
541 final Stream<byte[]> pmDictionaryFiles = new FileExtractor(getEtsiEntryManifestPath(), contentHandler)
542 .findFiles(ONAP_PM_DICTIONARY);
543 new PMDictionaryValidator()
544 .validate(pmDictionaryFiles, (String message) -> reportError(ErrorLevel.ERROR, message));
547 private String getEtsiEntryManifestPath() {
548 return toscaMetadata.getMetaEntries().get(ETSI_ENTRY_MANIFEST.getName());