summaryrefslogtreecommitdiffstats
path: root/csarvalidation/src/main/java/org
diff options
context:
space:
mode:
authorBogumil Zebek <bogumil.zebek@nokia.com>2019-04-26 08:05:20 +0200
committerZebek Bogumil <bogumil.zebek@nokia.com>2019-04-26 08:05:20 +0200
commit5222844a7befd0adaed24c7dbe6e90c63add9655 (patch)
tree6c89ad7036c2ed7a966a1a30c259a6a9018187cd /csarvalidation/src/main/java/org
parent089d8c3fb0a277351a55371dff8c2b27bd3f4ed5 (diff)
Basic PNFD validation
Change-Id: I959324f3fc0ba89d99a291d0608aa5a5ba778077 Issue-ID: VNFSDK-341 Signed-off-by: Zebek Bogumil <bogumil.zebek@nokia.com>
Diffstat (limited to 'csarvalidation/src/main/java/org')
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/VTPValidateCSAR.java13
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARBase.java16
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidatePnfCSARBase.java34
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092.java4
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR293901.java4
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR57019.java4
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787965.java4
7 files changed, 32 insertions, 47 deletions
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/VTPValidateCSAR.java b/csarvalidation/src/main/java/org/onap/cvc/csar/VTPValidateCSAR.java
index d348235..730b27d 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/VTPValidateCSAR.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/VTPValidateCSAR.java
@@ -24,6 +24,8 @@ import java.util.Properties;
import org.onap.cli.fw.cmd.OnapCommand;
import org.onap.cli.fw.error.OnapCommandException;
import org.onap.cli.fw.error.OnapCommandExecutionFailed;
+import org.onap.cli.fw.error.OnapCommandInvalidParameterValue;
+import org.onap.cli.fw.input.OnapCommandParameter;
import org.onap.cli.fw.output.OnapCommandResultType;
import org.onap.cli.fw.registrar.OnapCommandRegistrar;
import org.onap.cli.fw.schema.OnapCommandSchema;
@@ -39,6 +41,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@OnapCommandSchema(schema = "vtp-validate-csar.yaml")
public class VTPValidateCSAR extends OnapCommand {
private static final Logger LOG = LoggerFactory.getLogger(VTPValidateCSAR.class);
+ public static final String PNF_ATTRIBUTE_NAME = "pnf";
public static class CSARValidation {
public static class VNF {
@@ -184,7 +187,7 @@ public class VTPValidateCSAR extends OnapCommand {
protected void run() throws OnapCommandException {
//Read the input arguments
String path = (String) getParametersMap().get("csar").getValue();
- boolean isPnf = (boolean) getParametersMap().get("pnf").getValue();
+ boolean isPnf = (boolean) getParametersMap().get(PNF_ATTRIBUTE_NAME).getValue();
boolean overallPass = true;
try(CSARArchive csar = isPnf ? new PnfCSARArchive(): new CSARArchive()){
@@ -228,6 +231,7 @@ public class VTPValidateCSAR extends OnapCommand {
String command = "csar-validate-" + vnfreq;
OnapCommand cmd = OnapCommandRegistrar.getRegistrar().get(command, this.getInfo().getProduct());
cmd.getParametersMap().get("csar").setValue(path);
+ setPnfValueIfAvailable(isPnf, cmd);
result.setDescription(cmd.getDescription());
cmd.execute();
@@ -266,6 +270,13 @@ public class VTPValidateCSAR extends OnapCommand {
}
}
+ private void setPnfValueIfAvailable(boolean isPnf, OnapCommand cmd) throws OnapCommandInvalidParameterValue {
+ final OnapCommandParameter pnf = cmd.getParametersMap().get(PNF_ATTRIBUTE_NAME);
+ if(pnf!=null) {
+ pnf.setValue(isPnf);
+ }
+ }
+
private List<String> getPropertiesList(String key) {
String[] enabledReqs = prp.getProperty(key, "").split(",");
List<String> list = new ArrayList<>();
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARBase.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARBase.java
index bd771e0..eafdbde 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARBase.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARBase.java
@@ -19,9 +19,11 @@ package org.onap.cvc.csar.cc;
import org.onap.cli.fw.cmd.OnapCommand;
import org.onap.cli.fw.error.OnapCommandException;
import org.onap.cli.fw.error.OnapCommandExecutionFailed;
+import org.onap.cli.fw.input.OnapCommandParameter;
import org.onap.cvc.csar.CSARArchive;
import org.onap.cvc.csar.CSARArchive.CSARError;
import org.onap.cvc.csar.FileArchive;
+import org.onap.cvc.csar.PnfCSARArchive;
import org.onap.cvc.csar.ZipFileContentValidator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -44,9 +46,10 @@ public abstract class VTPValidateCSARBase extends OnapCommand {
protected void run() throws OnapCommandException {
//Read the input arguments
String path = (String) getParametersMap().get("csar").getValue();
+ boolean isPnf = isPnf();
//execute
- try (CSARArchive csar = this.createArchiveInstance()){
+ try (CSARArchive csar = isPnf ? new PnfCSARArchive(): new CSARArchive()){
csar.init(path);
@@ -77,7 +80,12 @@ public abstract class VTPValidateCSARBase extends OnapCommand {
this.getResult().setOutput(this.errors);
}
- protected CSARArchive createArchiveInstance(){
- return new CSARArchive();
- }
+ private boolean isPnf() {
+ final OnapCommandParameter pnf = getParametersMap().get("pnf");
+ return pnf != null && (boolean) pnf.getValue();
+ }
+
+ public List<CSARError> getErrors() {
+ return this.errors;
+ }
}
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidatePnfCSARBase.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidatePnfCSARBase.java
deleted file mode 100644
index 6c7d3a0..0000000
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidatePnfCSARBase.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2019 Nokia
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.onap.cvc.csar.cc;
-
-import org.onap.cvc.csar.CSARArchive;
-import org.onap.cvc.csar.PnfCSARArchive;
-
-import java.util.List;
-
-public abstract class VTPValidatePnfCSARBase extends VTPValidateCSARBase {
- @Override
- protected CSARArchive createArchiveInstance(){
- return new PnfCSARArchive();
- }
-
- public List<CSARArchive.CSARError> getErrors(){
- return this.errors;
- }
-}
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 1cdfe7a..3d767ff 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
@@ -22,7 +22,7 @@ import org.onap.cli.fw.schema.OnapCommandSchema;
import org.onap.cvc.csar.CSARArchive;
import org.onap.cvc.csar.PnfCSARError;
import org.onap.cvc.csar.PnfCSARError.PnfCSARErrorEntryMissing;
-import org.onap.cvc.csar.cc.VTPValidatePnfCSARBase;
+import org.onap.cvc.csar.cc.VTPValidateCSARBase;
import java.io.File;
import java.util.ArrayList;
@@ -33,7 +33,7 @@ import java.util.Set;
import java.util.stream.Collectors;
@OnapCommandSchema(schema = "vtp-validate-csar-r146092.yaml")
-public class VTPValidateCSARR146092 extends VTPValidatePnfCSARBase {
+public class VTPValidateCSARR146092 extends VTPValidateCSARBase {
private static final int UNKNOWN_LINE_NUMBER = -1;
private static final String SOURCE_ELEMENT_TAG = "source";
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR293901.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR293901.java
index b114880..a832b4d 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR293901.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR293901.java
@@ -21,12 +21,12 @@ package org.onap.cvc.csar.cc.sol004;
import org.onap.cli.fw.schema.OnapCommandSchema;
import org.onap.cvc.csar.CSARArchive;
import org.onap.cvc.csar.PnfCSARError.PnfCSARErrorEntryMissing;
-import org.onap.cvc.csar.cc.VTPValidatePnfCSARBase;
+import org.onap.cvc.csar.cc.VTPValidateCSARBase;
import java.util.Objects;
@OnapCommandSchema(schema = "vtp-validate-csar-r293901.yaml")
-public class VTPValidateCSARR293901 extends VTPValidatePnfCSARBase {
+public class VTPValidateCSARR293901 extends VTPValidateCSARBase {
private static final int UNKNOWN_LINE_NUMBER = -1;
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 8f6118b..3dea564 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
@@ -21,12 +21,12 @@ package org.onap.cvc.csar.cc.sol004;
import org.onap.cli.fw.schema.OnapCommandSchema;
import org.onap.cvc.csar.CSARArchive;
import org.onap.cvc.csar.PnfCSARError.PnfCSARErrorEntryMissing;
-import org.onap.cvc.csar.cc.VTPValidatePnfCSARBase;
+import org.onap.cvc.csar.cc.VTPValidateCSARBase;
import java.util.Objects;
@OnapCommandSchema(schema = "vtp-validate-csar-r57019.yaml")
-public class VTPValidateCSARR57019 extends VTPValidatePnfCSARBase {
+public class VTPValidateCSARR57019 extends VTPValidateCSARBase {
private static final int UNKNOWN_LINE_NUMBER = -1;
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787965.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787965.java
index ede1b6c..a5ff4ed 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787965.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787965.java
@@ -22,7 +22,7 @@ import org.onap.cli.fw.error.OnapCommandException;
import org.onap.cli.fw.schema.OnapCommandSchema;
import org.onap.cvc.csar.CSARArchive;
import org.onap.cvc.csar.FileArchive;
-import org.onap.cvc.csar.cc.VTPValidatePnfCSARBase;
+import org.onap.cvc.csar.cc.VTPValidateCSARBase;
import org.onap.cvc.csar.rsa.RSACertificateValidator;
import org.onap.cvc.csar.rsa.X509RsaCertification;
import org.slf4j.Logger;
@@ -34,7 +34,7 @@ import java.util.Base64;
import java.util.Optional;
@OnapCommandSchema(schema = "vtp-validate-csar-r787965.yaml")
-public class VTPValidateCSARR787965 extends VTPValidatePnfCSARBase {
+public class VTPValidateCSARR787965 extends VTPValidateCSARBase {
private static final Logger LOG = LoggerFactory.getLogger(VTPValidateCSARR787965.class);