diff options
author | Seshu-Kumar-M <seshu.kumar.m@huawei.com> | 2017-09-05 19:02:54 +0800 |
---|---|---|
committer | Seshu-Kumar-M <seshu.kumar.m@huawei.com> | 2017-09-06 10:09:44 +0530 |
commit | c8961a6aa9a7315b3fb19edd9ce986e87d910a44 (patch) | |
tree | e7f22856258eb2a1b923db775510eb063558f84f | |
parent | afa4c6f233365bf1ad794111a0c4dd177c4254b2 (diff) |
Sonar critical issues fix
Issue-Id : SO-98
Change-Id: I229819e850c36fce9f8715d1534f8e5c5d812a0a
Signed-off-by: Seshu-Kumar-M <seshu.kumar.m@huawei.com>
4 files changed, 74 insertions, 34 deletions
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/LoggingAndURNMappingPlugin.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/LoggingAndURNMappingPlugin.java index 2453700bce..26885132df 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/LoggingAndURNMappingPlugin.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/LoggingAndURNMappingPlugin.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * OPENECOMP - MSO + * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ @@ -412,7 +412,7 @@ public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { } } } catch(Exception e) { - // Do nothing + LOGGER.debug("Exception at notify: " + e); } } } diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java index 42114758b0..ac0c795d7a 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * OPENECOMP - MSO + * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ @@ -46,6 +46,7 @@ import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; +import org.openecomp.mso.logger.MsoLogger; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -58,7 +59,7 @@ import org.xml.sax.SAXException; public final class XmlTool { private static final Map<String, Integer> ENTITIES = new HashMap<String, Integer>(); - + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.BPEL); static { ENTITIES.put("amp", new Integer(38)); ENTITIES.put("quot", new Integer(34)); @@ -276,6 +277,7 @@ public final class XmlTool { */ public static String removeNamespaces(Object xml) { if (xml == null) { + LOGGER.debug("removeNamespaces input object is null , returning null"); return null; } @@ -326,7 +328,7 @@ public final class XmlTool { try { stream.close(); } catch (Exception e) { - // Ignore + LOGGER.debug("Exception at readResourceFile close stream: " + e); } } } diff --git a/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/URNMapPlugin.java b/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/URNMapPlugin.java index 09fdc1c85e..4f6ead0299 100644 --- a/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/URNMapPlugin.java +++ b/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/URNMapPlugin.java @@ -1,6 +1,6 @@ /*-
* ============LICENSE_START=======================================================
- * OPENECOMP - MSO
+ * ONAP - SO
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -32,14 +32,15 @@ import org.openecomp.camunda.bpmn.plugin.urnmap.resources.URNMapPluginRootResour public class URNMapPlugin extends AbstractCockpitPlugin{
public static final String ID = "urnMap-plugin";
-
+
+ @Override
public String getId() {
return ID;
}
@Override
public Set<Class<?>> getResourceClasses() {
- Set<Class<?>> classes = new HashSet<Class<?>>();
+ Set<Class<?>> classes = new HashSet<>();
classes.add(URNMapPluginRootResource.class);
diff --git a/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/resources/URNResource.java b/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/resources/URNResource.java index 3dc6c249f5..5ef77eec40 100644 --- a/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/resources/URNResource.java +++ b/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/resources/URNResource.java @@ -1,6 +1,6 @@ /*-
* ============LICENSE_START=======================================================
- * OPENECOMP - MSO
+ * ONAP - SO
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -28,6 +28,7 @@ import java.sql.SQLException; import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
+import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
@@ -60,11 +61,11 @@ public class URNResource extends AbstractCockpitPluginResource{ public List<URNData> getUrnDataMap()
{
List<URNData> list = new ArrayList();
-
+ PreparedStatement psData = null;
try {
conn = getDBConnection();
- PreparedStatement psData = conn
+ psData = conn
.prepareStatement("select * from MSO_URN_MAPPING order by NAME_");
ResultSet r = psData.executeQuery();
@@ -79,13 +80,25 @@ public class URNResource extends AbstractCockpitPluginResource{ list.add(d);
}
- psData.close();
- conn.close();
-
} catch (Exception e)
{
-
- e.printStackTrace();
+ msoLogger.debug("Exception in getUrnDataMap " + e);
+ } finally {
+ if(psData != null){
+ try {
+ psData.close();
+ conn.close();
+ } catch (SQLException e) {
+ msoLogger.debug("Exception while closing the PreparedStatement: " + e);
+ }
+ }
+ if(conn != null){
+ try {
+ conn.close();
+ } catch (SQLException e) {
+ msoLogger.debug("Exception while closing the connection: " + e);
+ }
+ }
}
for(URNData d: list)
@@ -130,8 +143,7 @@ public class URNResource extends AbstractCockpitPluginResource{ } catch (Exception e)
{
-
- e.printStackTrace();
+ msoLogger.debug("Exception in DBConnection " + e);
}
return conn;
@@ -158,24 +170,36 @@ public class URNResource extends AbstractCockpitPluginResource{ nRow.setVer_("1");
final String myKey = key_;
final String myValue = value_;
-
+ PreparedStatement psData = null;
+
msoLogger.debug("----------- START ----------------------");
try {
conn = getDBConnection();
- PreparedStatement psData = conn
+ psData = conn
.prepareStatement("Insert into MSO_URN_MAPPING values ('" + key_ + "', '" + value_ + "', '1')");
- psData.executeUpdate();
-
- psData.close();
- conn.close();
- //}
+ psData.executeUpdate();
} catch (Exception e)
{
-
- e.printStackTrace();
+ msoLogger.debug("Exception in insertNewRow " + e);
+ }finally {
+ if(psData != null){
+ try {
+ psData.close();
+ conn.close();
+ } catch (SQLException e) {
+ msoLogger.debug("Exception while closing the PreparedStatement: " + e);
+ }
+ }
+ if(conn != null){
+ try {
+ conn.close();
+ } catch (SQLException e) {
+ msoLogger.debug("Exception while closing the connection: " + e);
+ }
+ }
}
// getQueryService().executeQuery("cockpit.urnMap.insertNewRow", nRow, URNData.class);
}
@@ -184,21 +208,34 @@ public class URNResource extends AbstractCockpitPluginResource{ public void getPersistData(URNData d) {
//getQueryService().executeQuery("cockpit.urnMap.persistURNData", d, URNData.class);
-
+ PreparedStatement psData = null;
try {
conn = getDBConnection();
- PreparedStatement psData = conn
+ psData = conn
.prepareStatement("UPDATE MSO_URN_MAPPING set VALUE_ ='"+ d.getURNValue() + "' WHERE NAME_='" + d.getURNName() + "'");
psData.executeUpdate();
-
- psData.close();
- conn.close();
+
} catch (Exception e)
{
-
- e.printStackTrace();
+ msoLogger.debug("Exception in PersistData " + e);
+ }finally {
+ if(psData != null){
+ try {
+ psData.close();
+ conn.close();
+ } catch (SQLException e) {
+ msoLogger.debug("Exception while closing the PreparedStatement: " + e);
+ }
+ }
+ if(conn != null){
+ try {
+ conn.close();
+ } catch (SQLException e) {
+ msoLogger.debug("Exception while closing the connection: " + e);
+ }
+ }
}
}
|