summaryrefslogtreecommitdiffstats
path: root/ONAP-REST/src/main/java
diff options
context:
space:
mode:
authorMichael Mokry <mm117s@att.com>2018-05-25 13:25:26 -0500
committerMichael Mokry <mm117s@att.com>2018-05-25 14:26:53 -0500
commit142ae9408466e78a4509490eb9ffe8bbc19f634a (patch)
tree59165292b9d6da6cedaca266a89e8548c9bf9ef6 /ONAP-REST/src/main/java
parent2f8ab5851fb070fac82472cf8a3c8542a657ca01 (diff)
Sonar fixes for TOSCA Parser
I fixed the sonar blocker in regards to nullPointerException and few other majors that I found and were easy to fix. I ran my local sonar and the blocker was removed after the changes. Change-Id: I7dcd7584fc955e1b520235a8e1376cf871761d21 Issue-ID: POLICY-776 Signed-off-by: Michael Mokry <mm117s@att.com>
Diffstat (limited to 'ONAP-REST/src/main/java')
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java16
1 files changed, 10 insertions, 6 deletions
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java b/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java
index 1a62ccc88..1f40be60a 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java
@@ -35,6 +35,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
+
import java.util.Map.Entry;
import org.apache.commons.lang.StringUtils;
@@ -1036,7 +1037,6 @@ public class MSModelUtils {
logger.info(mainObject);
logger.info("###############################################################################");
}
-
LinkedHashMap<String,String> parseDataNodes(LinkedHashMap<String,String> map){
LinkedHashMap<String,String> dataMapForJson=new LinkedHashMap <>();
matchableValues = new HashMap <>();
@@ -1098,9 +1098,9 @@ public class MSModelUtils {
else{
StringBuilder stringListItems= new StringBuilder();
if(LIST.equalsIgnoreCase(typeValue)){
- stringListItems.append(uniqueDataKeySplit[1].toUpperCase()+":required-"+requiredValue +":MANY-false");
+ stringListItems.append(uniqueDataKeySplit[1].toUpperCase()+REQUIREDVALUE+requiredValue +MANYFALSE);
}else if( MAP.equalsIgnoreCase(typeValue)){
- stringListItems.append(uniqueDataKeySplit[1].toUpperCase()+":required-"+requiredValue +":MANY-true");
+ stringListItems.append(uniqueDataKeySplit[1].toUpperCase()+REQUIREDVALUE+requiredValue +MANYTRUE);
}
dataMapForJson.put(uniqueDataKey, stringListItems.toString());
boolean isConstraintsFound = false;
@@ -1109,7 +1109,8 @@ public class MSModelUtils {
logger.info("findConstraints => " + findConstraints);
String constraintsValue=map.get(findConstraints);
logger.info("constraintsValue => " + constraintsValue);
- if((constraintsValue==null || constraintsValue.isEmpty()) && i==0){ //if no constraints at all ( index i as 0 can tell this )
+
+ if((constraintsValue==null || constraintsValue.isEmpty()) && i==0){ //if no constraints at all ( index i as 0 can tell this )
isConstraintsFound = false;
//if type is list but no constraints
String newValue = dataMapForJson.get(uniqueDataKey).replace("MANY-false", "MANY-true");
@@ -1121,10 +1122,13 @@ public class MSModelUtils {
if(i == 0){ // only need to add one time for the same attribute
dataListBuffer.append(uniqueDataKeySplit[1].toUpperCase()+"=[");
}
-
- if(constraintsValue.contains("=")){
+
+ if(constraintsValue==null){
+ constraintsValue = "";
+ }else if (constraintsValue.contains("=")) {
constraintsValue = constraintsValue.replace("=", "equal-sign");
}
+
dataConstraints.add(constraintsValue);
dataListBuffer.append(constraintsValue+",");
}