Code style cleanup for prov authz and beans
[dmaap/datarouter.git] / datarouter-prov / src / main / java / org / onap / dmaap / datarouter / provisioning / beans / IngressRoute.java
index 1df093d..f1fa54c 100644 (file)
@@ -49,6 +49,7 @@ import org.onap.dmaap.datarouter.provisioning.utils.DB;
  * @author Robert P. Eby\r
  * @version $Id: IngressRoute.java,v 1.3 2013/12/16 20:30:23 eby Exp $\r
  */\r
+\r
 public class IngressRoute extends NodeClass implements Comparable<IngressRoute> {\r
 \r
     private static final String NODESET = "NODESET";\r
@@ -61,6 +62,14 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute>
     private int nodelist;\r
     private SortedSet<String> nodes;\r
 \r
+    /**\r
+     * Ingress route constructor.\r
+     * @param seq squence number\r
+     * @param feedid id for feed\r
+     * @param user user name\r
+     * @param subnet subnet string\r
+     * @param nodes collection of nodes\r
+     */\r
     public IngressRoute(int seq, int feedid, String user, String subnet, Collection<String> nodes) {\r
         this(seq, feedid, user, subnet);\r
         this.nodelist = -1;\r
@@ -91,13 +100,17 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute>
         }\r
     }\r
 \r
