diff options
author | Gao Weitao <victor.gao@huawei.com> | 2019-06-06 12:22:35 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-06-06 12:22:35 +0000 |
commit | 900dd46df0976d545ec66a4822fc1fc846f262b4 (patch) | |
tree | 80e0329f8aea05421976defbbb2fe4fe68fce9a0 /csarvalidation/src/main | |
parent | 379eb896b050fbb1f88ca7e736665c573f8c9f74 (diff) | |
parent | 84eb0c707c621e4855bf27e49be0cc69ded1f321 (diff) |
Merge "Specification change"dublin
Diffstat (limited to 'csarvalidation/src/main')
4 files changed, 27 insertions, 11 deletions
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java b/csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java index 0924de7..f1aff70 100644 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java @@ -738,6 +738,8 @@ public class CSARArchive implements AutoCloseable { } public static class Manifest{ + private boolean isNonManoAvailable; + public static class Metadata { private String providerId; @@ -792,12 +794,17 @@ public class CSARArchive implements AutoCloseable { this.metadata = metadata; } + public boolean isNonManoAvailable(){ + return isNonManoAvailable; + } + public Map<String, Map<String, List<String>>> getNonMano() { return nonMano; } public void setNonMano(Map<String, Map<String, List<String>>> nonMano) { this.nonMano = nonMano; + this.isNonManoAvailable = true; } } diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/PnfCSARArchive.java b/csarvalidation/src/main/java/org/onap/cvc/csar/PnfCSARArchive.java index 5ac67cd..6438306 100644 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/PnfCSARArchive.java +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/PnfCSARArchive.java @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Optional; public class PnfCSARArchive extends CSARArchive { @@ -37,15 +38,20 @@ public class PnfCSARArchive extends CSARArchive { Pair<Manifest.Metadata, List<CSARError>> metadataData = pnfManifestParser.fetchMetadata(); Pair<List<String>, List<CSARError>> sourcesSectionData = pnfManifestParser.fetchSourcesSection(); - Pair<Map<String, Map<String, List<String>>>, List<CSARError>> nonManoArtifactsData = pnfManifestParser.fetchNonManoArtifacts(); + Optional<Pair<Map<String, Map<String, List<String>>>, List<CSARError>>> nonManoArtifactsData = pnfManifestParser.fetchNonManoArtifacts(); PnfManifest manifest = (PnfManifest) this.getManifest(); manifest.setMetadata(metadataData.getKey()); - manifest.setSources(sourcesSectionData.getKey()); - manifest.setNonMano(nonManoArtifactsData.getKey()); this.getErrors().addAll(metadataData.getValue()); - this.getErrors().addAll(nonManoArtifactsData.getValue()); + + manifest.setSources(sourcesSectionData.getKey()); this.getErrors().addAll(sourcesSectionData.getValue()); + + if(nonManoArtifactsData.isPresent()){ + manifest.setNonMano(nonManoArtifactsData.get().getKey()); + this.getErrors().addAll(nonManoArtifactsData.get().getValue()); + } + } @Override diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/PnfManifestParser.java b/csarvalidation/src/main/java/org/onap/cvc/csar/PnfManifestParser.java index 5ef74fd..8831082 100644 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/PnfManifestParser.java +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/PnfManifestParser.java @@ -29,6 +29,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -118,7 +119,7 @@ class PnfManifestParser { return Pair.of(sources, errors); } - Pair<Map<String, Map<String, List<String>>>, List<CSARArchive.CSARError>> fetchNonManoArtifacts() { + Optional<Pair<Map<String, Map<String, List<String>>>, List<CSARArchive.CSARError>>> fetchNonManoArtifacts() { Map<String, Map<String, List<String>>> nonManoArtifacts = new HashMap<>(); List<CSARArchive.CSARError> errors = new ArrayList<>(); @@ -143,10 +144,10 @@ class PnfManifestParser { } if (!isNonManoArtifactsSectionAvailable) { - errors.add(new PnfCSARErrorEntryMissing(NON_MANO_ARTIFACT_SETS_TAG_SECTION, this.fileName, -1)); + return Optional.empty(); } - return Pair.of(nonManoArtifacts, errors); + return Optional.of(Pair.of(nonManoArtifacts, errors)); } private boolean isLineExcluded(String line) { 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 95b35bf..6150a04 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 @@ -59,10 +59,12 @@ public class VTPValidateCSARR146092 extends VTPValidateCSARBase { @Override protected void validateCSAR(CSARArchive csar) { - Optional<ValidateNonManoSection> validateNonManoSection = ValidateNonManoSection.getInstance(csar); - if(validateNonManoSection.isPresent()) { - List<CSARArchive.CSARError> csarErrors = validateNonManoSection.get().validate(); - this.errors.addAll(csarErrors); + if(csar.getManifest().isNonManoAvailable()) { + Optional<ValidateNonManoSection> validateNonManoSection = ValidateNonManoSection.getInstance(csar); + if(validateNonManoSection.isPresent()) { + List<CSARArchive.CSARError> csarErrors = validateNonManoSection.get().validate(); + this.errors.addAll(csarErrors); + } } } |