Fix logging and formatting
[dmaap/datarouter.git] / datarouter-prov / src / main / java / org / onap / dmaap / datarouter / provisioning / beans / EgressRoute.java
index 242c105..832b8ed 100644 (file)
@@ -44,13 +44,14 @@ import org.onap.dmaap.datarouter.provisioning.utils.DB;
  * @version $Id: EgressRoute.java,v 1.3 2013/12/16 20:30:23 eby Exp $\r
  */\r
 public class EgressRoute extends NodeClass implements Comparable<EgressRoute> {\r
+\r
     private static Logger intlogger = Logger.getLogger("org.onap.dmaap.datarouter.provisioning.internal");\r
     private final int subid;\r
     private final int nodeid;\r
 \r
     /**\r
-     * Get a set of all Egress Routes in the DB.  The set is sorted according to the natural sorting order\r
-     * of the routes (based on the subscription ID in each route).\r
+     * Get a set of all Egress Routes in the DB.  The set is sorted according to the natural sorting order of the routes\r
+     * (based on the subscription ID in each route).\r
      *\r
      * @return the sorted set\r
      */\r
@@ -60,15 +61,15 @@ public class EgressRoute extends NodeClass implements Comparable<EgressRoute> {
             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 SUBID, NODEID from EGRESS_ROUTES")) {\r
-                   while (rs.next()) {\r
-                       int subid = rs.getInt("SUBID");\r
-                       int nodeid = rs.getInt("NODEID");\r
-                       set.add(new EgressRoute(subid, nodeid));\r
-                   }\r
-               }\r
-           }\r
+            try (Statement stmt = conn.createStatement()) {\r
+                try (ResultSet rs = stmt.executeQuery("select SUBID, NODEID from EGRESS_ROUTES")) {\r
+                    while (rs.next()) {\r
+                        int subid = rs.getInt("SUBID");\r
+                        int nodeid = rs.getInt("NODEID");\r
+                        set.add(new EgressRoute(subid, nodeid));\r
+                    }\r
+                }\r
+            }\r
 \r
             db.release(conn);\r
         } catch (SQLException e) {\r
@@ -93,7 +94,7 @@ public class EgressRoute extends NodeClass implements Comparable<EgressRoute> {
             String sql = "select NODEID from EGRESS_ROUTES where SUBID = ?";\r
             ps = conn.prepareStatement(sql);\r
             ps.setInt(1, sub);\r
-            try(ResultSet rs = ps.executeQuery()) {\r
+            try (ResultSet rs = ps.executeQuery()) {\r
                 if (rs.next()) {\r
                     int node = rs.getInt("NODEID");\r
                     v = new EgressRoute(sub, node);\r
@@ -105,7 +106,7 @@ public class EgressRoute extends NodeClass implements Comparable<EgressRoute> {
             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
@@ -143,7 +144,7 @@ public class EgressRoute extends NodeClass implements Comparable<EgressRoute> {
             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
@@ -168,10 +169,9 @@ public class EgressRoute extends NodeClass implements Comparable<EgressRoute> {
             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
@@ -194,10 +194,9 @@ public class EgressRoute extends NodeClass implements Comparable<EgressRoute> {
         } 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
@@ -221,8 +220,9 @@ public class EgressRoute extends NodeClass implements Comparable<EgressRoute> {
 \r
     @Override\r
     public boolean equals(Object obj) {\r
-        if (!(obj instanceof EgressRoute))\r
+        if (!(obj instanceof EgressRoute)) {\r
             return false;\r
+        }\r
         EgressRoute on = (EgressRoute) obj;\r
         return (subid == on.subid) && (nodeid == on.nodeid);\r
     }\r