diff options
author | seshukm <seshu.kumar.m@huawei.com> | 2017-09-12 10:26:45 +0530 |
---|---|---|
committer | seshukm <seshu.kumar.m@huawei.com> | 2017-09-12 10:26:45 +0530 |
commit | 92ffbb4a56b1f84ed130b04ca3a9954ce610a02a (patch) | |
tree | ef7d115f9f5e58bd1aa4bbc051dbca8cbe609720 | |
parent | 3fa63b90661cea6d0563038f9f31f17a58a6f3c8 (diff) |
Fix for SONAR critical issues
Issue-Id : SO-117
Change-Id: I57e30d9a8a2b251a57466d92c49f41e2a5943b22
Signed-off-by: seshukm <seshu.kumar.m@huawei.com>
7 files changed, 52 insertions, 27 deletions
diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/TenantRequestCommon.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/TenantRequestCommon.java index e5a9904d36..98be3c1478 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/TenantRequestCommon.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/TenantRequestCommon.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,7 +30,10 @@ import javax.xml.bind.Marshaller; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.SerializationConfig; +import org.openecomp.mso.logger.MsoLogger; + public class TenantRequestCommon { + private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); public String toJsonString() { try { String jsonString = null; @@ -38,8 +42,7 @@ public class TenantRequestCommon { jsonString = mapper.writeValueAsString(this); return jsonString; } catch (Exception e) { - // Shouldn't happen... - e.printStackTrace(); + LOGGER.debug("Exception :",e); return ""; } } @@ -53,8 +56,7 @@ public class TenantRequestCommon { 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-network-adapter/src/main/java/org/openecomp/mso/adapters/network/BpelRestClient.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/BpelRestClient.java index 90d1180d77..83cadb8878 100644 --- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/BpelRestClient.java +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/BpelRestClient.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-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/TenantAdapterRest.java b/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/TenantAdapterRest.java index 66f278b0bc..581b0e1da9 100644 --- a/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/TenantAdapterRest.java +++ b/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/TenantAdapterRest.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. @@ -137,14 +138,17 @@ public class TenantAdapterRest { // tenantRollback); } catch (TenantAlreadyExists tae) { + LOGGER.debug("Exception :",tae); CreateTenantError exc = new CreateTenantError(tae.getMessage(), tae.getFaultInfo().getCategory(), Boolean.TRUE); return Response.status(HttpServletResponse.SC_NOT_IMPLEMENTED).entity(exc).build(); } catch (TenantException te) { + LOGGER.debug("Exception :",te); CreateTenantError exc = new CreateTenantError(te.getFaultInfo().getMessage(), te.getFaultInfo().getCategory(), Boolean.TRUE); return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); } catch (Exception e) { + LOGGER.debug("Exception :",e); CreateTenantError exc = new CreateTenantError(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE); return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); } @@ -189,10 +193,12 @@ public class TenantAdapterRest { tenantDeleted = deleted.value; } catch (TenantException te) { + LOGGER.debug("Exception :",te); DeleteTenantError exc = new DeleteTenantError(te.getFaultInfo().getMessage(), te.getFaultInfo().getCategory(), Boolean.TRUE); return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); } catch (Exception e) { + LOGGER.debug("Exception :",e); DeleteTenantError exc = new DeleteTenantError(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE); return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); } @@ -243,10 +249,12 @@ public class TenantAdapterRest { // tenant = TAImpl.queryTenant (cloudSiteId, tenantId, msoReq); } catch (TenantException te) { + LOGGER.debug("Exception :",te); QueryTenantError exc = new QueryTenantError(te.getFaultInfo().getMessage(), te.getFaultInfo().getCategory()); return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); } catch (Exception e) { + LOGGER.debug("Exception :",e); QueryTenantError exc = new QueryTenantError(e.getMessage(), MsoExceptionCategory.INTERNAL); return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); } @@ -282,10 +290,12 @@ public class TenantAdapterRest { impl.rollbackTenant(req.getTenantRollback()); } catch (TenantException te) { + LOGGER.debug("Exception :",te); RollbackTenantError exc = new RollbackTenantError(te.getFaultInfo().getMessage(), te.getFaultInfo().getCategory(), Boolean.TRUE); return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); } catch (Exception e) { + LOGGER.debug("Exception :",e); RollbackTenantError exc = new RollbackTenantError(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE); return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); } diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/RestfulUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/RestfulUtil.java index 19cbca80e3..dfedce8531 100644 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/RestfulUtil.java +++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/RestfulUtil.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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 RestfulUtil { try { EntityUtils.consume(httpResponse.getEntity()); } catch(Exception e) { - // Ignore + LOGGER.debug("Exception :",e); } } @@ -168,7 +169,7 @@ public class RestfulUtil { try { method.reset(); } catch(Exception e) { - // Ignore + LOGGER.debug("Exception :",e); } } } diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java index 6fab6a3663..44922a7a8a 100644 --- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.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. @@ -176,7 +177,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } } catch (Exception e) { // might be ok - both are just blank - LOGGER.debug("ERROR trying to parse the volumeGroupHeatStackId " + volumeGroupHeatStackId); + LOGGER.debug("ERROR trying to parse the volumeGroupHeatStackId " + volumeGroupHeatStackId,e); } this.createVfModule(cloudSiteId, tenantId, @@ -434,28 +435,28 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String str = "" + stackOutputs.get(key); stringOutputs.put(key, str); } catch (Exception e) { - LOGGER.debug("Unable to add " + key + " to outputs"); + LOGGER.debug("Unable to add " + key + " to outputs",e); } } else if (stackOutputs.get(key) instanceof JsonNode) { try { String str = this.convertNode((JsonNode) stackOutputs.get(key)); stringOutputs.put(key, str); } catch (Exception e) { - LOGGER.debug("Unable to add " + key + " to outputs - exception converting JsonNode"); + LOGGER.debug("Unable to add " + key + " to outputs - exception converting JsonNode",e); } } else if (stackOutputs.get(key) instanceof java.util.LinkedHashMap) { try { String str = JSON_MAPPER.writeValueAsString(stackOutputs.get(key)); stringOutputs.put(key, str); } catch (Exception e) { - LOGGER.debug("Unable to add " + key + " to outputs - exception converting LinkedHashMap"); + LOGGER.debug("Unable to add " + key + " to outputs - exception converting LinkedHashMap",e); } } else { try { String str = stackOutputs.get(key).toString(); stringOutputs.put(key, str); } catch (Exception e) { - LOGGER.debug("Unable to add " + key + " to outputs - unable to call .toString() " + e.getMessage()); + LOGGER.debug("Unable to add " + key + " to outputs - unable to call .toString() " + e.getMessage(),e); } } } @@ -553,6 +554,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { try { outputString = inputs.get(str).toString(); } catch (Exception e) { + LOGGER.debug("Exception :",e); outputString = "Unable to call toString() on the value for " + str; } sb.append("\t\nitem " + i++ + ": '" + str + "'='" + outputString + "'"); @@ -585,9 +587,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { 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]"; } @@ -609,7 +611,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String str = this.convertNode((JsonNode) obj); stringMap.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); //okay in this instance - only string values (fqdn) are expected to be needed } } else if (obj instanceof java.util.LinkedHashMap) { @@ -618,21 +620,21 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String str = JSON_MAPPER.writeValueAsString(obj); stringMap.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; stringMap.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(); stringMap.put(key, str); } catch (Exception e) { - LOGGER.debug("DANGER WILL ROBINSON: unable to convert value "+ key + " (" + e.getMessage() + ")"); + LOGGER.debug("DANGER WILL ROBINSON: unable to convert value "+ key + " (" + e.getMessage() + ")",e); } } } @@ -985,7 +987,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { minVersionVnf = vnfResource.getAicVersionMin(); maxVersionVnf = vnfResource.getAicVersionMax(); } catch (Exception e) { - LOGGER.debug("Unable to pull min/max version for this VNF Resource entry"); + LOGGER.debug("Unable to pull min/max version for this VNF Resource entry",e); minVersionVnf = null; maxVersionVnf = null; } @@ -1020,7 +1022,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { moreThanMax = aicV.isMoreRecentThan(maxVersionVnf); equalToMax = aicV.isTheSameVersion(maxVersionVnf); } catch (Exception e) { - LOGGER.debug("An exception occured while trying to test AIC Version " + e.getMessage() + " - will default to not check"); + LOGGER.debug("An exception occured while trying to test AIC Version " + e.getMessage() + " - will default to not check",e); doNotTest = true; } if (!doNotTest) { @@ -1282,7 +1284,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } LOGGER.debug(sb.toString()); } catch (Exception e) { - LOGGER.debug("??An exception occurred trying to go through Parameter Names " + e.getMessage()); + LOGGER.debug("??An exception occurred trying to go through Parameter Names " + e.getMessage(),e); } // Step 1 - convert what we got as inputs (Map<String, String>) to a // Map<String, Object> - where the object matches the param type identified in the template @@ -1386,12 +1388,12 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { throw new VnfException ("NullPointerException during heat.createStack"); } catch (Exception e) { LOGGER.recordMetricEvent (createStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while creating stack with OpenStack", "OpenStack", "CreateStack", vfModuleName); - LOGGER.debug("unhandled exception at heat.createStack"); + LOGGER.debug("unhandled exception at heat.createStack",e); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while creating stack with OpenStack"); throw new VnfException("Exception during heat.createStack! " + e.getMessage()); } } catch (Exception e) { - LOGGER.debug("unhandled exception in create VF"); + LOGGER.debug("unhandled exception in create VF",e); throw new VnfException("Exception during create VF " + e.getMessage()); } finally { @@ -1737,7 +1739,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { minVersionVnf = vnfResource.getAicVersionMin(); maxVersionVnf = vnfResource.getAicVersionMax(); } catch (Exception e) { - LOGGER.debug("Unable to pull min/max version for this VNF Resource entry"); + LOGGER.debug("Unable to pull min/max version for this VNF Resource entry",e); minVersionVnf = null; maxVersionVnf = null; } @@ -1993,12 +1995,12 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { //TODO - what to do here? //for now - send the error to debug, but just leave it as a String String errorMessage = jpe.getMessage(); - LOGGER.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage); + LOGGER.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage,jpe); hasJson = false; jsonNode = null; } catch (Exception e) { // or here? - LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage()); + LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage(),e); hasJson = false; jsonNode = null; } @@ -2015,12 +2017,12 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { //TODO - what to do here? //for now - send the error to debug, but just leave it as a String String errorMessage = jpe.getMessage(); - LOGGER.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage); + LOGGER.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage,jpe); hasJson = false; jsonNode = null; } catch (Exception e) { // or here? - LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage()); + LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage(),e); hasJson = false; jsonNode = null; } @@ -2184,6 +2186,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { try { vfModuleName = vfModuleStackId.substring(0, index); } catch (Exception e) { + LOGGER.debug("Exception", e); vfModuleName = null; } return vfModuleName; diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VnfAdapterRest.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VnfAdapterRest.java index 121ddfe638..21ad1ce490 100644 --- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VnfAdapterRest.java +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VnfAdapterRest.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. @@ -406,6 +407,7 @@ public class VnfAdapterRest { response = new CreateVfModuleResponse(req.getVnfId(), req.getVfModuleId(), vfModuleStackId.value, Boolean.TRUE, outputs.value, modRollback, req.getMessageId()); } catch (VnfException e) { + LOGGER.debug("Exception :",e); eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE, req.getMessageId()); } if (!req.isSynchronous()) { @@ -506,6 +508,7 @@ public class VnfAdapterRest { response = new UpdateVfModuleResponse(req.getVnfId(), req.getVfModuleId(), vfModuleStackId.value, outputs.value, req.getMessageId()); } catch (VnfException e) { + LOGGER.debug("Exception :",e); eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE, req.getMessageId()); } if (!req.isSynchronous()) { diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VolumeAdapterRest.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VolumeAdapterRest.java index 54920f5c6a..d2f1c86fda 100644 --- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VolumeAdapterRest.java +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VolumeAdapterRest.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. @@ -200,6 +201,7 @@ public class VolumeAdapterRest { rb, req.getMessageId()); } catch (VnfException e) { + LOGGER.debug("Exception :",e); eresp = new VolumeGroupExceptionResponse( e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); } @@ -287,6 +289,7 @@ public class VolumeAdapterRest { } response = new DeleteVolumeGroupResponse(true, req.getMessageId()); } catch (VnfException e) { + LOGGER.debug("Exception :",e); eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); } if (!req.isSynchronous()) { @@ -375,6 +378,7 @@ public class VolumeAdapterRest { vnfAdapter.rollbackVnf(vrb); response = new RollbackVolumeGroupResponse(true, req.getMessageId()); } catch (VnfException e) { + LOGGER.debug("Exception :",e); eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); } if (!req.isSynchronous()) { @@ -499,6 +503,7 @@ public class VolumeAdapterRest { req.getVolumeGroupId(), req.getVolumeGroupStackId(), outputs.value, req.getMessageId()); } catch (VnfException e) { + LOGGER.debug("Exception :",e); eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); } if (!req.isSynchronous()) { |