Fix Blocker/Critical sonar issues
authorshashikanth <shashikanth.vh@huawei.com>
Mon, 11 Sep 2017 12:51:17 +0000 (18:21 +0530)
committerShashikanth VH <shashikanth.vh@huawei.com>
Thu, 14 Sep 2017 13:47:39 +0000 (13:47 +0000)
Fix Blocker/Critical sonar issues in vnfapi module
https://sonar.onap.org/component_issues?id=org.openecomp.sdnc.core%3Asdnc-core#resolved=false|severities=BLOCKER

Issue-Id: CCSDK-67
Change-Id: Ie2ace1bc30bbb50d2b6f25a56e716c7a952e7ea0
Signed-off-by: shashikanth.vh <shashikanth.vh@huawei.com>
sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java

index 5270143..26d45ce 100644 (file)
 
 package org.onap.ccsdk.sli.core.sli;
 
-import java.io.File;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.LinkedList;
-
-import javax.xml.XMLConstants;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.xml.sax.Attributes;
@@ -41,6 +30,16 @@ import org.xml.sax.SAXNotRecognizedException;
 import org.xml.sax.SAXParseException;
 import org.xml.sax.helpers.DefaultHandler;
 
+import javax.xml.XMLConstants;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.LinkedList;
+
 /**
  * @author dt5972
  *
@@ -336,7 +335,7 @@ public class SvcLogicParser {
     Schema schema = null;
     String validateSchema = System.getProperty(SLI_VALIDATING_PARSER, "true");
 
-    if (validateSchema != null || validateSchema.equalsIgnoreCase("true")) {
+    if ("true".equalsIgnoreCase(validateSchema)) {
         xsdUrl = getClass().getResource(SVCLOGIC_XSD);
 
     }
@@ -362,7 +361,7 @@ public class SvcLogicParser {
         SAXParser saxParser = factory.newSAXParser();
 
         if (saxParser.isValidating()) {
-        LOGGER.info("Validating against schema " + xsdUrl.getPath());
+            LOGGER.info("Parser not configured to validate XML {}", (xsdUrl != null ? xsdUrl.getPath() : null));
         }
         graphs = new LinkedList<>();