+    /**\r
+     * Ingress route constructor.\r
+     * @param jo JSONObject\r
+     */\r
     public IngressRoute(JSONObject jo) {\r
         this.seq = jo.optInt("seq");\r
         this.feedid = jo.optInt("feedid");\r
-        String t = jo.optString("user");\r
-        this.userid = "".equals(t) ? "-" : t;\r
-        t = jo.optString("subnet");\r
-        this.subnet = "".equals(t) ? "-" : t;\r
+        String user = jo.optString("user");\r
+        this.userid = "".equals(user) ? "-" : user;\r
+        user = jo.optString("subnet");\r
+        this.subnet = "".equals(user) ? "-" : user;\r
         this.nodelist = -1;\r
         this.nodes = new TreeSet<>();\r
         JSONArray ja = jo.getJSONArray("node");\r
@@ -200,7 +213,7 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute>
      * @return the Ingress Route, or null of there is none\r
      */\r
     public static IngressRoute getIngressRoute(int feedid, String user, String subnet) {\r
-        IngressRoute v = null;\r
+        IngressRoute ir = null;\r
         DB db = new DB();\r
         String sql = "select SEQUENCE, NODESET from INGRESS_ROUTES where FEEDID = ? AND USERID = ? and SUBNET = ?";\r
         try (Connection conn = db.getConnection();\r
@@ -212,14 +225,14 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute>
                 if (rs.next()) {\r
                     int seq = rs.getInt("SEQUENCE");\r
                     int nodeset = rs.getInt(NODESET);\r
-                    v = new IngressRoute(seq, feedid, user, subnet, nodeset);\r
+                    ir = new IngressRoute(seq, feedid, user, subnet, nodeset);\r
                 }\r
             }\r
             db.release(conn);\r
         } catch (SQLException e) {\r
             intlogger.error("PROV0003 getIngressRoute: " + e.getMessage(), e);\r
         }\r
-        return v;\r
+        return ir;\r
     }\r
 \r
     /**\r
@@ -243,12 +256,12 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute>
             if (credentials == null || !credentials.startsWith("Basic ")) {\r
                 return false;\r
             }\r
-            String t = new String(Base64.decodeBase64(credentials.substring(6)));\r
-            int ix = t.indexOf(':');\r
+            String cred = new String(Base64.decodeBase64(credentials.substring(6)));\r
+            int ix = cred.indexOf(':');\r
             if (ix >= 0) {\r
-                t = t.substring(0, ix);\r
+                cred = cred.substring(0, ix);\r
             }\r
-            if (!t.equals(this.userid)) {\r
+            if (!cred.equals(this.userid)) {\r
                 return false;\r
             }\r
         }\r
@@ -283,8 +296,8 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute>
          * @param subnet The CIDR to match\r
          */\r
         public SubnetMatcher(String subnet) {\r
-            int i = subnet.lastIndexOf('/');\r
-            if (i == -1) {\r
+            int index = subnet.lastIndexOf('/');\r
+            if (index == -1) {\r
                 try {\r
                     sn = InetAddress.getByName(subnet).getAddress();\r
                     len = sn.length;\r
@@ -296,16 +309,16 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute>
                 }\r
                 mask = 0;\r
             } else {\r
-                int n = Integer.parseInt(subnet.substring(i + 1));\r
+                int num = Integer.parseInt(subnet.substring(index + 1));\r
                 try {\r
-                    sn = InetAddress.getByName(subnet.substring(0, i)).getAddress();\r
+                    sn = InetAddress.getByName(subnet.substring(0, index)).getAddress();\r
                     valid = true;\r
                 } catch (UnknownHostException e) {\r
                     intlogger.error("PROV0008 SubnetMatcher: " + e.getMessage(), e);\r
                     valid = false;\r
                 }\r
-                len = n / 8;\r
-                mask = ((0xff00) >> (n % 8)) & 0xff;\r
+                len = num / 8;\r
+                mask = ((0xff00) >> (num % 8)) & 0xff;\r
             }\r
         }\r
 \r
@@ -375,11 +388,11 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute>
      * @return true if the delete succeeded\r
      */\r
     @Override\r
-    public boolean doDelete(Connection c) {\r
+    public boolean doDelete(Connection conn) {\r
         boolean rv = true;\r
-        try (PreparedStatement ps = c.prepareStatement(\r
+        try (PreparedStatement ps = conn.prepareStatement(\r
                  "delete from INGRESS_ROUTES where FEEDID = ? and USERID = ? and SUBNET = ?");\r
-                PreparedStatement ps2 = c.prepareStatement("delete from NODESETS where SETID = ?")) {\r
+                PreparedStatement ps2 = conn.prepareStatement("delete from NODESETS where SETID = ?")) {\r
             // Delete the Ingress Route\r
             ps.setInt(1, feedid);\r
             ps.setString(2, userid);\r
@@ -397,10 +410,10 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute>
     }\r
 \r
     @Override\r
-    public boolean doInsert(Connection c) {\r
+    public boolean doInsert(Connection conn) {\r
         boolean rv = false;\r
-        try (PreparedStatement ps = c.prepareStatement("insert into NODESETS (SETID, NODEID) values (?,?)");\r
-                PreparedStatement ps2 = c.prepareStatement("insert into INGRESS_ROUTES (SEQUENCE, FEEDID, USERID,"\r
+        try (PreparedStatement ps = conn.prepareStatement("insert into NODESETS (SETID, NODEID) values (?,?)");\r
+                PreparedStatement ps2 = conn.prepareStatement("insert into INGRESS_ROUTES (SEQUENCE, FEEDID, USERID,"\r
                         + " SUBNET, NODESET) values (?, ?, ?, ?, ?)")) {\r
             // Create the NODESETS rows & set nodelist\r
             this.nodelist = getMaxNodeSetID() + 1;\r
@@ -425,8 +438,8 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute>
     }\r
 \r
     @Override\r
-    public boolean doUpdate(Connection c) {\r
-        return doDelete(c) && doInsert(c);\r
+    public boolean doUpdate(Connection conn) {\r
+        return doDelete(conn) && doInsert(conn);\r
     }\r
 \r
     @Override\r
@@ -469,21 +482,21 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute>
         if (in == null) {\r
             throw new NullPointerException();\r
         }\r
-        int n = this.feedid - in.feedid;\r
-        if (n != 0) {\r
-            return n;\r
+        int num = this.feedid - in.feedid;\r
+        if (num != 0) {\r
+            return num;\r
         }\r
-        n = this.seq - in.seq;\r
-        if (n != 0) {\r
-            return n;\r
+        num = this.seq - in.seq;\r
+        if (num != 0) {\r
+            return num;\r
         }\r
-        n = this.userid.compareTo(in.userid);\r
-        if (n != 0) {\r
-            return n;\r
+        num = this.userid.compareTo(in.userid);\r
+        if (num != 0) {\r
+            return num;\r
         }\r
-        n = this.subnet.compareTo(in.subnet);\r
-        if (n != 0) {\r
-            return n;\r
+        num = this.subnet.compareTo(in.subnet);\r
+        if (num != 0) {\r
+            return num;\r
         }\r
         return this.nodes.equals(in.nodes) ? 0 : 1;\r
     }\r