aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOURN-plugin
diff options
context:
space:
mode:
authorSeshu-Kumar-M <seshu.kumar.m@huawei.com>2017-09-05 19:02:54 +0800
committerSeshu-Kumar-M <seshu.kumar.m@huawei.com>2017-09-06 10:09:44 +0530
commitc8961a6aa9a7315b3fb19edd9ce986e87d910a44 (patch)
treee7f22856258eb2a1b923db775510eb063558f84f /bpmn/MSOURN-plugin
parentafa4c6f233365bf1ad794111a0c4dd177c4254b2 (diff)
Sonar critical issues fix
Issue-Id : SO-98 Change-Id: I229819e850c36fce9f8715d1534f8e5c5d812a0a Signed-off-by: Seshu-Kumar-M <seshu.kumar.m@huawei.com>
Diffstat (limited to 'bpmn/MSOURN-plugin')
-rw-r--r--bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/URNMapPlugin.java7
-rw-r--r--bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/resources/URNResource.java89
2 files changed, 67 insertions, 29 deletions
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);
+ }
+ }
}
}