Fix for SONAR critical issues 39/11639/5
authorseshukm <seshu.kumar.m@huawei.com>
Tue, 12 Sep 2017 10:43:47 +0000 (16:13 +0530)
committerseshukm <seshu.kumar.m@huawei.com>
Wed, 13 Sep 2017 09:14:41 +0000 (14:44 +0530)
Issue-Id : SO-118

Change-Id: Ifc7d21387f33c7cb28d63b50ab99241818dc5d24
Signed-off-by: seshukm <seshu.kumar.m@huawei.com>
adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java
adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtilsWithUpdate.java
adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java
adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/QueryVfModuleResponse.java
adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/QueryVolumeGroupResponse.java
adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VfResponseCommon.java
adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/BPRestCallback.java
adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterRest.java
adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterUtils.java

index a1cf7e1..8073c95 100644 (file)
@@ -3,6 +3,7 @@
  * ONAP - SO
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -425,7 +426,7 @@ public class MsoHeatUtils extends MsoCommonUtils {
                     try {
                         LOGGER.debug("Current stack " + this.getOutputsAsStringBuilder(heatStack).toString());
                     } catch (Exception e) {
-                        LOGGER.debug("an error occurred trying to print out the current outputs of the stack");
+                        LOGGER.debug("an error occurred trying to print out the current outputs of the stack", e);
                     }
 
                     if ("CREATE_IN_PROGRESS".equals (heatStack.getStackStatus ())) {
@@ -578,7 +579,7 @@ public class MsoHeatUtils extends MsoCommonUtils {
 
                                        } catch (MsoException me2) {
                                                // We got an exception on the delete - don't throw this exception - throw the original - just log.
-                                               LOGGER.debug("Exception thrown trying to delete " + canonicalName + " on a create->rollback: " + me2.getContextMessage());
+                                               LOGGER.debug("Exception thrown trying to delete " + canonicalName + " on a create->rollback: " + me2.getContextMessage(), me2);
                                                LOGGER.warn(MessageEnum.RA_CREATE_STACK_ERR, "Create Stack errored, then stack deletion FAILED - exception thrown", "", "", MsoLogger.ErrorCode.BusinessProcesssError, me2.getContextMessage());
                                        }
 
@@ -1178,7 +1179,7 @@ public class MsoHeatUtils extends MsoCommonUtils {
                                                String str = this.convertNode((JsonNode) obj);
                                                inputs.put(key, str);
                                        } catch (Exception e) {
-                                               LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for JsonNode "+ key);
+                                               LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for JsonNode "+ key, e);
                                                //effect here is this value will not have been copied to the inputs - and therefore will error out downstream
                                        }
                                } else if (obj instanceof java.util.LinkedHashMap) {
@@ -1187,21 +1188,21 @@ public class MsoHeatUtils extends MsoCommonUtils {
                                                String str = JSON_MAPPER.writeValueAsString(obj);
                                                inputs.put(key, str);
                                        } catch (Exception e) {
-                                               LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for LinkedHashMap "+ key);
+                                               LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for LinkedHashMap "+ key, e);
                                        }
                                } else if (obj instanceof Integer) {
                                        try {
                                                String str = "" + obj;
                                                inputs.put(key, str);
                                        } catch (Exception e) {
-                                               LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for Integer "+ key);
+                                               LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for Integer "+ key, e);
                                        }
                                } else {
                                        try {
                                                String str = obj.toString();
                                                inputs.put(key, str);
                                        } catch (Exception e) {
-                                               LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for Other "+ key +" (" + e.getMessage() + ")");
+                                               LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for Other "+ key +" (" + e.getMessage() + ")", e);
                                                //effect here is this value will not have been copied to the inputs - and therefore will error out downstream
                                        }
                                }
@@ -1237,7 +1238,7 @@ public class MsoHeatUtils extends MsoCommonUtils {
                                                String str = params.get(key).toString();
                                                sb.append("\n" + key + "=" + str);
                                        } catch (Exception e) {
-                                               //non fatal
+                                               LOGGER.debug("Exception :",e);
                                        }
                                }
                        }
