summaryrefslogtreecommitdiffstats
path: root/csarvalidation/src/main/java/org/onap
diff options
context:
space:
mode:
Diffstat (limited to 'csarvalidation/src/main/java/org/onap')
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092.java20
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR57019.java26
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR87234.java9
3 files changed, 38 insertions, 17 deletions
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092.java
index 3d767ff..95b35bf 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092.java
@@ -29,6 +29,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
@@ -58,10 +59,11 @@ public class VTPValidateCSARR146092 extends VTPValidateCSARBase {
@Override
protected void validateCSAR(CSARArchive csar) {
- ValidateNonManoSection validateNonManoSection = ValidateNonManoSection.getInstance(csar);
- List<CSARArchive.CSARError> csarErrors = validateNonManoSection.validate();
-
- this.errors.addAll(csarErrors);
+ Optional<ValidateNonManoSection> validateNonManoSection = ValidateNonManoSection.getInstance(csar);
+ if(validateNonManoSection.isPresent()) {
+ List<CSARArchive.CSARError> csarErrors = validateNonManoSection.get().validate();
+ this.errors.addAll(csarErrors);
+ }
}
@@ -71,10 +73,14 @@ public class VTPValidateCSARR146092 extends VTPValidateCSARBase {
private final Map<String, Map<String, List<String>>> nonMano;
private final List<CSARArchive.CSARError> errors = new ArrayList<>();
- static ValidateNonManoSection getInstance(CSARArchive csar) {
- final String fileName = csar.getManifestMfFile().getName();
+ static Optional<ValidateNonManoSection> getInstance(CSARArchive csar) {
+ final File manifestMfFile = csar.getManifestMfFile();
+ if(manifestMfFile == null){
+ return Optional.empty();
+ }
+ final String fileName = manifestMfFile.getName();
final Map<String, Map<String, List<String>>> nonMano = csar.getManifest().getNonMano();
- return new ValidateNonManoSection(csar, fileName,nonMano);
+ return Optional.of(new ValidateNonManoSection(csar, fileName,nonMano));
}
private ValidateNonManoSection(CSARArchive csar, String fileName, Map<String, Map<String, List<String>>> nonMano) {
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR57019.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR57019.java
index 3dea564..dc507dd 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR57019.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR57019.java
@@ -23,6 +23,7 @@ import org.onap.cvc.csar.CSARArchive;
import org.onap.cvc.csar.PnfCSARError.PnfCSARErrorEntryMissing;
import org.onap.cvc.csar.cc.VTPValidateCSARBase;
+import java.io.File;
import java.util.Objects;
@OnapCommandSchema(schema = "vtp-validate-csar-r57019.yaml")
@@ -30,15 +31,28 @@ public class VTPValidateCSARR57019 extends VTPValidateCSARBase {
private static final int UNKNOWN_LINE_NUMBER = -1;
+ public static class ToscaMetaNotAvailableError extends CSARArchive.CSARErrorInvalidEntryValue {
+ public ToscaMetaNotAvailableError() {
+ super("",
+ "CSAR Archive",
+ "Unable to find TOSCA.meta file in TOSCA-metadata directory.","");
+ this.setCode("0x1000");
+ }
+ }
+
@Override
protected void validateCSAR(CSARArchive csar) {
- final CSARArchive.Manifest.Metadata metadata = csar.getManifest().getMetadata();
- final String fileName = csar.getManifestMfFile().getName();
+ final CSARArchive.Manifest manifest = csar.getManifest();
+ final CSARArchive.Manifest.Metadata metadata = manifest.getMetadata();
+ final File manifestMfFile = csar.getManifestMfFile();
+ if(manifestMfFile!=null) {
+ final String fileName = manifestMfFile.getName();
- validateMetadataValue(fileName, metadata.getProviderId(), "pnfd_provider");
- validateMetadataValue(fileName, metadata.getProductName(), "pnfd_name");
- validateMetadataValue(fileName, metadata.getReleaseDateTime(), "pnfd_release_date_time");
- validateMetadataValue(fileName, metadata.getPackageVersion(), "pnfd_archive_version");
+ validateMetadataValue(fileName, metadata.getProviderId(), "pnfd_provider");
+ validateMetadataValue(fileName, metadata.getProductName(), "pnfd_name");
+ validateMetadataValue(fileName, metadata.getReleaseDateTime(), "pnfd_release_date_time");
+ validateMetadataValue(fileName, metadata.getPackageVersion(), "pnfd_archive_version");
+ }
}
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR87234.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR87234.java
index 6400012..259d32f 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR87234.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR87234.java
@@ -24,10 +24,11 @@ import org.onap.cvc.csar.cc.VTPValidateCSARBase;
@OnapCommandSchema(schema = "vtp-validate-csar-r87234.yaml")
public class VTPValidateCSARR87234 extends VTPValidateCSARBase {
- public static class CSARErrorInvalidEntryValueNonToscaMetaNotSupported extends CSARErrorInvalidEntryValue {
- public CSARErrorInvalidEntryValueNonToscaMetaNotSupported() {
- super("CSAR Mode", "CSAR Archive",
- "Only " + CSARArchive.Mode.WITH_TOSCA_META_DIR.name() + " mode is supported",
+ static class CSARErrorInvalidEntryValueNonToscaMetaNotSupported extends CSARErrorInvalidEntryValue {
+ CSARErrorInvalidEntryValueNonToscaMetaNotSupported() {
+ super("CSAR Mode",
+ "CSAR Archive",
+ "Only csar package with TOSCA-Metadata directory is supported. Unable to find TOSCA.meta file in TOSCA-metadata directory.",
CSARArchive.Mode.WITH_TOSCA_META_DIR.name());
this.setCode("0x1000");
}