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/VendorSoftwareProductManagerImpl.java4
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java112
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java2
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidatorTest.java109
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/TestConstants.java8
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactoryTest.java29
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/metafile/metaFileWithMultipleBlocks.meta8
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/vspmanager.csar/metadata/ValidETSItosca.meta4
-rw-r--r--openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java18
-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.java8
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImplTest.java4
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolConverterImpl.java21
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaSolConverterImplTest.java4
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/pom.xml6
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/AbstractOnboardingManifest.java18
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/CSARConstants.java9
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/Manifest.java8
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/SOL004ManifestOnboarding.java2
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/csar/ManifestParsingTest.java6
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/csar/MetadataParsingTest.java8
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/resources/vspmanager.csar/metadata/ValidETSItosca.meta4
21 files changed, 245 insertions, 147 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
index 5be982bede..49ec30eed7 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
@@ -17,7 +17,7 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
import static org.openecomp.sdc.tosca.csar.CSARConstants.MANIFEST_PNF_METADATA;
-import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ENTRY_MANIFEST;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_MANIFEST;
import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ORIG_PATH_FILE_NAME;
import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_PATH_FILE_NAME;
import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductInvalidErrorBuilder.candidateDataNotProcessedOrAbortedErrorBuilder;
@@ -664,7 +664,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
private InputStream getManifest(FileContentHandler handler) throws IOException {
ToscaMetadata metadata = getMetadata(handler);
- return getManifestInputStream(handler, metadata.getMetaEntries().get(TOSCA_META_ENTRY_MANIFEST));
+ return getManifestInputStream(handler, metadata.getMetaEntries().get(TOSCA_META_ETSI_ENTRY_MANIFEST));
}
private ToscaMetadata getMetadata(FileContentHandler handler) throws 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 a76acf5177..893fb7032d 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java
@@ -23,6 +23,7 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validati
import org.openecomp.core.converter.ServiceTemplateReaderService;
import org.openecomp.core.impl.services.ServiceTemplateReaderServiceImpl;
import org.openecomp.core.utilities.file.FileContentHandler;
+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;
@@ -41,6 +42,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
@@ -51,14 +53,15 @@ import static org.openecomp.sdc.tosca.csar.CSARConstants.MANIFEST_PNF_METADATA;
import static org.openecomp.sdc.tosca.csar.CSARConstants.MANIFEST_VNF_METADATA;
import static org.openecomp.sdc.tosca.csar.CSARConstants.NON_FILE_IMPORT_ATTRIBUTES;
import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_MANIFEST_FILE_EXT;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_CERTIFICATE;
import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_FILE_VERSION_ENTRY;
import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_CREATED_BY_ENTRY;
import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_CSAR_VERSION_ENTRY;
-import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ENTRY_CHANGE_LOG;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_CHANGE_LOG;
import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ENTRY_DEFINITIONS;
-import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ENTRY_LICENSES;
-import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ENTRY_MANIFEST;
-import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ENTRY_TESTS;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_LICENSES;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_MANIFEST;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_TESTS;
import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_FILE_VERSION;
import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_PATH_FILE_NAME;
import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_TYPE_PNF;
@@ -66,7 +69,7 @@ import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_TYPE_VNF;
/**
* 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.
+ * as defined in ETSI GS NFV-SOL 004 v2.6.1.
*
*/
@@ -74,6 +77,8 @@ 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";
private final List<ErrorMessage> errorsByFile = new ArrayList<>();
private final Set<String> verifiedImports = new HashSet<>();
@@ -100,14 +105,15 @@ class SOL004MetaDirectoryValidator implements Validator{
private void verifyManifestNameAndExtension(ToscaMetadata toscaMetadata) {
Map<String, String> entries = toscaMetadata.getMetaEntries();
- String manifestFileName = getFileName(entries.get(TOSCA_META_ENTRY_MANIFEST));
- String manifestExtension = getFileExtension(entries.get(TOSCA_META_ENTRY_MANIFEST));
+ String manifestFileName = getFileName(entries.get(TOSCA_META_ETSI_ENTRY_MANIFEST));
+ String manifestExtension = getFileExtension(entries.get(TOSCA_META_ETSI_ENTRY_MANIFEST));
String mainDefinitionFileName= getFileName(entries.get(TOSCA_META_ENTRY_DEFINITIONS));
if(!(TOSCA_MANIFEST_FILE_EXT).equals(manifestExtension)){
reportError(ErrorLevel.ERROR, Messages.MANIFEST_INVALID_EXT.getErrorMessage());
}
if(!mainDefinitionFileName.equals(manifestFileName)){
- reportError(ErrorLevel.ERROR, Messages.MANIFEST_INVALID_NAME.getErrorMessage());
+ reportError(ErrorLevel.ERROR, String.format(Messages.MANIFEST_INVALID_NAME.getErrorMessage(),
+ manifestFileName, mainDefinitionFileName));
}
}
@@ -136,31 +142,54 @@ class SOL004MetaDirectoryValidator implements Validator{
private void handleMetadataEntries(FileContentHandler contentHandler, List<String> folderList, ToscaMetadata toscaMetadata) {
for(Map.Entry entry: toscaMetadata.getMetaEntries().entrySet()){
- String key = (String) entry.getKey();
- String value = (String) entry.getValue();
- switch (key){
- case TOSCA_META_FILE_VERSION_ENTRY:
- case TOSCA_META_CSAR_VERSION_ENTRY:
- case TOSCA_META_CREATED_BY_ENTRY:
- verifyMetadataEntryVersions(key, value);
- break;
- case TOSCA_META_ENTRY_DEFINITIONS:
- validateDefinitionFile(contentHandler, value);
- break;
- case TOSCA_META_ENTRY_MANIFEST:
- validateManifestFile(contentHandler, value);
- break;
- case TOSCA_META_ENTRY_CHANGE_LOG:
- validateChangeLog(contentHandler, value);
- break;
- case TOSCA_META_ENTRY_TESTS:
- case TOSCA_META_ENTRY_LICENSES:
- validateOtherEntries(folderList, value);
- break;
- default:
- errorsByFile.add(new ErrorMessage(ErrorLevel.ERROR, String.format(Messages.METADATA_UNSUPPORTED_ENTRY.getErrorMessage(), entry)));
- LOGGER.warn(Messages.METADATA_UNSUPPORTED_ENTRY.getErrorMessage(), entry);
- break;
+ handleEntry(contentHandler, folderList, toscaMetadata, entry);
+ }
+ }
+
+ private void handleEntry(FileContentHandler contentHandler, List<String> folderList, ToscaMetadata toscaMetadata, Map.Entry entry) {
+ String key = (String) entry.getKey();
+ String value = (String) entry.getValue();
+ switch (key){
+ case TOSCA_META_FILE_VERSION_ENTRY:
+ case TOSCA_META_CSAR_VERSION_ENTRY:
+ case TOSCA_META_CREATED_BY_ENTRY:
+ verifyMetadataEntryVersions(key, value);
+ break;
+ case TOSCA_META_ENTRY_DEFINITIONS:
+ validateDefinitionFile(contentHandler, value);
+ break;
+ case TOSCA_META_ETSI_ENTRY_MANIFEST:
+ validateManifestFile(contentHandler, value);
+ break;
+ case TOSCA_META_ETSI_ENTRY_CHANGE_LOG:
+ validateChangeLog(contentHandler, value);
+ break;
+ case TOSCA_META_ETSI_ENTRY_TESTS:
+ case TOSCA_META_ETSI_ENTRY_LICENSES:
+ validateOtherEntries(folderList, entry, contentHandler, toscaMetadata);
+ break;
+ case TOSCA_META_ETSI_ENTRY_CERTIFICATE:
+ validateOtherEntries(folderList, value);
+ break;
+ default:
+ errorsByFile.add(new ErrorMessage(ErrorLevel.ERROR, String.format(Messages.METADATA_UNSUPPORTED_ENTRY.getErrorMessage(), entry)));
+ LOGGER.warn(Messages.METADATA_UNSUPPORTED_ENTRY.getErrorMessage(), entry);
+ break;
+ }
+ }
+
+ private void validateOtherEntries(List<String> folderList, Map.Entry entry, FileContentHandler contentHandler, ToscaMetadata toscaMetadata) {
+ String manifestFile = toscaMetadata.getMetaEntries().get(TOSCA_META_ETSI_ENTRY_MANIFEST);
+ if(verifyFileExists(contentHandler.getFileList(), manifestFile)){
+ Manifest onboardingManifest = new SOL004ManifestOnboarding();
+ onboardingManifest.parse(contentHandler.getFileContent(manifestFile));
+ Optional<ResourceTypeEnum> resourceType = onboardingManifest.getType();
+ if(resourceType.isPresent() && resourceType.get() == ResourceTypeEnum.VF){
+ String value = (String) entry.getValue();
+ validateOtherEntries(folderList, value);
+ }else{
+ String key = (String) entry.getKey();
+ reportError(ErrorLevel.ERROR, String.format(Messages.MANIFEST_INVALID_PNF_METADATA.getErrorMessage(), key));
}
}
@@ -225,7 +254,8 @@ class SOL004MetaDirectoryValidator implements Validator{
filePath = parentDir + "/" + filePath;
}
if(!verifyFileExists(existingFiles, filePath)){
- reportError(ErrorLevel.ERROR, String.format(Messages.MISSING_IMPORT_FILE.getErrorMessage(), (String) o));
+ reportError(ErrorLevel.ERROR, String.format(Messages.MISSING_IMPORT_FILE.getErrorMessage(), filePath,
+ parentDir));
return null;
}
return filePath;
@@ -237,7 +267,7 @@ class SOL004MetaDirectoryValidator implements Validator{
}
}
}else {
- reportError(ErrorLevel.ERROR, Messages.INVALID_IMPORT_STATEMENT.getErrorMessage());
+ reportError(ErrorLevel.ERROR, String.format(Messages.INVALID_IMPORT_STATEMENT.getErrorMessage(), parentDir));
}
return null;
}
@@ -271,7 +301,7 @@ class SOL004MetaDirectoryValidator implements Validator{
}
}
}else {
- reportError(ErrorLevel.ERROR, String.format(Messages.MANIFEST_NOT_EXIST.getErrorMessage(), filePath));
+ reportError(ErrorLevel.ERROR, String.format(Messages.MANIFEST_NOT_FOUND.getErrorMessage(), filePath));
}
}
@@ -318,9 +348,9 @@ class SOL004MetaDirectoryValidator implements Validator{
private void verifySourcesExists(Set<String> exitingFiles, Manifest onboardingManifest) {
List<String> sources = filterSources(onboardingManifest.getSources());
Map<String, List<String>> nonManoArtifacts = onboardingManifest.getNonManoSources();
- verifyFilesExist(exitingFiles, sources);
+ verifyFilesExist(exitingFiles, sources, MANIFEST_SOURCE);
for (Map.Entry entry : nonManoArtifacts.entrySet()) {
- verifyFilesExist(exitingFiles, filterSources((List)entry.getValue()));
+ verifyFilesExist(exitingFiles, filterSources((List)entry.getValue()), MANIFEST_NON_MANO_SOURCE);
}
}
@@ -344,10 +374,10 @@ class SOL004MetaDirectoryValidator implements Validator{
return folderList.contains(folderPath + "/");
}
- private void verifyFilesExist(Set<String> existingFiles, List<String> sources){
+ private void verifyFilesExist(Set<String> existingFiles, List<String> sources, String type){
for(String file: sources){
if(!verifyFileExists(existingFiles, file)){
- reportError(ErrorLevel.ERROR, String.format(Messages.MISSING_ARTIFACT.getErrorMessage(), file));
+ reportError(ErrorLevel.ERROR, String.format(Messages.MISSING_MANIFEST_SOURCE.getErrorMessage(), type, file));
}
}
@@ -355,7 +385,7 @@ class SOL004MetaDirectoryValidator implements Validator{
private void validateChangeLog(FileContentHandler contentHandler, String filePath){
if(!verifyFileExists(contentHandler.getFileList(), filePath)){
- reportError(ErrorLevel.ERROR, String.format(Messages.MISSING_ARTIFACT.getErrorMessage(), filePath));
+ reportError(ErrorLevel.ERROR, String.format(Messages.MISSING_METADATA_FILES.getErrorMessage(), filePath));
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java
index 7be3eb9fdb..665c63d64c 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java
@@ -51,7 +51,7 @@ import java.util.*;
public class OrchestrationTemplateProcessCsarHandler implements OrchestrationTemplateProcessHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(OrchestrationTemplateProcessCsarHandler.class);
- private static final String SDC_ONBOARDED_PACKAGE_DIR = "ONBOARDED_PACKAGE/";
+ private static final String SDC_ONBOARDED_PACKAGE_DIR = "Deployment/ONBOARDED_PACKAGE/";
private static final String EXT_SEPARATOR = ".";
private final CandidateService candidateService = CandidateServiceFactory.getInstance().createInterface();
private final ToscaTreeManager toscaTreeManager = new ToscaTreeManager();
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 8584d482b4..93c8b23268 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
@@ -14,6 +14,14 @@ import java.util.List;
import java.util.Map;
import static org.junit.Assert.assertTrue;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.SEPERATOR_MF_ATTRIBUTE;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ENTRY_DEFINITIONS;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_CERTIFICATE;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_CHANGE_LOG;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_LICENSES;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_MANIFEST;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_TESTS;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_PATH_FILE_NAME;
import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.*;
public class SOL004MetaDirectoryValidatorTest {
@@ -30,9 +38,9 @@ public class SOL004MetaDirectoryValidatorTest {
"TOSCA-Meta-File-Version: 1.0\n"+
"CSAR-Version: 1.1\n"+
"Created-by: Vendor\n"+
- "Entry-Definitions: Definitions/MainServiceTemplate.yaml\n"+
- "Entry-Manifest: Definitions/MainServiceTemplate.mf\n"+
- "Entry-Change-Log: Artifacts/changeLog.text\n";
+ TOSCA_META_ENTRY_DEFINITIONS + SEPERATOR_MF_ATTRIBUTE + "Definitions/MainServiceTemplate.yaml\n"+
+ TOSCA_META_ETSI_ENTRY_MANIFEST + SEPERATOR_MF_ATTRIBUTE + "Definitions/MainServiceTemplate.mf\n"+
+ TOSCA_META_ETSI_ENTRY_CHANGE_LOG + SEPERATOR_MF_ATTRIBUTE + "Artifacts/changeLog.text\n";
}
@Test
@@ -41,7 +49,7 @@ public class SOL004MetaDirectoryValidatorTest {
String metaFileWithInvalidEntry = "TOSCA-Meta-File-Version: \n" +
"Entry-Definitions: Definitions/MainServiceTemplate.yaml";
- handler.addFile(TOSCA_METADATA_FILEPATH, metaFileWithInvalidEntry.getBytes(StandardCharsets.UTF_8));
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileWithInvalidEntry.getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(TestConstants.SAMPLE_DEFINITION_FILE_PATH));
Map<String, List<ErrorMessage>> errors = sol004MetaDirectoryValidator.validateContent(handler, Collections.emptyList());
@@ -60,10 +68,10 @@ public class SOL004MetaDirectoryValidatorTest {
folderList.add("Files/Licenses/");
metaFile = metaFile +
- "Entry-Tests: "+ entryTestFilePath + "\n" +
- "Entry-Licenses: "+ entryLicenseFilePath +"\n";
+ TOSCA_META_ETSI_ENTRY_TESTS + SEPERATOR_MF_ATTRIBUTE + entryTestFilePath + "\n" +
+ TOSCA_META_ETSI_ENTRY_LICENSES + SEPERATOR_MF_ATTRIBUTE + entryLicenseFilePath +"\n";
- handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8));
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_DEFINITION_FILE_PATH));
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_MANIFEST_FILE_PATH));
@@ -81,7 +89,7 @@ public class SOL004MetaDirectoryValidatorTest {
metaFile = "Entry-Events: Definitions/events.log";
- handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8));
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8));
Map<String, List<ErrorMessage>> errors = sol004MetaDirectoryValidator.validateContent(handler, Collections.emptyList());
List<ErrorMessage> errorMessages = errors.get(SdcCommon.UPLOAD_FILE);
assertTrue(errors.size() == 1 && errorMessages.size() == 1);
@@ -95,12 +103,12 @@ public class SOL004MetaDirectoryValidatorTest {
String metaFile =
"TOSCA-Meta-File-Version: " + Integer.MAX_VALUE +
"\nCSAR-Version: " + Integer.MAX_VALUE +
- "\nCreated-by: Bilal Iqbal" +
- "\nEntry-Definitions: Definitions/MainServiceTemplate.yaml" +
- "\nEntry-Manifest: Definitions/MainServiceTemplate.mf"+
- "\nEntry-Change-Log: Artifacts/changeLog.text";
+ "\nCreated-by: Bilal Iqbal\n" +
+ TOSCA_META_ENTRY_DEFINITIONS+ SEPERATOR_MF_ATTRIBUTE + "Definitions/MainServiceTemplate.yaml\n" +
+ TOSCA_META_ETSI_ENTRY_MANIFEST + SEPERATOR_MF_ATTRIBUTE + "Definitions/MainServiceTemplate.mf\n"+
+ TOSCA_META_ETSI_ENTRY_CHANGE_LOG + SEPERATOR_MF_ATTRIBUTE + "Artifacts/changeLog.text";
- handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8));
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(TestConstants.SAMPLE_DEFINITION_FILE_PATH));
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_MANIFEST_FILE_PATH));
@@ -113,15 +121,11 @@ public class SOL004MetaDirectoryValidatorTest {
@Test
public void testGivenTOSCAMetaFile_withNonExistentFileReferenced_thenErrorsReturned(){
- metaFile = metaFile +
- "Entry-Tests: Files/Tests\n" +
- "Entry-License: Files/Licenses\n";
-
- handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8));
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8));
Map<String, List<ErrorMessage>> errors = sol004MetaDirectoryValidator.validateContent(handler, Collections.emptyList());
List<ErrorMessage> errorMessages = errors.get(SdcCommon.UPLOAD_FILE);
- assertTrue(errors.size() == 1 && errorMessages.size() == 5);
+ assertTrue(errors.size() == 1 && errorMessages.size() == 3);
}
@@ -131,7 +135,7 @@ public class SOL004MetaDirectoryValidatorTest {
String definitionFileWithValidImports = "/validation.files/definition/definitionFileWithValidImports.yaml";
- handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8));
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_MANIFEST_FILE_PATH));
handler.addFile(SAMPLE_SOURCE, "".getBytes());
@@ -149,7 +153,7 @@ public class SOL004MetaDirectoryValidatorTest {
byte [] sampleDefinitionFile2 = ValidatorUtil.getFileResource("/validation.files/definition/sampleDefinitionFile2.yaml");
byte [] sampleDefinitionFile3 = ValidatorUtil.getFileResource("/validation.files/definition/sampleDefinitionFile3.yaml");
- handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8));
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_MANIFEST_FILE_PATH));
handler.addFile(SAMPLE_SOURCE, "".getBytes());
@@ -166,7 +170,7 @@ public class SOL004MetaDirectoryValidatorTest {
String definitionFileWithInvalidImports = "/validation.files/definition/definitionFileWithInvalidImport.yaml";
- handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8));
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_MANIFEST_FILE_PATH));
handler.addFile(SAMPLE_SOURCE, "".getBytes());
@@ -180,7 +184,7 @@ public class SOL004MetaDirectoryValidatorTest {
@Test
public void testGivenDefinitionFile_whenReferencedImportDoesNotExist_thenErrorIsReturned() throws IOException{
- handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8));
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_MANIFEST_FILE_PATH));
handler.addFile(SAMPLE_SOURCE, "".getBytes());
@@ -198,7 +202,7 @@ public class SOL004MetaDirectoryValidatorTest {
String definitionFileWithInvalidYAML = "/validation.files/definition/invalidDefinitionFile.yaml";
- handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8));
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_MANIFEST_FILE_PATH));
handler.addFile(SAMPLE_SOURCE, "".getBytes());
@@ -215,7 +219,7 @@ public class SOL004MetaDirectoryValidatorTest {
String nonManoSource = "Artifacts/Deployment/Measurements/PM_Dictionary.yaml";
- handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8));
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource("/validation.files/manifest/validManifest.mf"));
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes());
handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_DEFINITION_FILE_PATH));
@@ -231,7 +235,7 @@ public class SOL004MetaDirectoryValidatorTest {
public void testGivenManifestFile_withNonExistentSourceFile_thenErrorIsReturned() throws IOException{
String nonManoSource = "Artifacts/Deployment/Measurements/PM_Dictionary.yaml";
- handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8));
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource("/validation.files/manifest/validManifest.mf"));
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes());
handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_DEFINITION_FILE_PATH));
@@ -246,7 +250,7 @@ public class SOL004MetaDirectoryValidatorTest {
@Test
public void testGivenManifestFile_withInvalidData_thenErrorIsReturned() throws IOException{
- handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8));
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource("/validation.files/manifest/invalidManifest.mf"));
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes());
handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_DEFINITION_FILE_PATH));
@@ -260,7 +264,7 @@ public class SOL004MetaDirectoryValidatorTest {
@Test
public void testGivenManifestAndDefinitionFile_withSameNames_thenNoErrorReturned() throws IOException {
- handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8));
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource("/validation.files/manifest/sampleManifest.mf"));
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes());
handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_DEFINITION_FILE_PATH));
@@ -276,11 +280,11 @@ public class SOL004MetaDirectoryValidatorTest {
"TOSCA-Meta-File-Version: 1.0\n"+
"CSAR-Version: 1.1\n"+
"Created-by: Vendor\n"+
- "Entry-Definitions: Definitions/MainServiceTemplate.yaml\n"+
- "Entry-Manifest: Definitions/MainServiceTemplate2.mf\n"+
- "Entry-Change-Log: Artifacts/changeLog.text\n";
+ TOSCA_META_ENTRY_DEFINITIONS + SEPERATOR_MF_ATTRIBUTE + "Definitions/MainServiceTemplate.yaml\n"+
+ TOSCA_META_ETSI_ENTRY_MANIFEST + SEPERATOR_MF_ATTRIBUTE +"Definitions/MainServiceTemplate2.mf\n"+
+ TOSCA_META_ETSI_ENTRY_CHANGE_LOG + SEPERATOR_MF_ATTRIBUTE +"Artifacts/changeLog.text\n";
- handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8));
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8));
handler.addFile("Definitions/MainServiceTemplate2.mf", ValidatorUtil.getFileResource("/validation.files/manifest/sampleManifest.mf"));
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes());
handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_DEFINITION_FILE_PATH));
@@ -298,10 +302,10 @@ public class SOL004MetaDirectoryValidatorTest {
"CSAR-Version: 1.1\n"+
"Created-by: Vendor\n"+
"Entry-Definitions: Definitions/MainServiceTemplate.yaml\n"+
- "Entry-Manifest: Definitions/MainServiceTemplate.txt\n"+
- "Entry-Change-Log: Artifacts/changeLog.text\n";
+ TOSCA_META_ETSI_ENTRY_MANIFEST + SEPERATOR_MF_ATTRIBUTE + "Definitions/MainServiceTemplate.txt\n"+
+ TOSCA_META_ETSI_ENTRY_CHANGE_LOG + SEPERATOR_MF_ATTRIBUTE + "Artifacts/changeLog.text\n";
- handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8));
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8));
handler.addFile("Definitions/MainServiceTemplate.txt", ValidatorUtil.getFileResource("/validation.files/manifest/sampleManifest.mf"));
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes());
handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_DEFINITION_FILE_PATH));
@@ -314,7 +318,7 @@ public class SOL004MetaDirectoryValidatorTest {
@Test
public void testGivenManifestFile_withValidVnfMetadata_thenNoErrorsReturned() throws IOException{
- handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8));
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource("/validation.files/manifest/sampleManifest.mf"));
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes());
handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_DEFINITION_FILE_PATH));
@@ -325,7 +329,7 @@ public class SOL004MetaDirectoryValidatorTest {
@Test
public void testGivenManifestFile_withValidPnfMetadata_thenNoErrorsReturned() throws IOException {
- handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8));
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource("/validation.files/manifest/sampleManifest2.mf"));
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes());
handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_DEFINITION_FILE_PATH));
@@ -337,7 +341,7 @@ public class SOL004MetaDirectoryValidatorTest {
@Test
public void testGivenManifestFile_withMetadataContainingMixedPnfVnfMetadata_thenErrorIsReturned() throws IOException {
- handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8));
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource("/validation.files/manifest/manifestInvalidMetadata.mf"));
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes());
handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_DEFINITION_FILE_PATH));
@@ -350,7 +354,7 @@ public class SOL004MetaDirectoryValidatorTest {
@Test
public void testGivenManifestFile_withMetadataMissingPnfOrVnfMandatoryEntries_thenErrorIsReturned() throws IOException{
- handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8));
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource("/validation.files/manifest/manifestInvalidMetadata2.mf"));
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes());
handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_DEFINITION_FILE_PATH));
@@ -361,7 +365,7 @@ public class SOL004MetaDirectoryValidatorTest {
@Test
public void testGivenManifestFile_withMetadataMissingMandatoryPnfEntries_thenErrorIsReturned() throws IOException{
- handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8));
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource("/validation.files/manifest/manifestInvalidMetadata4.mf"));
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes());
handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_DEFINITION_FILE_PATH));
@@ -373,7 +377,7 @@ public class SOL004MetaDirectoryValidatorTest {
@Test
public void testGivenManifestFile_withMetadataMissingMandatoryVnfEntries_thenErrorIsReturned() throws IOException{
- handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8));
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource("/validation.files/manifest/manifestInvalidMetadata5.mf"));
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes());
handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_DEFINITION_FILE_PATH));
@@ -385,7 +389,7 @@ public class SOL004MetaDirectoryValidatorTest {
@Test
public void testGivenManifestFile_withMetadataEntriesExceedingTheLimit_thenErrorIsReturned() throws IOException{
- handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8));
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource("/validation.files/manifest/manifestInvalidMetadata3.mf"));
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes());
handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_DEFINITION_FILE_PATH));
@@ -394,6 +398,27 @@ public class SOL004MetaDirectoryValidatorTest {
assertExpectedErrors("Manifest with more than 4 metadata entries should return error", errors, 2);
}
+ @Test
+ public void testGivenManifestFile_withPnfMetadataAndVfEntries_thenErrorIsReturned() throws IOException {
+
+ List<String> folderList = new ArrayList<>();
+ folderList.add("Files/Certificates/");
+
+ metaFile = metaFile +
+ TOSCA_META_ETSI_ENTRY_TESTS + SEPERATOR_MF_ATTRIBUTE + "Files/Tests\n" +
+ TOSCA_META_ETSI_ENTRY_LICENSES + SEPERATOR_MF_ATTRIBUTE + "Files/Licenses\n" +
+ TOSCA_META_ETSI_ENTRY_CERTIFICATE + SEPERATOR_MF_ATTRIBUTE + "Files/Certificates";
+
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8));
+ handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource("/validation.files/manifest/sampleManifest2.mf"));
+ handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes());
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_DEFINITION_FILE_PATH));
+
+ Map<String, List<ErrorMessage>> errors = sol004MetaDirectoryValidator.validateContent(handler, folderList);
+ assertExpectedErrors("Tosca.meta should not have entries applicable only to VF", errors, 2);
+
+ }
+
private void assertExpectedErrors( String testCase, Map<String, List<ErrorMessage>> errors, int expectedErrors){
if(expectedErrors > 0){
List<ErrorMessage> errorMessages = errors.get(SdcCommon.UPLOAD_FILE);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/TestConstants.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/TestConstants.java
index 0a88ebc37d..ce338df5d0 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/TestConstants.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/TestConstants.java
@@ -7,17 +7,9 @@ class TestConstants {
public static final String SAMPLE_SOURCE = "Artifacts/Deployment/Events/RadioNode_pnf_v1.yaml";
public static final String SAMPLE_DEFINITION_FILE_PATH = "/validation.files/definition/sampleDefinitionFile.yaml";
public static final String SAMPLE_MANIFEST_FILE_PATH = "/validation.files/manifest/sampleManifest.mf";
-
- public static final String ENTRY_DEFINITIONS = "Entry-Definitions";
- public static final String ENTRY_MANIFEST = "Entry-Manifest";
- public static final String ENTRY_CHANGE_LOG = "Entry-Change-Log";
-
- public static final String ENTRY_SEPARATOR = ":";
-
public static final String TOSCA_DEFINITION_FILEPATH = "Definitions/MainServiceTemplate.yaml";
public static final String TOSCA_MANIFEST_FILEPATH = "Definitions/MainServiceTemplate.mf";
public static final String TOSCA_CHANGELOG_FILEPATH = "Artifacts/changeLog.text";
- public static final String TOSCA_METADATA_FILEPATH = "TOSCA-Metadata/TOSCA.meta";
private TestConstants(){
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 287662283c..3f42c5715c 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
@@ -3,19 +3,18 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validati
import org.junit.Before;
import org.junit.Test;
import org.openecomp.core.utilities.file.FileContentHandler;
-
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import static org.junit.Assert.assertEquals;
-import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.ENTRY_CHANGE_LOG;
-import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.ENTRY_DEFINITIONS;
-import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.ENTRY_MANIFEST;
-import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.ENTRY_SEPARATOR;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.SEPERATOR_MF_ATTRIBUTE;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ENTRY_DEFINITIONS;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_CHANGE_LOG;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_MANIFEST;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.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;
import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.TOSCA_MANIFEST_FILEPATH;
-import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.TOSCA_METADATA_FILEPATH;
public class ValidatorFactoryTest {
@@ -33,7 +32,7 @@ public class ValidatorFactoryTest {
@Test(expected = IOException.class)
public void testGivenEmptyMetaFile_thenIOExceptionIsThrown() throws IOException{
- handler.addFile(TOSCA_METADATA_FILEPATH, "".getBytes(StandardCharsets.UTF_8));
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, "".getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_DEFINITION_FILEPATH, "".getBytes());
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_MANIFEST_FILEPATH, "".getBytes(StandardCharsets.UTF_8));
@@ -43,7 +42,7 @@ public class ValidatorFactoryTest {
@Test
public void testGivenEmptyBlock0_thenONAPCsarValidatorIsReturned() throws IOException{
- handler.addFile(TOSCA_METADATA_FILEPATH, " ".getBytes(StandardCharsets.UTF_8));
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, " ".getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_DEFINITION_FILEPATH, "".getBytes());
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_MANIFEST_FILEPATH, "".getBytes(StandardCharsets.UTF_8));
@@ -55,8 +54,8 @@ public class ValidatorFactoryTest {
@Test
public void testGivenNonSOL004MetaDirectoryCompliantMetaFile_thenONAPCSARValidatorIsReturned() throws IOException{
metaFile = metaFile +
- ENTRY_DEFINITIONS + ENTRY_SEPARATOR + TOSCA_DEFINITION_FILEPATH;
- handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8));
+ TOSCA_META_ENTRY_DEFINITIONS + SEPERATOR_MF_ATTRIBUTE + TOSCA_DEFINITION_FILEPATH;
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8));
assertEquals(ONAPCsarValidator.class, ValidatorFactory.getValidator(handler).getClass());
}
@@ -65,10 +64,10 @@ public class ValidatorFactoryTest {
public void testGivenSOL004MetaDirectoryCompliantMetafile_thenONAPCsarValidatorIsReturned() throws IOException{
metaFile = metaFile +
- ENTRY_DEFINITIONS + ENTRY_SEPARATOR + TOSCA_DEFINITION_FILEPATH + "\n"
- + ENTRY_MANIFEST + ENTRY_SEPARATOR + TOSCA_MANIFEST_FILEPATH + "\n"
- + ENTRY_CHANGE_LOG + ENTRY_SEPARATOR + TOSCA_CHANGELOG_FILEPATH + "\n";
- handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8));
+ TOSCA_META_ENTRY_DEFINITIONS + SEPERATOR_MF_ATTRIBUTE + TOSCA_DEFINITION_FILEPATH + "\n"
+ + TOSCA_META_ETSI_ENTRY_MANIFEST + SEPERATOR_MF_ATTRIBUTE + TOSCA_MANIFEST_FILEPATH + "\n"
+ + TOSCA_META_ETSI_ENTRY_CHANGE_LOG + SEPERATOR_MF_ATTRIBUTE + TOSCA_CHANGELOG_FILEPATH + "\n";
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8));
assertEquals(SOL004MetaDirectoryValidator.class, ValidatorFactory.getValidator(handler).getClass());
}
@@ -76,7 +75,7 @@ public class ValidatorFactoryTest {
@Test
public void testGivenMultiBlockMetadataWithSOL00CompliantMetaFile_thenSOL004MetaDirectoryValidatorReturned() throws IOException {
- handler.addFile(TOSCA_METADATA_FILEPATH, ValidatorUtil.getFileResource("/validation.files/metafile/metaFileWithMultipleBlocks.meta"));
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, ValidatorUtil.getFileResource("/validation.files/metafile/metaFileWithMultipleBlocks.meta"));
handler.addFile(TOSCA_DEFINITION_FILEPATH, "".getBytes());
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_MANIFEST_FILEPATH, "".getBytes(StandardCharsets.UTF_8));
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/metafile/metaFileWithMultipleBlocks.meta b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/metafile/metaFileWithMultipleBlocks.meta
index 38440a2133..ce2a10a724 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/metafile/metaFileWithMultipleBlocks.meta
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/metafile/metaFileWithMultipleBlocks.meta
@@ -2,9 +2,9 @@ TOSCA-Meta-File-Version: 1.0
CSAR-Version: 1.1
Created-by: Bilal Iqbal
Entry-Definitions: Definitions/MainServiceTemplate.yml
-Entry-Manifest: Definitions/MainServiceTemplate.mf
-Entry-Change-Log: Definitions/changeLog.text
+ETSI-Entry-Manifest: Definitions/MainServiceTemplate.mf
+ETSI-Entry-Change-Log: Definitions/changeLog.text
Entry-Definitions: Definitions/MainServiceTemplate2.yml
-Entry-Manifest: Definitions/MainServiceTemplate2.mf
-Entry-Change-Log: Definitions/changeLog2.text \ No newline at end of file
+ETSI-Entry-Manifest: Definitions/MainServiceTemplate2.mf
+ETSI-Entry-Change-Log: Definitions/changeLog2.text \ No newline at end of file
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/vspmanager.csar/metadata/ValidETSItosca.meta b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/vspmanager.csar/metadata/ValidETSItosca.meta
index 0d74a150b1..8a51a625f2 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/vspmanager.csar/metadata/ValidETSItosca.meta
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/vspmanager.csar/metadata/ValidETSItosca.meta
@@ -2,5 +2,5 @@ TOSCA-Meta-File-Version: 1.0
CSAR-Version: 1.1
Created-By: Sergey Sachkov
Entry-Definitions: Definitions/MainServiceTemplate.yaml
-Entry-Manifest: MainServiceTemplate.mf
-Entry-Change-Log: change.log
+ETSI-Entry-Manifest: MainServiceTemplate.mf
+ETSI-Entry-Change-Log: change.log
diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java
index 8c62cfc0d0..2111f6d547 100644
--- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java
+++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java
@@ -33,10 +33,11 @@ public enum Messages {
MANIFEST_NO_METADATA("Manifest must contain metadata"),
MANIFEST_NO_SOURCES("Manifest must contain Source"),
MANIFEST_METADATA_MISSING_ENTRY("Manifest metadata missing entry %s"),
- MANIFEST_INVALID_NAME("Manifest file has a different name than main TOSCA definitions file"),
- MANIFEST_INVALID_EXT("Manifest file does not have extension \".mf\" "),
+ MANIFEST_INVALID_NAME("Manifest file %s and TOSCA definitions file %s must have the same name"),
+ MANIFEST_INVALID_EXT("Manifest file must have extension \".mf\" "),
MANIFEST_METADATA_INVALID_ENTRY("Manifest metadata should only have pnf or vnf entries"),
- MANIFEST_METADATA_DOES_NOT_MATCH_LIMIT("Manifest metadata must only have the required number of values [%s]"),
+ MANIFEST_INVALID_PNF_METADATA("%s TOSCA.meta file is applicable for VF only"),
+ MANIFEST_METADATA_DOES_NOT_MATCH_LIMIT("Manifest metadata must only have the required number [%s] of values"),
MANIFEST_EMPTY("Manifest must contain data"),
MANIFEST_PARSER_INTERNAL("Invalid manifest file"),
METADATA_PARSER_INTERNAL("Invalid Metadata file"),
@@ -44,7 +45,7 @@ public enum Messages {
METADATA_UNSUPPORTED_ENTRY("Following entry not supported in TOSCA.meta %s"),
METADATA_INVALID_VERSION("Invalid entry %s value %s"),
METADATA_INVALID_VALUE("Invalid value %s in TOSCA.meta file"),
- METADATA_MISSING_ENTRY("TOSCA.meta file missing entry %s"),
+ METADATA_MISSING_ENTRY("TOSCA.meta file in TOSCA-metadata directory missing entry %s"),
METADATA_NO_ENTRY_DEFINITIONS("TOSCA.meta must contain Entry Definitions"),
METADATA_INVALID_ENTRY_DEFINITIONS("TOSCA.meta must contain key:value entries"),
FAILED_TO_VALIDATE_METADATA("Failed to validate metadata file"),
@@ -68,6 +69,7 @@ public enum Messages {
"Wrong VES EVENT Artifact was uploaded - all files contained in Artifact must be YAML files" +
" (using .yaml/.yml extensions)"),
MANIFEST_NOT_EXIST("Manifest doesn't exist"),
+ MANIFEST_NOT_FOUND("Manifest file %s referenced in TOSCA.meta does not exist"),
FILE_TYPE_NOT_LEGAL("File type not legal as data for other file"),
MODULE_IN_MANIFEST_NO_YAML("Module '%s', has no yaml file reference"),
NO_MODULES_IN_MANIFEST("At least one Base/Module must be defined \n"),
@@ -95,6 +97,8 @@ public enum Messages {
MISSING_FILE_NAME_IN_MANIFEST("Missing file name in manifest"),
MISSING_NESTED_FILE("Missing nested file - %s"),
MISSING_ARTIFACT("Missing artifact - %s"),
+ MISSING_MANIFEST_SOURCE("%s artifact %s referenced in manifest file does not exist"),
+ MISSING_METADATA_FILES("%s file referenced in TOSCA.meta does not exist"),
WRONG_HEAT_FILE_EXTENSION("Wrong HEAT file extension - %s"),
WRONG_ENV_FILE_EXTENSION("Wrong ENV file extension - %s"),
INVALID_MANIFEST_FILE("invalid manifest file"),
@@ -105,9 +109,9 @@ public enum Messages {
TOSCA_PARSING_FAILURE("Invalid tosca file. Error code : %s, Error message : %s/"),
/*definition errors*/
- MISSING_DEFINITION_FILE("Definition file %s does not exist"),
- MISSING_IMPORT_FILE("Package must contain the referenced import file %s"),
- INVALID_IMPORT_STATEMENT("Definition file contains an invalid import statement"),
+ MISSING_DEFINITION_FILE("Definition file %s referenced in TOSCA.meta does not exist"),
+ MISSING_IMPORT_FILE("Package must contain the referenced import file %s in %s directory"),
+ INVALID_IMPORT_STATEMENT("Definition file contains an invalid import statement in %s"),
/* content errors*/
INVALID_YAML_FORMAT("Invalid YAML format - %s"),
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 9984df1ccc..6dac3c8f60 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
@@ -35,9 +35,9 @@ import org.openecomp.sdc.tosca.csar.Manifest;
import org.openecomp.sdc.tosca.csar.OnboardingToscaMetadata;
import org.openecomp.sdc.tosca.csar.ToscaMetadata;
-import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ENTRY_CHANGE_LOG;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_CHANGE_LOG;
import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ENTRY_DEFINITIONS;
-import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ENTRY_MANIFEST;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_MANIFEST;
import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ORIG_PATH_FILE_NAME;
import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_PATH_FILE_NAME;
@@ -116,8 +116,8 @@ public class ETSIServiceImpl implements ETSIService {
ToscaMetadata toscaMetadata = OnboardingToscaMetadata.parseToscaMetadataFile(metadataInputStream);
Map<String, String> metaDataEntries = toscaMetadata.getMetaEntries();
- return metaDataEntries.containsKey(TOSCA_META_ENTRY_DEFINITIONS) && metaDataEntries.containsKey(TOSCA_META_ENTRY_MANIFEST)
- && metaDataEntries.containsKey(TOSCA_META_ENTRY_CHANGE_LOG);
+ return metaDataEntries.containsKey(TOSCA_META_ENTRY_DEFINITIONS) && metaDataEntries.containsKey(TOSCA_META_ETSI_ENTRY_MANIFEST)
+ && metaDataEntries.containsKey(TOSCA_META_ETSI_ENTRY_CHANGE_LOG);
}
private boolean isMetaFilePresent(Map<String, byte[]> handler) {
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImplTest.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImplTest.java
index 2dc37f17e4..b3eaf30eb1 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImplTest.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImplTest.java
@@ -25,8 +25,8 @@ public class ETSIServiceImplTest {
"CSAR-Version: 1.0\n" +
"Created-By: Kuku\n" +
"Entry-Definitions: MainServiceTemplate.yaml\n" +
- "Entry-Manifest: MainServiceTemplate.mf\n" +
- "Entry-Change-Log: MainServiceTemplate.log";
+ "ETSI-Entry-Manifest: MainServiceTemplate.mf\n" +
+ "ETSI-Entry-Change-Log: MainServiceTemplate.log";
private String metaFile = "TOSCA-Meta-Version: 1.0\n" +
"CSAR-Version: 1.0\n" +
"Created-By: Kuku\n" +
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolConverterImpl.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolConverterImpl.java
index 78a23f43ea..46a5904299 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolConverterImpl.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolConverterImpl.java
@@ -55,19 +55,21 @@ public class ToscaSolConverterImpl extends AbstractToscaConverter {
Map<String, ServiceTemplate> serviceTemplates = new HashMap<>();
FileContentHandler artifacts = new FileContentHandler();
GlobalSubstitutionServiceTemplate gsst = new GlobalSubstitutionServiceTemplate();
- String mServiceDefinitionFileName = getMainServiceDefinitionFileName(fileContentHandler);
- handleMainServiceTemplate(csarFiles, serviceTemplates, gsst, mServiceDefinitionFileName);
+ String mServiceDefinitionPath = getMainServiceDefinitionFileName(fileContentHandler);
+ handleMainServiceTemplate(csarFiles, serviceTemplates, gsst, mServiceDefinitionPath);
handleExternalArtifacts(csarFiles, serviceTemplates, artifacts);
handleMetadataFile(csarFiles);
- updateToscaServiceModel(toscaServiceModel, serviceTemplates, artifacts, gsst, csarFiles, mServiceDefinitionFileName);
+ updateToscaServiceModel(toscaServiceModel, serviceTemplates, artifacts, gsst, csarFiles, getSimpleName(mServiceDefinitionPath));
return toscaServiceModel;
}
private void handleMainServiceTemplate(Map<String, byte[]> csarFiles, Map<String, ServiceTemplate> serviceTemplates,
GlobalSubstitutionServiceTemplate gsst, String mServiceDefinitionFileName) {
- handleServiceTemplate(mServiceDefinitionFileName, mServiceDefinitionFileName, csarFiles, serviceTemplates);
- handleImportDefinitions(mServiceDefinitionFileName, csarFiles, mServiceDefinitionFileName.substring(0,
- mServiceDefinitionFileName.lastIndexOf("/")), gsst);
+ if(mServiceDefinitionFileName != null){
+ handleServiceTemplate(getSimpleName(mServiceDefinitionFileName), mServiceDefinitionFileName, csarFiles, serviceTemplates);
+ String parentDir = mServiceDefinitionFileName.substring(0, mServiceDefinitionFileName.lastIndexOf("/"));
+ handleImportDefinitions(mServiceDefinitionFileName, csarFiles, parentDir, gsst);
+ }
}
private void handleExternalArtifacts(Map<String, byte[]> csarFiles, Map<String, ServiceTemplate> serviceTemplates, FileContentHandler artifacts) {
@@ -128,4 +130,11 @@ public class ToscaSolConverterImpl extends AbstractToscaConverter {
throw new IOException(e.getMessage());
}
}
+
+ private String getSimpleName(String path){
+ if(path != null && path.contains("/")){
+ path = path.substring(path.lastIndexOf("/") + 1);
+ }
+ return path;
+ }
} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaSolConverterImplTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaSolConverterImplTest.java
index ad2e61523f..45d6332e06 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaSolConverterImplTest.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaSolConverterImplTest.java
@@ -71,9 +71,9 @@ public class ToscaSolConverterImplTest {
Map<String, ServiceTemplate> serviceTemplateMap = toscaServiceModel.getServiceTemplates();
String entryDefinitionTemplateName = toscaServiceModel.getEntryDefinitionServiceTemplate();
Assert.assertTrue("Artifacts should contain external files", contentHandler.containsFile("Main.mf"));
- Assert.assertTrue("Main service template should exist", serviceTemplateMap.containsKey("Definitions/Main.yaml"));
+ Assert.assertTrue("Main service template should exist", serviceTemplateMap.containsKey("Main.yaml"));
Assert.assertEquals("Entry Definition name should be same as passed in TOSCA.meta",
- "Definitions/Main.yaml", entryDefinitionTemplateName);
+ "Main.yaml", entryDefinitionTemplateName);
}
@Test(expected = IOException.class)
diff --git a/openecomp-be/lib/openecomp-tosca-lib/pom.xml b/openecomp-be/lib/openecomp-tosca-lib/pom.xml
index 834e8e36b2..6b7ca2fa17 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/pom.xml
+++ b/openecomp-be/lib/openecomp-tosca-lib/pom.xml
@@ -97,6 +97,12 @@
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.be</groupId>
+ <artifactId>common-be</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
<properties>
<useSystemClassLoader>false</useSystemClassLoader>
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/AbstractOnboardingManifest.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/AbstractOnboardingManifest.java
index 50c2c106ff..00eb46183a 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/AbstractOnboardingManifest.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/AbstractOnboardingManifest.java
@@ -19,6 +19,7 @@ package org.openecomp.sdc.tosca.csar;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
+import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
@@ -33,18 +34,22 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.MANIFEST_PNF_METADATA;
import static org.openecomp.sdc.tosca.csar.CSARConstants.METADATA_MF_ATTRIBUTE;
import static org.openecomp.sdc.tosca.csar.CSARConstants.SEPERATOR_MF_ATTRIBUTE;
abstract class AbstractOnboardingManifest implements Manifest{
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractOnboardingManifest.class);
+ private static final int MAX_ALLOWED_MANIFEST_META_ENTRIES = 4;
protected Map<String, String> metadata;
protected List<String> sources;
protected List<String> errors;
protected Map<String, List<String>> nonManoSources;
+ protected ResourceTypeEnum type;
protected AbstractOnboardingManifest() {
errors = new ArrayList<>();
@@ -54,6 +59,19 @@ import static org.openecomp.sdc.tosca.csar.CSARConstants.SEPERATOR_MF_ATTRIBUTE;
}
@Override
+ public Optional<ResourceTypeEnum> getType(){
+ if(errors.isEmpty() && !metadata.isEmpty() && metadata.size() == MAX_ALLOWED_MANIFEST_META_ENTRIES) {
+ for (String key : metadata.keySet()) {
+ if (MANIFEST_PNF_METADATA.stream().anyMatch(key::equals)) {
+ return Optional.of(ResourceTypeEnum.PNF);
+ }
+ return Optional.of(ResourceTypeEnum.VF);
+ }
+ }
+ return Optional.empty();
+ }
+
+ @Override
public void parse(InputStream is) {
try {
ImmutableList<String> lines = readAllLines(is);
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/CSARConstants.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/CSARConstants.java
index 826a72b6fd..d7dd3d450f 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/CSARConstants.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/CSARConstants.java
@@ -32,10 +32,11 @@ public class CSARConstants {
public static final String TOSCA_META_CSAR_VERSION_ENTRY = "CSAR-Version";
public static final String TOSCA_META_CREATED_BY_ENTRY = "Created-by";
public static final String TOSCA_META_ENTRY_DEFINITIONS="Entry-Definitions";
- public static final String TOSCA_META_ENTRY_MANIFEST="Entry-Manifest";
- public static final String TOSCA_META_ENTRY_CHANGE_LOG="Entry-Change-Log";
- public static final String TOSCA_META_ENTRY_TESTS = "Entry-Tests";
- public static final String TOSCA_META_ENTRY_LICENSES= "Entry-Licenses";
+ public static final String TOSCA_META_ETSI_ENTRY_MANIFEST ="ETSI-Entry-Manifest";
+ public static final String TOSCA_META_ETSI_ENTRY_CHANGE_LOG ="ETSI-Entry-Change-Log";
+ public static final String TOSCA_META_ETSI_ENTRY_TESTS = "ETSI-Entry-Tests";
+ public static final String TOSCA_META_ETSI_ENTRY_LICENSES = "ETSI-Entry-Licenses";
+ public static final String TOSCA_META_ETSI_ENTRY_CERTIFICATE = "ETSI-Entry-Certificate";
public static final ImmutableSet<String> ELIGIBLE_FILES =
of(MAIN_SERVICE_TEMPLATE_MF_FILE_NAME,MAIN_SERVICE_TEMPLATE_YAML_FILE_NAME);
public static final ImmutableSet<String> MANIFEST_PNF_METADATA =
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/Manifest.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/Manifest.java
index 1a11ecf6f6..c11f4a3ddc 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/Manifest.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/Manifest.java
@@ -20,9 +20,11 @@
package org.openecomp.sdc.tosca.csar;
+import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
public interface Manifest {
@@ -62,4 +64,10 @@ public interface Manifest {
* @return
*/
Map<String, List<String>> getNonManoSources();
+
+ /**
+ * Gets the type based on the metadata of manifest file (VF/PNF)
+ * @return enum for type values
+ */
+ Optional<ResourceTypeEnum> getType();
}
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/SOL004ManifestOnboarding.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/SOL004ManifestOnboarding.java
index 267729596b..1ee1c1b1ae 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/SOL004ManifestOnboarding.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/SOL004ManifestOnboarding.java
@@ -32,7 +32,7 @@ import static org.openecomp.sdc.tosca.csar.CSARConstants.NON_MANO_MF_ATTRIBUTE;
import static org.openecomp.sdc.tosca.csar.CSARConstants.SEPERATOR_MF_ATTRIBUTE;
import static org.openecomp.sdc.tosca.csar.CSARConstants.SOURCE_MF_ATTRIBUTE;
-public class SOL004ManifestOnboarding extends AbstractOnboardingManifest implements Manifest {
+public class SOL004ManifestOnboarding extends AbstractOnboardingManifest {
@Override
protected void processMetadata(Iterator<String> iterator) {
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/csar/ManifestParsingTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/csar/ManifestParsingTest.java
index 2e8a1ecbd0..b083cfad3a 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/csar/ManifestParsingTest.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/csar/ManifestParsingTest.java
@@ -18,9 +18,11 @@ package org.openecomp.sdc.tosca.csar;
import org.junit.Before;
import org.junit.Test;
+import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.common.errors.Messages;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Optional;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertEquals;
@@ -44,6 +46,10 @@ public class ManifestParsingTest {
assertTrue(manifest.isValid());
assertEquals(manifest.getMetadata().size(), 4);
assertEquals(manifest.getSources().size(), 5);
+ Optional<ResourceTypeEnum> resourceTypeEnum = manifest.getType();
+ if(resourceTypeEnum.isPresent()){
+ assertTrue(resourceTypeEnum.get() == ResourceTypeEnum.VF);
+ }
}
}
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 5e32820bc3..4519ee7bd3 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
@@ -4,9 +4,9 @@ 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.CSARConstants.TOSCA_META_ENTRY_CHANGE_LOG;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_CHANGE_LOG;
import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ENTRY_DEFINITIONS;
-import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ENTRY_MANIFEST;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_MANIFEST;
import java.io.IOException;
import java.io.InputStream;
@@ -61,8 +61,8 @@ public class MetadataParsingTest {
.getResourceAsStream("/vspmanager.csar/metadata/ValidETSItosca.meta")) {
ToscaMetadata onboardingToscaMetadata = OnboardingToscaMetadata.parseToscaMetadataFile(is);
assertEquals(onboardingToscaMetadata.getMetaEntries().get(TOSCA_META_ENTRY_DEFINITIONS), "Definitions/MainServiceTemplate.yaml");
- assertEquals(onboardingToscaMetadata.getMetaEntries().get(TOSCA_META_ENTRY_MANIFEST), "MainServiceTemplate.mf");
- assertEquals(onboardingToscaMetadata.getMetaEntries().get(TOSCA_META_ENTRY_CHANGE_LOG), "change.log");
+ assertEquals(onboardingToscaMetadata.getMetaEntries().get(TOSCA_META_ETSI_ENTRY_MANIFEST), "MainServiceTemplate.mf");
+ assertEquals(onboardingToscaMetadata.getMetaEntries().get(TOSCA_META_ETSI_ENTRY_CHANGE_LOG), "change.log");
}
}
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/vspmanager.csar/metadata/ValidETSItosca.meta b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/vspmanager.csar/metadata/ValidETSItosca.meta
index 0d74a150b1..8a51a625f2 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/vspmanager.csar/metadata/ValidETSItosca.meta
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/vspmanager.csar/metadata/ValidETSItosca.meta
@@ -2,5 +2,5 @@ TOSCA-Meta-File-Version: 1.0
CSAR-Version: 1.1
Created-By: Sergey Sachkov
Entry-Definitions: Definitions/MainServiceTemplate.yaml
-Entry-Manifest: MainServiceTemplate.mf
-Entry-Change-Log: change.log
+ETSI-Entry-Manifest: MainServiceTemplate.mf
+ETSI-Entry-Change-Log: change.log