From 9730517e01a5c8d866f6c0d8e9051a92ccf29dd6 Mon Sep 17 00:00:00 2001 From: econwar Date: Thu, 9 May 2019 12:52:29 +0000 Subject: Remove critical code smells Bean classes Change-Id: Ia39f58c8b4dd6c0fd15e022aee126f6524aec175 Issue-ID: DMAAP-1195 Signed-off-by: econwar --- .../datarouter/provisioning/beans/EgressRoute.java | 26 ++++++++-------- .../dmaap/datarouter/provisioning/beans/Feed.java | 35 +++++++++++----------- .../dmaap/datarouter/provisioning/beans/Group.java | 24 ++++++++------- .../provisioning/beans/IngressRoute.java | 34 ++++++++++----------- .../datarouter/provisioning/beans/LogRecord.java | 2 +- .../provisioning/beans/NetworkRoute.java | 25 ++++++++-------- .../datarouter/provisioning/beans/Parameters.java | 17 ++++++----- .../provisioning/beans/Subscription.java | 27 +++++++++-------- 8 files changed, 97 insertions(+), 93 deletions(-) (limited to 'datarouter-prov') diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRoute.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRoute.java index 12135969..e766e704 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRoute.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRoute.java @@ -47,6 +47,7 @@ import org.onap.dmaap.datarouter.provisioning.utils.DB; public class EgressRoute extends NodeClass implements Comparable { private static EELFLogger intlogger = EELFManager.getInstance().getLogger("InternalLog"); + private static final String SQLEXCEPTION = "SQLException: "; private final int subid; private final int nodeid; @@ -57,7 +58,7 @@ public class EgressRoute extends NodeClass implements Comparable { * @return the sorted set */ public static SortedSet getAllEgressRoutes() { - SortedSet set = new TreeSet(); + SortedSet set = new TreeSet<>(); try { DB db = new DB(); @SuppressWarnings("resource") @@ -74,7 +75,7 @@ public class EgressRoute extends NodeClass implements Comparable { db.release(conn); } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error("PROV0008 EgressRoute.getAllEgressRoutes: " + e.getMessage(), e); } return set; } @@ -104,20 +105,20 @@ public class EgressRoute extends NodeClass implements Comparable { ps.close(); db.release(conn); } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error("PROV0009 EgressRoute.getEgressRoute: " + e.getMessage(), e); } finally { try { if (ps != null) { ps.close(); } } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage(), e); } } return v; } - public EgressRoute(int subid, int nodeid) throws IllegalArgumentException { + public EgressRoute(int subid, int nodeid) { this.subid = subid; this.nodeid = nodeid; // Note: unlike for Feeds, it subscriptions can be removed from the tables, so it is @@ -126,7 +127,7 @@ public class EgressRoute extends NodeClass implements Comparable { // throw new IllegalArgumentException("No such subscription: "+subid); } - public EgressRoute(int subid, String node) throws IllegalArgumentException { + public EgressRoute(int subid, String node) { this(subid, lookupNodeName(node)); } @@ -141,15 +142,14 @@ public class EgressRoute extends NodeClass implements Comparable { ps.execute(); } catch (SQLException e) { rv = false; - intlogger.warn("PROV0007 doDelete: " + e.getMessage()); - intlogger.error("SQLException " + e.getMessage()); + intlogger.error("PROV0007 doDelete: " + e.getMessage(), e); } finally { try { if (ps != null) { ps.close(); } } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage(), e); } } return rv; @@ -169,14 +169,14 @@ public class EgressRoute extends NodeClass implements Comparable { ps.close(); rv = true; } catch (SQLException e) { - intlogger.warn("PROV0005 doInsert: " + e.getMessage()); + intlogger.warn("PROV0005 doInsert: " + e.getMessage(), e); } finally { try { if (ps != null) { ps.close(); } } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage(), e); } } return rv; @@ -194,14 +194,14 @@ public class EgressRoute extends NodeClass implements Comparable { ps.executeUpdate(); } catch (SQLException e) { rv = false; - intlogger.warn("PROV0006 doUpdate: " + e.getMessage()); + intlogger.warn("PROV0006 doUpdate: " + e.getMessage(), e); } finally { try { if (ps != null) { ps.close(); } } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage(), e); } } return rv; diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java index 506821e2..cab4d3d2 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java @@ -47,6 +47,7 @@ import java.util.*; public class Feed extends Syncable { private static EELFLogger intlogger = EELFManager.getInstance().getLogger("InternalLog"); private static int next_feedid = getMaxFeedID() + 1; + private static final String SQLEXCEPTION = "SQLException: "; private int feedid; private int groupid; //New field is added - Groups feature Rally:US708115 - 1610 @@ -85,7 +86,7 @@ public class Feed extends Syncable { } db.release(conn); } catch (SQLException e) { - intlogger.warn("PROV0024 Feed.isFeedValid: ", e.getMessage()); + intlogger.warn("PROV0024 Feed.isFeedValid: " + e.getMessage(), e); } return count != 0; } @@ -135,7 +136,7 @@ public class Feed extends Syncable { } db.release(conn); } catch (SQLException e) { - intlogger.warn("PROV0025 Feed.countActiveFeeds: ", e.getMessage()); + intlogger.warn("PROV0025 Feed.countActiveFeeds: " + e.getMessage(), e); } return count; } @@ -155,7 +156,7 @@ public class Feed extends Syncable { } db.release(conn); } catch (SQLException e) { - intlogger.warn("PROV0026 Feed.getMaxFeedID: ", e.getMessage()); + intlogger.warn("PROV0026 Feed.getMaxFeedID: " + e.getMessage(), e); } return max; } @@ -201,7 +202,7 @@ public class Feed extends Syncable { } db.release(conn); } catch (SQLException e) { - intlogger.warn("PROV0027 Feed.getAllFeeds: ", e.getMessage()); + intlogger.warn("PROV0027 Feed.getAllFeeds: " + e.getMessage(), e); } return map.values(); } @@ -235,7 +236,7 @@ public class Feed extends Syncable { } db.release(conn); } catch (SQLException e) { - intlogger.warn("PROV0028 Feed.getFilteredFeedUrlList: ", e.getMessage()); + intlogger.warn("PROV0028 Feed.getFilteredFeedUrlList: " + e.getMessage(), e); } return list; } @@ -272,7 +273,7 @@ public class Feed extends Syncable { } db.release(conn); } catch (SQLException e) { - intlogger.warn("PROV0029 Feed.getFeedBySQL: ", e.getMessage()); + intlogger.warn("PROV0029 Feed.getFeedBySQL: " + e.getMessage(), e); } return feed; } @@ -338,6 +339,7 @@ public class Feed extends Syncable { try { this.version = jo.getString("version"); } catch (JSONException e) { + intlogger.warn("PROV0023 Feed.Feed: " + e.getMessage(), e); this.version = null; } if(version != null && version.length() > 20) @@ -379,11 +381,10 @@ public class Feed extends Syncable { JSONObject jol = jo.optJSONObject("links"); this.links = (jol == null) ? (new FeedLinks()) : (new FeedLinks(jol)); } catch (InvalidObjectException e) { - intlogger.warn("PROV0030 Feed.Feed: ", e.getMessage()); throw e; } catch (Exception e) { - intlogger.error("PROV0031 Feed.Feed: invalid JSON: "+e); - throw new InvalidObjectException("invalid JSON: " + e.getMessage()); + intlogger.warn("Invalid JSON: " + e.getMessage(), e); + throw new InvalidObjectException("Invalid JSON: " + e.getMessage()); } } @@ -555,15 +556,14 @@ public class Feed extends Syncable { ps.execute(); } catch (SQLException e) { rv = false; - intlogger.warn("PROV0007 doDelete: " + e.getMessage()); - intlogger.error("SQLException " + e.getMessage()); + intlogger.error("PROV0007 doDelete: " + e.getMessage(), e); } finally { try { if(ps!=null) { ps.close(); } } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage(), e); } } return rv; @@ -624,8 +624,7 @@ public class Feed extends Syncable { } } catch (SQLException e) { rv = false; - intlogger.warn("PROV0005 doInsert: " + e.getMessage()); - intlogger.error("SQLException " + e.getMessage()); + intlogger.error("PROV0005 doInsert: " + e.getMessage(), e); } return rv; } @@ -705,13 +704,13 @@ public class Feed extends Syncable { ps.close(); } catch (SQLException e) { rv = false; - intlogger.warn("PROV0006 doUpdate: " + e.getMessage()); + intlogger.warn("PROV0006 doUpdate: " + e.getMessage(), e); } finally { try { if (ps != null) ps.close(); } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage(), e); } } return rv; @@ -737,14 +736,14 @@ public class Feed extends Syncable { ps.close(); } catch (SQLException e) { rv = false; - intlogger.warn("PROV0006 doUpdate: " + e.getMessage()); + intlogger.warn("PROV0008 changeOwnerShip: " + e.getMessage(), e); } finally { try { if(ps!=null) { ps.close(); } } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage(), e); } } return rv; diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Group.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Group.java index 8904765a..be4c6409 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Group.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Group.java @@ -46,6 +46,7 @@ public class Group extends Syncable { private static EELFLogger intlogger = EELFManager.getInstance().getLogger("InternalLog"); private static int next_groupid = getMaxGroupID() + 1; + private static final String SQLEXCEPTION = "SQLException: "; private int groupid; private String authid; @@ -107,7 +108,7 @@ public class Group extends Syncable { } db.release(conn); } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error("PROV0009 getGroupsForSQL: " + e.getMessage(), e); } return list; } @@ -127,7 +128,7 @@ public class Group extends Syncable { } db.release(conn); } catch (SQLException e) { - intlogger.info("getMaxSubID: " + e.getMessage()); + intlogger.info("PROV0001 getMaxSubID: " + e.getMessage(), e); } return max; } @@ -150,7 +151,7 @@ public class Group extends Syncable { } db.release(conn); } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error("PROV0002 getGroupsByClassfication: " + e.getMessage(), e); } return list; } @@ -175,7 +176,7 @@ public class Group extends Syncable { } db.release(conn); } catch (SQLException e) { - intlogger.warn("PROV0008 countActiveSubscriptions: " + e.getMessage()); + intlogger.warn("PROV0008 countActiveSubscriptions: " + e.getMessage(), e); } return count; } @@ -229,7 +230,8 @@ public class Group extends Syncable { } catch (InvalidObjectException e) { throw e; } catch (Exception e) { - throw new InvalidObjectException("invalid JSON: " + e.getMessage()); + intlogger.warn("Invalid JSON: " + e.getMessage(), e); + throw new InvalidObjectException("Invalid JSON: " + e.getMessage()); } } @@ -346,14 +348,14 @@ public class Group extends Syncable { ps.close(); } catch (SQLException e) { rv = false; - intlogger.warn("PROV0005 doInsert: " + e.getMessage()); + intlogger.warn("PROV0005 doInsert: " + e.getMessage(), e); } finally { try { if (ps != null) { ps.close(); } } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage(), e); } } return rv; @@ -375,14 +377,14 @@ public class Group extends Syncable { ps.executeUpdate(); } catch (SQLException e) { rv = false; - intlogger.warn("PROV0006 doUpdate: " + e.getMessage()); + intlogger.warn("PROV0006 doUpdate: " + e.getMessage(), e); } finally { try { if (ps != null) { ps.close(); } } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage(), e); } } return rv; @@ -399,14 +401,14 @@ public class Group extends Syncable { ps.execute(); } catch (SQLException e) { rv = false; - intlogger.warn("PROV0007 doDelete: " + e.getMessage()); + intlogger.warn("PROV0007 doDelete: " + e.getMessage(), e); } finally { try { if (ps != null) { ps.close(); } } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage(), e); } } return rv; diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRoute.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRoute.java index bbed37a3..4332d7d7 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRoute.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRoute.java @@ -55,6 +55,7 @@ import org.onap.dmaap.datarouter.provisioning.utils.DB; public class IngressRoute extends NodeClass implements Comparable { private static EELFLogger intlogger = EELFManager.getInstance().getLogger("InternalLog"); + private static final String SQLEXCEPTION = "SQLException: "; private final int seq; private final int feedid; private final String userid; @@ -102,7 +103,7 @@ public class IngressRoute extends NodeClass implements Comparable } db.release(conn); } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error("PROV0001 getAllIngressRoutesForSQL: " + e.getMessage(), e); } return set; } @@ -140,7 +141,7 @@ public class IngressRoute extends NodeClass implements Comparable } db.release(conn); } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error("PROV0002 getMax: " + e.getMessage(), e); } return rv; } @@ -175,14 +176,14 @@ public class IngressRoute extends NodeClass implements Comparable ps.close(); db.release(conn); } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error("PROV0003 getIngressRoute: " + e.getMessage(), e); } finally { try { if (ps != null) { ps.close(); } } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage(), e); } } return v; @@ -215,7 +216,7 @@ public class IngressRoute extends NodeClass implements Comparable } db.release(conn); } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error("PROV0004 getIngressRoute: " + e.getMessage(), e); } return rv; } @@ -307,6 +308,7 @@ public class IngressRoute extends NodeClass implements Comparable SubnetMatcher sm = new SubnetMatcher(subnet); return sm.matches(inet.getAddress()); } catch (UnknownHostException e) { + intlogger.error("PROV0008 matches: " + e.getMessage(), e); return false; } } @@ -337,6 +339,7 @@ public class IngressRoute extends NodeClass implements Comparable len = sn.length; valid = true; } catch (UnknownHostException e) { + intlogger.error("PROV0008 SubnetMatcher: " + e.getMessage(), e); len = 0; valid = false; } @@ -347,6 +350,7 @@ public class IngressRoute extends NodeClass implements Comparable sn = InetAddress.getByName(subnet.substring(0, i)).getAddress(); valid = true; } catch (UnknownHostException e) { + intlogger.error("PROV0008 SubnetMatcher: " + e.getMessage(), e); valid = false; } len = n / 8; @@ -390,7 +394,7 @@ public class IngressRoute extends NodeClass implements Comparable } private Collection readNodes() { - Collection set = new TreeSet(); + Collection set = new TreeSet<>(); try { DB db = new DB(); @SuppressWarnings("resource") @@ -407,7 +411,7 @@ public class IngressRoute extends NodeClass implements Comparable } db.release(conn); } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage(), e); } return set; } @@ -434,14 +438,14 @@ public class IngressRoute extends NodeClass implements Comparable ps.execute(); } catch (SQLException e) { rv = false; - intlogger.warn("PROV0007 doDelete: " + e.getMessage()); + intlogger.warn("PROV0007 doDelete: " + e.getMessage(), e); } finally { try { if (ps != null) { ps.close(); } } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage(), e); } } return rv; @@ -477,14 +481,14 @@ public class IngressRoute extends NodeClass implements Comparable ps.close(); rv = true; } catch (SQLException e) { - intlogger.warn("PROV0005 doInsert: " + e.getMessage()); + intlogger.warn("PROV0005 doInsert: " + e.getMessage(), e); } finally { try { if (ps != null) { ps.close(); } } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage(), e); } } return rv; @@ -524,14 +528,10 @@ public class IngressRoute extends NodeClass implements Comparable @Override public boolean equals(Object obj) { - try { - if (!(obj instanceof IngressRoute)) { - return false; - } - return this.compareTo((IngressRoute) obj) == 0; - } catch (NullPointerException e) { + if (!(obj instanceof IngressRoute)) { return false; } + return this.compareTo((IngressRoute) obj) == 0; } @Override diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecord.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecord.java index 86d1faea..cbddbf43 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecord.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecord.java @@ -77,7 +77,7 @@ public class LogRecord extends BaseLogRecord { } } } catch (SQLException e) { - intlogger.error("SQLException: " + e.getMessage()); + intlogger.error("PROV0001 printLogRecords: " + e.getMessage(), e); } } diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRoute.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRoute.java index 94eeec4a..eeca0903 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRoute.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRoute.java @@ -47,6 +47,7 @@ import org.onap.dmaap.datarouter.provisioning.utils.DB; public class NetworkRoute extends NodeClass implements Comparable { private static EELFLogger intlogger = EELFManager.getInstance().getLogger("InternalLog"); + private static final String SQLEXCEPTION = "SQLException: "; private final int fromnode; private final int tonode; private final int vianode; @@ -58,7 +59,7 @@ public class NetworkRoute extends NodeClass implements Comparable * @return the sorted set */ public static SortedSet getAllNetworkRoutes() { - SortedSet set = new TreeSet(); + SortedSet set = new TreeSet<>(); try { DB db = new DB(); @SuppressWarnings("resource") @@ -75,30 +76,30 @@ public class NetworkRoute extends NodeClass implements Comparable } db.release(conn); } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage(), e); } return set; } - public NetworkRoute(String fromnode, String tonode) throws IllegalArgumentException { + public NetworkRoute(String fromnode, String tonode) { this.fromnode = lookupNodeName(fromnode); this.tonode = lookupNodeName(tonode); this.vianode = -1; } - public NetworkRoute(String fromnode, String tonode, String vianode) throws IllegalArgumentException { + public NetworkRoute(String fromnode, String tonode, String vianode) { this.fromnode = lookupNodeName(fromnode); this.tonode = lookupNodeName(tonode); this.vianode = lookupNodeName(vianode); } - public NetworkRoute(JSONObject jo) throws IllegalArgumentException { + public NetworkRoute(JSONObject jo) { this.fromnode = lookupNodeName(jo.getString("from")); this.tonode = lookupNodeName(jo.getString("to")); this.vianode = lookupNodeName(jo.getString("via")); } - public NetworkRoute(int fromnode, int tonode, int vianode) throws IllegalArgumentException { + public NetworkRoute(int fromnode, int tonode, int vianode) { this.fromnode = fromnode; this.tonode = tonode; this.vianode = vianode; @@ -128,14 +129,14 @@ public class NetworkRoute extends NodeClass implements Comparable ps.execute(); } catch (SQLException e) { rv = false; - intlogger.warn("PROV0007 doDelete: " + e.getMessage()); + intlogger.warn("PROV0007 doDelete: " + e.getMessage(), e); } finally { try { if (ps != null) { ps.close(); } } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage(), e); } } return rv; @@ -157,14 +158,14 @@ public class NetworkRoute extends NodeClass implements Comparable ps.close(); rv = true; } catch (SQLException e) { - intlogger.warn("PROV0005 doInsert: " + e.getMessage()); + intlogger.warn("PROV0005 doInsert: " + e.getMessage(), e); } finally { try { if (ps != null) { ps.close(); } } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage(), e); } } } @@ -184,14 +185,14 @@ public class NetworkRoute extends NodeClass implements Comparable ps.executeUpdate(); } catch (SQLException e) { rv = false; - intlogger.warn("PROV0006 doUpdate: " + e.getMessage()); + intlogger.warn("PROV0006 doUpdate: " + e.getMessage(), e); } finally { try { if (ps != null) { ps.close(); } } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage(), e); } } return rv; diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Parameters.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Parameters.java index 08914868..fff10ac7 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Parameters.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Parameters.java @@ -69,6 +69,7 @@ public class Parameters extends Syncable { public static final String STATIC_ROUTING_NODES = "STATIC_ROUTING_NODES"; //Adding new param for static Routing - Rally:US664862-1610 private static EELFLogger intlogger = EELFManager.getInstance().getLogger("InternalLog"); + private static final String SQLEXCEPTION = "SQLException: "; private String keyname; private String value; @@ -103,7 +104,7 @@ public class Parameters extends Syncable { } db.release(conn); } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage()); } return coll; } @@ -131,7 +132,7 @@ public class Parameters extends Syncable { } db.release(conn); } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage()); } return v; } @@ -187,14 +188,14 @@ public class Parameters extends Syncable { ps.execute(); } catch (SQLException e) { rv = false; - intlogger.warn("PROV0005 doInsert: " + e.getMessage()); + intlogger.warn("PROV0005 doInsert: " + e.getMessage(), e); } finally { try { if (ps != null) { ps.close(); } } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage()); } } return rv; @@ -213,14 +214,14 @@ public class Parameters extends Syncable { ps.executeUpdate(); } catch (SQLException e) { rv = false; - intlogger.warn("PROV0006 doUpdate: " + e.getMessage()); + intlogger.warn("PROV0006 doUpdate: " + e.getMessage(),e); } finally { try { if (ps != null) { ps.close(); } } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage(), e); } } return rv; @@ -238,14 +239,14 @@ public class Parameters extends Syncable { ps.execute(); } catch (SQLException e) { rv = false; - intlogger.warn("PROV0007 doDelete: " + e.getMessage()); + intlogger.warn("PROV0007 doDelete: " + e.getMessage(), e); } finally { try { if (ps != null) { ps.close(); } } catch (SQLException e) { - intlogger.error("SQLException " + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage(), e); } } return rv; diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Subscription.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Subscription.java index 442a7642..c12d83d3 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Subscription.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Subscription.java @@ -117,7 +117,7 @@ public class Subscription extends Syncable { } db.release(conn); } catch (SQLException e) { - intlogger.error(e.toString()); + intlogger.error("PROV0001 getSubscriptionsForSQL: " + e.toString(), e); } return list; } @@ -137,7 +137,7 @@ public class Subscription extends Syncable { } db.release(conn); } catch (SQLException e) { - intlogger.info("getMaxSubID: " + e.getMessage()); + intlogger.info("getMaxSubID: " + e.getMessage(), e); } return max; } @@ -161,7 +161,7 @@ public class Subscription extends Syncable { } db.release(conn); } catch (SQLException e) { - intlogger.error(SQLEXCEPTION + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage(), e); } return list; } @@ -186,7 +186,7 @@ public class Subscription extends Syncable { } db.release(conn); } catch (SQLException e) { - intlogger.warn("PROV0008 countActiveSubscriptions: " + e.getMessage()); + intlogger.warn("PROV0008 countActiveSubscriptions: " + e.getMessage(), e); } return count; } @@ -274,7 +274,8 @@ public class Subscription extends Syncable { } catch (InvalidObjectException e) { throw e; } catch (Exception e) { - throw new InvalidObjectException("invalid JSON: " + e.getMessage()); + intlogger.warn("Invalid JSON: " + e.getMessage(), e); + throw new InvalidObjectException("Invalid JSON: " + e.getMessage()); } } @@ -474,14 +475,14 @@ public class Subscription extends Syncable { ps.close(); } catch (SQLException e) { rv = false; - intlogger.warn("PROV0005 doInsert: " + e.getMessage()); + intlogger.warn("PROV0005 doInsert: " + e.getMessage(), e); } finally { try { if (ps != null) { ps.close(); } } catch (SQLException e) { - intlogger.error(SQLEXCEPTION + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage(), e); } } return rv; @@ -508,14 +509,14 @@ public class Subscription extends Syncable { ps.executeUpdate(); } catch (SQLException e) { rv = false; - intlogger.warn("PROV0006 doUpdate: " + e.getMessage()); + intlogger.warn("PROV0006 doUpdate: " + e.getMessage(), e); } finally { try { if (ps != null) { ps.close(); } } catch (SQLException e) { - intlogger.error(SQLEXCEPTION + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage(), e); } } return rv; @@ -541,14 +542,14 @@ public class Subscription extends Syncable { ps.close(); } catch (SQLException e) { rv = false; - intlogger.warn("PROV0006 doUpdate: " + e.getMessage()); + intlogger.warn("PROV0006 doUpdate: " + e.getMessage(), e); } finally { try { if (ps != null) { ps.close(); } } catch (SQLException e) { - intlogger.error(SQLEXCEPTION + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage(), e); } } return rv; @@ -566,14 +567,14 @@ public class Subscription extends Syncable { ps.execute(); } catch (SQLException e) { rv = false; - intlogger.warn("PROV0007 doDelete: " + e.getMessage()); + intlogger.warn("PROV0007 doDelete: " + e.getMessage(), e); } finally { try { if (ps != null) { ps.close(); } } catch (SQLException e) { - intlogger.error(SQLEXCEPTION + e.getMessage()); + intlogger.error(SQLEXCEPTION + e.getMessage(), e); } } return rv; -- cgit 1.2.3-korg