summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/PathFinder.java6
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/impl/ProvAuthorizer.java12
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Subscription.java85
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/DRRouteCLI.java7
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/LogfileLoader.java30
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/URLUtilities.java2
6 files changed, 74 insertions, 68 deletions
diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/PathFinder.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/PathFinder.java
index 98beebca..f9173e9b 100644
--- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/PathFinder.java
+++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/PathFinder.java
@@ -32,9 +32,9 @@ import java.util.*;
public class PathFinder {
private static class Hop {
- public boolean mark;
- public boolean bad;
- public NodeConfig.ProvHop basis;
+ boolean mark;
+ boolean bad;
+ NodeConfig.ProvHop basis;
}
private Vector<String> errors = new Vector<String>();
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/impl/ProvAuthorizer.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/impl/ProvAuthorizer.java
index b7df151c..c76ce42a 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/impl/ProvAuthorizer.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/impl/ProvAuthorizer.java
@@ -126,21 +126,21 @@ public class ProvAuthorizer implements Authorizer {
private boolean allowFeedsCollectionAccess(AuthzResource resource, String method, String subject, String subjectgroup) {
// Allow GET or POST unconditionally
- return method != null && (method.equalsIgnoreCase("GET") || method.equalsIgnoreCase("POST"));
+ return method != null && ("GET".equalsIgnoreCase(method) || "POST".equalsIgnoreCase(method));
}
private boolean allowSubsCollectionAccess(AuthzResource resource, String method, String subject, String subjectgroup) {
// Allow GET or POST unconditionally
- return method != null && (method.equalsIgnoreCase("GET") || method.equalsIgnoreCase("POST"));
+ return method != null && ("GET".equalsIgnoreCase(method) || "POST".equalsIgnoreCase(method));
}
private boolean allowFeedAccess(AuthzResource resource, String method, String subject, String subjectgroup) {
boolean decision = false;
// Allow GET, PUT, or DELETE if requester (subject) is the owner (publisher) of the feed
- if ( method != null && (method.equalsIgnoreCase("GET") || method.equalsIgnoreCase("PUT") ||
- method.equalsIgnoreCase("DELETE"))) {
+ if ( method != null && ("GET".equalsIgnoreCase(method) || "PUT".equalsIgnoreCase(method) ||
+ "DELETE".equalsIgnoreCase(method))) {
String owner = provData.getFeedOwner(resource.getId());
decision = (owner != null) && owner.equals(subject);
@@ -159,8 +159,8 @@ public class ProvAuthorizer implements Authorizer {
boolean decision = false;
// Allow GET, PUT, or DELETE if requester (subject) is the owner of the subscription (subscriber)
- if (method != null && (method.equalsIgnoreCase("GET") || method.equalsIgnoreCase("PUT") ||
- method.equalsIgnoreCase("DELETE") || method.equalsIgnoreCase("POST"))) {
+ if (method != null && ("GET".equalsIgnoreCase(method) || "PUT".equalsIgnoreCase(method) ||
+ "DELETE".equalsIgnoreCase(method) || "POST".equalsIgnoreCase(method))) {
String owner = provData.getSubscriptionOwner(resource.getId());
decision = (owner != null) && owner.equals(subject);
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Subscription.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Subscription.java
index 027d859c..1333b55e 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Subscription.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Subscription.java
@@ -29,18 +29,13 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
import org.apache.log4j.Logger;
import org.json.JSONObject;
import org.onap.dmaap.datarouter.provisioning.utils.DB;
import org.onap.dmaap.datarouter.provisioning.utils.URLUtilities;
-import java.util.Properties;
-
/**
* The representation of a Subscription. Subscriptions can be retrieved from the DB, or stored/updated in the DB.
*
@@ -93,14 +88,14 @@ public class Subscription extends Syncable {
DB db = new DB();
@SuppressWarnings("resource")
Connection conn = db.getConnection();
- Statement stmt = conn.createStatement();
- ResultSet rs = stmt.executeQuery(sql);
- while (rs.next()) {
- Subscription sub = new Subscription(rs);
- list.add(sub);
+ try(Statement stmt = conn.createStatement()) {
+ try(ResultSet rs = stmt.executeQuery(sql)) {
+ while (rs.next()) {
+ Subscription sub = new Subscription(rs);
+ list.add(sub);
+ }
+ }
}
- rs.close();
- stmt.close();
db.release(conn);
} catch (SQLException e) {
e.printStackTrace();
@@ -114,13 +109,13 @@ public class Subscription extends Syncable {
DB db = new DB();
@SuppressWarnings("resource")
Connection conn = db.getConnection();
- Statement stmt = conn.createStatement();
- ResultSet rs = stmt.executeQuery("select MAX(subid) from SUBSCRIPTIONS");
- if (rs.next()) {
- max = rs.getInt(1);
+ try(Statement stmt = conn.createStatement()) {
+ try(ResultSet rs = stmt.executeQuery("select MAX(subid) from SUBSCRIPTIONS")) {
+ if (rs.next()) {
+ max = rs.getInt(1);
+ }
+ }
}
- rs.close();
- stmt.close();
db.release(conn);
} catch (SQLException e) {
intlogger.info("getMaxSubID: " + e.getMessage());
@@ -136,14 +131,14 @@ public class Subscription extends Syncable {
DB db = new DB();
@SuppressWarnings("resource")
Connection conn = db.getConnection();
- Statement stmt = conn.createStatement();
- ResultSet rs = stmt.executeQuery(sql);
- while (rs.next()) {
- int subid = rs.getInt("SUBID");
- list.add(URLUtilities.generateSubscriptionURL(subid));
+ try(Statement stmt = conn.createStatement()) {
+ try(ResultSet rs = stmt.executeQuery(sql)) {
+ while (rs.next()) {
+ int subid = rs.getInt("SUBID");
+ list.add(URLUtilities.generateSubscriptionURL(subid));
+ }
+ }
}
- rs.close();
- stmt.close();
db.release(conn);
} catch (SQLException e) {
e.printStackTrace();
@@ -162,13 +157,13 @@ public class Subscription extends Syncable {
DB db = new DB();
@SuppressWarnings("resource")
Connection conn = db.getConnection();
- Statement stmt = conn.createStatement();
- ResultSet rs = stmt.executeQuery("select count(*) from SUBSCRIPTIONS");
- if (rs.next()) {
- count = rs.getInt(1);
+ try(Statement stmt = conn.createStatement()) {
+ try(ResultSet rs = stmt.executeQuery("select count(*) from SUBSCRIPTIONS")) {
+ if (rs.next()) {
+ count = rs.getInt(1);
+ }
+ }
}
- rs.close();
- stmt.close();
db.release(conn);
} catch (SQLException e) {
intlogger.warn("PROV0008 countActiveSubscriptions: " + e.getMessage());
@@ -391,11 +386,6 @@ public class Subscription extends Syncable {
ps.setInt(10, groupid); //New field is added - Groups feature Rally:US708115 - 1610
ps.execute();
ps.close();
-// ResultSet rs = ps.getGeneratedKeys();
-// rs.first();
-// setSubid(rs.getInt(1)); // side effect - sets the link URLs
-// ps.close();
-
// Update the row to set the URLs
sql = "update SUBSCRIPTIONS set SELF_LINK = ?, LOG_LINK = ? where SUBID = ?";
ps = c.prepareStatement(sql);
@@ -410,7 +400,9 @@ public class Subscription extends Syncable {
e.printStackTrace();
} finally {
try {
- ps.close();
+ if(ps!=null) {
+ ps.close();
+ }
} catch (SQLException e) {
e.printStackTrace();
}
@@ -440,7 +432,9 @@ public class Subscription extends Syncable {
e.printStackTrace();
} finally {
try {
- ps.close();
+ if(ps!=null) {
+ ps.close();
+ }
} catch (SQLException e) {
e.printStackTrace();
}
@@ -473,7 +467,9 @@ public class Subscription extends Syncable {
e.printStackTrace();
} finally {
try {
- ps.close();
+ if(ps!=null) {
+ ps.close();
+ }
} catch (SQLException e) {
e.printStackTrace();
}
@@ -497,7 +493,9 @@ public class Subscription extends Syncable {
e.printStackTrace();
} finally {
try {
- ps.close();
+ if(ps!=null) {
+ ps.close();
+ }
} catch (SQLException e) {
e.printStackTrace();
}
@@ -535,6 +533,11 @@ public class Subscription extends Syncable {
}
@Override
+ public int hashCode() {
+ return Objects.hash(subid, feedid, groupid, delivery, metadataOnly, subscriber, links, suspended, last_mod, created_date);
+ }
+
+ @Override
public String toString() {
return "SUB: subid=" + subid + ", feedid=" + feedid;
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/DRRouteCLI.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/DRRouteCLI.java
index 1bbf4460..af8bd6d3 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/DRRouteCLI.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/DRRouteCLI.java
@@ -339,8 +339,11 @@ public class DRRouteCLI {
sb.append("Egress Routing Table\n");
sb.append(String.format("%s Node\n", ext("SubID", cw1)));
for (int i = 0; i < subs.length; i++) {
- String node = ert.getString(subs[i]);
- sb.append(String.format("%s %s\n", ext(subs[i], cw1), node));
+ if(ert!=null&&ert.length()!=0) {
+ String node = ert.getString(subs[i]);
+ sb.append(String.format("%s %s\n", ext(subs[i], cw1), node));
+ }
+
}
}
if (tbl.startsWith("al") || tbl.startsWith("ne")) {
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/LogfileLoader.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/LogfileLoader.java
index 8975f161..110c63de 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/LogfileLoader.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/LogfileLoader.java
@@ -188,6 +188,7 @@ public class LogfileLoader extends Thread {
try {
Thread.sleep(1000L);
} catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
}
idle = false;
} else {
@@ -332,26 +333,25 @@ public class LogfileLoader extends Thread {
Connection conn = null;
try {
conn = db.getConnection();
- Statement stmt = conn.createStatement();
- // Build a bitset of all records in the LOG_RECORDS table
- // We need to run this SELECT in stages, because otherwise we run out of memory!
RLEBitSet nbs = new RLEBitSet();
- final long stepsize = 6000000L;
- boolean go_again = true;
- for (long i = 0; go_again; i += stepsize) {
- String sql = String.format("select RECORD_ID from LOG_RECORDS LIMIT %d,%d", i, stepsize);
- try(ResultSet rs = stmt.executeQuery(sql)) {
- go_again = false;
- while (rs.next()) {
- long n = rs.getLong("RECORD_ID");
- nbs.set(n);
- go_again = true;
+ try(Statement stmt = conn.createStatement()) {
+ // Build a bitset of all records in the LOG_RECORDS table
+ // We need to run this SELECT in stages, because otherwise we run out of memory!
+ final long stepsize = 6000000L;
+ boolean go_again = true;
+ for (long i = 0; go_again; i += stepsize) {
+ String sql = String.format("select RECORD_ID from LOG_RECORDS LIMIT %d,%d", i, stepsize);
+ try (ResultSet rs = stmt.executeQuery(sql)) {
+ go_again = false;
+ while (rs.next()) {
+ long n = rs.getLong("RECORD_ID");
+ nbs.set(n);
+ go_again = true;
+ }
}
}
}
- stmt.close();
seq_set = nbs;
-
// Compare with the range for this server
// Determine the next ID for this set of record IDs
RLEBitSet tbs = (RLEBitSet) nbs.clone();
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/URLUtilities.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/URLUtilities.java
index b58ab5a0..4576bd26 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/URLUtilities.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/URLUtilities.java
@@ -115,7 +115,7 @@ public class URLUtilities {
public static String generatePeerLogsURL() {
//Fixes for Itrack ticket - DATARTR-4#Fixing if only one Prov is configured, not to give exception to fill logs.
String peerPodUrl = getPeerPodName();
- if (peerPodUrl.equals("") || peerPodUrl.equals(null)) {
+ if (peerPodUrl.equals("") || peerPodUrl==null) {
return "";
}