Fix logging and formatting fot NetworkRoute 73/69273/1
authoresobmar <mariusz.sobucki@ericsson.com>
Thu, 27 Sep 2018 10:24:27 +0000 (11:24 +0100)
committeresobmar <mariusz.sobucki@ericsson.com>
Thu, 27 Sep 2018 10:24:41 +0000 (11:24 +0100)
Change-Id: I70b2f851a84630ae3ebeb13a00338e13a6921e16
Signed-off-by: Mariusz Sobucki <mariusz.sobucki@ericsson.com>
Issue-ID: DMAAP-775

datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRoute.java

index bad6f53..8264de2 100644 (file)
@@ -44,14 +44,15 @@ import org.onap.dmaap.datarouter.provisioning.utils.DB;
  * @version $Id: NetworkRoute.java,v 1.2 2013/12/16 20:30:23 eby Exp $\r
  */\r
 public class NetworkRoute extends NodeClass implements Comparable<NetworkRoute> {\r
+\r
     private static Logger intlogger = Logger.getLogger("org.onap.dmaap.datarouter.provisioning.internal");\r
     private final int fromnode;\r
     private final int tonode;\r
     private final int vianode;\r
 \r
     /**\r
-     * Get a set of all Network Routes in the DB.  The set is sorted according to the natural sorting order\r
-     * of the routes (based on the from and to node names in each route).\r
+     * Get a set of all Network Routes in the DB.  The set is sorted according to the natural sorting order of the\r
+     * routes (based on the from and to node names in each route).\r
      *\r
      * @return the sorted set\r
      */\r
@@ -61,8 +62,8 @@ public class NetworkRoute extends NodeClass implements Comparable<NetworkRoute>
             DB db = new DB();\r
             @SuppressWarnings("resource")\r
             Connection conn = db.getConnection();\r
-            try(Statement stmt = conn.createStatement()) {\r
-                try(ResultSet rs = stmt.executeQuery("select FROMNODE, TONODE, VIANODE from NETWORK_ROUTES")) {\r
+            try (Statement stmt = conn.createStatement()) {\r
+                try (ResultSet rs = stmt.executeQuery("select FROMNODE, TONODE, VIANODE from NETWORK_ROUTES")) {\r
                     while (rs.next()) {\r
                         int fromnode = rs.getInt("FROMNODE");\r
                         int tonode = rs.getInt("TONODE");\r
@@ -127,10 +128,9 @@ public class NetworkRoute extends NodeClass implements Comparable<NetworkRoute>
         } catch (SQLException e) {\r
             rv = false;\r
             intlogger.warn("PROV0007 doDelete: " + e.getMessage());\r
-            intlogger.error("SQLException " + e.getMessage());\r
         } finally {\r
             try {\r
-                if(ps!=null) {\r
+                if (ps != null) {\r
                     ps.close();\r
                 }\r
             } catch (SQLException e) {\r
@@ -157,10 +157,9 @@ public class NetworkRoute extends NodeClass implements Comparable<NetworkRoute>
                 rv = true;\r
             } catch (SQLException e) {\r
                 intlogger.warn("PROV0005 doInsert: " + e.getMessage());\r
-                intlogger.error("SQLException " + e.getMessage());\r
             } finally {\r
                 try {\r
-                    if(ps!=null) {\r
+                    if (ps != null) {\r
                         ps.close();\r
                     }\r
                 } catch (SQLException e) {\r
@@ -185,10 +184,9 @@ public class NetworkRoute extends NodeClass implements Comparable<NetworkRoute>
         } catch (SQLException e) {\r
             rv = false;\r
             intlogger.warn("PROV0006 doUpdate: " + e.getMessage());\r
-            intlogger.error("SQLException " + e.getMessage());\r
         } finally {\r
             try {\r
-                if(ps!=null) {\r
+                if (ps != null) {\r
                     ps.close();\r
                 }\r
             } catch (SQLException e) {\r
@@ -214,8 +212,9 @@ public class NetworkRoute extends NodeClass implements Comparable<NetworkRoute>
 \r
     @Override\r
     public boolean equals(Object obj) {\r
-        if (!(obj instanceof NetworkRoute))\r
+        if (!(obj instanceof NetworkRoute)) {\r
             return false;\r
+        }\r
         NetworkRoute on = (NetworkRoute) obj;\r
         return (fromnode == on.fromnode) && (tonode == on.tonode) && (vianode == on.vianode);\r
     }\r
@@ -228,8 +227,9 @@ public class NetworkRoute extends NodeClass implements Comparable<NetworkRoute>
     @Override\r
     public int compareTo(NetworkRoute o) {\r
         if (this.fromnode == o.fromnode) {\r
-            if (this.tonode == o.tonode)\r
+            if (this.tonode == o.tonode) {\r
                 return this.vianode - o.vianode;\r
+            }\r
             return this.tonode - o.tonode;\r
         }\r
         return this.fromnode - o.fromnode;\r