- /**\r
- * Get a collection of all Ingress Routes with a particular sequence number.\r
- *\r
- * @param seq the sequence number to look for\r
- * @return the collection (may be empty).\r
- */\r
- public static Collection<IngressRoute> getIngressRoute(int seq) {\r
- Collection<IngressRoute> rv = new ArrayList<IngressRoute>();\r
- try {\r
- DB db = new DB();\r
- @SuppressWarnings("resource")\r
- Connection conn = db.getConnection();\r
- String sql = "select FEEDID, USERID, SUBNET, NODESET from INGRESS_ROUTES where SEQUENCE = ?";\r
- try (PreparedStatement ps = conn.prepareStatement(sql)) {\r
- ps.setInt(1, seq);\r
- try (ResultSet rs = ps.executeQuery()) {\r
- while (rs.next()) {\r
- int feedid = rs.getInt("FEEDID");\r
- String user = rs.getString("USERID");\r
- String subnet = rs.getString("SUBNET");\r
- int nodeset = rs.getInt("NODESET");\r
- rv.add(new IngressRoute(seq, feedid, user, subnet, nodeset));\r
- }\r
- }\r
- }\r
- db.release(conn);\r
- } catch (SQLException e) {\r
- intlogger.error("PROV0004 getIngressRoute: " + e.getMessage(), e);\r
- }\r
- return rv;\r
- }\r
-\r
- public IngressRoute(int seq, int feedid, String user, String subnet, Collection<String> nodes)\r
- throws IllegalArgumentException {\r
- this(seq, feedid, user, subnet);\r
- this.nodelist = -1;\r
- this.nodes = new TreeSet<String>(nodes);\r
- }\r
-\r
- public IngressRoute(int seq, int feedid, String user, String subnet, int nodeset)\r
- throws IllegalArgumentException {\r
- this(seq, feedid, user, subnet);\r
- this.nodelist = nodeset;\r
- this.nodes = new TreeSet<String>(readNodes());\r
- }\r
-\r
- private IngressRoute(int seq, int feedid, String user, String subnet)\r
- throws IllegalArgumentException {\r
- this.seq = seq;\r
- this.feedid = feedid;\r
- this.userid = (user == null) ? "-" : user;\r
- this.subnet = (subnet == null) ? "-" : subnet;\r
- this.nodelist = -1;\r
- this.nodes = null;\r
- if (Feed.getFeedById(feedid) == null) {\r
- throw new IllegalArgumentException("No such feed: " + feedid);\r
- }\r
- if (!this.subnet.equals("-")) {\r
- SubnetMatcher sm = new SubnetMatcher(subnet);\r
- if (!sm.isValid()) {\r
- throw new IllegalArgumentException("Invalid subnet: " + subnet);\r
- }\r
- }\r
- }\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 = t.equals("") ? "-" : t;\r
- t = jo.optString("subnet");\r
- this.subnet = t.equals("") ? "-" : t;\r
- this.nodelist = -1;\r
- this.nodes = new TreeSet<String>();\r
- JSONArray ja = jo.getJSONArray("node");\r
- for (int i = 0; i < ja.length(); i++) {\r
- this.nodes.add(ja.getString(i));\r
- }\r
- }\r
-\r