From 794e9b58686cc4ec76a80010a47573a3d3514b68 Mon Sep 17 00:00:00 2001 From: seshukm Date: Wed, 13 Sep 2017 14:46:37 +0530 Subject: Sonar defect issues IssueId: SO-118 Change-Id: I19221e6b4c41db7f00201dbc6805e76068bf099e Signed-off-by: seshukm --- .../java/org/openecomp/mso/asdc/client/ASDCController.java | 3 ++- .../org/openecomp/mso/asdc/installer/VfResourceStructure.java | 10 +++++++--- .../mso/asdc/installer/heat/ToscaResourceInstaller.java | 4 ++-- .../java/org/openecomp/mso/asdc/util/NotificationLogging.java | 5 +++++ bpmn/MSOCommonBPMN/pom.xml | 5 +++++ .../java/org/openecomp/mso/bpmn/common/util/CryptoHandler.java | 6 ++++++ .../bpmn/common/workflow/service/AbstractCallbackService.java | 1 + .../mso/bpmn/common/workflow/service/WorkflowResource.java | 7 ++++--- 8 files changed, 32 insertions(+), 9 deletions(-) diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCController.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCController.java index f722be7fd2..3ca8527b05 100644 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCController.java +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCController.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. @@ -397,7 +398,7 @@ public class ASDCController { outFile.write(payloadBytes, 0, payloadBytes.length); outFile.close(); } catch (Exception e) { - e.printStackTrace(); + LOGGER.debug("Exception :",e); LOGGER.error(MessageEnum.ASDC_ARTIFACT_DOWNLOAD_FAIL, artifact.getArtifactName (), artifact.getArtifactURL (), diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfResourceStructure.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfResourceStructure.java index 176f655b3a..70fa7c14be 100644 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfResourceStructure.java +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfResourceStructure.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. @@ -47,11 +48,14 @@ import org.openecomp.mso.db.catalog.beans.ServiceToAllottedResources; import org.openecomp.mso.db.catalog.beans.ServiceToNetworks; import org.openecomp.mso.db.catalog.beans.VnfResource; +import org.openecomp.mso.logger.MsoLogger; /** * This structure exists to avoid having issues if the order of the vfResource/vfmodule artifact is not good (tree structure). * */ public final class VfResourceStructure { + + protected static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.ASDC); private boolean isDeployedSuccessfully=false; /** @@ -231,11 +235,11 @@ public final class VfResourceStructure { return listVFModuleMetaData; } catch (JsonParseException e) { - e.printStackTrace(); + LOGGER.debug("JsonParseException : ",e); } catch (JsonMappingException e) { - e.printStackTrace(); + LOGGER.debug("JsonMappingException : ",e); } catch (IOException e) { - e.printStackTrace(); + LOGGER.debug("IOException : ",e); } return null; } diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/ToscaResourceInstaller.java index 3d3c87f2e8..f9fd9c395d 100644 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/ToscaResourceInstaller.java +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/ToscaResourceInstaller.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. @@ -558,8 +559,7 @@ public class ToscaResourceInstaller {// implements IVfResourceInstaller { vfResourceStructure.setSuccessfulDeployment(); }catch(Exception e){ - System.out.println("Exception" + e.getMessage()); - e.printStackTrace(); + logger.debug("Exception :",e); Throwable dbExceptionToCapture = e; while (!(dbExceptionToCapture instanceof ConstraintViolationException || dbExceptionToCapture instanceof LockAcquisitionException) diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/NotificationLogging.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/NotificationLogging.java index da356bd2c6..9b38a50daf 100644 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/NotificationLogging.java +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/NotificationLogging.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. @@ -33,6 +34,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.openecomp.mso.logger.MsoLogger; import org.openecomp.sdc.api.notification.INotificationData; @@ -40,6 +42,8 @@ public class NotificationLogging implements InvocationHandler { private static Map> objectMethodsToLog = new HashMap<>(); + protected static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.ASDC); + private static InvocationHandler handler = new InvocationHandler() { @Override public Object invoke(Object arg0, Method arg1, Object[] arg2) @@ -93,6 +97,7 @@ public class NotificationLogging implements InvocationHandler { buffer.append(testNull(m.invoke(iNotif, (Object[])null))); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + LOGGER.debug("Exception :"+e); buffer.append("UNREADABLE"); } buffer.append(System.lineSeparator()); diff --git a/bpmn/MSOCommonBPMN/pom.xml b/bpmn/MSOCommonBPMN/pom.xml index 24c881d566..89e5ce24ea 100644 --- a/bpmn/MSOCommonBPMN/pom.xml +++ b/bpmn/MSOCommonBPMN/pom.xml @@ -358,6 +358,11 @@ tests test + + org.openecomp.so + common + ${project.version} + javax.ws.rs javax.ws.rs-api diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/CryptoHandler.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/CryptoHandler.java index 5394ba9601..e938a25fab 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/CryptoHandler.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/CryptoHandler.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. @@ -21,8 +22,10 @@ package org.openecomp.mso.bpmn.common.util; import java.security.GeneralSecurityException; +import org.openecomp.mso.logger.MsoLogger; public class CryptoHandler implements ICryptoHandler { + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); private static String msoKey = "aa3871669d893c7fb8abbcda31b88b4f"; //private static String msoAaiPwd = "mso0206"; @@ -32,6 +35,7 @@ public class CryptoHandler implements ICryptoHandler { try { return CryptoUtils.decrypt(msoAaiEncryptedPwd, msoKey); } catch (GeneralSecurityException e) { + LOGGER.debug("GeneralSecurityException :",e); return null; } } @@ -41,6 +45,7 @@ public class CryptoHandler implements ICryptoHandler { try { return CryptoUtils.encrypt(plainMsoPwd, msoKey); } catch (GeneralSecurityException e) { + LOGGER.debug("GeneralSecurityException :",e); return null; } } @@ -50,6 +55,7 @@ public class CryptoHandler implements ICryptoHandler { try { return CryptoUtils.decrypt(encryptedPwd, msoKey); } catch (GeneralSecurityException e) { + LOGGER.debug("GeneralSecurityException :",e); return null; } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/AbstractCallbackService.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/AbstractCallbackService.java index 49e42acaf6..a4a88597bd 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/AbstractCallbackService.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/AbstractCallbackService.java @@ -76,6 +76,7 @@ public abstract class AbstractCallbackService { logCallbackSuccess(method, startTime); return new CallbackSuccess(); } catch (Exception e) { + LOGGER.debug("Exception :",e); String msg = "Caught " + e.getClass().getSimpleName() + " processing " + messageEventName + " with " + correlationVariable + " = '" + correlationValue + "'"; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResource.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResource.java index 7db4e76ef1..7a537218b3 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResource.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResource.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. @@ -183,8 +184,7 @@ public class WorkflowResource { workflowResponse.setMessageCode(500); return Response.status(500).entity(workflowResponse).build(); } catch (Exception ex) { - msoLogger.debug(LOGMARKER + "Exception in startProcessInstance by key"); - ex.printStackTrace(); + msoLogger.debug(LOGMARKER + "Exception in startProcessInstance by key",ex); workflowResponse.setMessage("Fail" ); workflowResponse.setResponse("Error occurred while executing the process: " + ex.getMessage()); if (processInstance != null) workflowResponse.setProcessInstanceID(processInstance.getId()); @@ -258,6 +258,7 @@ public class WorkflowResource { try { return pes.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult() == null ? true : false ; } catch (Exception e) { + msoLogger.debug("Exception :",e); return true; } } @@ -601,7 +602,7 @@ public class WorkflowResource { + processKey + " with response: " + response.getResponse()); - + msoLogger.debug("Exception :",ex); } msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, -- cgit 1.2.3-korg