From 171ec7b74a11658277f9e9fe1dcc893a8225db9e Mon Sep 17 00:00:00 2001 From: seshukm Date: Tue, 12 Sep 2017 16:13:47 +0530 Subject: Fix for SONAR critical issues Issue-Id : SO-117 Change-Id: Icdc64605b475e20af7e871135af327f7d0e38792 Signed-off-by: seshukm --- .../mso/openstack/utils/MsoHeatUtils.java | 34 +++++++++++++--------- .../openstack/utils/MsoHeatUtilsWithUpdate.java | 12 ++++++-- .../mso/openstack/utils/MsoYamlEditorWithEnvt.java | 1 + .../adapters/vnfrest/QueryVfModuleResponse.java | 10 +++++-- .../adapters/vnfrest/QueryVolumeGroupResponse.java | 8 ++++- .../mso/adapters/vnfrest/VfResponseCommon.java | 10 ++++--- .../adapters/workflowmessage/BPRestCallback.java | 5 ++-- .../adapters/workflowmessage/WMAdapterRest.java | 2 ++ .../adapters/workflowmessage/WMAdapterUtils.java | 3 +- 9 files changed, 58 insertions(+), 27 deletions(-) (limited to 'adapters') diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java index a1cf7e1b61..8073c953e9 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java @@ -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 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 diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtilsWithUpdate.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtilsWithUpdate.java index 1497e2d5ea..dba52d4306 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtilsWithUpdate.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtilsWithUpdate.java @@ -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]"; } diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java index 712b18a12b..4e715fa06e 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java @@ -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. diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/QueryVfModuleResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/QueryVfModuleResponse.java index da35b0e78f..f3f252d96e 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/QueryVfModuleResponse.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/QueryVfModuleResponse.java @@ -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; } } diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/QueryVolumeGroupResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/QueryVolumeGroupResponse.java index 776bdf3111..e70b9ddc71 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/QueryVolumeGroupResponse.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/QueryVolumeGroupResponse.java @@ -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; } } diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VfResponseCommon.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VfResponseCommon.java index 39201d550c..4a902bdd83 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VfResponseCommon.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VfResponseCommon.java @@ -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 ""; } } diff --git a/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/BPRestCallback.java b/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/BPRestCallback.java index 1d07d7d233..253523eaac 100644 --- a/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/BPRestCallback.java +++ b/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/BPRestCallback.java @@ -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); } } diff --git a/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterRest.java b/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterRest.java index 3b6c16085a..dc94a78733 100644 --- a/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterRest.java +++ b/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterRest.java @@ -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); } } diff --git a/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterUtils.java b/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterUtils.java index 761263f423..f152931ae5 100644 --- a/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterUtils.java +++ b/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterUtils.java @@ -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); } } -- cgit 1.2.3-korg