-// if (Subscription.getSubscriptionById(subid) == null)\r
-// throw new IllegalArgumentException("No such subscription: "+subid);\r
- }\r
-\r
- public EgressRoute(int subid, String node) throws IllegalArgumentException {\r
- this(subid, lookupNodeName(node));\r
- }\r
-\r
- @Override\r
- public boolean doDelete(Connection c) {\r
- boolean rv = true;\r
- PreparedStatement ps = null;\r
- try {\r
- String sql = "delete from EGRESS_ROUTES where SUBID = ?";\r
- ps = c.prepareStatement(sql);\r
- ps.setInt(1, subid);\r
- ps.execute();\r
- } catch (SQLException e) {\r
- rv = false;\r
- intlogger.warn("PROV0007 doDelete: "+e.getMessage());\r
- e.printStackTrace();\r
- } finally {\r
- try {\r
- ps.close();\r
- } catch (SQLException e) {\r
- e.printStackTrace();\r
- }\r
- }\r
- return rv;\r
- }\r
-\r
- @Override\r
- public boolean doInsert(Connection c) {\r
- boolean rv = false;\r
- PreparedStatement ps = null;\r
- try {\r
- // Create the NETWORK_ROUTES row\r
- String sql = "insert into EGRESS_ROUTES (SUBID, NODEID) values (?, ?)";\r
- ps = c.prepareStatement(sql);\r
- ps.setInt(1, this.subid);\r
- ps.setInt(2, this.nodeid);\r
- ps.execute();\r
- ps.close();\r
- rv = true;\r
- } catch (SQLException e) {\r
- intlogger.warn("PROV0005 doInsert: "+e.getMessage());\r
- e.printStackTrace();\r
- } finally {\r
- try {\r
- ps.close();\r
- } catch (SQLException e) {\r
- e.printStackTrace();\r
- }\r
- }\r
- return rv;\r
- }\r
-\r
- @Override\r
- public boolean doUpdate(Connection c) {\r
- boolean rv = true;\r
- PreparedStatement ps = null;\r
- try {\r
- String sql = "update EGRESS_ROUTES set NODEID = ? where SUBID = ?";\r
- ps = c.prepareStatement(sql);\r
- ps.setInt(1, nodeid);\r
- ps.setInt(2, subid);\r
- ps.executeUpdate();\r
- } catch (SQLException e) {\r
- rv = false;\r
- intlogger.warn("PROV0006 doUpdate: "+e.getMessage());\r
- e.printStackTrace();\r
- } finally {\r
- try {\r
- ps.close();\r
- } catch (SQLException e) {\r
- e.printStackTrace();\r
- }\r
- }\r
- return rv;\r
- }\r
-\r
- @Override\r
- public JSONObject asJSONObject() {\r
- JSONObject jo = new JSONObject();\r
- jo.put(""+subid, lookupNodeID(nodeid));\r
- return jo;\r
- }\r
-\r
- @Override\r
- public String getKey() {\r
- return ""+subid;\r
- }\r
-\r
- @Override\r
- public boolean equals(Object obj) {\r
- if (!(obj instanceof EgressRoute))\r
- return false;\r
- EgressRoute on = (EgressRoute)obj;\r
- return (subid == on.subid) && (nodeid == on.nodeid);\r
- }\r
-\r
- @Override\r
- public int compareTo(EgressRoute o) {\r
- return this.subid - o.subid;\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- return String.format("EGRESS: sub=%d, node=%d", subid, nodeid);\r
- }\r
+// if (Subscription.getSubscriptionById(subid) == null)\r
+// throw new IllegalArgumentException("No such subscription: "+subid);\r
+ }\r
+\r
+ public EgressRoute(int subid, String node) throws IllegalArgumentException {\r
+ this(subid, lookupNodeName(node));\r
+ }\r
+\r
+ @Override\r
+ public boolean doDelete(Connection c) {\r
+ boolean rv = true;\r
+ PreparedStatement ps = null;\r
+ try {\r
+ String sql = "delete from EGRESS_ROUTES where SUBID = ?";\r
+ ps = c.prepareStatement(sql);\r
+ ps.setInt(1, subid);\r
+ ps.execute();\r
+ } 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
+ ps.close();\r
+ }\r
+ } catch (SQLException e) {\r
+ intlogger.error("SQLException " + e.getMessage());\r
+ }\r
+ }\r
+ return rv;\r
+ }\r
+\r
+ @Override\r
+ public boolean doInsert(Connection c) {\r
+ boolean rv = false;\r
+ PreparedStatement ps = null;\r
+ try {\r
+ // Create the NETWORK_ROUTES row\r
+ String sql = "insert into EGRESS_ROUTES (SUBID, NODEID) values (?, ?)";\r
+ ps = c.prepareStatement(sql);\r
+ ps.setInt(1, this.subid);\r
+ ps.setInt(2, this.nodeid);\r
+ ps.execute();\r
+ ps.close();\r
+ rv = true;\r
+ } catch (SQLException e) {\r
+ intlogger.warn("PROV0005 doInsert: " + e.getMessage());\r
+ } finally {\r
+ try {\r
+ if (ps != null) {\r
+ ps.close();\r
+ }\r
+ } catch (SQLException e) {\r
+ intlogger.error("SQLException " + e.getMessage());\r
+ }\r
+ }\r
+ return rv;\r
+ }\r
+\r
+ @Override\r
+ public boolean doUpdate(Connection c) {\r
+ boolean rv = true;\r
+ PreparedStatement ps = null;\r
+ try {\r
+ String sql = "update EGRESS_ROUTES set NODEID = ? where SUBID = ?";\r
+ ps = c.prepareStatement(sql);\r
+ ps.setInt(1, nodeid);\r
+ ps.setInt(2, subid);\r
+ ps.executeUpdate();\r
+ } catch (SQLException e) {\r
+ rv = false;\r
+ intlogger.warn("PROV0006 doUpdate: " + e.getMessage());\r
+ } finally {\r
+ try {\r
+ if (ps != null) {\r
+ ps.close();\r
+ }\r
+ } catch (SQLException e) {\r
+ intlogger.error("SQLException " + e.getMessage());\r
+ }\r
+ }\r
+ return rv;\r
+ }\r
+\r
+ @Override\r
+ public JSONObject asJSONObject() {\r
+ JSONObject jo = new JSONObject();\r
+ jo.put("" + subid, lookupNodeID(nodeid));\r
+ return jo;\r
+ }\r
+\r
+ @Override\r
+ public String getKey() {\r
+ return "" + subid;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (!(obj instanceof EgressRoute)) {\r
+ return false;\r
+ }\r
+ EgressRoute on = (EgressRoute) obj;\r
+ return (subid == on.subid) && (nodeid == on.nodeid);\r
+ }\r
+\r
+ @Override\r
+ public int compareTo(EgressRoute o) {\r
+ return this.subid - o.subid;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ return String.format("EGRESS: sub=%d, node=%d", subid, nodeid);\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ return Objects.hash(subid, nodeid);\r
+ }\r