diff options
Diffstat (limited to 'datarouter-prov/src/main/java/org/onap/dmaap')
5 files changed, 126 insertions, 105 deletions
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRoute.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRoute.java index 242c1053..832b8edc 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRoute.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRoute.java @@ -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 $
*/
public class EgressRoute extends NodeClass implements Comparable<EgressRoute> {
+
private static Logger intlogger = Logger.getLogger("org.onap.dmaap.datarouter.provisioning.internal");
private final int subid;
private final int nodeid;
/**
- * Get a set of all Egress Routes in the DB. The set is sorted according to the natural sorting order
- * of the routes (based on the subscription ID in each route).
+ * Get a set of all Egress Routes in the DB. The set is sorted according to the natural sorting order of the routes
+ * (based on the subscription ID in each route).
*
* @return the sorted set
*/
@@ -60,15 +61,15 @@ public class EgressRoute extends NodeClass implements Comparable<EgressRoute> { DB db = new DB();
@SuppressWarnings("resource")
Connection conn = db.getConnection();
- try( Statement stmt = conn.createStatement()) {
- try(ResultSet rs = stmt.executeQuery("select SUBID, NODEID from EGRESS_ROUTES")) {
- while (rs.next()) {
- int subid = rs.getInt("SUBID");
- int nodeid = rs.getInt("NODEID");
- set.add(new EgressRoute(subid, nodeid));
- }
- }
- }
+ try (Statement stmt = conn.createStatement()) {
+ try (ResultSet rs = stmt.executeQuery("select SUBID, NODEID from EGRESS_ROUTES")) {
+ while (rs.next()) {
+ int subid = rs.getInt("SUBID");
+ int nodeid = rs.getInt("NODEID");
+ set.add(new EgressRoute(subid, nodeid));
+ }
+ }
+ }
db.release(conn);
} catch (SQLException e) {
@@ -93,7 +94,7 @@ public class EgressRoute extends NodeClass implements Comparable<EgressRoute> { String sql = "select NODEID from EGRESS_ROUTES where SUBID = ?";
ps = conn.prepareStatement(sql);
ps.setInt(1, sub);
- try(ResultSet rs = ps.executeQuery()) {
+ try (ResultSet rs = ps.executeQuery()) {
if (rs.next()) {
int node = rs.getInt("NODEID");
v = new EgressRoute(sub, node);
@@ -105,7 +106,7 @@ public class EgressRoute extends NodeClass implements Comparable<EgressRoute> { intlogger.error("SQLException " + e.getMessage());
} finally {
try {
- if(ps!=null) {
+ if (ps != null) {
ps.close();
}
} catch (SQLException e) {
@@ -143,7 +144,7 @@ public class EgressRoute extends NodeClass implements Comparable<EgressRoute> { intlogger.error("SQLException " + e.getMessage());
} finally {
try {
- if(ps!=null) {
+ if (ps != null) {
ps.close();
}
} catch (SQLException e) {
@@ -168,10 +169,9 @@ public class EgressRoute extends NodeClass implements Comparable<EgressRoute> { rv = true;
} catch (SQLException e) {
intlogger.warn("PROV0005 doInsert: " + e.getMessage());
- intlogger.error("SQLException " + e.getMessage());
} finally {
try {
- if(ps!=null) {
+ if (ps != null) {
ps.close();
}
} catch (SQLException e) {
@@ -194,10 +194,9 @@ public class EgressRoute extends NodeClass implements Comparable<EgressRoute> { } catch (SQLException e) {
rv = false;
intlogger.warn("PROV0006 doUpdate: " + e.getMessage());
- intlogger.error("SQLException " + e.getMessage());
} finally {
try {
- if(ps!=null) {
+ if (ps != null) {
ps.close();
}
} catch (SQLException e) {
@@ -221,8 +220,9 @@ public class EgressRoute extends NodeClass implements Comparable<EgressRoute> { @Override
public boolean equals(Object obj) {
- if (!(obj instanceof EgressRoute))
+ if (!(obj instanceof EgressRoute)) {
return false;
+ }
EgressRoute on = (EgressRoute) obj;
return (subid == on.subid) && (nodeid == on.nodeid);
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java index 334863dc..f1873424 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java @@ -683,7 +683,6 @@ public class Feed extends Syncable { } catch (SQLException e) {
rv = false;
intlogger.warn("PROV0006 doUpdate: " + e.getMessage());
- intlogger.error("SQLException " + e.getMessage());
} finally {
try {
if (ps != null)
@@ -716,7 +715,6 @@ public class Feed extends Syncable { } catch (SQLException e) {
rv = false;
intlogger.warn("PROV0006 doUpdate: " + e.getMessage());
- intlogger.error("SQLException " + e.getMessage());
} finally {
try {
if(ps!=null) {
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Group.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Group.java index 35363094..3f5f7c76 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Group.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Group.java @@ -43,6 +43,7 @@ import org.onap.dmaap.datarouter.provisioning.utils.URLUtilities; * @version $Id: Group.java,v 1.0 2016/07/19
*/
public class Group extends Syncable {
+
private static Logger intlogger = Logger.getLogger("org.onap.dmaap.datarouter.provisioning.internal");
private static int next_groupid = getMaxGroupID() + 1;
@@ -96,8 +97,8 @@ public class Group extends Syncable { DB db = new DB();
@SuppressWarnings("resource")
Connection conn = db.getConnection();
- try(Statement stmt = conn.createStatement()) {
- try(ResultSet rs = stmt.executeQuery(sql)) {
+ try (Statement stmt = conn.createStatement()) {
+ try (ResultSet rs = stmt.executeQuery(sql)) {
while (rs.next()) {
Group group = new Group(rs);
list.add(group);
@@ -117,8 +118,8 @@ public class Group extends Syncable { DB db = new DB();
@SuppressWarnings("resource")
Connection conn = db.getConnection();
- try(Statement stmt = conn.createStatement()) {
- try(ResultSet rs = stmt.executeQuery("select MAX(groupid) from GROUPS")) {
+ try (Statement stmt = conn.createStatement()) {
+ try (ResultSet rs = stmt.executeQuery("select MAX(groupid) from GROUPS")) {
if (rs.next()) {
max = rs.getInt(1);
}
@@ -127,7 +128,6 @@ public class Group extends Syncable { db.release(conn);
} catch (SQLException e) {
intlogger.info("getMaxSubID: " + e.getMessage());
- intlogger.error("SQLException " + e.getMessage());
}
return max;
}
@@ -139,9 +139,9 @@ public class Group extends Syncable { DB db = new DB();
@SuppressWarnings("resource")
Connection conn = db.getConnection();
- try(PreparedStatement stmt = conn.prepareStatement(sql)) {
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setString(1, classfication);
- try(ResultSet rs = stmt.executeQuery()) {
+ try (ResultSet rs = stmt.executeQuery()) {
while (rs.next()) {
int groupid = rs.getInt("groupid");
@@ -166,8 +166,8 @@ public class Group extends Syncable { DB db = new DB();
@SuppressWarnings("resource")
Connection conn = db.getConnection();
- try(Statement stmt = conn.createStatement()) {
- try(ResultSet rs = stmt.executeQuery("select count(*) from SUBSCRIPTIONS")) {
+ try (Statement stmt = conn.createStatement()) {
+ try (ResultSet rs = stmt.executeQuery("select count(*) from SUBSCRIPTIONS")) {
if (rs.next()) {
count = rs.getInt(1);
}
@@ -176,7 +176,6 @@ public class Group extends Syncable { db.release(conn);
} catch (SQLException e) {
intlogger.warn("PROV0008 countActiveSubscriptions: " + e.getMessage());
- intlogger.error("SQLException " + e.getMessage());
}
return count;
}
@@ -221,10 +220,12 @@ public class Group extends Syncable { this.classification = jo.getString("classification");
this.members = jo.getString("members");
- if (gname.length() > 50)
+ if (gname.length() > 50) {
throw new InvalidObjectException("Group name is too long");
- if (gdescription.length() > 256)
+ }
+ if (gdescription.length() > 256) {
throw new InvalidObjectException("Group Description is too long");
+ }
} catch (InvalidObjectException e) {
throw e;
} catch (Exception e) {
@@ -328,9 +329,9 @@ public class Group extends Syncable { setGroupid(next_groupid++);
}
// In case we insert a gropup from synchronization
- if (groupid > next_groupid)
+ if (groupid > next_groupid) {
next_groupid = groupid + 1;
-
+ }
// Create the GROUPS row
String sql = "insert into GROUPS (GROUPID, AUTHID, NAME, DESCRIPTION, CLASSIFICATION, MEMBERS) values (?, ?, ?, ?, ?, ?)";
@@ -346,10 +347,9 @@ public class Group extends Syncable { } catch (SQLException e) {
rv = false;
intlogger.warn("PROV0005 doInsert: " + e.getMessage());
- intlogger.error("SQLException " + e.getMessage());
} finally {
try {
- if(ps!=null) {
+ if (ps != null) {
ps.close();
}
} catch (SQLException e) {
@@ -376,10 +376,9 @@ public class Group extends Syncable { } catch (SQLException e) {
rv = false;
intlogger.warn("PROV0006 doUpdate: " + e.getMessage());
- intlogger.error("SQLException " + e.getMessage());
} finally {
try {
- if(ps!=null) {
+ if (ps != null) {
ps.close();
}
} catch (SQLException e) {
@@ -401,10 +400,9 @@ public class Group extends Syncable { } catch (SQLException e) {
rv = false;
intlogger.warn("PROV0007 doDelete: " + e.getMessage());
- intlogger.error("SQLException " + e.getMessage());
} finally {
try {
- if(ps!=null) {
+ if (ps != null) {
ps.close();
}
} catch (SQLException e) {
@@ -421,21 +419,28 @@ public class Group extends Syncable { @Override
public boolean equals(Object obj) {
- if (!(obj instanceof Group))
+ if (!(obj instanceof Group)) {
return false;
+ }
Group os = (Group) obj;
- if (groupid != os.groupid)
+ if (groupid != os.groupid) {
return false;
- if (authid != os.authid)
+ }
+ if (authid != os.authid) {
return false;
- if (!name.equals(os.name))
+ }
+ if (!name.equals(os.name)) {
return false;
- if (description != os.description)
+ }
+ if (description != os.description) {
return false;
- if (!classification.equals(os.classification))
+ }
+ if (!classification.equals(os.classification)) {
return false;
- if (!members.equals(os.members))
+ }
+ if (!members.equals(os.members)) {
return false;
+ }
return true;
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRoute.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRoute.java index 6b390c43..033b3900 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRoute.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRoute.java @@ -52,6 +52,7 @@ import org.onap.dmaap.datarouter.provisioning.utils.DB; * @version $Id: IngressRoute.java,v 1.3 2013/12/16 20:30:23 eby Exp $
*/
public class IngressRoute extends NodeClass implements Comparable<IngressRoute> {
+
private static Logger intlogger = Logger.getLogger("org.onap.dmaap.datarouter.provisioning.internal");
private final int seq;
private final int feedid;
@@ -76,7 +77,8 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute> * @return a set of IngressRoutes
*/
public static Set<IngressRoute> getIngressRoutesForSeq(int seq) {
- return getAllIngressRoutesForSQL("select SEQUENCE, FEEDID, USERID, SUBNET, NODESET from INGRESS_ROUTES where SEQUENCE = " + seq);
+ return getAllIngressRoutesForSQL(
+ "select SEQUENCE, FEEDID, USERID, SUBNET, NODESET from INGRESS_ROUTES where SEQUENCE = " + seq);
}
private static SortedSet<IngressRoute> getAllIngressRoutesForSQL(String sql) {
@@ -85,8 +87,8 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute> DB db = new DB();
@SuppressWarnings("resource")
Connection conn = db.getConnection();
- try(Statement stmt = conn.createStatement()) {
- try(ResultSet rs = stmt.executeQuery(sql)) {
+ try (Statement stmt = conn.createStatement()) {
+ try (ResultSet rs = stmt.executeQuery(sql)) {
while (rs.next()) {
int seq = rs.getInt("SEQUENCE");
int feedid = rs.getInt("FEEDID");
@@ -128,12 +130,12 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute> DB db = new DB();
@SuppressWarnings("resource")
Connection conn = db.getConnection();
- try(Statement stmt = conn.createStatement()) {
- try(ResultSet rs = stmt.executeQuery(sql)) {
- if (rs.next()) {
- rv = rs.getInt("MAX");
- }
- }
+ try (Statement stmt = conn.createStatement()) {
+ try (ResultSet rs = stmt.executeQuery(sql)) {
+ if (rs.next()) {
+ rv = rs.getInt("MAX");
+ }
+ }
}
db.release(conn);
} catch (SQLException e) {
@@ -146,7 +148,7 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute> * Get an Ingress Route for a particular feed ID, user, and subnet
*
* @param feedid the Feed ID to look for
- * @param user the user name to look for
+ * @param user the user name to look for
* @param subnet the subnet to look for
* @return the Ingress Route, or null of there is none
*/
@@ -162,7 +164,7 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute> ps.setInt(1, feedid);
ps.setString(2, user);
ps.setString(3, subnet);
- try(ResultSet rs = ps.executeQuery()) {
+ try (ResultSet rs = ps.executeQuery()) {
if (rs.next()) {
int seq = rs.getInt("SEQUENCE");
int nodeset = rs.getInt("NODESET");
@@ -175,7 +177,7 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute> intlogger.error("SQLException " + e.getMessage());
} finally {
try {
- if(ps!=null) {
+ if (ps != null) {
ps.close();
}
} catch (SQLException e) {
@@ -198,9 +200,9 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute> @SuppressWarnings("resource")
Connection conn = db.getConnection();
String sql = "select FEEDID, USERID, SUBNET, NODESET from INGRESS_ROUTES where SEQUENCE = ?";
- try(PreparedStatement ps = conn.prepareStatement(sql)) {
+ try (PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setInt(1, seq);
- try(ResultSet rs = ps.executeQuery()) {
+ try (ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
int feedid = rs.getInt("FEEDID");
String user = rs.getString("USERID");
@@ -239,12 +241,14 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute> this.subnet = (subnet == null) ? "-" : subnet;
this.nodelist = -1;
this.nodes = null;
- if (Feed.getFeedById(feedid) == null)
+ if (Feed.getFeedById(feedid) == null) {
throw new IllegalArgumentException("No such feed: " + feedid);
+ }
if (!this.subnet.equals("-")) {
SubnetMatcher sm = new SubnetMatcher(subnet);
- if (!sm.isValid())
+ if (!sm.isValid()) {
throw new IllegalArgumentException("Invalid subnet: " + subnet);
+ }
}
}
@@ -258,37 +262,41 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute> this.nodelist = -1;
this.nodes = new TreeSet<String>();
JSONArray ja = jo.getJSONArray("node");
- for (int i = 0; i < ja.length(); i++)
+ for (int i = 0; i < ja.length(); i++) {
this.nodes.add(ja.getString(i));
+ }
}
/**
- * Does this particular IngressRoute match a request, represented by feedid and req?
- * To match, <i>feedid</i> must match the feed ID in the route, the user in the route
- * (if specified) must match the user in the request, and the subnet in the route (if specified)
- * must match the subnet from the request.
+ * Does this particular IngressRoute match a request, represented by feedid and req? To match, <i>feedid</i> must
+ * match the feed ID in the route, the user in the route (if specified) must match the user in the request, and the
+ * subnet in the route (if specified) must match the subnet from the request.
*
* @param feedid the feedid for this request
- * @param req the remainder of the request
+ * @param req the remainder of the request
* @return true if a match, false otherwise
*/
public boolean matches(int feedid, HttpServletRequest req) {
// Check feedid
- if (this.feedid != feedid)
+ if (this.feedid != feedid) {
return false;
+ }
// Get user from request and compare
// Note: we don't check the password; the node will do that
if (userid.length() > 0 && !userid.equals("-")) {
String credentials = req.getHeader("Authorization");
- if (credentials == null || !credentials.startsWith("Basic "))
+ if (credentials == null || !credentials.startsWith("Basic ")) {
return false;
+ }
String t = new String(Base64.decodeBase64(credentials.substring(6)));
int ix = t.indexOf(':');
- if (ix >= 0)
+ if (ix >= 0) {
t = t.substring(0, ix);
- if (!t.equals(this.userid))
+ }
+ if (!t.equals(this.userid)) {
return false;
+ }
}
// If this route has a subnet, match it against the requester's IP addr
@@ -305,10 +313,11 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute> }
/**
- * Compare IP addresses as byte arrays to a subnet specified as a CIDR.
- * Taken from org.onap.dmaap.datarouter.node.SubnetMatcher and modified somewhat.
+ * Compare IP addresses as byte arrays to a subnet specified as a CIDR. Taken from
+ * org.onap.dmaap.datarouter.node.SubnetMatcher and modified somewhat.
*/
public class SubnetMatcher {
+
private byte[] sn;
private int len;
private int mask;
@@ -386,9 +395,9 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute> @SuppressWarnings("resource")
Connection conn = db.getConnection();
String sql = "select NODEID from NODESETS where SETID = ?";
- try(PreparedStatement ps = conn.prepareStatement(sql)) {
+ try (PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setInt(1, nodelist);
- try(ResultSet rs = ps.executeQuery()) {
+ try (ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
int id = rs.getInt("NODEID");
set.add(lookupNodeID(id));
@@ -425,10 +434,9 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute> } catch (SQLException e) {
rv = false;
intlogger.warn("PROV0007 doDelete: " + e.getMessage());
- intlogger.error("SQLException " + e.getMessage());
} finally {
try {
- if(ps!=null) {
+ if (ps != null) {
ps.close();
}
} catch (SQLException e) {
@@ -457,7 +465,8 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute> }
// Create the INGRESS_ROUTES row
- ps = c.prepareStatement("insert into INGRESS_ROUTES (SEQUENCE, FEEDID, USERID, SUBNET, NODESET) values (?, ?, ?, ?, ?)");
+ ps = c.prepareStatement(
+ "insert into INGRESS_ROUTES (SEQUENCE, FEEDID, USERID, SUBNET, NODESET) values (?, ?, ?, ?, ?)");
ps.setInt(1, this.seq);
ps.setInt(2, this.feedid);
ps.setString(3, this.userid);
@@ -468,10 +477,9 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute> rv = true;
} catch (SQLException e) {
intlogger.warn("PROV0005 doInsert: " + e.getMessage());
- intlogger.error("SQLException " + e.getMessage());
} finally {
try {
- if(ps!=null) {
+ if (ps != null) {
ps.close();
}
} catch (SQLException e) {
@@ -491,10 +499,12 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute> JSONObject jo = new JSONObject();
jo.put("feedid", feedid);
// Note: for user and subnet, null, "", and "-" are equivalent
- if (userid != null && !userid.equals("-") && !userid.equals(""))
+ if (userid != null && !userid.equals("-") && !userid.equals("")) {
jo.put("user", userid);
- if (subnet != null && !subnet.equals("-") && !subnet.equals(""))
+ }
+ if (subnet != null && !subnet.equals("-") && !subnet.equals("")) {
jo.put("subnet", subnet);
+ }
jo.put("seq", seq);
jo.put("node", nodes);
return jo;
@@ -502,7 +512,8 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute> @Override
public String getKey() {
- return String.format("%d/%s/%s/%d", feedid, (userid == null) ? "" : userid, (subnet == null) ? "" : subnet, seq);
+ return String
+ .format("%d/%s/%s/%d", feedid, (userid == null) ? "" : userid, (subnet == null) ? "" : subnet, seq);
}
@Override
@@ -513,8 +524,9 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute> @Override
public boolean equals(Object obj) {
try {
- if (!(obj instanceof IngressRoute))
+ if (!(obj instanceof IngressRoute)) {
return false;
+ }
return this.compareTo((IngressRoute) obj) == 0;
} catch (NullPointerException e) {
return false;
@@ -523,25 +535,31 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute> @Override
public int compareTo(IngressRoute in) {
- if (in == null)
+ if (in == null) {
throw new NullPointerException();
+ }
int n = this.feedid - in.feedid;
- if (n != 0)
+ if (n != 0) {
return n;
+ }
n = this.seq - in.seq;
- if (n != 0)
+ if (n != 0) {
return n;
+ }
n = this.userid.compareTo(in.userid);
- if (n != 0)
+ if (n != 0) {
return n;
+ }
n = this.subnet.compareTo(in.subnet);
- if (n != 0)
+ if (n != 0) {
return n;
+ }
return this.nodes.equals(in.nodes) ? 0 : 1;
}
@Override
public String toString() {
- return String.format("INGRESS: feed=%d, userid=%s, subnet=%s, seq=%d", feedid, (userid == null) ? "" : userid, (subnet == null) ? "" : subnet, seq);
+ return String.format("INGRESS: feed=%d, userid=%s, subnet=%s, seq=%d", feedid, (userid == null) ? "" : userid,
+ (subnet == null) ? "" : subnet, seq);
}
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRoute.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRoute.java index bad6f537..8264de28 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRoute.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRoute.java @@ -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 $
*/
public class NetworkRoute extends NodeClass implements Comparable<NetworkRoute> {
+
private static Logger intlogger = Logger.getLogger("org.onap.dmaap.datarouter.provisioning.internal");
private final int fromnode;
private final int tonode;
private final int vianode;
/**
- * Get a set of all Network Routes in the DB. The set is sorted according to the natural sorting order
- * of the routes (based on the from and to node names in each route).
+ * Get a set of all Network Routes in the DB. The set is sorted according to the natural sorting order of the
+ * routes (based on the from and to node names in each route).
*
* @return the sorted set
*/
@@ -61,8 +62,8 @@ public class NetworkRoute extends NodeClass implements Comparable<NetworkRoute> DB db = new DB();
@SuppressWarnings("resource")
Connection conn = db.getConnection();
- try(Statement stmt = conn.createStatement()) {
- try(ResultSet rs = stmt.executeQuery("select FROMNODE, TONODE, VIANODE from NETWORK_ROUTES")) {
+ try (Statement stmt = conn.createStatement()) {
+ try (ResultSet rs = stmt.executeQuery("select FROMNODE, TONODE, VIANODE from NETWORK_ROUTES")) {
while (rs.next()) {
int fromnode = rs.getInt("FROMNODE");
int tonode = rs.getInt("TONODE");
@@ -127,10 +128,9 @@ public class NetworkRoute extends NodeClass implements Comparable<NetworkRoute> } catch (SQLException e) {
rv = false;
intlogger.warn("PROV0007 doDelete: " + e.getMessage());
- intlogger.error("SQLException " + e.getMessage());
} finally {
try {
- if(ps!=null) {
+ if (ps != null) {
ps.close();
}
} catch (SQLException e) {
@@ -157,10 +157,9 @@ public class NetworkRoute extends NodeClass implements Comparable<NetworkRoute> rv = true;
} catch (SQLException e) {
intlogger.warn("PROV0005 doInsert: " + e.getMessage());
- intlogger.error("SQLException " + e.getMessage());
} finally {
try {
- if(ps!=null) {
+ if (ps != null) {
ps.close();
}
} catch (SQLException e) {
@@ -185,10 +184,9 @@ public class NetworkRoute extends NodeClass implements Comparable<NetworkRoute> } catch (SQLException e) {
rv = false;
intlogger.warn("PROV0006 doUpdate: " + e.getMessage());
- intlogger.error("SQLException " + e.getMessage());
} finally {
try {
- if(ps!=null) {
+ if (ps != null) {
ps.close();
}
} catch (SQLException e) {
@@ -214,8 +212,9 @@ public class NetworkRoute extends NodeClass implements Comparable<NetworkRoute> @Override
public boolean equals(Object obj) {
- if (!(obj instanceof NetworkRoute))
+ if (!(obj instanceof NetworkRoute)) {
return false;
+ }
NetworkRoute on = (NetworkRoute) obj;
return (fromnode == on.fromnode) && (tonode == on.tonode) && (vianode == on.vianode);
}
@@ -228,8 +227,9 @@ public class NetworkRoute extends NodeClass implements Comparable<NetworkRoute> @Override
public int compareTo(NetworkRoute o) {
if (this.fromnode == o.fromnode) {
- if (this.tonode == o.tonode)
+ if (this.tonode == o.tonode) {
return this.vianode - o.vianode;
+ }
return this.tonode - o.tonode;
}
return this.fromnode - o.fromnode;
|