@@ -1251,9 +1252,9 @@ public class MsoHeatUtils extends MsoCommonUtils {
                        final String json = JSON_MAPPER.writeValueAsString(obj);
                        return json;
                } catch (JsonParseException jpe) {
-                       LOGGER.debug("Error converting json to string " + jpe.getMessage());
+                       LOGGER.debug("Error converting json to string " + jpe.getMessage(), jpe);
                } catch (Exception e) {
-                       LOGGER.debug("Error converting json to string " + e.getMessage());
+                       LOGGER.debug("Error converting json to string " + e.getMessage(), e);
                }
                return "[Error converting json to string]";
        }
@@ -1290,6 +1291,7 @@ public class MsoHeatUtils extends MsoCommonUtils {
                                        String str = JSON_MAPPER.writeValueAsString(obj);
                                        sb.append(str + " (a java.util.LinkedHashMap)");
                                } catch (Exception e) {
+                                       LOGGER.debug("Exception :",e);
                                        sb.append("(a LinkedHashMap value that would not convert nicely)");
                                }                               
                        } else if (obj instanceof Integer) {
@@ -1297,6 +1299,7 @@ public class MsoHeatUtils extends MsoCommonUtils {
                                try {
                                        str = obj.toString() + " (an Integer)\n";
                                } catch (Exception e) {
+                                       LOGGER.debug("Exception :",e);
                                        str = "(an Integer unable to call .toString() on)";
                                }
                                sb.append(str);
@@ -1305,6 +1308,7 @@ public class MsoHeatUtils extends MsoCommonUtils {
                                try {
                                        str = obj.toString() + " (an ArrayList)";
                                } catch (Exception e) {
+                                       LOGGER.debug("Exception :",e);
                                        str = "(an ArrayList unable to call .toString() on?)";
                                }
                                sb.append(str);
@@ -1313,6 +1317,7 @@ public class MsoHeatUtils extends MsoCommonUtils {
                                try {
                                        str = obj.toString() + " (a Boolean)";
                                } catch (Exception e) {
+                                       LOGGER.debug("Exception :",e);
                                        str = "(an Boolean unable to call .toString() on?)";
                                }
                                sb.append(str);
@@ -1322,6 +1327,7 @@ public class MsoHeatUtils extends MsoCommonUtils {
                                try {
                                        str = obj.toString() + " (unknown Object type)";
                                } catch (Exception e) {
+                                       LOGGER.debug("Exception :",e);
                                        str = "(a value unable to call .toString() on?)";
                                }
                                sb.append(str);
@@ -1399,7 +1405,7 @@ public class MsoHeatUtils extends MsoCommonUtils {
                        String jsonString = lhm.toString();
                        jsonNode = new ObjectMapper().readTree(jsonString);
                } catch (Exception e) {
-                       LOGGER.debug("Unable to convert " + lhm.toString() + " to a JsonNode " + e.getMessage());
+                       LOGGER.debug("Unable to convert " + lhm.toString() + " to a JsonNode " + e.getMessage(), e);
                        jsonNode = null;
                }
                return jsonNode;
@@ -1450,7 +1456,7 @@ public class MsoHeatUtils extends MsoCommonUtils {
                        Set<HeatTemplateParam> paramSet = template.getParameters();
                        LOGGER.debug("paramSet has " + paramSet.size() + " entries");
                } catch (Exception e) {
-                       LOGGER.debug("Exception occurred in convertInputMap:" + e.getMessage());
+                       LOGGER.debug("Exception occurred in convertInputMap:" + e.getMessage(), e);
                }
                
                for (HeatTemplateParam htp : template.getParameters()) {
@@ -1497,7 +1503,7 @@ public class MsoHeatUtils extends MsoCommonUtils {
                                try {
                                        anInteger = Integer.parseInt(integerString);
                                } catch (Exception e) {
-                                       LOGGER.debug("Unable to convert " + integerString + " to an integer!!");
+                                       LOGGER.debug("Unable to convert " + integerString + " to an integer!!", e);
                                        anInteger = null;
                                }
                                if (anInteger != null) {
@@ -1518,7 +1524,7 @@ public class MsoHeatUtils extends MsoCommonUtils {
                        try {
                                jsonNode = new ObjectMapper().readTree(jsonString);
                        } catch (Exception e) {
-                                       LOGGER.debug("Unable to convert " + jsonString + " to a JsonNode!!");
+                                       LOGGER.debug("Unable to convert " + jsonString + " to a JsonNode!!", e);
                                        jsonNode = null;
                        }
                        if (jsonNode != null) {
@@ -1542,7 +1548,7 @@ public class MsoHeatUtils extends MsoCommonUtils {
                                        else
                                                newInputs.put(key, anArrayList);
                                } catch (Exception e) {
-                                       LOGGER.debug("Unable to convert " + commaSeparated + " to an ArrayList!!");
+                                       LOGGER.debug("Unable to convert " + commaSeparated + " to an ArrayList!!", e);
                                        if (alias)
                                                newInputs.put(realName, commaSeparated);
                                        else
index 1497e2d..dba52d4 100644 (file)
@@ -3,6 +3,7 @@
  * ONAP - SO
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -281,7 +282,7 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
                     try {
                        LOGGER.debug("Current stack " + this.getOutputsAsStringBuilder(heatStack).toString());
                     } catch (Exception e) {
-                       LOGGER.debug("an error occurred trying to print out the current outputs of the stack");
+                       LOGGER.debug("an error occurred trying to print out the current outputs of the stack", e);
                     }
 
 
@@ -378,6 +379,7 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
                                        String str = JSON_MAPPER.writeValueAsString(obj);
                                        sb.append(str + " (a java.util.LinkedHashMap)");
                                } catch (Exception e) {
+                                       LOGGER.debug("Exception :", e);
                                        sb.append("(a LinkedHashMap value that would not convert nicely)");
                                }                               
                        } else if (obj instanceof Integer) {
@@ -385,6 +387,7 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
                                try {
                                        str = obj.toString() + " (an Integer)\n";
                                } catch (Exception e) {
+                                       LOGGER.debug("Exception :", e);
                                        str = "(an Integer unable to call .toString() on)";
                                }
                                sb.append(str);
@@ -393,6 +396,7 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
                                try {
                                        str = obj.toString() + " (an ArrayList)";
                                } catch (Exception e) {
+                                       LOGGER.debug("Exception :", e);
                                        str = "(an ArrayList unable to call .toString() on?)";
                                }
                                sb.append(str);
@@ -401,6 +405,7 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
                                try {
                                        str = obj.toString() + " (a Boolean)";
                                } catch (Exception e) {
+                                       LOGGER.debug("Exception :", e);
                                        str = "(an Boolean unable to call .toString() on?)";
                                }
                                sb.append(str);
@@ -410,6 +415,7 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
                                try {
                                        str = obj.toString() + " (unknown Object type)";
                                } catch (Exception e) {
+                                       LOGGER.debug("Exception :", e);
                                        str = "(a value unable to call .toString() on?)";
                                }
                                sb.append(str);
@@ -426,9 +432,9 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
                        final String json = JSON_MAPPER.writeValueAsString(obj);
                        return json;
                } catch (JsonParseException jpe) {
-                       LOGGER.debug("Error converting json to string " + jpe.getMessage());
+                       LOGGER.debug("Error converting json to string " + jpe.getMessage(), jpe);
                } catch (Exception e) {
-                       LOGGER.debug("Error converting json to string " + e.getMessage());
+                       LOGGER.debug("Error converting json to string " + e.getMessage(), e);
                }
                return "[Error converting json to string]";
        }
index 712b18a..4e715fa 100644 (file)
@@ -3,6 +3,7 @@
  * ONAP - SO
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index da35b0e..f3f252d 100644 (file)
@@ -3,6 +3,7 @@
  * ONAP - SO
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,6 +21,8 @@
 
 package org.openecomp.mso.adapters.vnfrest;
 
+import org.openecomp.mso.logger.MsoLogger;
+
 
 import java.util.Map;
 
@@ -27,12 +30,13 @@ import javax.xml.bind.annotation.XmlRootElement;
 
 import org.codehaus.jackson.map.ObjectMapper;
 import org.jboss.resteasy.annotations.providers.NoJackson;
-
+import org.openecomp.mso.logger.MsoLogger;
 import org.openecomp.mso.openstack.beans.VnfStatus;
 
 @XmlRootElement(name = "queryVfModuleResponse")
 @NoJackson
 public class QueryVfModuleResponse {
+       private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
        private String vnfId;
        private String vfModuleId;
        private String vfModuleStackId;
@@ -100,7 +104,9 @@ public class QueryVfModuleResponse {
                        ObjectMapper mapper = new ObjectMapper();
                        jsonString = mapper.writeValueAsString(this);
                }
-               catch (Exception e) {}
+               catch (Exception e) {
+                       LOGGER.debug("Exception :",e);
+               }
                return jsonString;
        }
 }
index 776bdf3..e70b9dd 100644 (file)
@@ -3,6 +3,7 @@
  * ONAP - SO
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,11 +30,14 @@ import org.codehaus.jackson.map.ObjectMapper;
 import org.codehaus.jackson.map.SerializationConfig;
 import org.jboss.resteasy.annotations.providers.NoJackson;
 
+import org.openecomp.mso.logger.MsoLogger;
+
 import org.openecomp.mso.openstack.beans.VnfStatus;
 
 @XmlRootElement(name = "queryVolumeGroupResponse")
 @NoJackson
 public class QueryVolumeGroupResponse {
+       private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
        private String volumeGroupId;
        private String volumeGroupStackId;
        private VnfStatus volumeGroupStatus;
@@ -94,7 +98,9 @@ public class QueryVolumeGroupResponse {
                        mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE);
                        jsonString = mapper.writeValueAsString(this);
                }
-               catch (Exception e) {}
+               catch (Exception e) {
+                       LOGGER.debug("Exception :",e);
+               }
                return jsonString;
        }
 }
index 39201d5..4a902bd 100644 (file)
@@ -3,6 +3,7 @@
  * ONAP - SO
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,6 +27,8 @@ import java.io.ByteArrayOutputStream;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.Marshaller;
 
+import org.openecomp.mso.logger.MsoLogger;
+
 import org.codehaus.jackson.map.ObjectMapper;
 import org.codehaus.jackson.map.SerializationConfig;
 
@@ -34,6 +37,7 @@ import org.codehaus.jackson.map.SerializationConfig;
  * except for QueryVfModuleResponse and QueryVolumeGroupResponse.
  */
 public abstract class VfResponseCommon {
+       private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
        private String messageId;
 
        public VfResponseCommon() {
@@ -60,8 +64,7 @@ public abstract class VfResponseCommon {
                        jsonString = mapper.writeValueAsString(this);
                        return jsonString;
                } catch (Exception e) {
-                       // Shouldn't happen...
-                       e.printStackTrace();
+                       LOGGER.debug("Exception :",e);
                        return "";
                }
        }
@@ -75,8 +78,7 @@ public abstract class VfResponseCommon {
                        marshaller.marshal(this, bs);
                        return bs.toString();
                } catch (Exception e) {
-                       // Shouldn't happen...
-                       e.printStackTrace();
+                       LOGGER.debug("Exception :",e);
                        return "";
                }
        }
index 1d07d7d..253523e 100644 (file)
@@ -3,6 +3,7 @@
  * ONAP - SO
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -160,7 +161,7 @@ public class BPRestCallback {
                                try {
                                        EntityUtils.consume(httpResponse.getEntity());
                                } catch (Exception e) {
-                                       // Ignore
+                                       LOGGER.debug("Exception :",e);
                                }
                        }
 
@@ -168,7 +169,7 @@ public class BPRestCallback {
                                try {
                                        method.reset();
                                } catch (Exception e) {
-                                       // Ignore
+                                       LOGGER.debug("Exception :",e);
                                }
                        }
 
index 3b6c160..dc94a78 100644 (file)
@@ -3,6 +3,7 @@
  * ONAP - SO
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -99,6 +100,7 @@ public class WMAdapterRest {
                                contentType = ContentType.parse(contentTypeHeader);
                        } catch (Exception e) {
                                // If we don't get a valid one, we handle it below.
+                               LOGGER.debug("Exception :",e);
                        }
                }
 
index 761263f..f152931 100644 (file)
@@ -3,6 +3,7 @@
  * ONAP - SO
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,7 +37,7 @@ public final class WMAdapterUtils {
                try {
                        return UriUtils.encodePathSegment(pathSegment, "UTF-8");
                } catch (UnsupportedEncodingException e) {
-                       throw new RuntimeException("UTF-8 encoding is not supported");
+                       throw new RuntimeException("UTF-8 encoding is not supported",e);
                }
        }