summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java2
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/EtsiSol004Version251Validator.java113
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ONAPCsarValidator.java2
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java126
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004Version3MetaDirectoryValidator.java4
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004Version4MetaDirectoryValidator.java4
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/resources/META-INF/services/org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.Validator1
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidatorTest.java18
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004Version3MetaDirectoryValidatorTest.java2
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004Version4MetaDirectoryValidatorTest.java2
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactoryTest.java12
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImpl.java6
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaSolConverter.java2
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaModelConverter.java2
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/OnboardingToscaMetadata.java2
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/ToscaMetaEntry.java43
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/ToscaMetaEntryVersion251.java50
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/ToscaMetaEntryVersion261.java48
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImpl.java8
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/csar/MetadataParsingTest.java7
20 files changed, 325 insertions, 129 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 {
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/resources/META-INF/services/org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.Validator b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/resources/META-INF/services/org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.Validator
new file mode 100644
index 0000000000..3b8a78a32b
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/resources/META-INF/services/org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.Validator
@@ -0,0 +1 @@
+org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.EtsiSol004Version251Validator \ No newline at end of file
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidatorTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidatorTest.java
index a4fd64626a..d45031f789 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidatorTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidatorTest.java
@@ -42,15 +42,15 @@ import static org.openecomp.sdc.tosca.csar.ManifestTokenType.PNFD_RELEASE_DATE_T
import static org.openecomp.sdc.tosca.csar.ManifestTokenType.VNF_PRODUCT_NAME;
import static org.openecomp.sdc.tosca.csar.ManifestTokenType.VNF_PROVIDER_ID;
import static org.openecomp.sdc.tosca.csar.ManifestTokenType.VNF_RELEASE_DATE_TIME;
-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_CHANGE_LOG;
-import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ETSI_ENTRY_LICENSES;
-import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ETSI_ENTRY_MANIFEST;
-import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ETSI_ENTRY_TESTS;
-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_CHANGE_LOG;
+import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion261.ETSI_ENTRY_LICENSES;
+import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion261.ETSI_ENTRY_MANIFEST;
+import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion261.ETSI_ENTRY_TESTS;
+import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion261.TOSCA_META_FILE_VERSION_ENTRY;
import static org.openecomp.sdc.tosca.csar.ToscaMetadataFileInfo.TOSCA_META_PATH_FILE_NAME;
import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.EMPTY_YAML_FILE_PATH;
import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.INVALID_YAML_FILE_PATH;
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004Version3MetaDirectoryValidatorTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004Version3MetaDirectoryValidatorTest.java
index f26ff584c8..9235f363eb 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004Version3MetaDirectoryValidatorTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004Version3MetaDirectoryValidatorTest.java
@@ -19,7 +19,7 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation;
import static org.openecomp.sdc.tosca.csar.ManifestTokenType.ATTRIBUTE_VALUE_SEPARATOR;
-import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.OTHER_DEFINITIONS;
+import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion261.OTHER_DEFINITIONS;
import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.TOSCA_DEFINITION_FILEPATH;
import org.openecomp.sdc.tosca.csar.ManifestTokenType;
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004Version4MetaDirectoryValidatorTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004Version4MetaDirectoryValidatorTest.java
index 0f6f63bcbf..fade5d18ad 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004Version4MetaDirectoryValidatorTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004Version4MetaDirectoryValidatorTest.java
@@ -24,7 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.openecomp.sdc.be.config.NonManoArtifactType.ONAP_CNF_HELM;
import static org.openecomp.sdc.be.test.util.TestResourcesHandler.getResourceBytesOrFail;
import static org.openecomp.sdc.tosca.csar.ManifestTokenType.ATTRIBUTE_VALUE_SEPARATOR;
-import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.OTHER_DEFINITIONS;
+import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion261.OTHER_DEFINITIONS;
import static org.openecomp.sdc.tosca.csar.ToscaMetadataFileInfo.TOSCA_META_PATH_FILE_NAME;
import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.SAMPLE_DEFINITION_FILE_PATH;
import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.SAMPLE_DEFINITION_IMPORT_FILE_PATH;
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactoryTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactoryTest.java
index 9d66d627f9..39a62deaa0 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactoryTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactoryTest.java
@@ -26,12 +26,12 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.openecomp.sdc.be.test.util.TestResourcesHandler.getResourceBytesOrFail;
import static org.openecomp.sdc.tosca.csar.ManifestTokenType.ATTRIBUTE_VALUE_SEPARATOR;
-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_CHANGE_LOG;
-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_CHANGE_LOG;
+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_PATH_FILE_NAME;
import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.TOSCA_CHANGELOG_FILEPATH;
import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.TOSCA_DEFINITION_FILEPATH;
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImpl.java
index 258b058df7..2e06202471 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImpl.java
@@ -25,9 +25,9 @@ import static org.openecomp.sdc.tosca.csar.CSARConstants.MAIN_SERVICE_TEMPLATE_M
import static org.openecomp.sdc.tosca.csar.CSARConstants.MANIFEST_PNF_METADATA;
import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ORIG_PATH_FILE_NAME;
import static org.openecomp.sdc.tosca.csar.ManifestTokenType.COMPATIBLE_SPECIFICATION_VERSIONS;
-import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ENTRY_DEFINITIONS;
-import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ETSI_ENTRY_CHANGE_LOG;
-import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ETSI_ENTRY_MANIFEST;
+import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion261.ENTRY_DEFINITIONS;
+import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion261.ETSI_ENTRY_CHANGE_LOG;
+import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion261.ETSI_ENTRY_MANIFEST;
import static org.openecomp.sdc.tosca.csar.ToscaMetadataFileInfo.TOSCA_META_PATH_FILE_NAME;
import com.vdurmont.semver4j.Semver;
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaSolConverter.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaSolConverter.java
index fb170e3ece..e53dd4f02f 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaSolConverter.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaSolConverter.java
@@ -22,7 +22,7 @@
package org.openecomp.core.impl;
import static org.openecomp.core.converter.datatypes.Constants.GLOBAL_ST_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/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaModelConverter.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaModelConverter.java
index 2656382972..52b69966c9 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaModelConverter.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaModelConverter.java
@@ -22,7 +22,7 @@
package org.openecomp.core.impl;
import static org.openecomp.core.converter.datatypes.Constants.GLOBAL_ST_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/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/OnboardingToscaMetadata.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/OnboardingToscaMetadata.java
index bc104335f5..fda50f52cd 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/OnboardingToscaMetadata.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/OnboardingToscaMetadata.java
@@ -21,7 +21,7 @@ package org.openecomp.sdc.tosca.csar;
import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters;
import static org.openecomp.sdc.tosca.csar.ManifestTokenType.ATTRIBUTE_VALUE_SEPARATOR;
-import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ENTRY_DEFINITIONS;
+import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion261.ENTRY_DEFINITIONS;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/ToscaMetaEntry.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/ToscaMetaEntry.java
index 9219c77bea..c3cdf02e67 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/ToscaMetaEntry.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/ToscaMetaEntry.java
@@ -1,12 +1,14 @@
/*
- *(===========LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation
- * (===============================================================================
+ * -
+ * ============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
+ * 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.
@@ -14,37 +16,12 @@
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
- * (===========LICENSE_END=========================================================
+ * ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.tosca.csar;
-
-import java.util.Arrays;
-import java.util.Optional;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-/**
- * Represents entry keys in a TOSCA.meta file.
- */
-@AllArgsConstructor
-@Getter
-public enum ToscaMetaEntry {
- // @formatter:off
- TOSCA_META_FILE_VERSION_ENTRY("TOSCA-Meta-File-Version"),
- CSAR_VERSION_ENTRY("CSAR-Version"),
- CREATED_BY_ENTRY("Created-By"),
- ENTRY_DEFINITIONS("Entry-Definitions"),
- ETSI_ENTRY_MANIFEST("ETSI-Entry-Manifest"),
- ETSI_ENTRY_CHANGE_LOG("ETSI-Entry-Change-Log"),
- ETSI_ENTRY_TESTS("ETSI-Entry-Tests"),
- ETSI_ENTRY_LICENSES("ETSI-Entry-Licenses"),
- ETSI_ENTRY_CERTIFICATE("ETSI-Entry-Certificate"),
- OTHER_DEFINITIONS("Other-Definitions");
- // @formatter:on
+package org.openecomp.sdc.tosca.csar;
- private final String name;
+public interface ToscaMetaEntry {
- public static Optional<ToscaMetaEntry> parse(final String name) {
- return Arrays.stream(values()).filter(toscaMetaEntry -> toscaMetaEntry.getName().equals(name)).findFirst();
- }
+ String getName();
}
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/ToscaMetaEntryVersion251.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/ToscaMetaEntryVersion251.java
new file mode 100644
index 0000000000..7dcb6acfc7
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/ToscaMetaEntryVersion251.java
@@ -0,0 +1,50 @@
+/*
+ * -
+ * ============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.tosca.csar;
+
+import java.util.Arrays;
+import java.util.Optional;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * Represents entry keys in a TOSCA.meta file.
+ */
+@AllArgsConstructor
+@Getter
+public enum ToscaMetaEntryVersion251 implements ToscaMetaEntry {
+ TOSCA_META_FILE_VERSION_ENTRY("TOSCA-Meta-File-Version"),
+ CSAR_VERSION_ENTRY("CSAR-Version"),
+ CREATED_BY_ENTRY("Created-By"),
+ ENTRY_DEFINITIONS("Entry-Definitions"),
+ ENTRY_MANIFEST("Entry-Manifest"),
+ ENTRY_CHANGE_LOG("Entry-Change-Log"),
+ ENTRY_TESTS("Entry-Tests"),
+ ENTRY_LICENSES("Entry-Licenses"),
+ ENTRY_CERTIFICATE("Entry-Certificate");
+
+ private final String name;
+
+ public static Optional<ToscaMetaEntryVersion251> parse(final String name) {
+ return Arrays.stream(values()).filter(toscaMetaEntry -> toscaMetaEntry.getName().equals(name)).findFirst();
+ }
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/ToscaMetaEntryVersion261.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/ToscaMetaEntryVersion261.java
new file mode 100644
index 0000000000..3d9f98396e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/ToscaMetaEntryVersion261.java
@@ -0,0 +1,48 @@
+/*
+ *(===========LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * (===============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.tosca.csar;
+
+import java.util.Arrays;
+import java.util.Optional;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * Represents entry keys in a TOSCA.meta file.
+ */
+@AllArgsConstructor
+@Getter
+public enum ToscaMetaEntryVersion261 implements ToscaMetaEntry {
+ TOSCA_META_FILE_VERSION_ENTRY("TOSCA-Meta-File-Version"),
+ CSAR_VERSION_ENTRY("CSAR-Version"),
+ CREATED_BY_ENTRY("Created-By"),
+ ENTRY_DEFINITIONS("Entry-Definitions"),
+ ETSI_ENTRY_MANIFEST("ETSI-Entry-Manifest"),
+ ETSI_ENTRY_CHANGE_LOG("ETSI-Entry-Change-Log"),
+ ETSI_ENTRY_TESTS("ETSI-Entry-Tests"),
+ ETSI_ENTRY_LICENSES("ETSI-Entry-Licenses"),
+ ETSI_ENTRY_CERTIFICATE("ETSI-Entry-Certificate"),
+ OTHER_DEFINITIONS("Other-Definitions");
+
+ private final String name;
+
+ public static Optional<ToscaMetaEntryVersion261> parse(final String name) {
+ return Arrays.stream(values()).filter(toscaMetaEntry -> toscaMetaEntry.getName().equals(name)).findFirst();
+ }
+}
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImpl.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImpl.java
index 90047aa6df..d0df54b105 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImpl.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImpl.java
@@ -15,10 +15,10 @@
*/
package org.openecomp.sdc.tosca.services.impl;
-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.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.TOSCA_META_FILE_VERSION_ENTRY;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/csar/MetadataParsingTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/csar/MetadataParsingTest.java
index 51cdfa990d..045c5042a4 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/csar/MetadataParsingTest.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/csar/MetadataParsingTest.java
@@ -24,13 +24,12 @@ package org.openecomp.sdc.tosca.csar;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
-import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ENTRY_DEFINITIONS;
-import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ETSI_ENTRY_CHANGE_LOG;
-import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ETSI_ENTRY_MANIFEST;
+import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion261.ENTRY_DEFINITIONS;
+import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion261.ETSI_ENTRY_CHANGE_LOG;
+import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion261.ETSI_ENTRY_MANIFEST;
import java.io.IOException;
import java.io.InputStream;
-
import org.junit.Test;