aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main
diff options
context:
space:
mode:
authorbilal.iqbal <bilal.iqbal@est.tech>2019-03-14 10:49:36 +0000
committerbilal.iqbal <bilal.iqbal@est.tech>2019-03-14 10:49:36 +0000
commit1b6adf74f6a436978a8afd8c68a453bde9956589 (patch)
treea69c7d8ea46856611855bb218ce37ff6df9350b0 /openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main
parentd83268a4cb465fa79f8b57483517226d588fb427 (diff)
Add source support
Change-Id: I71f578764f666dd33c4aa42c7e8613b58ecb2f93 Issue-ID: SDC-2173 Signed-off-by: bilal.iqbal <bilal.iqbal@est.tech>
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main')
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java5
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ONAPCsarValidator.java5
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java35
3 files changed, 31 insertions, 14 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 51a4bdd3fd..36cd58dabf 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
@@ -70,6 +70,7 @@ import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.tosca.csar.OnboardingToscaMetadata;
import org.openecomp.sdc.tosca.csar.ToscaMetadata;
+import org.openecomp.sdc.tosca.csar.SOL004ManifestOnboarding;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.tosca.services.impl.ToscaFileOutputServiceCsarImpl;
import org.openecomp.sdc.validation.util.ValidationManagerUtil;
@@ -114,7 +115,6 @@ import org.openecomp.sdc.vendorsoftwareproduct.errors.PackageNotFoundErrorBuilde
import org.openecomp.sdc.vendorsoftwareproduct.errors.TranslationFileCreationErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductInvalidErrorBuilder;
import org.openecomp.sdc.tosca.csar.Manifest;
-import org.openecomp.sdc.tosca.csar.OnboardingManifest;
import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactGenerator;
import org.openecomp.sdc.vendorsoftwareproduct.services.impl.etsi.ETSIService;
import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService;
@@ -635,7 +635,8 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
if(etsiService.isSol004WithToscaMetaDirectory(toscaServiceModel.getArtifactFiles())){
FileContentHandler handler = toscaServiceModel.getArtifactFiles();
try(InputStream manifestInputStream = getManifest(handler)) {
- Manifest onboardingManifest = OnboardingManifest.parse(manifestInputStream);
+ Manifest onboardingManifest = new SOL004ManifestOnboarding();
+ onboardingManifest.parse(manifestInputStream);
etsiService.moveNonManoFileToArtifactFolder(handler, onboardingManifest);
}
}
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 0f44427edd..e5a06e5d42 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
@@ -28,7 +28,7 @@ import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.csar.Manifest;
-import org.openecomp.sdc.tosca.csar.OnboardingManifest;
+import org.openecomp.sdc.tosca.csar.ONAPManifestOnboarding;
import org.openecomp.sdc.tosca.csar.OnboardingToscaMetadata;
import org.openecomp.sdc.tosca.csar.ToscaMetadata;
import java.io.IOException;
@@ -99,7 +99,8 @@ class ONAPCsarValidator implements Validator {
try (InputStream fileContent = contentMap.getFileContent(MAIN_SERVICE_TEMPLATE_MF_FILE_NAME)) {
- Manifest onboardingManifest = OnboardingManifest.parse(fileContent);
+ Manifest onboardingManifest = new ONAPManifestOnboarding();
+ onboardingManifest.parse(fileContent);
if (!onboardingManifest.isValid()) {
onboardingManifest.getErrors().forEach(error -> uploadFileErrors.add(new ErrorMessage(ErrorLevel.ERROR,
error)));
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 570eee3736..49233c4ff9 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
@@ -30,8 +30,8 @@ import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.csar.Manifest;
-import org.openecomp.sdc.tosca.csar.OnboardingManifest;
import org.openecomp.sdc.tosca.csar.OnboardingToscaMetadata;
+import org.openecomp.sdc.tosca.csar.SOL004ManifestOnboarding;
import org.openecomp.sdc.tosca.csar.ToscaMetadata;
import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.exceptions.InvalidManifestMetadataException;
import java.io.IOException;
@@ -42,6 +42,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.stream.Collectors;
import static org.openecomp.sdc.tosca.csar.CSARConstants.CSAR_VERSION_1_0;
import static org.openecomp.sdc.tosca.csar.CSARConstants.CSAR_VERSION_1_1;
@@ -49,6 +50,7 @@ import static org.openecomp.sdc.tosca.csar.CSARConstants.MANIFEST_METADATA_LIMIT
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_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;
@@ -59,6 +61,8 @@ import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ENTRY_MANIFE
import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_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;
+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
@@ -99,7 +103,7 @@ class SOL004MetaDirectoryValidator implements Validator{
String manifestFileName = getFileName(entries.get(TOSCA_META_ENTRY_MANIFEST));
String manifestExtension = getFileExtension(entries.get(TOSCA_META_ENTRY_MANIFEST));
String mainDefinitionFileName= getFileName(entries.get(TOSCA_META_ENTRY_DEFINITIONS));
- if(!("mf").equals(manifestExtension)){
+ if(!(TOSCA_MANIFEST_FILE_EXT).equals(manifestExtension)){
reportError(ErrorLevel.ERROR, Messages.MANIFEST_INVALID_EXT.getErrorMessage());
}
if(!mainDefinitionFileName.equals(manifestFileName)){
@@ -165,8 +169,8 @@ class SOL004MetaDirectoryValidator implements Validator{
private void verifyMetadataEntryVersions(String key, String version) {
if(!(isValidTOSCAVersion(key,version) || isValidCSARVersion(key, version) || TOSCA_META_CREATED_BY_ENTRY.equals(key))) {
- errorsByFile.add(new ErrorMessage(ErrorLevel.ERROR, Messages.ENTITY_NOT_FOUND.getErrorMessage()));
- LOGGER.error("{}: key {} - value {} ", Messages.ENTITY_NOT_FOUND.getErrorMessage(), key, version);
+ 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);
}
}
@@ -175,7 +179,7 @@ class SOL004MetaDirectoryValidator implements Validator{
}
private boolean isValidCSARVersion(String value, String version){
- return "CSAR-Version".equals(value) && (CSAR_VERSION_1_1.equals(version)
+ return TOSCA_META_CSAR_VERSION_ENTRY.equals(value) && (CSAR_VERSION_1_1.equals(version)
|| CSAR_VERSION_1_0.equals(version));
}
@@ -250,7 +254,8 @@ class SOL004MetaDirectoryValidator implements Validator{
private void validateManifestFile(FileContentHandler contentHandler, String filePath){
final Set<String> exitingFiles = contentHandler.getFileList();
if(verifyFileExists(exitingFiles, filePath)) {
- Manifest onboardingManifest = OnboardingManifest.parse(contentHandler.getFileContent(filePath));
+ Manifest onboardingManifest = new SOL004ManifestOnboarding();
+ onboardingManifest.parse(contentHandler.getFileContent(filePath));
if(onboardingManifest.isValid()){
try {
verifyManifestMetadata(onboardingManifest.getMetadata());
@@ -286,12 +291,12 @@ class SOL004MetaDirectoryValidator implements Validator{
String metadataType = null;
for(String key: metadata.keySet()) {
if(metadataType == null){
- metadataType = key.contains("pnf") ? "pnf" : "vnf";
+ metadataType = key.contains(TOSCA_TYPE_PNF) ? TOSCA_TYPE_PNF : TOSCA_TYPE_VNF;
}else if(!key.contains(metadataType)){
throw new InvalidManifestMetadataException(Messages.MANIFEST_METADATA_INVALID_ENTRY.getErrorMessage());
}
}
- return "pnf".equals(metadataType);
+ return TOSCA_TYPE_PNF.equals(metadataType);
}
private void handleVnfMetadataEntries(Map<String, String> metadata) {
@@ -311,14 +316,24 @@ class SOL004MetaDirectoryValidator implements Validator{
}
private void verifySourcesExists(Set<String> exitingFiles, Manifest onboardingManifest) {
- List<String> sources = onboardingManifest.getSources();
+ List<String> sources = filterSources(onboardingManifest.getSources());
Map<String, List<String>> nonManoArtifacts = onboardingManifest.getNonManoSources();
verifyFilesExist(exitingFiles, sources);
for (Map.Entry entry : nonManoArtifacts.entrySet()) {
- verifyFilesExist(exitingFiles, (List) entry.getValue());
+ verifyFilesExist(exitingFiles, filterSources((List)entry.getValue()));
}
}
+ private List<String> filterSources(List<String> source){
+ return source.stream()
+ .filter(this::externalFileReferences)
+ .collect(Collectors.toList());
+ }
+
+ private boolean externalFileReferences(String filePath){
+ return !filePath.contains("://");
+ }
+
private void validateOtherEntries(List<String> folderList, String folderPath){
if(!verifyFoldersExist(folderList, folderPath))
reportError(ErrorLevel.ERROR, String.format(Messages.METADATA_MISSING_OPTIONAL_FOLDERS.getErrorMessage(),