Fix sonar issues in MSOCoreBPMN 82/92982/1
authorParshad Patel <pars.patel@samsung.com>
Thu, 8 Aug 2019 04:10:59 +0000 (13:10 +0900)
committerParshad Patel <pars.patel@samsung.com>
Thu, 8 Aug 2019 04:12:09 +0000 (13:12 +0900)
Either log or rethrow this exception
Make "serviceParams" transient or serializable
Make "extSystemErrorSource" transient or serializable

Issue-ID: SO-1841
Change-Id: If752c7898a0934212d425b1c80b8d2ee34098ad3
Signed-off-by: Parshad Patel <pars.patel@samsung.com>
bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/WorkflowException.java
bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceInstance.java
bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/json/JsonUtils.java

index 7d5bb0d..21847e1 100644 (file)
@@ -33,7 +33,7 @@ public class WorkflowException implements Serializable {
     private final int errorCode;
     private final String errorMessage;
     private final String workStep;
-    private TargetEntities extSystemErrorSource;
+    private transient TargetEntities extSystemErrorSource;
 
     /**
      * Constructor
index b0b837b..fad6490 100644 (file)
@@ -22,9 +22,7 @@ package org.onap.so.bpmn.core.domain;
 
 import java.io.Serializable;
 import java.util.Map;
-import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonRootName;
 
 /**
  * This class is used to store instance data of services aka ServiceDecomposition
@@ -46,7 +44,7 @@ public class ServiceInstance extends JsonWrapper implements Serializable {
     private ModelInfo modelInfo;
     private String environmentContext;
     private String workloadContext;
-    private Map serviceParams;
+    private transient Map serviceParams;
     private Customer customer = new Customer();
     private String e2eVpnKey;
 
index d3d07f9..3f10df3 100644 (file)
@@ -323,7 +323,7 @@ public class JsonUtils {
                     logger.debug("getJsonValue(): the raw value is a String Object={}", rawValue);
                     return (String) rawValue;
                 } else {
-                    logger.debug("getJsonValue(): the raw value is NOT a String Object={}", rawValue.toString());
+                    logger.debug("getJsonValue(): the raw value is NOT a String Object={}", rawValue);
                     return rawValue.toString();
                 }
             }
@@ -352,7 +352,7 @@ public class JsonUtils {
                     logger.debug("getJsonNodeValue(): the raw value is a String Object={}", rawValue);
                     return (String) rawValue;
                 } else {
-                    logger.debug("getJsonNodeValue(): the raw value is NOT a String Object={}", rawValue.toString());
+                    logger.debug("getJsonNodeValue(): the raw value is NOT a String Object={}", rawValue);
                     return rawValue.toString();
                 }
             }
@@ -380,11 +380,10 @@ public class JsonUtils {
                 return 0;
             } else {
                 if (rawValue instanceof Integer) {
-                    logger.debug("getJsonIntValue(): the raw value is an Integer Object={}",
-                            ((String) rawValue).toString());
+                    logger.debug("getJsonIntValue(): the raw value is an Integer Object={}", rawValue);
                     return (Integer) rawValue;
                 } else {
-                    logger.debug("getJsonIntValue(): the raw value is NOT an Integer Object={}", rawValue.toString());
+                    logger.debug("getJsonIntValue(): the raw value is NOT an Integer Object={}", rawValue);
                     return 0;
                 }
             }
@@ -412,8 +411,7 @@ public class JsonUtils {
                     logger.debug("getJsonBooleanValue(): the raw value is a Boolean Object={}", rawValue);
                     return (Boolean) rawValue;
                 } else {
-                    logger.debug("getJsonBooleanValue(): the raw value is NOT an Boolean Object={}",
-                            rawValue.toString());
+                    logger.debug("getJsonBooleanValue(): the raw value is NOT an Boolean Object={}", rawValue);
                     return false;
                 }
             }
@@ -455,7 +453,7 @@ public class JsonUtils {
                 return null;
             } else {
                 if (rawValue instanceof JSONArray) {
-                    logger.debug("getJsonParamValue(): keys={} points to JSONArray: {}", keys, rawValue.toString());
+                    logger.debug("getJsonParamValue(): keys={} points to JSONArray: {}", keys, rawValue);
                     int arrayLen = ((JSONArray) rawValue).length();
                     if (index < 0 || arrayLen < index + 1) {
                         logger.debug("getJsonParamValue(): index: {} is out of bounds for array size of {}", index,
@@ -464,8 +462,7 @@ public class JsonUtils {
                     }
                     int foundCnt = 0;
                     for (int i = 0; i < arrayLen; i++) {
-                        logger.debug("getJsonParamValue(): index: {}, value: {}", i,
-                                ((JSONArray) rawValue).get(i).toString());
+                        logger.debug("getJsonParamValue(): index: {}, value: {}", i, ((JSONArray) rawValue).get(i));
                         if (((JSONArray) rawValue).get(i) instanceof JSONObject) {
                             JSONObject jsonObj = (JSONObject) ((JSONArray) rawValue).get(i);
                             String parmValue = jsonObj.get(name).toString();
@@ -482,16 +479,14 @@ public class JsonUtils {
                                 continue;
                             }
                         } else {
-                            logger.debug("getJsonParamValue(): the JSONArray element is NOT a JSONObject={}",
-                                    rawValue.toString());
+                            logger.debug("getJsonParamValue(): the JSONArray element is NOT a JSONObject={}", rawValue);
                             return null;
                         }
                     }
                     logger.debug("getJsonParamValue(): content value NOT found for name: {}", name);
                     return null;
                 } else {
-                    logger.debug("getJsonParamValue(): the raw value is NOT a JSONArray Object={}",
-                            rawValue.toString());
+                    logger.debug("getJsonParamValue(): the raw value is NOT a JSONArray Object={}", rawValue);
                     return null;
                 }
             }
@@ -1057,13 +1052,13 @@ public class JsonUtils {
             JsonValidator validator = factory.getValidator();
 
             ProcessingReport report = validator.validate(schema, document);
-            logger.debug("JSON schema validation report: {}", report.toString());
+            logger.debug("JSON schema validation report: {}", report);
             return report.toString();
         } catch (IOException e) {
-            logger.debug("IOException performing JSON schema validation on document: {}", e.toString());
+            logger.debug("IOException performing JSON schema validation on document:", e);
             throw new ValidationException(e.getMessage());
         } catch (ProcessingException e) {
-            logger.debug("ProcessingException performing JSON schema validation on document: {}", e.toString());
+            logger.debug("ProcessingException performing JSON schema validation on document:", e);
             throw new ValidationException(e.getMessage());
         }
     }