summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHailong Zhang <zhanghailong22@huawei.com>2019-09-04 15:40:25 +0800
committerHailong Zhang <zhanghailong22@huawei.com>2019-09-04 15:47:38 +0800
commit9c07c95e34bbc24022cb49efa584234f4067534a (patch)
tree696f131129b806fd288bb4ce94a883562f01a707
parent26514e7bb8b174ba5bbbcf903b697160eb397e03 (diff)
modify Sonar Issue
Issue-ID: VNFSDK-462 Signed-off-by: Hailong Zhang <zhanghailong22@huawei.com> Change-Id: I010d99d82c1ac8919907cf70ea4f8893e0a4b06d
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java44
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/VTPValidateCSAR.java4
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARBase.java4
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR09467.java4
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR32155.java6
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR35851.java14
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR54356.java99
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR67895.java6
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR95321.java6
-rw-r--r--csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java14
-rw-r--r--csarvalidation/src/main/java/org/onap/validation/csar/FileUtil.java3
-rw-r--r--csarvalidation/src/main/java/org/onap/validation/csar/ValidationException.java54
-rw-r--r--csarvalidation/src/main/java/org/onap/validation/csar/ValidatorSchemaLoader.java31
13 files changed, 133 insertions, 156 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 180dadd..7311e87 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java
@@ -98,6 +98,8 @@ public class CSARArchive implements AutoCloseable {
public static final String CSAR_ARCHIVE = "CSAR Archive";
+ public static final String DOESS_NOT_EXIST = " does not exist";
+
public enum Mode {
WITH_TOSCA_META_DIR,
WITHOUT_TOSCA_META_DIR
@@ -348,7 +350,7 @@ public class CSARArchive implements AutoCloseable {
super(TOSCA_METADATA_TOSCA_META_ENTRY_DEFINITIONS,
TOSCA_METADATA_TOSCA_META,
lineNo,
- definitionYaml + " does not exist",
+ definitionYaml + DOESS_NOT_EXIST,
null);
this.setCode("0x0006");
@@ -360,7 +362,7 @@ public class CSARArchive implements AutoCloseable {
super(entryManifestArgumentName,
TOSCA_METADATA_TOSCA_META,
lineNo,
- manifest + " does not exist",
+ manifest + DOESS_NOT_EXIST,
null);
this.setCode("0x0007");
@@ -372,7 +374,7 @@ public class CSARArchive implements AutoCloseable {
super(entryChangeLogArgumentName,
TOSCA_METADATA_TOSCA_META,
lineNo,
- logs + " does not exist",
+ logs + DOESS_NOT_EXIST,
null);
this.setCode("0x0008");
@@ -396,7 +398,7 @@ public class CSARArchive implements AutoCloseable {
super(TOSCA_METADATA_TOSCA_META_ENTRY_LICENSES,
TOSCA_METADATA_TOSCA_META,
lineNo,
- license + " does not exist",
+ license + DOESS_NOT_EXIST,
null);
this.setCode("0x000a");
@@ -408,7 +410,7 @@ public class CSARArchive implements AutoCloseable {
super(TOSCA_METADATA_TOSCA_META_ENTRY_CERTIFICATE,
TOSCA_METADATA_TOSCA_META,
lineNo,
- certificate + " does not exist",
+ certificate + DOESS_NOT_EXIST,
null);
this.setCode("0x000b");
@@ -661,6 +663,8 @@ public class CSARArchive implements AutoCloseable {
public static class Definition {
private String toscaDefinitionVersion;
+ private Definition.Metadata metadata = new Metadata();
+
public String getToscaDefinitionVersion() {
return toscaDefinitionVersion;
}
@@ -701,8 +705,6 @@ public class CSARArchive implements AutoCloseable {
}
}
- private Definition.Metadata metadata = new Metadata();
-
public Definition.Metadata getMetadata() {
return metadata;
}
@@ -1024,9 +1026,7 @@ public class CSARArchive implements AutoCloseable {
lineNo ++;
line = line.trim();
- if (line.startsWith("#")) {
- continue;
- } else if (line.trim().isEmpty()) {
+ if (line.startsWith("#") || line.trim().isEmpty()) {
continue;
}
@@ -1131,13 +1131,7 @@ public class CSARArchive implements AutoCloseable {
} else {
//definition files
- File []files = this.tempDir.toFile().listFiles(new FilenameFilter() {
-
- @Override
- public boolean accept(File dir, String name) {
- return name.endsWith(".yaml");
- }
- });
+ File []files = this.tempDir.toFile().listFiles((dir, name) -> name.endsWith(".yaml"));
if (files.length == 0) {
errors.add(
@@ -1154,13 +1148,7 @@ public class CSARArchive implements AutoCloseable {
this.toscaMeta.setEntryDefinitionYaml(this.definitionYamlFile.getName());
//manifest
- files = this.tempDir.toFile().listFiles(new FilenameFilter() {
-
- @Override
- public boolean accept(File dir, String name) {
- return name.endsWith(".mf");
- }
- });
+ files = this.tempDir.toFile().listFiles((dir, name) -> name.endsWith(".mf"));
if (files.length > 1) {
List<String> fileNames = new ArrayList<>();
@@ -1187,13 +1175,7 @@ public class CSARArchive implements AutoCloseable {
}
//certificate
- files = this.tempDir.toFile().listFiles(new FilenameFilter() {
-
- @Override
- public boolean accept(File dir, String name) {
- return name.endsWith(".cert");
- }
- });
+ files = this.tempDir.toFile().listFiles((dir, name) -> name.endsWith(".cert"));
if (files.length > 1) {
List<String> fileNames = new ArrayList<>();
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 a852d78..20700ac 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/VTPValidateCSAR.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/VTPValidateCSAR.java
@@ -291,7 +291,9 @@ public class VTPValidateCSAR extends OnapCommand {
String[] enabledReqs = properties.getProperty(key, "").split(",");
List<String> list = new ArrayList<>();
for(String req: enabledReqs) {
- if (!req.isEmpty()) list.add(req);
+ if (!req.isEmpty()) {
+ list.add(req);
+ }
}
return list;
}
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 6e67df9..3fee188 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
@@ -32,11 +32,13 @@ import java.util.List;
public abstract class VTPValidateCSARBase extends OnapCommand {
protected static final Logger LOG = LoggerFactory.getLogger(VTPValidateCSARBase.class);
+ protected List<CSARError> errors = new ArrayList<>();
+
protected abstract void validateCSAR(CSARArchive csar) throws Exception;
protected abstract String getVnfReqsNo();
- protected List<CSARError> errors = new ArrayList<>();
+
@Override
protected void run() throws OnapCommandException {
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR09467.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR09467.java
index 407d872..4ffe003 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR09467.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR09467.java
@@ -56,12 +56,12 @@ public class VTPValidateCSARR09467 extends VTPValidateCSARBase {
Map<String, ?> node = (Map<String, ?>) nodeO;
if (node.containsKey("type")) {
String type = (String)node.get("type");
- if (type.equalsIgnoreCase("tosca.nodes.nfv.VDU.Compute")) {
+ if ("tosca.nodes.nfv.VDU.Compute".equalsIgnoreCase(type)) {
computeExist = true;
}
- if (type.equalsIgnoreCase("tosca.nodes.nfv.VDU.VirtualStorage")) {
+ if ("tosca.nodes.nfv.VDU.VirtualStorage".equalsIgnoreCase(type)) {
storageExist = true;
}
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR32155.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR32155.java
index c5f6319..12fcf28 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR32155.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR32155.java
@@ -43,7 +43,7 @@ public class VTPValidateCSARR32155 extends VTPValidateCSARBase {
yaml = (Map<String, ?>) yaml.get("topology_template");
Map<String, ?> yamlTmpls = (Map<String, ?>) yaml.get("node_templates");
- boolean vlExist[] = new boolean[2];
+ boolean []vlExist = new boolean[2];
for (Object node0 : yamlTmpls.values()) {
@@ -52,12 +52,12 @@ public class VTPValidateCSARR32155 extends VTPValidateCSARBase {
if (node.containsKey("type")) {
String type = (String) node.get("type");
- if (type.equalsIgnoreCase("tosca.nodes.nfv.VnfVirtualLinkDesc")) {
+ if ("tosca.nodes.nfv.VnfVirtualLinkDesc".equalsIgnoreCase(type)) {
vlExist[0] = true;
}
- if (type.equalsIgnoreCase("tosca.capabilities.nfv.VirtualLinkable")) {
+ if ("tosca.capabilities.nfv.VirtualLinkable".equalsIgnoreCase(type)) {
vlExist[1] = true;
}
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR35851.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR35851.java
index f25afd7..52582a6 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR35851.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR35851.java
@@ -28,10 +28,12 @@ import org.yaml.snakeyaml.Yaml;
@OnapCommandSchema(schema = "vtp-validate-csar-r35851.yaml")
public class VTPValidateCSARR35851 extends VTPValidateCSARBase {
+ private static final String SET_CODE = "0x1000";
+
public static class CSARErrorEntryMissingDefinitionYamlVnfVirtualLink extends CSARErrorEntryMissing {
public CSARErrorEntryMissingDefinitionYamlVnfVirtualLink(String defYaml, String entry) {
super(entry, defYaml);
- this.setCode("0x1000");
+ this.setCode(SET_CODE);
}
}
@@ -39,14 +41,14 @@ public class VTPValidateCSARR35851 extends VTPValidateCSARBase {
public static class CSARErrorEntryMissingDefinitionYamlVduCp extends CSARErrorEntryMissing {
public CSARErrorEntryMissingDefinitionYamlVduCp(String defYaml, String entry) {
super(entry, defYaml);
- this.setCode("0x1000");
+ this.setCode(SET_CODE);
}
}
public static class CSARErrorEntryMissingDefinitionYamlVnfExtCp extends CSARErrorEntryMissing {
public CSARErrorEntryMissingDefinitionYamlVnfExtCp(String defYaml, String entry) {
super(entry, defYaml);
- this.setCode("0x1000");
+ this.setCode(SET_CODE);
}
}
@@ -63,17 +65,17 @@ public class VTPValidateCSARR35851 extends VTPValidateCSARBase {
Map<String, ?> node = (Map<String, ?>) nodeO;
if (node.containsKey("type")) {
String type = (String)node.get("type");
- if (type.equalsIgnoreCase("tosca.nodes.nfv.VnfVirtualLink")) {
+ if ("tosca.nodes.nfv.VnfVirtualLink".equalsIgnoreCase(type)) {
vlExist[0] = true;
}
- if (type.equalsIgnoreCase("tosca.nodes.nfv.VduCp")) {
+ if ("tosca.nodes.nfv.VduCp".equalsIgnoreCase(type)) {
vlExist[1] = true;
}
- if (type.equalsIgnoreCase("tosca.nodes.nfv.VnfExtCp")) {
+ if ("tosca.nodes.nfv.VnfExtCp".equalsIgnoreCase(type)) {
vlExist[2] = true;
}
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR54356.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR54356.java
index eaf9ad9..334d4ff 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR54356.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR54356.java
@@ -26,171 +26,172 @@ import java.util.Map;
@OnapCommandSchema(schema = "vtp-validate-csar-r54356.yaml")
public class VTPValidateCSARR54356 extends VTPValidateCSARBase {
+ private static final String SET_CODE = "0x1000";
public static class CSARErrorEntryMissingDefinitionYamldatatypesL3AddressData extends CSARArchive.CSARErrorEntryMissing {
public CSARErrorEntryMissingDefinitionYamldatatypesL3AddressData(String defYaml, String entry) {
super(entry, defYaml);
- this.setCode("0x1000");
+ this.setCode( SET_CODE);
}
}
public static class CSARErrorEntryMissingDefinitionYamldatatypesAddressData extends CSARArchive.CSARErrorEntryMissing {
public CSARErrorEntryMissingDefinitionYamldatatypesAddressData(String defYaml, String entry) {
super(entry, defYaml);
- this.setCode("0x1000");
+ this.setCode( SET_CODE);
}
}
public static class CSARErrorEntryMissingDefinitionYamldatatypesVirtualNetworkInterfaceRequirements extends CSARArchive.CSARErrorEntryMissing {
public CSARErrorEntryMissingDefinitionYamldatatypesVirtualNetworkInterfaceRequirements(String defYaml, String entry) {
super(entry, defYaml);
- this.setCode("0x1000");
+ this.setCode( SET_CODE);
}
}
public static class CSARErrorEntryMissingDefinitionYamldatatypesConnectivityType extends CSARArchive.CSARErrorEntryMissing {
public CSARErrorEntryMissingDefinitionYamldatatypesConnectivityType(String defYaml, String entry) {
super(entry, defYaml);
- this.setCode("0x1000");
+ this.setCode( SET_CODE);
}
}
public static class CSARErrorEntryMissingDefinitionYamldatatypesRequestedAdditionalCapability extends CSARArchive.CSARErrorEntryMissing {
public CSARErrorEntryMissingDefinitionYamldatatypesRequestedAdditionalCapability(String defYaml, String entry) {
super(entry, defYaml);
- this.setCode("0x1000");
+ this.setCode( SET_CODE);
}
}
public static class CSARErrorEntryMissingDefinitionYamldatatypesVirtualMemory extends CSARArchive.CSARErrorEntryMissing {
public CSARErrorEntryMissingDefinitionYamldatatypesVirtualMemory(String defYaml, String entry) {
super(entry, defYaml);
- this.setCode("0x1000");
+ this.setCode( SET_CODE);
}
}
public static class CSARErrorEntryMissingDefinitionYamldatatypesVirtualCpu extends CSARArchive.CSARErrorEntryMissing {
public CSARErrorEntryMissingDefinitionYamldatatypesVirtualCpu(String defYaml, String entry) {
super(entry, defYaml);
- this.setCode("0x1000");
+ this.setCode( SET_CODE);
}
}
public static class CSARErrorEntryMissingDefinitionYamldatatypesVirtualCpuPinning extends CSARArchive.CSARErrorEntryMissing {
public CSARErrorEntryMissingDefinitionYamldatatypesVirtualCpuPinning(String defYaml, String entry) {
super(entry, defYaml);
- this.setCode("0x1000");
+ this.setCode( SET_CODE);
}
}
public static class CSARErrorEntryMissingDefinitionYamldatatypesVnfcConfigurableProperties extends CSARArchive.CSARErrorEntryMissing {
public CSARErrorEntryMissingDefinitionYamldatatypesVnfcConfigurableProperties(String defYaml, String entry) {
super(entry, defYaml);
- this.setCode("0x1000");
+ this.setCode( SET_CODE);
}
}
public static class CSARErrorEntryMissingDefinitionYamldatatypesVduProfile extends CSARArchive.CSARErrorEntryMissing {
public CSARErrorEntryMissingDefinitionYamldatatypesVduProfile(String defYaml, String entry) {
super(entry, defYaml);
- this.setCode("0x1000");
+ this.setCode( SET_CODE);
}
}
public static class CSARErrorEntryMissingDefinitionYamldatatypesVlProfile extends CSARArchive.CSARErrorEntryMissing {
public CSARErrorEntryMissingDefinitionYamldatatypesVlProfile(String defYaml, String entry) {
super(entry, defYaml);
- this.setCode("0x1000");
+ this.setCode( SET_CODE);
}
}
public static class CSARErrorEntryMissingDefinitionYamldatatypesInstantiationLevel extends CSARArchive.CSARErrorEntryMissing {
public CSARErrorEntryMissingDefinitionYamldatatypesInstantiationLevel(String defYaml, String entry) {
super(entry, defYaml);
- this.setCode("0x1000");
+ this.setCode( SET_CODE);
}
}
public static class CSARErrorEntryMissingDefinitionYamldatatypesVduLevel extends CSARArchive.CSARErrorEntryMissing {
public CSARErrorEntryMissingDefinitionYamldatatypesVduLevel(String defYaml, String entry) {
super(entry, defYaml);
- this.setCode("0x1000");
+ this.setCode( SET_CODE);
}
}
public static class CSARErrorEntryMissingDefinitionYamldatatypesScaleInfo extends CSARArchive.CSARErrorEntryMissing {
public CSARErrorEntryMissingDefinitionYamldatatypesScaleInfo(String defYaml, String entry) {
super(entry, defYaml);
- this.setCode("0x1000");
+ this.setCode( SET_CODE);
}
}
public static class CSARErrorEntryMissingDefinitionYamldatatypesinjectFile extends CSARArchive.CSARErrorEntryMissing {
public CSARErrorEntryMissingDefinitionYamldatatypesinjectFile(String defYaml, String entry) {
super(entry, defYaml);
- this.setCode("0x1000");
+ this.setCode( SET_CODE);
}
}
public static class CSARErrorEntryMissingDefinitionYamldatatypesScalingAspect extends CSARArchive.CSARErrorEntryMissing {
public CSARErrorEntryMissingDefinitionYamldatatypesScalingAspect(String defYaml, String entry) {
super(entry, defYaml);
- this.setCode("0x1000");
+ this.setCode( SET_CODE);
}
}
public static class CSARErrorEntryMissingDefinitionYamldatatypesLinkBitRateRequirements extends CSARArchive.CSARErrorEntryMissing {
public CSARErrorEntryMissingDefinitionYamldatatypesLinkBitRateRequirements(String defYaml, String entry) {
super(entry, defYaml);
- this.setCode("0x1000");
+ this.setCode( SET_CODE);
}
}
public static class CSARErrorEntryMissingDefinitionYamldatatypesQos extends CSARArchive.CSARErrorEntryMissing {
public CSARErrorEntryMissingDefinitionYamldatatypesQos(String defYaml, String entry) {
super(entry, defYaml);
- this.setCode("0x1000");
+ this.setCode( SET_CODE);
}
}
public static class CSARErrorEntryMissingDefinitionYamldatatypesCpProtocolData extends CSARArchive.CSARErrorEntryMissing {
public CSARErrorEntryMissingDefinitionYamldatatypesCpProtocolData(String defYaml, String entry) {
super(entry, defYaml);
- this.setCode("0x1000");
+ this.setCode( SET_CODE);
}
}
public static class CSARErrorEntryMissingDefinitionYamldatatypesVnfConfigurableProperties extends CSARArchive.CSARErrorEntryMissing {
public CSARErrorEntryMissingDefinitionYamldatatypesVnfConfigurableProperties(String defYaml, String entry) {
super(entry, defYaml);
- this.setCode("0x1000");
+ this.setCode( SET_CODE);
}
}
public static class CSARErrorEntryMissingDefinitionYamldatatypesVnfAdditionalConfigurableProperties extends CSARArchive.CSARErrorEntryMissing {
public CSARErrorEntryMissingDefinitionYamldatatypesVnfAdditionalConfigurableProperties(String defYaml, String entry) {
super(entry, defYaml);
- this.setCode("0x1000");
+ this.setCode( SET_CODE);
}
}
public static class CSARErrorEntryMissingDefinitionYamldatatypesVnfInfoModifiableAttributes extends CSARArchive.CSARErrorEntryMissing {
public CSARErrorEntryMissingDefinitionYamldatatypesVnfInfoModifiableAttributes(String defYaml, String entry) {
super(entry, defYaml);
- this.setCode("0x1000");
+ this.setCode( SET_CODE);
}
}
public static class CSARErrorEntryMissingDefinitionYamldatatypesVnfInfoModifiableAttributesExtensions extends CSARArchive.CSARErrorEntryMissing {
public CSARErrorEntryMissingDefinitionYamldatatypesVnfInfoModifiableAttributesExtensions(String defYaml, String entry) {
super(entry, defYaml);
- this.setCode("0x1000");
+ this.setCode( SET_CODE);
}
}
public static class CSARErrorEntryMissingDefinitionYamldatatypesVnfInfoModifiableAttributesMetadata extends CSARArchive.CSARErrorEntryMissing {
public CSARErrorEntryMissingDefinitionYamldatatypesVnfInfoModifiableAttributesMetadata(String defYaml, String entry) {
super(entry, defYaml);
- this.setCode("0x1000");
+ this.setCode( SET_CODE);
}
}
@@ -201,125 +202,125 @@ public class VTPValidateCSARR54356 extends VTPValidateCSARBase {
yaml = (Map<String, ?>) yaml.get("topology_template");
Map<String, ?> nodeTmpls = (Map<String, ?>) yaml.get("node_templates");
- boolean vlExist[] = new boolean[30];
+ boolean []vlExist = new boolean[30];
for (Object nodeO : nodeTmpls.values()) {
Map<String, ?> node = (Map<String, ?>) nodeO;
if (node.containsKey("type")) {
String type = (String) node.get("type");
- if (type.equalsIgnoreCase("tosca.datatypes.nfv.L3AddressData")) {
+ if ("tosca.datatypes.nfv.L3AddressData".equalsIgnoreCase(type)) {
vlExist[0] = true;
}
- if (type.equalsIgnoreCase("tosca.datatypes.nfv.AddressData")) {
+ if ("tosca.datatypes.nfv.AddressData".equalsIgnoreCase(type)) {
vlExist[1] = true;
}
- if (type.equalsIgnoreCase("tosca.datatypes.nfv.VirtualNetworkInterfaceRequirements")) {
+ if ("tosca.datatypes.nfv.VirtualNetworkInterfaceRequirements".equalsIgnoreCase(type)) {
vlExist[2] = true;
}
- if (type.equalsIgnoreCase("tosca.datatypes.nfv.ConnectivityType")) {
+ if ("tosca.datatypes.nfv.ConnectivityType".equalsIgnoreCase(type)) {
vlExist[3] = true;
}
- if (type.equalsIgnoreCase("tosca.datatypes.nfv.RequestedAdditionalCapability")) {
+ if ("tosca.datatypes.nfv.RequestedAdditionalCapability".equalsIgnoreCase(type)) {
vlExist[4] = true;
}
- if (type.equalsIgnoreCase("tosca.datatypes.nfv.VirtualMemory")) {
+ if ("tosca.datatypes.nfv.VirtualMemory".equalsIgnoreCase(type)) {
vlExist[5] = true;
}
- if (type.equalsIgnoreCase("tosca.datatypes.nfv.VirtualCpu")) {
+ if ("tosca.datatypes.nfv.VirtualCpu".equalsIgnoreCase(type)) {
vlExist[6] = true;
}
- if (type.equalsIgnoreCase("tosca.datatypes.nfv.VirtualCpuPinning")) {
+ if ("tosca.datatypes.nfv.VirtualCpuPinning".equalsIgnoreCase(type)) {
vlExist[7] = true;
}
- if (type.equalsIgnoreCase("tosca.datatypes.nfv.VnfcConfigurableProperties")) {
+ if ("tosca.datatypes.nfv.VnfcConfigurableProperties".equalsIgnoreCase(type)) {
vlExist[8] = true;
}
- if (type.equalsIgnoreCase("tosca.datatypes.nfv.VduProfile")) {
+ if ("tosca.datatypes.nfv.VduProfile".equalsIgnoreCase(type)) {
vlExist[9] = true;
}
- if (type.equalsIgnoreCase("tosca.datatypes.nfv.VlProfile")) {
+ if ("tosca.datatypes.nfv.VlProfile".equalsIgnoreCase(type)) {
vlExist[10] = true;
}
- if (type.equalsIgnoreCase("tosca.datatypes.nfv.InstantiationLevel")) {
+ if ("tosca.datatypes.nfv.InstantiationLevel".equalsIgnoreCase(type)) {
vlExist[11] = true;
}
- if (type.equalsIgnoreCase("tosca.datatypes.nfv.VduLevel")) {
+ if ("tosca.datatypes.nfv.VduLevel".equalsIgnoreCase(type)) {
vlExist[12] = true;
}
- if (type.equalsIgnoreCase("tosca.datatypes.nfv.ScaleInfo")) {
+ if ("tosca.datatypes.nfv.ScaleInfo".equalsIgnoreCase(type)) {
vlExist[13] = true;
}
- if (type.equalsIgnoreCase("tosca.datatypes.nfv.injectFile")) {
+ if ("tosca.datatypes.nfv.injectFile".equalsIgnoreCase(type)) {
vlExist[14] = true;
}
- if (type.equalsIgnoreCase("tosca.datatypes.nfv.ScalingAspect")) {
+ if ("tosca.datatypes.nfv.ScalingAspect".equalsIgnoreCase(type)) {
vlExist[15] = true;
}
- if (type.equalsIgnoreCase("tosca.datatypes.nfv.LinkBitRateRequirements")) {
+ if ("tosca.datatypes.nfv.LinkBitRateRequirements".equalsIgnoreCase(type)) {
vlExist[16] = true;
}
- if (type.equalsIgnoreCase("tosca.datatypes.nfv.Qos")) {
+ if ("tosca.datatypes.nfv.Qos".equalsIgnoreCase(type)) {
vlExist[17] = true;
}
- if (type.equalsIgnoreCase("tosca.datatypes.nfv.CpProtocolData")) {
+ if ("tosca.datatypes.nfv.CpProtocolData".equalsIgnoreCase(type)) {
vlExist[18] = true;
}
- if (type.equalsIgnoreCase("tosca.datatypes.nfv.VnfConfigurableProperties")) {
+ if ("tosca.datatypes.nfv.VnfConfigurableProperties".equalsIgnoreCase(type)) {
vlExist[19] = true;
}
- if (type.equalsIgnoreCase("tosca.datatypes.nfv.VnfAdditionalConfigurableProperties")) {
+ if ("tosca.datatypes.nfv.VnfAdditionalConfigurableProperties".equalsIgnoreCase(type)) {
vlExist[20] = true;
}
- if (type.equalsIgnoreCase("tosca.datatypes.nfv.VnfInfoModifiableAttributes")) {
+ if ("tosca.datatypes.nfv.VnfInfoModifiableAttributes".equalsIgnoreCase(type)) {
vlExist[21] = true;
}
- if (type.equalsIgnoreCase("tosca.datatypes.nfv.VnfInfoModifiableAttributesExtensions")) {
+ if ("tosca.datatypes.nfv.VnfInfoModifiableAttributesExtensions".equalsIgnoreCase(type)) {
vlExist[22] = true;
}
- if (type.equalsIgnoreCase("tosca.datatypes.nfv.VnfInfoModifiableAttributesMetadata")) {
+ if ("tosca.datatypes.nfv.VnfInfoModifiableAttributesMetadata".equalsIgnoreCase(type)) {
vlExist[23] = true;
}
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR67895.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR67895.java
index c6075bc..19cb518 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR67895.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR67895.java
@@ -48,18 +48,18 @@ public class VTPValidateCSARR67895 extends VTPValidateCSARBase {
yaml = (Map<String, ?>) yaml.get("topology_template");
Map<String, ?> nodeTmpls = (Map<String, ?>) yaml.get("node_templates");
- boolean vlExist[] = new boolean[2];
+ boolean []vlExist = new boolean[2];
for (Object nodeO : nodeTmpls.values()) {
Map<String, ?> node = (Map<String, ?>) nodeO;
if (node.containsKey("type")) {
String type = (String) node.get("type");
- if (type.equalsIgnoreCase("tosca.capabilities.nfv.VirtualBindable")) {
+ if ("tosca.capabilities.nfv.VirtualBindable".equalsIgnoreCase(type)) {
vlExist[0] = true;
}
- if (type.equalsIgnoreCase("tosca.capabilities.nfv.VirtualLinkable")) {
+ if ("tosca.capabilities.nfv.VirtualLinkable".equalsIgnoreCase(type)) {
vlExist[1] = true;
}
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR95321.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR95321.java
index c7daafe..47eed83 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR95321.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR95321.java
@@ -49,18 +49,18 @@ public class VTPValidateCSARR95321 extends VTPValidateCSARBase {
yaml = (Map<String, ?>) yaml.get("topology_template");
Map<String, ?> nodeTmpls = (Map<String, ?>) yaml.get("node_templates");
- boolean vlExist[] = new boolean[2];
+ boolean []vlExist = new boolean[2];
for (Object nodeO : nodeTmpls.values()) {
Map<String, ?> node = (Map<String, ?>) nodeO;
if (node.containsKey("type")) {
String type = (String) node.get("type");
- if (type.equalsIgnoreCase("tosca.relationships.nfv.VirtualBindsTo")) {
+ if ("tosca.relationships.nfv.VirtualBindsTo".equalsIgnoreCase(type)) {
vlExist[0] = true;
}
- if (type.equalsIgnoreCase("tosca.relationships.nfv.VirtualLinksTo")) {
+ if ("tosca.relationships.nfv.VirtualLinksTo".equalsIgnoreCase(type)) {
vlExist[1] = true;
}
diff --git a/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java b/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java
index ced4158..e92f2b2 100644
--- a/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java
+++ b/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java
@@ -46,13 +46,13 @@ public class CsarValidator {
private static final Logger LOG = LoggerFactory.getLogger(CsarValidator.class);
// Schema files
- static private ValidatorSchemaLoader vsl;
+ private static ValidatorSchemaLoader vsl;
// Map of CSAR file and un-zipped file indices
- static private HashMap<String, String> csarFiles;
+ private static HashMap<String, String> csarFiles;
// Map of packageId and CSAR files
- private static HashMap<String, HashMap<String, String>> csar = new HashMap<String, HashMap<String, String>>();
+ private static HashMap<String, HashMap<String, String>> csar = new HashMap<>();
private static String MAINSERV_TEMPLATE = CommonConstants.MAINSERV_TEMPLATE;
@@ -170,7 +170,7 @@ public class CsarValidator {
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
String tempString = null;
while((tempString = reader.readLine()) != null) {
- if(!tempString.equals("")) {
+ if(!"".equals(tempString)) {
int count1 = tempString.indexOf(":");
String meta = tempString.substring(0, count1).trim();
if(meta.equalsIgnoreCase(CommonConstants.CSAR_TYPE_META)) {
@@ -285,7 +285,6 @@ public class CsarValidator {
// Rel-2 SOL004 requirement
if(StringUtils.isEmpty(mainServManifest)) {
// Do nothing for Rel-1
- // return false;
}
String mainservTemplate = MAINSERV_TEMPLATE;
@@ -392,10 +391,7 @@ public class CsarValidator {
List<? super String> lResult =
subValues.keySet().stream().filter(attributes::contains).collect(Collectors.toList());
- if(lResult.size() == 0) {
- return false;
- }
- return true;
+ return !lResult.isEmpty();
}
/**
diff --git a/csarvalidation/src/main/java/org/onap/validation/csar/FileUtil.java b/csarvalidation/src/main/java/org/onap/validation/csar/FileUtil.java
index e5605ac..f7471bd 100644
--- a/csarvalidation/src/main/java/org/onap/validation/csar/FileUtil.java
+++ b/csarvalidation/src/main/java/org/onap/validation/csar/FileUtil.java
@@ -17,9 +17,6 @@ package org.onap.validation.csar;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.core.JsonGenerationException;
-import com.fasterxml.jackson.core.JsonParseException;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
diff --git a/csarvalidation/src/main/java/org/onap/validation/csar/ValidationException.java b/csarvalidation/src/main/java/org/onap/validation/csar/ValidationException.java
index ec0c45c..7c124d7 100644
--- a/csarvalidation/src/main/java/org/onap/validation/csar/ValidationException.java
+++ b/csarvalidation/src/main/java/org/onap/validation/csar/ValidationException.java
@@ -21,21 +21,47 @@ import java.util.TreeMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ValidationException extends RuntimeException {
+
+ private static final long serialVersionUID = 1L;
public static final Logger logger = LoggerFactory.getLogger(ValidationException.class);
private String errorMessage;
+ private ErrorCodes errorCode;
+ private final transient Map<String,Object> properties = new TreeMap<>();
+
public ValidationException(){
super();
}
-
+ public static ValidationException wrappedInfo(Throwable exception) {
+ return wrappedInfo(exception, null);
+ }
+
public ValidationException(ErrorCodes errCode, String message) {
super(message);
}
+
+ public ValidationException(ErrorCodes fileIo) {
+ this.errorCode = fileIo;
+ }
+
+ public ValidationException(String message, ErrorCodes errorCode) {
+ super(message);
+ this.errorCode = errorCode;
+ }
+
+ public ValidationException(Throwable cause, ErrorCodes errorCode) {
+ super(cause);
+ this.errorCode = errorCode;
+ }
+
+ public ValidationException(String message, Throwable cause, ErrorCodes errorCode) {
+ super(message, cause);
+ this.errorCode = errorCode;
+ }
public String toString(){
return ("Exception Number = "+errorMessage) ;
}
- private static final long serialVersionUID = 1L;
public static ValidationException wrappedInfo(Throwable exception, ErrorCodes errorCode) {
if (exception instanceof ValidationException) {
@@ -49,31 +75,9 @@ public class ValidationException extends RuntimeException {
}
}
- public static ValidationException wrappedInfo(Throwable exception) {
- return wrappedInfo(exception, null);
- }
-
- private ErrorCodes errorCode;
- private final transient Map<String,Object> properties = new TreeMap<String,Object>();
-
- public ValidationException(ErrorCodes fileIo) {
- this.errorCode = fileIo;
- }
-
- public ValidationException(String message, ErrorCodes errorCode) {
- super(message);
- this.errorCode = errorCode;
- }
- public ValidationException(Throwable cause, ErrorCodes errorCode) {
- super(cause);
- this.errorCode = errorCode;
- }
+
- public ValidationException(String message, Throwable cause, ErrorCodes errorCode) {
- super(message, cause);
- this.errorCode = errorCode;
- }
public ErrorCodes getErrorCode() {
return errorCode;
diff --git a/csarvalidation/src/main/java/org/onap/validation/csar/ValidatorSchemaLoader.java b/csarvalidation/src/main/java/org/onap/validation/csar/ValidatorSchemaLoader.java
index eb9c9da..0ed0bdc 100644
--- a/csarvalidation/src/main/java/org/onap/validation/csar/ValidatorSchemaLoader.java
+++ b/csarvalidation/src/main/java/org/onap/validation/csar/ValidatorSchemaLoader.java
@@ -16,27 +16,18 @@
package org.onap.validation.csar;
-import org.apache.commons.io.FileSystemUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import java.io.*;
-import java.net.URI;
import java.net.URISyntaxException;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
import java.util.*;
-import java.util.stream.Stream;
-
-import org.apache.commons.io.FilenameUtils;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.scanner.ScannerException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.nio.file.Path;
public class ValidatorSchemaLoader {
+ private static final String FILE_NAME = "/schema/";
+
private static final Logger LOG = LoggerFactory.getLogger(ValidatorSchemaLoader.class);
// Map of Schema files
@@ -49,16 +40,16 @@ public class ValidatorSchemaLoader {
private Map<String, ?> mrfManifest;
// List of configured schemas
- static List<String> schemaFileList = new ArrayList<String>();
+ static List<String> schemaFileList = new ArrayList<>();
// SOL004 rule files
static HashMap<String, String> optionOneSchema;
static HashMap<String, String> optionTwoSchema;
- private String schema_folder;
+ private String schemaFolder;
- public ValidatorSchemaLoader() throws NullPointerException, FileNotFoundException, ScannerException, IOException {
+ public ValidatorSchemaLoader() {
try {
loadResources();
@@ -67,7 +58,7 @@ public class ValidatorSchemaLoader {
} catch(URISyntaxException e) {
// TODO Auto-generated catch block
- e.printStackTrace();
+ LOG.error("Illegal character in query at index", e);
}
}
@@ -81,16 +72,16 @@ public class ValidatorSchemaLoader {
for (String metaFile: new String []{"TOSCA.meta", "CSAR.meta", "MRF.mf" }) {
switch(metaFile) {
case "TOSCA.meta":
- toscaMeta = this.readYaml("/schema/" + metaFile);
+ toscaMeta = this.readYaml(FILE_NAME + metaFile);
break;
case "CSAR.meta":
- csarentryd = this.readYaml("/schema/" + metaFile);
+ csarentryd = this.readYaml(FILE_NAME + metaFile);
break;
case "MRF.yaml":
- mrfYaml = this.readYaml("/schema/" + metaFile);
+ mrfYaml = this.readYaml(FILE_NAME + metaFile);
break;
- case "MRF.mf":
- mrfManifest = this.readYaml("/schema/" + metaFile);
+ default:
+ mrfManifest = this.readYaml(FILE_NAME + metaFile);
break;
}
}