summaryrefslogtreecommitdiffstats
path: root/datarouter-prov/src/main/java
diff options
context:
space:
mode:
authoregernug <gerard.nugent@est.tech>2019-08-12 13:17:32 +0000
committeregernug <gerard.nugent@est.tech>2019-08-12 13:17:32 +0000
commit6fb37eb225e48b58b1f30fc0423d19046509a54b (patch)
treebd70acfb5fa4931d5db2a201fd0b36655b07f1f4 /datarouter-prov/src/main/java
parent632e4aaf606ca99ddc5a5cba11deb5e2ee2a90c5 (diff)
Checkstyle fixes for datarouter prov
Change-Id: I4bd93505d56b9eb4db9510d1d2b4ec8a6ebd7cb7 Issue-ID: DMAAP-1250 Signed-off-by: egernug <gerard.nugent@est.tech>
Diffstat (limited to 'datarouter-prov/src/main/java')
-rwxr-xr-xdatarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/BaseServlet.java131
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/DRFeedsServlet.java33
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/FeedLogServlet.java1
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/FeedServlet.java48
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/GroupServlet.java26
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/InternalServlet.java71
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/LogServlet.java145
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Main.java81
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Poker.java36
-rwxr-xr-xdatarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/ProxyServlet.java20
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/PublishServlet.java36
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/RouteServlet.java93
-rwxr-xr-xdatarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/StatisticsServlet.java126
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/SubscribeServlet.java31
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServlet.java27
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/SynchronizerTask.java43
16 files changed, 563 insertions, 385 deletions
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/BaseServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/BaseServlet.java
index 159a8966..7a7167d2 100755
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/BaseServlet.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/BaseServlet.java
@@ -123,7 +123,8 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
public static final String PROVFULL_CONTENT_TYPE2 = "application/vnd.dmaap-dr.provfeed-full; version=2.0";
public static final String CERT_ATTRIBUTE = "javax.servlet.request.X509Certificate";
- static final String DB_PROBLEM_MSG = "There has been a problem with the DB. It is suggested you try the operation again.";
+ static final String DB_PROBLEM_MSG = "There has been a problem with the DB. It is suggested you "
+ + "try the operation again.";
private static final int DEFAULT_MAX_FEEDS = 10000;
private static final int DEFAULT_MAX_SUBS = 100000;
@@ -305,6 +306,11 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
}
}
+ /**
+ * Get ID from Path.
+ * @param req HTTPServletRequest
+ * @return int ID
+ */
public static int getIdFromPath(HttpServletRequest req) {
String path = req.getPathInfo();
if (path == null || path.length() < 2) {
@@ -466,18 +472,18 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
* Check if an IP address matches a network address.
*
* @param ip the IP address
- * @param s the network address; a bare IP address may be matched also
+ * @param str the network address; a bare IP address may be matched also
* @return true if they intersect
*/
- private static boolean addressMatchesNetwork(InetAddress ip, String s) {
+ private static boolean addressMatchesNetwork(InetAddress ip, String str) {
int mlen = -1;
- int n = s.indexOf('/');
- if (n >= 0) {
- mlen = Integer.parseInt(s.substring(n + 1));
- s = s.substring(0, n);
+ int substr = str.indexOf('/');
+ if (substr >= 0) {
+ mlen = Integer.parseInt(str.substring(substr + 1));
+ str = str.substring(0, substr);
}
try {
- InetAddress i2 = InetAddress.getByName(s);
+ InetAddress i2 = InetAddress.getByName(str);
byte[] b1 = ip.getAddress();
byte[] b2 = i2.getAddress();
if (b1.length != b2.length) {
@@ -485,18 +491,18 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
}
if (mlen > 0) {
byte[] masks = {
- (byte) 0x00, (byte) 0x80, (byte) 0xC0, (byte) 0xE0,
- (byte) 0xF0, (byte) 0xF8, (byte) 0xFC, (byte) 0xFE
+ (byte) 0x00, (byte) 0x80, (byte) 0xC0, (byte) 0xE0,
+ (byte) 0xF0, (byte) 0xF8, (byte) 0xFC, (byte) 0xFE
};
byte mask = masks[mlen % 8];
- for (n = mlen / 8; n < b1.length; n++) {
- b1[n] &= mask;
- b2[n] &= mask;
+ for (substr = mlen / 8; substr < b1.length; substr++) {
+ b1[substr] &= mask;
+ b2[substr] &= mask;
mask = 0;
}
}
- for (n = 0; n < b1.length; n++) {
- if (b1[n] != b2[n]) {
+ for (substr = 0; substr < b1.length; substr++) {
+ if (b1[substr] != b2[substr]) {
return false;
}
}
@@ -513,8 +519,8 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
*/
static void provisioningDataChanged() {
long now = System.currentTimeMillis();
- Poker p = Poker.getPoker();
- p.setTimers(now + (pokeTimer1 * 1000L), now + (pokeTimer2 * 1000L));
+ Poker pkr = Poker.getPoker();
+ pkr.setTimers(now + (pokeTimer1 * 1000L), now + (pokeTimer2 * 1000L));
}
/**
@@ -653,7 +659,7 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
}
/**
- * Gets the FQDN of the initially STANDBY_POD provisioning server (POD). Note: this used to be called isStandbyPOD(),
+ * Gets the FQDN of the initially STANDBY_POD provisioning server (POD).Note: this used to be called isStandbyPOD(),
* however, that is a misnomer, as the standby status could shift to the active POD without these parameters
* changing. Hence, the function names have been changed to more accurately reflect their purpose.
*
@@ -736,19 +742,19 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
}
private static boolean getBoolean(Map<String, String> map, String name) {
- String s = map.get(name);
- return "true".equalsIgnoreCase(s);
+ String str = map.get(name);
+ return "true".equalsIgnoreCase(str);
}
private static String getString(Map<String, String> map, String name, String dflt) {
- String s = map.get(name);
- return (s != null) ? s : dflt;
+ String str = map.get(name);
+ return (str != null) ? str : dflt;
}
private static int getInt(Map<String, String> map, String name, int dflt) {
try {
- String s = map.get(name);
- return Integer.parseInt(s);
+ String str = map.get(name);
+ return Integer.parseInt(str);
} catch (NumberFormatException e) {
return dflt;
}
@@ -756,9 +762,9 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
private static Set<String> getSet(Map<String, String> map, String name) {
Set<String> set = new HashSet<>();
- String s = map.get(name);
- if (s != null) {
- String[] pp = s.split("\\|");
+ String str = map.get(name);
+ if (str != null) {
+ String[] pp = str.split("\\|");
if (pp != null) {
for (String t : pp) {
String t2 = t.trim();
@@ -784,9 +790,9 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
this("", "1.0");
}
- ContentHeader(String t, String v) {
- type = t.trim();
- map.put("version", v);
+ ContentHeader(String headertype, String version) {
+ type = headertype.trim();
+ map.put("version", version);
}
public String getType() {
@@ -794,11 +800,11 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
}
String getAttribute(String key) {
- String s = map.get(key);
- if (s == null) {
- s = "";
+ String str = map.get(key);
+ if (str == null) {
+ str = "";
}
- return s;
+ return str;
}
}
@@ -810,16 +816,16 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
*/
ContentHeader getContentHeader(HttpServletRequest req) {
ContentHeader ch = new ContentHeader();
- String s = req.getHeader("Content-Type");
- if (s != null) {
- String[] pp = s.split(";");
+ String str = req.getHeader("Content-Type");
+ if (str != null) {
+ String[] pp = str.split(";");
ch.type = pp[0].trim();
for (int i = 1; i < pp.length; i++) {
int ix = pp[i].indexOf('=');
if (ix > 0) {
- String k = pp[i].substring(0, ix).trim();
- String v = pp[i].substring(ix + 1).trim();
- ch.map.put(k, v);
+ String type = pp[i].substring(0, ix).trim();
+ String version = pp[i].substring(ix + 1).trim();
+ ch.map.put(type, version);
} else {
ch.map.put(pp[i].trim(), "");
}
@@ -832,10 +838,10 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
@Override
public String getFeedOwner(String feedId) {
try {
- int n = Integer.parseInt(feedId);
- Feed f = Feed.getFeedById(n);
- if (f != null) {
- return f.getPublisher();
+ int intID = Integer.parseInt(feedId);
+ Feed feed = Feed.getFeedById(intID);
+ if (feed != null) {
+ return feed.getPublisher();
}
} catch (NumberFormatException e) {
// ignore
@@ -846,10 +852,10 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
@Override
public String getFeedClassification(String feedId) {
try {
- int n = Integer.parseInt(feedId);
- Feed f = Feed.getFeedById(n);
- if (f != null) {
- return f.getAuthorization().getClassification();
+ int intID = Integer.parseInt(feedId);
+ Feed feed = Feed.getFeedById(intID);
+ if (feed != null) {
+ return feed.getAuthorization().getClassification();
}
} catch (NumberFormatException e) {
// ignore
@@ -860,10 +866,10 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
@Override
public String getSubscriptionOwner(String subId) {
try {
- int n = Integer.parseInt(subId);
- Subscription s = Subscription.getSubscriptionById(n);
- if (s != null) {
- return s.getSubscriber();
+ int intID = Integer.parseInt(subId);
+ Subscription sub = Subscription.getSubscriptionById(intID);
+ if (sub != null) {
+ return sub.getSubscriber();
}
} catch (NumberFormatException e) {
// ignore
@@ -879,9 +885,9 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
private boolean isUserMemberOfGroup(Group group, String user) {
String groupDetails = group.getMembers().replace("]", "").replace("[", "");
- String[] s = groupDetails.split("},");
+ String[] str = groupDetails.split("},");
- for (String value : s) {
+ for (String value : str) {
JSONObject jsonObj;
try {
jsonObj = new JSONObject(value + "}");
@@ -904,9 +910,9 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
@Override
public String getGroupByFeedGroupId(String owner, String feedId) {
try {
- Feed f = Feed.getFeedById(Integer.parseInt(feedId));
- if (f != null) {
- int groupid = f.getGroupid();
+ Feed feed = Feed.getFeedById(Integer.parseInt(feedId));
+ if (feed != null) {
+ int groupid = feed.getGroupid();
if (groupid > 0) {
Group group = Group.getGroupById(groupid);
if (group != null && isUserMemberOfGroup(group, owner)) {
@@ -928,10 +934,10 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
@Override
public String getGroupBySubGroupId(String owner, String subId) {
try {
- int n = Integer.parseInt(subId);
- Subscription s = Subscription.getSubscriptionById(n);
- if (s != null) {
- int groupid = s.getGroupid();
+ int intID = Integer.parseInt(subId);
+ Subscription sub = Subscription.getSubscriptionById(intID);
+ if (sub != null) {
+ int groupid = sub.getGroupid();
if (groupid > 0) {
Group group = Group.getGroupById(groupid);
if (group != null && isUserMemberOfGroup(group, owner)) {
@@ -1025,7 +1031,8 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
/*
* AAF changes: TDP EPIC US# 307413
- * @Method - getSubscriberPermission - Forming permission string for subscription part to check AAF access in CADI Framework
+ * @Method - getSubscriberPermission - Forming permission string for subscription part to check
+ * AAF access in CADI Framework
* @Params - aafInstance Passing aafInstance as it's used in permission string
* @Params - userAction Passing CONST values to set different actions in permission string
*/
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/DRFeedsServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/DRFeedsServlet.java
index 960d5094..f0ab3956 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/DRFeedsServlet.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/DRFeedsServlet.java
@@ -24,22 +24,24 @@
package org.onap.dmaap.datarouter.provisioning;
+import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.sendResponseError;
+
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
+import java.io.IOException;
+import java.io.InvalidObjectException;
+import java.util.List;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import org.json.JSONObject;
+
import org.onap.dmaap.datarouter.authz.AuthorizationResponse;
import org.onap.dmaap.datarouter.provisioning.beans.EventLogRecord;
import org.onap.dmaap.datarouter.provisioning.beans.Feed;
import org.onap.dmaap.datarouter.provisioning.eelf.EelfMsgs;
import org.onap.dmaap.datarouter.provisioning.utils.JSONUtilities;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.InvalidObjectException;
-import java.util.List;
-import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.sendResponseError;
/**
* This servlet handles provisioning for the &lt;drFeedsURL&gt; which is the URL on the provisioning server used to
@@ -63,7 +65,8 @@ public class DRFeedsServlet extends ProxyServlet {
setIpFqdnRequestIDandInvocationIDForEelf("doDelete", req);
eelfLogger.info(EelfMsgs.ENTRY);
try {
- eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
+ eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID,
+ req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
String message = "DELETE not allowed for the drFeedsURL.";
EventLogRecord elr = new EventLogRecord(req);
elr.setMessage(message);
@@ -84,7 +87,8 @@ public class DRFeedsServlet extends ProxyServlet {
setIpFqdnRequestIDandInvocationIDForEelf("doGet", req);
eelfLogger.info(EelfMsgs.ENTRY);
try {
- eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
+ eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID,
+ req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
EventLogRecord elr = new EventLogRecord(req);
String message = isAuthorizedForProvisioning(req);
if (message != null) {
@@ -165,14 +169,14 @@ public class DRFeedsServlet extends ProxyServlet {
} else {
list = Feed.getFilteredFeedUrlList("all", null);
}
- String t = JSONUtilities.createJSONArray(list);
+ String strList = JSONUtilities.createJSONArray(list);
// send response
elr.setResult(HttpServletResponse.SC_OK);
eventlogger.info(elr.toString());
resp.setStatus(HttpServletResponse.SC_OK);
resp.setContentType(FEEDLIST_CONTENT_TYPE);
try {
- resp.getOutputStream().print(t);
+ resp.getOutputStream().print(strList);
} catch (IOException ioe) {
eventlogger.error("PROV0112 DRFeedServlet.doGet " + ioe.getMessage(), ioe);
}
@@ -190,7 +194,8 @@ public class DRFeedsServlet extends ProxyServlet {
setIpFqdnRequestIDandInvocationIDForEelf("doPut", req);
eelfLogger.info(EelfMsgs.ENTRY);
try {
- eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
+ eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID,
+ req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
String message = "PUT not allowed for the drFeedsURL.";
EventLogRecord elr = new EventLogRecord(req);
elr.setMessage(message);
@@ -295,7 +300,8 @@ public class DRFeedsServlet extends ProxyServlet {
*/
String aafInstance = feed.getAafInstance();
if (Boolean.parseBoolean(isCadiEnabled)) {
- if ((aafInstance == null || "".equals(aafInstance) || ("legacy".equalsIgnoreCase(aafInstance)) && "true".equalsIgnoreCase(req.getHeader(EXCLUDE_AAF_HEADER)))) {
+ if ((aafInstance == null || "".equals(aafInstance) || ("legacy".equalsIgnoreCase(aafInstance))
+ && "true".equalsIgnoreCase(req.getHeader(EXCLUDE_AAF_HEADER)))) {
// Check with the Authorizer
AuthorizationResponse aresp = authz.decide(req);
if (!aresp.isAuthorized()) {
@@ -308,7 +314,8 @@ public class DRFeedsServlet extends ProxyServlet {
}
} else {
if ("true".equalsIgnoreCase(req.getHeader(EXCLUDE_AAF_HEADER))) {
- message = "DRFeedsServlet.doPost() -Invalid request exclude_AAF should not be true if passing AAF_Instance value= " + aafInstance;
+ message = "DRFeedsServlet.doPost() -Invalid request exclude_AAF should not be true if passing "
+ + "AAF_Instance value= " + aafInstance;
elr.setMessage(message);
elr.setResult(HttpServletResponse.SC_FORBIDDEN);
eventlogger.error(elr.toString());
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/FeedLogServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/FeedLogServlet.java
index 2a1a8424..f37eecc1 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/FeedLogServlet.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/FeedLogServlet.java
@@ -31,6 +31,7 @@ package org.onap.dmaap.datarouter.provisioning;
* @version $Id: FeedLogServlet.java,v 1.1 2013/04/26 21:00:24 eby Exp $
*/
@SuppressWarnings("serial")
+
public class FeedLogServlet extends LogServlet {
public FeedLogServlet() {
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/FeedServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/FeedServlet.java
index de90fdee..321df9d3 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/FeedServlet.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/FeedServlet.java
@@ -24,23 +24,23 @@
package org.onap.dmaap.datarouter.provisioning;
+import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.sendResponseError;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import java.io.IOException;
import java.io.InvalidObjectException;
-
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
import org.json.JSONException;
import org.json.JSONObject;
+
import org.onap.dmaap.datarouter.authz.AuthorizationResponse;
import org.onap.dmaap.datarouter.provisioning.beans.EventLogRecord;
import org.onap.dmaap.datarouter.provisioning.beans.Feed;
import org.onap.dmaap.datarouter.provisioning.eelf.EelfMsgs;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.sendResponseError;
/**
* This servlet handles provisioning for the &lt;feedURL&gt; which is generated by the provisioning
@@ -51,6 +51,7 @@ import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.send
* @version $Id$
*/
@SuppressWarnings("serial")
+
public class FeedServlet extends ProxyServlet {
//Adding EELF Logger Rally:US664892
@@ -66,7 +67,8 @@ public class FeedServlet extends ProxyServlet {
setIpFqdnRequestIDandInvocationIDForEelf("doDelete", req);
eelfLogger.info(EelfMsgs.ENTRY);
try {
- eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER),getIdFromPath(req)+"");
+ eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID,
+ req.getHeader(BEHALF_HEADER),getIdFromPath(req) + "");
EventLogRecord elr = new EventLogRecord(req);
String message = isAuthorizedForProvisioning(req);
if (message != null) {
@@ -157,6 +159,7 @@ public class FeedServlet extends ProxyServlet {
eelfLogger.info(EelfMsgs.EXIT);
}
}
+
/**
* Get information on the feed at the address /feed/&lt;feednumber&gt;.
* See the <i>Retrieving Information about a Feed</i> section in the <b>Provisioning API</b>
@@ -167,7 +170,8 @@ public class FeedServlet extends ProxyServlet {
setIpFqdnRequestIDandInvocationIDForEelf("doGet", req);
eelfLogger.info(EelfMsgs.ENTRY);
try {
- eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER),getIdFromPath(req)+"");
+ eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID,
+ req.getHeader(BEHALF_HEADER),getIdFromPath(req) + "");
EventLogRecord elr = new EventLogRecord(req);
String message = isAuthorizedForProvisioning(req);
if (message != null) {
@@ -233,6 +237,7 @@ public class FeedServlet extends ProxyServlet {
eelfLogger.info(EelfMsgs.EXIT);
}
}
+
/**
* PUT on the &lt;feedURL&gt; for a feed.
* See the <i>Modifying a Feed</i> section in the <b>Provisioning API</b>
@@ -243,7 +248,8 @@ public class FeedServlet extends ProxyServlet {
setIpFqdnRequestIDandInvocationIDForEelf("doPut", req);
eelfLogger.info(EelfMsgs.ENTRY);
try {
- eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER),getIdFromPath(req)+"");
+ eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID,
+ req.getHeader(BEHALF_HEADER),getIdFromPath(req) + "");
EventLogRecord elr = new EventLogRecord(req);
String message = isAuthorizedForProvisioning(req);
if (message != null) {
@@ -304,8 +310,9 @@ public class FeedServlet extends ProxyServlet {
sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST, message, eventlogger);
return;
}
- if (intlogger.isDebugEnabled())
+ if (intlogger.isDebugEnabled()) {
intlogger.debug(jo.toString());
+ }
Feed feed;
try {
feed = new Feed(jo);
@@ -320,7 +327,8 @@ public class FeedServlet extends ProxyServlet {
feed.setFeedid(feedid);
feed.setPublisher(bhdr); // set from X-DMAAP-DR-ON-BEHALF-OF header
- String subjectgroup = (req.getHeader("X-DMAAP-DR-ON-BEHALF-OF-GROUP")); //Adding for group feature:Rally US708115
+ //Adding for group feature:Rally US708115
+ String subjectgroup = (req.getHeader("X-DMAAP-DR-ON-BEHALF-OF-GROUP"));
if (!oldFeed.getPublisher().equals(feed.getPublisher()) && subjectgroup == null) {
message = "This feed must be modified by the same publisher that created it.";
elr.setMessage(message);
@@ -338,13 +346,14 @@ public class FeedServlet extends ProxyServlet {
return;
}
// US DSCDR-19 for DCAE if version is not null, version can't be changed
- if ((oldFeed.getVersion() != null) && (feed.getVersion() != null) && !oldFeed.getVersion().equals(feed.getVersion())) {
- message = "The version of the feed may not be updated.";
- elr.setMessage(message);
- elr.setResult(HttpServletResponse.SC_BAD_REQUEST);
- eventlogger.error(elr.toString());
- sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST, message, eventlogger);
- return;
+ if ((oldFeed.getVersion() != null) && (feed.getVersion() != null)
+ && !oldFeed.getVersion().equals(feed.getVersion())) {
+ message = "The version of the feed may not be updated.";
+ elr.setMessage(message);
+ elr.setResult(HttpServletResponse.SC_BAD_REQUEST);
+ eventlogger.error(elr.toString());
+ sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST, message, eventlogger);
+ return;
}
/*
@@ -419,6 +428,7 @@ public class FeedServlet extends ProxyServlet {
eelfLogger.info(EelfMsgs.EXIT);
}
}
+
/**
* POST on the &lt;feedURL&gt; -- not supported.
*/
@@ -435,7 +445,7 @@ public class FeedServlet extends ProxyServlet {
eventlogger.error(elr.toString());
sendResponseError(resp, HttpServletResponse.SC_METHOD_NOT_ALLOWED, message, eventlogger);
} finally {
- eelfLogger.info(EelfMsgs.EXIT);
- }
+ eelfLogger.info(EelfMsgs.EXIT);
+ }
}
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/GroupServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/GroupServlet.java
index 484d54b5..c3cf8876 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/GroupServlet.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/GroupServlet.java
@@ -24,17 +24,18 @@
package org.onap.dmaap.datarouter.provisioning;
+import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.sendResponseError;
+
import java.io.IOException;
import java.io.InvalidObjectException;
-
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
import org.json.JSONObject;
+
import org.onap.dmaap.datarouter.provisioning.beans.EventLogRecord;
import org.onap.dmaap.datarouter.provisioning.beans.Group;
-import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.sendResponseError;
+
/**
* This servlet handles provisioning for the &lt;groups&gt; which is generated by the provisioning
@@ -61,6 +62,7 @@ public class GroupServlet extends ProxyServlet {
eventlogger.error(elr.toString());
sendResponseError(resp, HttpServletResponse.SC_METHOD_NOT_ALLOWED, message, eventlogger);
}
+
/**
* GET on the the list of groups to a feed/sub.
* See the <i>Groups Collection Query</i> section in the <b>Provisioning API</b>
@@ -113,6 +115,7 @@ public class GroupServlet extends ProxyServlet {
}
}
+
/**
* PUT on the &lt;GROUPS&gt; -- not supported.
*/
@@ -178,8 +181,9 @@ public class GroupServlet extends ProxyServlet {
sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST, message, eventlogger);
return;
}
- if (intlogger.isDebugEnabled())
+ if (intlogger.isDebugEnabled()) {
intlogger.debug(jo.toString());
+ }
Group gup;
try {
gup = new Group(jo);
@@ -194,9 +198,9 @@ public class GroupServlet extends ProxyServlet {
gup.setGroupid(oldgup.getGroupid());
Group gb2 = Group.getGroupMatching(gup, oldgup.getGroupid());
if (gb2 != null) {
- eventlogger.warn("PROV0011 Creating a duplicate Group: "+gup.getName());
+ eventlogger.warn("PROV0011 Creating a duplicate Group: " + gup.getName());
elr.setResult(HttpServletResponse.SC_BAD_REQUEST);
- sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST, "Duplicate Group:"+gup.getName(), eventlogger);
+ sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST,"Duplicate Group:" + gup.getName(), eventlogger);
return;
}
@@ -220,6 +224,7 @@ public class GroupServlet extends ProxyServlet {
sendResponseError(resp, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, DB_PROBLEM_MSG, eventlogger);
}
}
+
/**
* POST on the &lt;groups&gt; -- create a new GROUPS to a feed.
* See the <i>Creating a GROUPS</i> section in the <b>Provisioning API</b>
@@ -253,7 +258,7 @@ public class GroupServlet extends ProxyServlet {
ContentHeader ch = getContentHeader(req);
String ver = ch.getAttribute("version");
if (!ch.getType().equals(GROUP_BASECONTENT_TYPE) || !(ver.equals("1.0") || ver.equals("2.0"))) {
- intlogger.debug("Content-type is: "+req.getHeader("Content-Type"));
+ intlogger.debug("Content-type is: " + req.getHeader("Content-Type"));
message = "Incorrect content-type";
elr.setMessage(message);
elr.setResult(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
@@ -270,8 +275,9 @@ public class GroupServlet extends ProxyServlet {
sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST, message, eventlogger);
return;
}
- if (intlogger.isDebugEnabled())
+ if (intlogger.isDebugEnabled()) {
intlogger.debug(jo.toString());
+ }
Group gup;
try {
@@ -288,9 +294,9 @@ public class GroupServlet extends ProxyServlet {
// Check if this group already exists; not an error (yet), just warn
Group gb2 = Group.getGroupMatching(gup);
if (gb2 != null) {
- eventlogger.warn("PROV0011 Creating a duplicate Group: "+gup.getName());
+ eventlogger.warn("PROV0011 Creating a duplicate Group: " + gup.getName());
elr.setResult(HttpServletResponse.SC_BAD_REQUEST);
- sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST, "Duplicate Group:"+gup.getName(), eventlogger);
+ sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST,"Duplicate Group:" + gup.getName(), eventlogger);
return;
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/InternalServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/InternalServlet.java
index 8ae9fa20..12bd6ef4 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/InternalServlet.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/InternalServlet.java
@@ -24,6 +24,10 @@
package org.onap.dmaap.datarouter.provisioning;
+import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.sendResponseError;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
@@ -48,10 +52,7 @@ import org.onap.dmaap.datarouter.provisioning.utils.DB;
import org.onap.dmaap.datarouter.provisioning.utils.LogfileLoader;
import org.onap.dmaap.datarouter.provisioning.utils.RLEBitSet;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.sendResponseError;
/**
* <p>
@@ -128,7 +129,8 @@ import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.send
* <tr class="altColor">
* <td class="colFirst">/internal/route/*</td>
* <td class="colOne">*</td>
- * <td class="colLast">URLs under this path are handled via the {@link org.onap.dmaap.datarouter.provisioning.RouteServlet}</td>
+ * <td class="colLast">URLs under this path are handled via the
+ * {@link org.onap.dmaap.datarouter.provisioning.RouteServlet}</td>
* </tr>
* </table>
* </div>
@@ -153,6 +155,7 @@ import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.send
* @author Robert Eby
* @version $Id: InternalServlet.java,v 1.23 2014/03/24 18:47:10 eby Exp $
*/
+
@SuppressWarnings("serial")
public class InternalServlet extends ProxyServlet {
@@ -172,7 +175,8 @@ public class InternalServlet extends ProxyServlet {
setIpFqdnRequestIDandInvocationIDForEelf("doDelete", req);
eelfLogger.info(EelfMsgs.ENTRY);
try {
- eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
+ eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID,
+ req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
EventLogRecord elr = new EventLogRecord(req);
if (!isAuthorizedForInternal(req)) {
elr.setMessage(UNAUTHORIZED);
@@ -202,7 +206,8 @@ public class InternalServlet extends ProxyServlet {
// Something went wrong with the DELETE
elr.setResult(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
eventlogger.error(elr.toString());
- sendResponseError(resp, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, DB_PROBLEM_MSG, eventlogger);
+ sendResponseError(resp, HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
+ DB_PROBLEM_MSG, eventlogger);
}
return;
}
@@ -223,7 +228,8 @@ public class InternalServlet extends ProxyServlet {
setIpFqdnRequestIDandInvocationIDForEelf("doGet",req);
eelfLogger.info(EelfMsgs.ENTRY);
try {
- eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
+ eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID,
+ req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
String path = req.getPathInfo();
Properties props = (new DB()).getProperties();
if ("/halt".equals(path) && !req.isSecure()) {
@@ -250,8 +256,8 @@ public class InternalServlet extends ProxyServlet {
}
if ("/fetchProv".equals(path) && !req.isSecure()) {
// if request came from active_pod or standby_pod and it is not us, reload prov data
- SynchronizerTask s = SynchronizerTask.getSynchronizer();
- s.doFetch();
+ SynchronizerTask sync = SynchronizerTask.getSynchronizer();
+ sync.doFetch();
resp.setStatus(HttpServletResponse.SC_OK);
return;
}
@@ -263,11 +269,11 @@ public class InternalServlet extends ProxyServlet {
// fall back to returning the local data if the remote is unreachable
intlogger.info("Active server unavailable; falling back to local copy.");
}
- Poker p = Poker.getPoker();
+ Poker pkr = Poker.getPoker();
resp.setStatus(HttpServletResponse.SC_OK);
resp.setContentType(PROVFULL_CONTENT_TYPE2);
try {
- resp.getOutputStream().print(p.getProvisioningString());
+ resp.getOutputStream().print(pkr.getProvisioningString());
} catch (IOException ioe) {
intlogger.error("PROV0131 InternalServlet.doGet: " + ioe.getMessage(), ioe);
}
@@ -350,7 +356,8 @@ public class InternalServlet extends ProxyServlet {
setIpFqdnRequestIDandInvocationIDForEelf("doPut", req);
eelfLogger.info(EelfMsgs.ENTRY);
try {
- eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
+ eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID,
+ req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
EventLogRecord elr = new EventLogRecord(req);
if (!isAuthorizedForInternal(req)) {
elr.setMessage(UNAUTHORIZED);
@@ -369,8 +376,8 @@ public class InternalServlet extends ProxyServlet {
if (key.length() > 0) {
Parameters param = Parameters.getParameter(key);
if (param != null) {
- String t = catValues(req.getParameterValues("val"));
- param.setValue(t);
+ String str = catValues(req.getParameterValues("val"));
+ param.setValue(str);
if (doUpdate(param)) {
elr.setResult(HttpServletResponse.SC_OK);
eventlogger.info(elr.toString());
@@ -381,7 +388,8 @@ public class InternalServlet extends ProxyServlet {
// Something went wrong with the UPDATE
elr.setResult(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
eventlogger.error(elr.toString());
- sendResponseError(resp, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, DB_PROBLEM_MSG, eventlogger);
+ sendResponseError(resp, HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
+ DB_PROBLEM_MSG, eventlogger);
}
return;
}
@@ -423,8 +431,8 @@ public class InternalServlet extends ProxyServlet {
if (key.length() > 0) {
Parameters param = Parameters.getParameter(key);
if (param == null) {
- String t = catValues(req.getParameterValues("val"));
- param = new Parameters(key, t);
+ String str = catValues(req.getParameterValues("val"));
+ param = new Parameters(key, str);
if (doInsert(param)) {
elr.setResult(HttpServletResponse.SC_OK);
eventlogger.info(elr.toString());
@@ -435,7 +443,8 @@ public class InternalServlet extends ProxyServlet {
// Something went wrong with the INSERT
elr.setResult(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
eventlogger.error(elr.toString());
- sendResponseError(resp, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, DB_PROBLEM_MSG, eventlogger);
+ sendResponseError(resp, HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
+ DB_PROBLEM_MSG, eventlogger);
}
return;
}
@@ -451,7 +460,8 @@ public class InternalServlet extends ProxyServlet {
eventlogger.error(elr.toString());
return;
}
- String spooldir = (new DB()).getProperties().getProperty("org.onap.dmaap.datarouter.provserver.spooldir");
+ String spooldir =
+ (new DB()).getProperties().getProperty("org.onap.dmaap.datarouter.provserver.spooldir");
String spoolname = String.format("%d-%d-", System.currentTimeMillis(), Thread.currentThread().getId());
synchronized (lock) {
// perhaps unnecessary, but it helps make the name unique
@@ -495,7 +505,8 @@ public class InternalServlet extends ProxyServlet {
Path tmppath = Paths.get(spooldir, spoolname);
Path donepath = Paths.get(spooldir, "IN." + spoolname);
try {
- Files.copy(req.getInputStream(), Paths.get(spooldir, spoolname), StandardCopyOption.REPLACE_EXISTING);
+ Files.copy(req.getInputStream(), Paths.get(spooldir, spoolname),
+ StandardCopyOption.REPLACE_EXISTING);
Files.move(tmppath, donepath, StandardCopyOption.REPLACE_EXISTING);
elr.setResult(HttpServletResponse.SC_CREATED);
resp.setStatus(HttpServletResponse.SC_CREATED);
@@ -524,10 +535,10 @@ public class InternalServlet extends ProxyServlet {
while ((ch = is.read()) >= 0) {
bos.write(ch);
}
- RLEBitSet bs = new RLEBitSet(bos.toString()); // The set of records to retrieve
elr.setResult(HttpServletResponse.SC_OK);
resp.setStatus(HttpServletResponse.SC_OK);
resp.setContentType(TEXT_CT);
+ RLEBitSet bs = new RLEBitSet(bos.toString()); // The set of records to retrieve
LogRecord.printLogRecords(resp.getOutputStream(), bs);
eventlogger.info(elr.toString());
} catch (IOException ioe) {
@@ -544,11 +555,11 @@ public class InternalServlet extends ProxyServlet {
}
}
- private String catValues(String[] v) {
+ private String catValues(String[] val) {
StringBuilder sb = new StringBuilder();
- if (v != null) {
+ if (val != null) {
String pfx = "";
- for (String s : v) {
+ for (String s : val) {
sb.append(pfx);
sb.append(s);
pfx = "|";
@@ -559,13 +570,13 @@ public class InternalServlet extends ProxyServlet {
private JSONArray generateLogfileList() {
JSONArray ja = new JSONArray();
- Properties p = (new DB()).getProperties();
- String s = p.getProperty("org.onap.dmaap.datarouter.provserver.accesslog.dir");
- if (s != null) {
- String[] dirs = s.split(",");
+ Properties prop = (new DB()).getProperties();
+ String str = prop.getProperty("org.onap.dmaap.datarouter.provserver.accesslog.dir");
+ if (str != null) {
+ String[] dirs = str.split(",");
for (String dir : dirs) {
- File f = new File(dir);
- String[] list = f.list();
+ File file = new File(dir);
+ String[] list = file.list();
if (list != null) {
for (String s2 : list) {
if (!s2.startsWith(".")) {
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/LogServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/LogServlet.java
index e3b9c57b..0bea9f40 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/LogServlet.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/LogServlet.java
@@ -24,6 +24,10 @@
package org.onap.dmaap.datarouter.provisioning;
+import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.sendResponseError;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
@@ -34,7 +38,6 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
-
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -49,10 +52,9 @@ import org.onap.dmaap.datarouter.provisioning.eelf.EelfMsgs;
import org.onap.dmaap.datarouter.provisioning.utils.DB;
import org.onap.dmaap.datarouter.provisioning.utils.LOGJSONObject;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.sendResponseError;
+
+
/**
* This servlet handles requests to the &lt;feedLogURL&gt; and &lt;subLogURL&gt;,
@@ -62,6 +64,7 @@ import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.send
* @version $Id: LogServlet.java,v 1.11 2014/03/28 17:27:02 eby Exp $
*/
@SuppressWarnings("serial")
+
public class LogServlet extends BaseServlet {
//Adding EELF Logger Rally:US664892
private static EELFLogger eelfLogger = EELFManager.getInstance().getLogger(LogServlet.class);
@@ -82,11 +85,22 @@ public class LogServlet extends BaseServlet {
private final String[] fields;
private boolean firstrow;
- public RowHandler(ServletOutputStream out, String fieldparam, boolean b) {
+ /**
+ * Row setter.
+ * @param out ServletOutputStream
+ * @param fieldparam String field
+ * @param bool boolean
+ */
+ public RowHandler(ServletOutputStream out, String fieldparam, boolean bool) {
this.out = out;
- this.firstrow = b;
+ this.firstrow = bool;
this.fields = (fieldparam != null) ? fieldparam.split(":") : null;
}
+
+ /**
+ * Handling row from DB.
+ * @param rs DB Resultset
+ */
public void handleRow(ResultSet rs) {
try {
LOGJSONable js = buildJSONable(rs);
@@ -95,44 +109,52 @@ public class LogServlet extends BaseServlet {
// filter out unwanted fields
LOGJSONObject j2 = new LOGJSONObject();
for (String key : fields) {
- Object v = jo.opt(key);
- if (v != null)
- j2.put(key, v);
+ Object val = jo.opt(key);
+ if (val != null) {
+ j2.put(key, val);
+ }
}
jo = j2;
}
- String t = firstrow ? "\n" : ",\n";
- t += jo.toString();
- out.print(t);
+ String str = firstrow ? "\n" : ",\n";
+ str += jo.toString();
+ out.print(str);
firstrow = false;
} catch (Exception exception) {
intlogger.info("Failed to handle row. Exception = " + exception.getMessage(),exception);
}
}
+
public abstract LOGJSONable buildJSONable(ResultSet rs) throws SQLException;
}
+
public class PublishRecordRowHandler extends RowHandler {
- public PublishRecordRowHandler(ServletOutputStream out, String fields, boolean b) {
- super(out, fields, b);
+ public PublishRecordRowHandler(ServletOutputStream out, String fields, boolean bool) {
+ super(out, fields, bool);
}
+
@Override
public LOGJSONable buildJSONable(ResultSet rs) throws SQLException {
return new PublishRecord(rs);
}
}
+
public class DeliveryRecordRowHandler extends RowHandler {
- public DeliveryRecordRowHandler(ServletOutputStream out, String fields, boolean b) {
- super(out, fields, b);
+ public DeliveryRecordRowHandler(ServletOutputStream out, String fields, boolean bool) {
+ super(out, fields, bool);
}
+
@Override
public LOGJSONable buildJSONable(ResultSet rs) throws SQLException {
return new DeliveryRecord(rs);
}
}
+
public class ExpiryRecordRowHandler extends RowHandler {
- public ExpiryRecordRowHandler(ServletOutputStream out, String fields, boolean b) {
- super(out, fields, b);
+ public ExpiryRecordRowHandler(ServletOutputStream out, String fields, boolean bool) {
+ super(out, fields, bool);
}
+
@Override
public LOGJSONable buildJSONable(ResultSet rs) throws SQLException {
return new ExpiryRecord(rs);
@@ -156,7 +178,8 @@ public class LogServlet extends BaseServlet {
setIpFqdnRequestIDandInvocationIDForEelf("doDelete", req);
eelfLogger.info(EelfMsgs.ENTRY);
try {
- eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
+ eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID,
+ req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
String message = "DELETE not allowed for the logURL.";
EventLogRecord elr = new EventLogRecord(req);
elr.setMessage(message);
@@ -167,6 +190,7 @@ public class LogServlet extends BaseServlet {
eelfLogger.info(EelfMsgs.EXIT);
}
}
+
/**
* GET a logging URL -- retrieve logging data for a feed or subscription.
* See the <b>Logging API</b> document for details on how this method should be invoked.
@@ -176,15 +200,18 @@ public class LogServlet extends BaseServlet {
setIpFqdnRequestIDandInvocationIDForEelf("doGet", req);
eelfLogger.info(EelfMsgs.ENTRY);
try {
- eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
+ eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID,
+ req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
int id = getIdFromPath(req);
if (id < 0) {
- sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST, "Missing or bad feed/subscription number.", eventlogger);
+ sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST,
+ "Missing or bad feed/subscription number.", eventlogger);
return;
}
Map<String, String> map = buildMapFromRequest(req);
if (map.get("err") != null) {
- sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST, "Invalid arguments: " + map.get("err"), eventlogger);
+ sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST,
+ "Invalid arguments: " + map.get("err"), eventlogger);
return;
}
// check Accept: header??
@@ -238,6 +265,7 @@ public class LogServlet extends BaseServlet {
eelfLogger.info(EelfMsgs.EXIT);
}
}
+
/**
* PUT a logging URL -- not supported.
*/
@@ -246,7 +274,8 @@ public class LogServlet extends BaseServlet {
setIpFqdnRequestIDandInvocationIDForEelf("doPut", req);
eelfLogger.info(EelfMsgs.ENTRY);
try {
- eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER),getIdFromPath(req)+"");
+ eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID,
+ req.getHeader(BEHALF_HEADER),getIdFromPath(req) + "");
String message = "PUT not allowed for the logURL.";
EventLogRecord elr = new EventLogRecord(req);
elr.setMessage(message);
@@ -257,6 +286,7 @@ public class LogServlet extends BaseServlet {
eelfLogger.info(EelfMsgs.EXIT);
}
}
+
/**
* POST a logging URL -- not supported.
*/
@@ -279,10 +309,10 @@ public class LogServlet extends BaseServlet {
private Map<String, String> buildMapFromRequest(HttpServletRequest req) {
Map<String, String> map = new HashMap<>();
- String s = req.getParameter("type");
- if (s != null) {
- if ("pub".equals(s) || "del".equals(s) || "exp".equals(s)) {
- map.put("type", s);
+ String str = req.getParameter("type");
+ if (str != null) {
+ if ("pub".equals(str) || "del".equals(str) || "exp".equals(str)) {
+ map.put("type", str);
} else {
map.put("err", "bad type");
return map;
@@ -296,24 +326,24 @@ public class LogServlet extends BaseServlet {
map.put(REASON_SQL, "");
map.put(FILENAMESQL, "");
- s = req.getParameter("publishId");
- if (s != null) {
- if (s.indexOf("'") >= 0) {
+ str = req.getParameter("publishId");
+ if (str != null) {
+ if (str.indexOf("'") >= 0) {
map.put("err", "bad publishId");
return map;
}
- map.put(PUBLISHSQL, " AND PUBLISH_ID = '"+s+"'");
+ map.put(PUBLISHSQL, " AND PUBLISH_ID = '" + str + "'");
}
- s = req.getParameter("filename");
- if (s != null) {
- map.put(FILENAMESQL, " AND FILENAME = '" + s + "'");
+ str = req.getParameter("filename");
+ if (str != null) {
+ map.put(FILENAMESQL, " AND FILENAME = '" + str + "'");
}
- s = req.getParameter("statusCode");
- if (s != null) {
+ str = req.getParameter("statusCode");
+ if (str != null) {
String sql = null;
- switch (s) {
+ switch (str) {
case "success":
sql = " AND STATUS >= 200 AND STATUS < 300";
break;
@@ -325,9 +355,9 @@ public class LogServlet extends BaseServlet {
break;
default:
try {
- int n = Integer.parseInt(s);
- if ((n >= 100 && n < 600) || (n == -1)) {
- sql = " AND STATUS = " + n;
+ int statusCode = Integer.parseInt(str);
+ if ((statusCode >= 100 && statusCode < 600) || (statusCode == -1)) {
+ sql = " AND STATUS = " + statusCode;
}
} catch (NumberFormatException e) {
intlogger.error("Failed to parse input", e);
@@ -342,16 +372,16 @@ public class LogServlet extends BaseServlet {
map.put(RESULTSQL, sql.replaceAll("STATUS", "RESULT"));
}
- s = req.getParameter("expiryReason");
- if (s != null) {
+ str = req.getParameter("expiryReason");
+ if (str != null) {
map.put("type", "exp");
- if ("notRetryable".equals(s)) {
+ if ("notRetryable".equals(str)) {
map.put(REASON_SQL, " AND REASON = 'notRetryable'");
- } else if ("retriesExhausted".equals(s)) {
+ } else if ("retriesExhausted".equals(str)) {
map.put(REASON_SQL, " AND REASON = 'retriesExhausted'");
- } else if ("diskFull".equals(s)) {
+ } else if ("diskFull".equals(str)) {
map.put(REASON_SQL, " AND REASON = 'diskFull'");
- } else if ("other".equals(s)) {
+ } else if ("other".equals(str)) {
map.put(REASON_SQL, " AND REASON = 'other'");
} else {
map.put("err", "bad expiryReason");
@@ -380,25 +410,27 @@ public class LogServlet extends BaseServlet {
map.put(TIMESQL, String.format(" AND EVENT_TIME >= %d AND EVENT_TIME <= %d", stime, etime));
return map;
}
- private long getTimeFromParam(final String s) {
- if (s == null)
+
+ private long getTimeFromParam(final String str) {
+ if (str == null) {
return 0;
+ }
try {
// First, look for an RFC 3339 date
- String fmt = (s.indexOf('.') > 0) ? FMT_2 : FMT_1;
+ String fmt = (str.indexOf('.') > 0) ? FMT_2 : FMT_1;
SimpleDateFormat sdf = new SimpleDateFormat(fmt);
- Date d = sdf.parse(s);
- return d.getTime();
+ Date date = sdf.parse(str);
+ return date.getTime();
} catch (ParseException parseException) {
intlogger.error("Exception in getting Time :- " + parseException.getMessage(),parseException);
}
try {
// Also allow a long (in ms); useful for testing
- return Long.parseLong(s);
+ return Long.parseLong(str);
} catch (NumberFormatException numberFormatException) {
intlogger.error("Exception in getting Time :- " + numberFormatException.getMessage(),numberFormatException);
}
- intlogger.info("Error parsing time=" + s);
+ intlogger.info("Error parsing time=" + str);
return -1;
}
@@ -411,6 +443,7 @@ public class LogServlet extends BaseServlet {
getRecordsForSQL(sql, rh);
}
}
+
private void getDeliveryRecordsForFeed(int feedid, RowHandler rh, Map<String, String> map) {
String type = map.get("type");
if ("all".equals(type) || "del".equals(type)) {
@@ -420,6 +453,7 @@ public class LogServlet extends BaseServlet {
getRecordsForSQL(sql, rh);
}
}
+
private void getDeliveryRecordsForSubscription(int subid, RowHandler rh, Map<String, String> map) {
String type = map.get("type");
if ("all".equals(type) || "del".equals(type)) {
@@ -429,6 +463,7 @@ public class LogServlet extends BaseServlet {
getRecordsForSQL(sql, rh);
}
}
+
private void getExpiryRecordsForFeed(int feedid, RowHandler rh, Map<String, String> map) {
String type = map.get("type");
if ("all".equals(type) || "exp".equals(type)) {
@@ -441,6 +476,7 @@ public class LogServlet extends BaseServlet {
}
}
}
+
private void getExpiryRecordsForSubscription(int subid, RowHandler rh, Map<String, String> map) {
String type = map.get("type");
if ("all".equals(type) || "exp".equals(type)) {
@@ -471,8 +507,9 @@ public class LogServlet extends BaseServlet {
} catch (SQLException sqlException) {
intlogger.info("Failed to get Records. Exception = " + sqlException.getMessage(),sqlException);
} finally {
- if (conn != null)
+ if (conn != null) {
db.release(conn);
+ }
}
intlogger.debug("Time: " + (System.currentTimeMillis() - start) + " ms");
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Main.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Main.java
index 7c693bd2..aefe8cdf 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Main.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Main.java
@@ -24,11 +24,24 @@
package org.onap.dmaap.datarouter.provisioning;
-
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.Security;
+import java.util.EnumSet;
+import java.util.Properties;
+import java.util.Timer;
+import javax.servlet.DispatcherType;
import org.eclipse.jetty.http.HttpVersion;
-import org.eclipse.jetty.server.*;
+import org.eclipse.jetty.server.Connector;
+import org.eclipse.jetty.server.Handler;
+import org.eclipse.jetty.server.HttpConfiguration;
+import org.eclipse.jetty.server.HttpConnectionFactory;
+import org.eclipse.jetty.server.NCSARequestLog;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.ServerConnector;
+import org.eclipse.jetty.server.SslConnectionFactory;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerCollection;
@@ -39,15 +52,12 @@ import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.onap.aaf.cadi.PropAccess;
-import org.onap.dmaap.datarouter.provisioning.utils.*;
-import javax.servlet.DispatcherType;
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.Security;
-import java.util.EnumSet;
-import java.util.Properties;
-import java.util.Timer;
+import org.onap.dmaap.datarouter.provisioning.utils.DB;
+import org.onap.dmaap.datarouter.provisioning.utils.DRProvCadiFilter;
+import org.onap.dmaap.datarouter.provisioning.utils.LogfileLoader;
+import org.onap.dmaap.datarouter.provisioning.utils.PurgeLogDirTask;
+import org.onap.dmaap.datarouter.provisioning.utils.ThrottleFilter;
/**
* <p>
@@ -81,7 +91,7 @@ import java.util.Timer;
public class Main {
/**
- * The truststore to use if none is specified
+ * The truststore to use if none is specified.
*/
static final String DEFAULT_TRUSTSTORE = "/opt/java/jdk/jdk180/jre/lib/security/cacerts";
static final String KEYSTORE_TYPE_PROPERTY = "org.onap.dmaap.datarouter.provserver.keystore.type";
@@ -89,10 +99,11 @@ public class Main {
static final String KEYSTORE_PASS_PROPERTY = "org.onap.dmaap.datarouter.provserver.keystore.password";
static final String TRUSTSTORE_PATH_PROPERTY = "org.onap.dmaap.datarouter.provserver.truststore.path";
static final String TRUSTSTORE_PASS_PROPERTY = "org.onap.dmaap.datarouter.provserver.truststore.password";
- public static final EELFLogger intlogger = EELFManager.getInstance().getLogger("org.onap.dmaap.datarouter.provisioning.internal");
+ public static final EELFLogger intlogger = EELFManager.getInstance()
+ .getLogger("org.onap.dmaap.datarouter.provisioning.internal");
/**
- * The one and only {@link Server} instance in this JVM
+ * The one and only {@link Server} instance in this JVM.
*/
private static Server server;
@@ -116,7 +127,6 @@ public class Main {
*/
public static void main(String[] args) throws Exception {
Security.setProperty("networkaddress.cache.ttl", "4");
- Properties provProperties = (new DB()).getProperties();
// Check DB is accessible and contains the expected tables
if (!checkDatabase()) {
System.exit(1);
@@ -125,8 +135,11 @@ public class Main {
intlogger.info("PROV0000 **** AT&T Data Router Provisioning Server starting....");
Security.setProperty("networkaddress.cache.ttl", "4");
- int httpPort = Integer.parseInt(provProperties.getProperty("org.onap.dmaap.datarouter.provserver.http.port", "8080"));
- int httpsPort = Integer.parseInt(provProperties.getProperty("org.onap.dmaap.datarouter.provserver.https.port", "8443"));
+ Properties provProperties = (new DB()).getProperties();
+ int httpPort = Integer.parseInt(provProperties
+ .getProperty("org.onap.dmaap.datarouter.provserver.http.port", "8080"));
+ final int httpsPort = Integer.parseInt(provProperties
+ .getProperty("org.onap.dmaap.datarouter.provserver.https.port", "8443"));
// Server's thread pool
QueuedThreadPool queuedThreadPool = new QueuedThreadPool();
@@ -143,7 +156,9 @@ public class Main {
// Request log configuration
NCSARequestLog ncsaRequestLog = new NCSARequestLog();
- ncsaRequestLog.setFilename(provProperties.getProperty("org.onap.dmaap.datarouter.provserver.accesslog.dir") + "/request.log.yyyy_mm_dd");
+ ncsaRequestLog.setFilename(provProperties
+ .getProperty("org.onap.dmaap.datarouter.provserver.accesslog.dir")
+ + "/request.log.yyyy_mm_dd");
ncsaRequestLog.setFilenameDateFormat("yyyyMMdd");
ncsaRequestLog.setRetainDays(90);
ncsaRequestLog.setAppend(true);
@@ -167,7 +182,8 @@ public class Main {
//HTTP Connector
HandlerCollection handlerCollection;
- try (ServerConnector httpServerConnector = new ServerConnector(server, new HttpConnectionFactory(httpConfiguration))) {
+ try (ServerConnector httpServerConnector =
+ new ServerConnector(server, new HttpConnectionFactory(httpConfiguration))) {
httpServerConnector.setPort(httpPort);
httpServerConnector.setAcceptQueueSize(2);
httpServerConnector.setIdleTimeout(300000);
@@ -177,7 +193,8 @@ public class Main {
sslContextFactory.setKeyStoreType(provProperties.getProperty(KEYSTORE_TYPE_PROPERTY, "jks"));
sslContextFactory.setKeyStorePath(provProperties.getProperty(KEYSTORE_PATH_PROPERTY));
sslContextFactory.setKeyStorePassword(provProperties.getProperty(KEYSTORE_PASS_PROPERTY));
- sslContextFactory.setKeyManagerPassword(provProperties.getProperty("org.onap.dmaap.datarouter.provserver.keymanager.password"));
+ sslContextFactory.setKeyManagerPassword(provProperties
+ .getProperty("org.onap.dmaap.datarouter.provserver.keymanager.password"));
String ts = provProperties.getProperty(TRUSTSTORE_PATH_PROPERTY);
if (ts != null && ts.length() > 0) {
@@ -201,12 +218,17 @@ public class Main {
);
sslContextFactory.addExcludeProtocols("SSLv3");
sslContextFactory.setIncludeProtocols(provProperties.getProperty(
- "org.onap.dmaap.datarouter.provserver.https.include.protocols", "TLSv1.1|TLSv1.2").trim().split("\\|"));
-
- intlogger.info("Not supported protocols prov server:-" + String.join(",", sslContextFactory.getExcludeProtocols()));
- intlogger.info("Supported protocols prov server:-" + String.join(",", sslContextFactory.getIncludeProtocols()));
- intlogger.info("Not supported ciphers prov server:-" + String.join(",", sslContextFactory.getExcludeCipherSuites()));
- intlogger.info("Supported ciphers prov server:-" + String.join(",", sslContextFactory.getIncludeCipherSuites()));
+ "org.onap.dmaap.datarouter.provserver.https.include.protocols",
+ "TLSv1.1|TLSv1.2").trim().split("\\|"));
+
+ intlogger.info("Not supported protocols prov server:-"
+ + String.join(",", sslContextFactory.getExcludeProtocols()));
+ intlogger.info("Supported protocols prov server:-"
+ + String.join(",", sslContextFactory.getIncludeProtocols()));
+ intlogger.info("Not supported ciphers prov server:-"
+ + String.join(",", sslContextFactory.getExcludeCipherSuites()));
+ intlogger.info("Supported ciphers prov server:-"
+ + String.join(",", sslContextFactory.getIncludeCipherSuites()));
// HTTPS configuration
HttpConfiguration httpsConfiguration = new HttpConfiguration(httpConfiguration);
@@ -235,10 +257,12 @@ public class Main {
servletContextHandler.addServlet(new ServletHolder(new InternalServlet()), "/internal/*");
servletContextHandler.addServlet(new ServletHolder(new RouteServlet()), "/internal/route/*");
servletContextHandler.addServlet(new ServletHolder(new DRFeedsServlet()), "/");
- servletContextHandler.addFilter(new FilterHolder(new ThrottleFilter()), "/publish/*", EnumSet.of(DispatcherType.REQUEST));
+ servletContextHandler.addFilter(new FilterHolder(new ThrottleFilter()),
+ "/publish/*", EnumSet.of(DispatcherType.REQUEST));
//CADI Filter activation check
- if (Boolean.parseBoolean(provProperties.getProperty("org.onap.dmaap.datarouter.provserver.cadi.enabled", "false"))) {
+ if (Boolean.parseBoolean(provProperties.getProperty(
+ "org.onap.dmaap.datarouter.provserver.cadi.enabled", "false"))) {
//Get cadi properties
Properties cadiProperties = null;
try {
@@ -254,7 +278,8 @@ public class Main {
intlogger.info("PROV0001 aaf_url set to - " + cadiProperties.getProperty("aaf_url"));
PropAccess access = new PropAccess(cadiProperties);
- servletContextHandler.addFilter(new FilterHolder(new DRProvCadiFilter(true, access)), "/*", EnumSet.of(DispatcherType.REQUEST));
+ servletContextHandler.addFilter(new FilterHolder(new DRProvCadiFilter(true, access)),
+ "/*", EnumSet.of(DispatcherType.REQUEST));
}
ContextHandlerCollection contextHandlerCollection = new ContextHandlerCollection();
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Poker.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Poker.java
index f1660f94..5f421b0f 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Poker.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Poker.java
@@ -23,6 +23,8 @@
package org.onap.dmaap.datarouter.provisioning;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.InetAddress;
@@ -36,12 +38,10 @@ import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
import java.util.TreeSet;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;
+
import org.onap.dmaap.datarouter.provisioning.beans.EgressRoute;
import org.onap.dmaap.datarouter.provisioning.beans.Feed;
import org.onap.dmaap.datarouter.provisioning.beans.Group;
@@ -58,10 +58,11 @@ import org.onap.dmaap.datarouter.provisioning.utils.DB;
* @author Robert Eby
* @version $Id: Poker.java,v 1.11 2014/01/08 16:13:47 eby Exp $
*/
+
public class Poker extends TimerTask {
/**
- * Template used to generate the URL to issue the GET against
+ * Template used to generate the URL to issue the GET against.
*/
private static final String POKE_URL_TEMPLATE = "http://%s/internal/fetchProv";
@@ -69,7 +70,7 @@ public class Poker extends TimerTask {
private static final String CARRIAGE_RETURN = "\n],\n";
/**
- * This is a singleton -- there is only one Poker object in the server
+ * This is a singleton -- there is only one Poker object in the server.
*/
private static Poker poker;
private long timer1;
@@ -81,7 +82,6 @@ public class Poker extends TimerTask {
private Poker() {
timer1 = timer2 = 0;
- Timer rolex = new Timer();
logger = EELFManager.getInstance().getLogger("InternalLog");
try {
thisPod = InetAddress.getLocalHost().getHostName();
@@ -90,7 +90,7 @@ public class Poker extends TimerTask {
logger.info("UnknownHostException: Setting thisPod to \"*UNKNOWN_POD*\"", e);
}
provString = buildProvisioningString();
-
+ Timer rolex = new Timer();
rolex.scheduleAtFixedRate(this, 0L, 1000L); // Run once a second to check the timers
}
@@ -186,7 +186,7 @@ public class Poker extends TimerTask {
private void pokeNode(final String nodename) {
logger.debug("PROV0012 Poking node " + nodename + " ...");
String nodeUrl = String.format(POKE_URL_TEMPLATE, nodename + ":" + DB.getHttpPort());
- Runnable r = () -> {
+ Runnable runn = () -> {
try {
URL url = new URL(nodeUrl);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
@@ -203,7 +203,7 @@ public class Poker extends TimerTask {
.getMessage(), e);
}
};
- r.run();
+ runn.run();
}
private String buildProvisioningString() {
@@ -251,15 +251,15 @@ public class Poker extends TimerTask {
ivals.addAll(Arrays.asList(intv.split("\\|")));
}
for (String key : new TreeSet<String>(props.keySet())) {
- String v = props.get(key);
+ String val = props.get(key);
sb.append(pfx);
sb.append(" \"").append(key).append("\": ");
if (ivals.contains(key)) {
// integer value
- sb.append(v);
+ sb.append(val);
} else if (key.endsWith("S")) {
// Split and append array of strings
- String[] pp = v.split("\\|");
+ String[] pp = val.split("\\|");
String p2 = "";
sb.append("[");
for (String t : pp) {
@@ -268,7 +268,7 @@ public class Poker extends TimerTask {
}
sb.append("]");
} else {
- sb.append("\"").append(quote(v)).append("\"");
+ sb.append("\"").append(quote(val)).append("\"");
}
pfx = ",\n";
}
@@ -288,9 +288,9 @@ public class Poker extends TimerTask {
sb.append("\"egress\": {");
for (EgressRoute eg : EgressRoute.getAllEgressRoutes()) {
sb.append(pfx);
- String t = eg.asJSONObject().toString();
- t = t.substring(1, t.length() - 1);
- sb.append(t);
+ String str = eg.asJSONObject().toString();
+ str = str.substring(1, str.length() - 1);
+ sb.append(str);
pfx = ",\n";
}
sb.append("\n},\n");
@@ -315,9 +315,9 @@ public class Poker extends TimerTask {
return tempProvString;
}
- private String quote(String s) {
+ private String quote(String str) {
StringBuilder sb = new StringBuilder();
- for (char ch : s.toCharArray()) {
+ for (char ch : str.toCharArray()) {
if (ch == '\\' || ch == '"') {
sb.append('\\');
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/ProxyServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/ProxyServlet.java
index e47f9fbb..9a8037a8 100755
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/ProxyServlet.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/ProxyServlet.java
@@ -65,6 +65,7 @@ import org.onap.dmaap.datarouter.provisioning.utils.URLUtilities;
* @version $Id: ProxyServlet.java,v 1.3 2014/03/24 18:47:10 eby Exp $
*/
@SuppressWarnings("serial")
+
public class ProxyServlet extends BaseServlet {
private boolean inited = false;
@@ -80,11 +81,8 @@ public class ProxyServlet extends BaseServlet {
try {
// Set up keystore
Properties props = (new DB()).getProperties();
- String type = props.getProperty(Main.KEYSTORE_TYPE_PROPERTY, "jks");
String store = props.getProperty(Main.KEYSTORE_PATH_PROPERTY);
String pass = props.getProperty(Main.KEYSTORE_PASS_PROPERTY);
- KeyStore keyStore = readStore(store, pass, type);
-
store = props.getProperty(Main.TRUSTSTORE_PATH_PROPERTY);
pass = props.getProperty(Main.TRUSTSTORE_PASS_PROPERTY);
if (store == null || store.length() == 0) {
@@ -95,6 +93,8 @@ public class ProxyServlet extends BaseServlet {
// We are connecting with the node name, but the certificate will have the CNAME
// So we need to accept a non-matching certificate name
+ String type = props.getProperty(Main.KEYSTORE_TYPE_PROPERTY, "jks");
+ KeyStore keyStore = readStore(store, pass, type);
SSLSocketFactory socketFactory = new SSLSocketFactory(keyStore,
props.getProperty(Main.KEYSTORE_PASS_PROPERTY), trustStore);
socketFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
@@ -126,10 +126,10 @@ public class ProxyServlet extends BaseServlet {
* @return true or false
*/
boolean isProxyOK(final HttpServletRequest req) {
- String t = req.getQueryString();
- if (t != null) {
- t = t.replaceAll("&amp;", "&");
- for (String s : t.split("&")) {
+ String str = req.getQueryString();
+ if (str != null) {
+ str = str.replaceAll("&amp;", "&");
+ for (String s : str.split("&")) {
if ("noproxy".equals(s) || s.startsWith("noproxy=")) {
return false;
}
@@ -272,9 +272,9 @@ public class ProxyServlet extends BaseServlet {
StringBuilder sb = new StringBuilder("https://");
sb.append(URLUtilities.getPeerPodName());
sb.append(req.getRequestURI());
- String q = req.getQueryString();
- if (q != null) {
- sb.append("?").append(q);
+ String query = req.getQueryString();
+ if (query != null) {
+ sb.append("?").append(query);
}
return sb.toString();
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/PublishServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/PublishServlet.java
index 2ef5087f..2ca24539 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/PublishServlet.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/PublishServlet.java
@@ -28,7 +28,9 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@@ -53,6 +55,7 @@ import org.onap.dmaap.datarouter.provisioning.utils.DB;
* @version $Id: PublishServlet.java,v 1.8 2014/03/12 19:45:41 eby Exp $
*/
@SuppressWarnings("serial")
+
public class PublishServlet extends BaseServlet {
private int nextNode;
@@ -78,7 +81,8 @@ public class PublishServlet extends BaseServlet {
setUpEelfForPublishServlet(req, "doDelete");
eelfLogger.info(EelfMsgs.ENTRY);
try {
- eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
+ eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID,
+ req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
redirect(req, resp);
} finally {
eelfLogger.info(EelfMsgs.EXIT);
@@ -90,8 +94,9 @@ public class PublishServlet extends BaseServlet {
setUpEelfForPublishServlet(req, "doGet");
eelfLogger.info(EelfMsgs.ENTRY);
try {
- eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
- redirect(req, resp);
+ eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID,
+ req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
+ redirect(req, resp);
} finally {
eelfLogger.info(EelfMsgs.EXIT);
}
@@ -102,8 +107,9 @@ public class PublishServlet extends BaseServlet {
setUpEelfForPublishServlet(req, "doPut");
eelfLogger.info(EelfMsgs.ENTRY);
try {
- eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
- redirect(req, resp);
+ eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID,
+ req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
+ redirect(req, resp);
} finally {
eelfLogger.info(EelfMsgs.EXIT);
}
@@ -114,8 +120,8 @@ public class PublishServlet extends BaseServlet {
setUpEelfForPublishServlet(req, "doPost");
eelfLogger.info(EelfMsgs.ENTRY);
try {
- eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF, req.getHeader(BEHALF_HEADER));
- redirect(req, resp);
+ eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF, req.getHeader(BEHALF_HEADER));
+ redirect(req, resp);
} finally {
eelfLogger.info(EelfMsgs.EXIT);
}
@@ -123,7 +129,8 @@ public class PublishServlet extends BaseServlet {
}
private void setUpEelfForPublishServlet(HttpServletRequest req, String method) {
- if (StringUtils.isBlank(req.getHeader("X-ONAP-RequestID")) || StringUtils.isBlank(req.getHeader("X-InvocationID"))) {
+ if (StringUtils.isBlank(req.getHeader("X-ONAP-RequestID"))
+ || StringUtils.isBlank(req.getHeader("X-InvocationID"))) {
setIpFqdnForEelf(method);
} else {
setIpFqdnRequestIDandInvocationIDForEelf(method, req);
@@ -175,12 +182,12 @@ public class PublishServlet extends BaseServlet {
private String getRedirectNode(int feedid, HttpServletRequest req) {
// Check to see if the IRT needs to be updated
- Poker p = Poker.getPoker();
- String s = p.getProvisioningString();
+ Poker pkr = Poker.getPoker();
+ String str = pkr.getProvisioningString();
synchronized (lock) {
- if (irt == null || (s.length() != provstring.length()) || !s.equals(provstring)) {
+ if (irt == null || (str.length() != provstring.length()) || !str.equals(provstring)) {
// Provisioning string has changed -- update the IRT
- provstring = s;
+ provstring = str;
JSONObject jo = new JSONObject(new JSONTokener(provstring));
JSONArray ja = jo.getJSONArray("ingress");
List<IngressRoute> newlist = new ArrayList<>();
@@ -207,8 +214,7 @@ public class PublishServlet extends BaseServlet {
// No IRT rule matches, do round robin of all active nodes
String[] nodes = getNodes();
- if (nextNode >= nodes.length) // The list of nodes may have grown/shrunk
- {
+ if (nextNode >= nodes.length) { // The list of nodes may have grown/shrunk
nextNode = 0;
}
return nodes[nextNode++];
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/RouteServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/RouteServlet.java
index 383798fb..8506530b 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/RouteServlet.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/RouteServlet.java
@@ -24,14 +24,15 @@
package org.onap.dmaap.datarouter.provisioning;
+import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.sendResponseError;
+
import java.io.IOException;
import java.util.Set;
-
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
import org.json.JSONException;
import org.json.JSONObject;
+
import org.onap.dmaap.datarouter.provisioning.beans.Deleteable;
import org.onap.dmaap.datarouter.provisioning.beans.EgressRoute;
import org.onap.dmaap.datarouter.provisioning.beans.EventLogRecord;
@@ -40,7 +41,7 @@ import org.onap.dmaap.datarouter.provisioning.beans.Insertable;
import org.onap.dmaap.datarouter.provisioning.beans.NetworkRoute;
import org.onap.dmaap.datarouter.provisioning.beans.NodeClass;
-import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.sendResponseError;
+
/**
* <p>
@@ -50,7 +51,10 @@ import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.send
* </p>
* <div class="contentContainer">
* <table class="packageSummary" border="0" cellpadding="3" cellspacing="0">
- * <caption><span>URL Path Summary</span><span class="tabEnd">&nbsp;</span></caption>
+ * <caption>
+ * <span>URL Path Summary</span>
+ * <span class="tabEnd">&nbsp;</span>
+ * </caption>
* <tr>
* <th class="colFirst" width="35%">URL Path</th>
* <th class="colOne">Method</th>
@@ -109,6 +113,7 @@ import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.send
* and <i>tonode</i>.</td>
* </tr>
* </table>
+ * </div>
* <p>
* Authorization to use these URLs is a little different than for other URLs on the provisioning server.
* For the most part, the IP address that the request comes from should be either:
@@ -128,6 +133,7 @@ import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.send
* @version $Id$
*/
@SuppressWarnings("serial")
+
public class RouteServlet extends ProxyServlet {
/**
@@ -150,7 +156,7 @@ public class RouteServlet extends ProxyServlet {
String path = req.getPathInfo();
String[] parts = path.substring(1).split("/");
- Deleteable[] d = null;
+ Deleteable[] deleteables = null;
if ("ingress".equals(parts[0])) {
if (parts.length == 4) {
// /internal/route/ingress/<feed>/<user>/<subnet>
@@ -158,12 +164,15 @@ public class RouteServlet extends ProxyServlet {
int feedid = Integer.parseInt(parts[1]);
IngressRoute er = IngressRoute.getIngressRoute(feedid, parts[2], parts[3].replaceAll("!", "/"));
if (er == null) {
- sendResponseError(resp, HttpServletResponse.SC_NOT_FOUND, "The specified ingress route does not exist.", eventlogger);
+ sendResponseError(resp,
+ HttpServletResponse.SC_NOT_FOUND, "The specified ingress route does not exist.",
+ eventlogger);
return;
}
- d = new Deleteable[] { er };
+ deleteables = new Deleteable[] { er };
} catch (NumberFormatException e) {
- sendResponseError(resp, HttpServletResponse.SC_NOT_FOUND, "Invalid feed ID in 'delete ingress' command.", eventlogger);
+ sendResponseError(resp, HttpServletResponse.SC_NOT_FOUND,
+ "Invalid feed ID in 'delete ingress' command.", eventlogger);
return;
}
} else if (parts.length == 2) {
@@ -171,13 +180,15 @@ public class RouteServlet extends ProxyServlet {
try {
int seq = Integer.parseInt(parts[1]);
Set<IngressRoute> set = IngressRoute.getIngressRoutesForSeq(seq);
- d = set.toArray(new Deleteable[0]);
+ deleteables = set.toArray(new Deleteable[0]);
} catch (NumberFormatException e) {
- sendResponseError(resp, HttpServletResponse.SC_NOT_FOUND, "Invalid sequence number in 'delete ingress' command.", eventlogger);
+ sendResponseError(resp, HttpServletResponse.SC_NOT_FOUND,
+ "Invalid sequence number in 'delete ingress' command.", eventlogger);
return;
}
} else {
- sendResponseError(resp, HttpServletResponse.SC_NOT_FOUND, "Invalid number of arguments in 'delete ingress' command.", eventlogger);
+ sendResponseError(resp, HttpServletResponse.SC_NOT_FOUND,
+ "Invalid number of arguments in 'delete ingress' command.", eventlogger);
return;
}
} else if ("egress".equals(parts[0])) {
@@ -187,27 +198,30 @@ public class RouteServlet extends ProxyServlet {
int subid = Integer.parseInt(parts[1]);
EgressRoute er = EgressRoute.getEgressRoute(subid);
if (er == null) {
- sendResponseError(resp, HttpServletResponse.SC_NOT_FOUND, "The specified egress route does not exist.", eventlogger);
+ sendResponseError(resp, HttpServletResponse.SC_NOT_FOUND,
+ "The specified egress route does not exist.", eventlogger);
return;
}
- d = new Deleteable[] { er };
+ deleteables = new Deleteable[] { er };
} catch (NumberFormatException e) {
- sendResponseError(resp, HttpServletResponse.SC_NOT_FOUND, "Invalid sub ID in 'delete egress' command.", eventlogger);
+ sendResponseError(resp, HttpServletResponse.SC_NOT_FOUND,
+ "Invalid sub ID in 'delete egress' command.", eventlogger);
return;
}
} else {
- sendResponseError(resp, HttpServletResponse.SC_NOT_FOUND, "Invalid number of arguments in 'delete egress' command.", eventlogger);
+ sendResponseError(resp, HttpServletResponse.SC_NOT_FOUND,
+ "Invalid number of arguments in 'delete egress' command.", eventlogger);
return;
}
} else if ("network".equals(parts[0])) {
if (parts.length == 3) {
// /internal/route/network/<from>/<to>
- try {//
+ try {
NetworkRoute nr = new NetworkRoute(
NodeClass.normalizeNodename(parts[1]),
NodeClass.normalizeNodename(parts[2])
);
- d = new Deleteable[] { nr };
+ deleteables = new Deleteable[] { nr };
} catch (IllegalArgumentException e) {
String message = "The specified network route does not exist.";
eventlogger.error(message, e);
@@ -215,16 +229,17 @@ public class RouteServlet extends ProxyServlet {
return;
}
} else {
- sendResponseError(resp, HttpServletResponse.SC_NOT_FOUND, "Invalid number of arguments in 'delete network' command.", eventlogger);
+ sendResponseError(resp, HttpServletResponse.SC_NOT_FOUND,
+ "Invalid number of arguments in 'delete network' command.", eventlogger);
return;
}
}
- if (d == null) {
+ if (deleteables == null) {
sendResponseError(resp, HttpServletResponse.SC_NOT_FOUND, BAD_URL, eventlogger);
return;
}
boolean rv = true;
- for (Deleteable dd : d) {
+ for (Deleteable dd : deleteables) {
rv &= doDelete(dd);
}
if (rv) {
@@ -240,6 +255,7 @@ public class RouteServlet extends ProxyServlet {
sendResponseError(resp, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, DB_PROBLEM_MSG, eventlogger);
}
}
+
/**
* GET route table entries from the route table tree specified by the URL path.
*/
@@ -259,8 +275,9 @@ public class RouteServlet extends ProxyServlet {
}
String path = req.getPathInfo();
- if (!path.endsWith("/"))
+ if (!path.endsWith("/")) {
path += "/";
+ }
if (!"/".equals(path) && !INGRESS.equals(path) && !EGRESS.equals(path) && !NETWORK.equals(path)) {
sendResponseError(resp, HttpServletResponse.SC_NOT_FOUND, BAD_URL, eventlogger);
return;
@@ -321,6 +338,7 @@ public class RouteServlet extends ProxyServlet {
eventlogger.error("PROV0162 RouteServlet.doGet: " + ioe.getMessage(), ioe);
}
}
+
/**
* PUT on &lt;/internal/route/*&gt; -- not supported.
*/
@@ -336,6 +354,7 @@ public class RouteServlet extends ProxyServlet {
}
sendResponseError(resp, HttpServletResponse.SC_NOT_FOUND, BAD_URL, eventlogger);
}
+
/**
* POST - modify existing route table entries in the route table tree specified by the URL path.
*/
@@ -361,18 +380,22 @@ public class RouteServlet extends ProxyServlet {
// Although it probably doesn't make sense, you can install two identical routes in the IRT
int feedid = Integer.parseInt(req.getParameter("feed"));
String user = req.getParameter("user");
- if (user == null)
+ if (user == null) {
user = "-";
+ }
String subnet = req.getParameter("subnet");
- if (subnet == null)
+ if (subnet == null) {
subnet = "-";
+ }
String nodepatt = req.getParameter("nodepatt");
- String t = req.getParameter("seq");
- int seq = (t != null) ? Integer.parseInt(t) : (IngressRoute.getMaxSequence() + 100);
- ins = new Insertable[] { new IngressRoute(seq, feedid, user, subnet, NodeClass.lookupNodeNames(nodepatt)) };
+ String str = req.getParameter("seq");
+ int seq = (str != null) ? Integer.parseInt(str) : (IngressRoute.getMaxSequence() + 100);
+ ins = new Insertable[] { new IngressRoute(seq, feedid,
+ user, subnet, NodeClass.lookupNodeNames(nodepatt)) };
} catch (Exception e) {
intlogger.info(e.toString(), e);
- sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST, "Invalid arguments in 'add ingress' command.", intlogger);
+ sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST,
+ "Invalid arguments in 'add ingress' command.", intlogger);
return;
}
} else if (path.startsWith(EGRESS)) {
@@ -381,14 +404,16 @@ public class RouteServlet extends ProxyServlet {
int subid = Integer.parseInt(req.getParameter("sub"));
EgressRoute er = EgressRoute.getEgressRoute(subid);
if (er != null) {
- sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST, "An egress route already exists for that subscriber.", intlogger);
+ sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST,
+ "An egress route already exists for that subscriber.", intlogger);
return;
}
String node = NodeClass.normalizeNodename(req.getParameter("node"));
ins = new Insertable[] { new EgressRoute(subid, node) };
} catch (Exception e) {
intlogger.info(e.toString(), e);
- sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST, "Invalid arguments in 'add egress' command.", intlogger);
+ sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST,
+ "Invalid arguments in 'add egress' command.", intlogger);
return;
}
} else if (path.startsWith(NETWORK)) {
@@ -398,7 +423,8 @@ public class RouteServlet extends ProxyServlet {
String nto = req.getParameter("to");
String nvia = req.getParameter("via");
if (nfrom == null || nto == null || nvia == null) {
- sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST, "Missing arguments in 'add network' command.", intlogger);
+ sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST,
+ "Missing arguments in 'add network' command.", intlogger);
return;
}
nfrom = NodeClass.normalizeNodename(nfrom);
@@ -407,14 +433,17 @@ public class RouteServlet extends ProxyServlet {
NetworkRoute nr = new NetworkRoute(nfrom, nto, nvia);
for (NetworkRoute route : NetworkRoute.getAllNetworkRoutes()) {
if (route.getFromnode() == nr.getFromnode() && route.getTonode() == nr.getTonode()) {
- sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST, "Network route table already contains a route for " + nfrom + " and " + nto, intlogger);
+ sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST,
+ "Network route table already contains a route for " + nfrom
+ + " and " + nto, intlogger);
return;
}
}
ins = new Insertable[] { nr };
} catch (IllegalArgumentException e) {
intlogger.info(e.toString(), e);
- sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST, "Invalid arguments in 'add network' command.", intlogger);
+ sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST,
+ "Invalid arguments in 'add network' command.", intlogger);
return;
}
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/StatisticsServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/StatisticsServlet.java
index b0695449..fcdca0a3 100755
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/StatisticsServlet.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/StatisticsServlet.java
@@ -23,6 +23,8 @@
package org.onap.dmaap.datarouter.provisioning;
+import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.sendResponseError;
+
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -43,17 +45,17 @@ import org.onap.dmaap.datarouter.provisioning.beans.EventLogRecord;
import org.onap.dmaap.datarouter.provisioning.utils.DB;
import org.onap.dmaap.datarouter.provisioning.utils.LOGJSONObject;
-import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.sendResponseError;
/**
* This Servlet handles requests to the &lt;Statistics API&gt; and &lt;Statistics consilidated
- * resultset&gt;,
+ * resultset&gt;.
*
* @author Manish Singh
* @version $Id: StatisticsServlet.java,v 1.11 2016/08/10 17:27:02 Manish Exp $
*/
@SuppressWarnings("serial")
+
public class StatisticsServlet extends BaseServlet {
private static final long TWENTYFOUR_HOURS = (24 * 60 * 60 * 1000L);
@@ -83,7 +85,8 @@ public class StatisticsServlet extends BaseServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp) {
Map<String, String> map = buildMapFromRequest(req);
if (map.get("err") != null) {
- sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST, "Invalid arguments: " + map.get("err"), eventlogger);
+ sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST,
+ "Invalid arguments: " + map.get("err"), eventlogger);
return;
}
// check Accept: header??
@@ -159,10 +162,12 @@ public class StatisticsServlet extends BaseServlet {
/**
- * rsToJson - Converting RS to JSON object
+ * rsToJson - Converting RS to JSON object.
*
- * @param out ServletOutputStream, rs as ResultSet
- * @throws IOException, SQLException
+ * @param out ServletOutputStream
+ * @param rs as ResultSet
+ * @throws IOException input/output exception
+ * @throws SQLException SQL exception
*/
public void rsToCSV(ResultSet rs, ServletOutputStream out) throws IOException, SQLException {
String header = "FEEDNAME,FEEDID,FILES_PUBLISHED,PUBLISH_LENGTH, FILES_DELIVERED, "
@@ -199,10 +204,12 @@ public class StatisticsServlet extends BaseServlet {
}
/**
- * rsToJson - Converting RS to JSON object
+ * rsToJson - Converting RS to JSON object.
*
- * @param out ServletOutputStream, rs as ResultSet
- * @throws IOException, SQLException
+ * @param out ServletOutputStream
+ * @param rs as ResultSet
+ * @throws IOException input/output exception
+ * @throws SQLException SQL exception
*/
private void rsToJson(ResultSet rs, ServletOutputStream out) throws IOException, SQLException {
String[] fields = {"FEEDNAME", FEEDID, "FILES_PUBLISHED", "PUBLISH_LENGTH", "FILES_DELIVERED",
@@ -213,9 +220,9 @@ public class StatisticsServlet extends BaseServlet {
while (rs.next()) {
LOGJSONObject j2 = new LOGJSONObject();
for (String key : fields) {
- Object v = rs.getString(key);
- if (v != null) {
- j2.put(key.toLowerCase(), v);
+ Object val = rs.getString(key);
+ if (val != null) {
+ j2.put(key.toLowerCase(), val);
} else {
j2.put(key.toLowerCase(), "");
}
@@ -271,7 +278,7 @@ public class StatisticsServlet extends BaseServlet {
/**
- * queryGeneretor - Generating sql query
+ * queryGeneretor - Generating sql query.
*
* @param map as key value pare of all user input fields
*/
@@ -307,11 +314,18 @@ public class StatisticsServlet extends BaseServlet {
if (endTime == null && startTime == null) {
sql = "SELECT (SELECT NAME FROM FEEDS AS f WHERE f.FEEDID in(" + feedids
- + ") and f.FEEDID=e.FEEDID) AS FEEDNAME, e.FEEDID as FEEDID, (SELECT COUNT(*) FROM LOG_RECORDS AS c WHERE c.FEEDID in("
+ + ") and f.FEEDID=e.FEEDID) AS FEEDNAME, e.FEEDID as FEEDID, "
+ + "(SELECT COUNT(*) FROM LOG_RECORDS AS c WHERE c.FEEDID in("
+ feedids
- + ") and c.FEEDID=e.FEEDID AND c.TYPE='PUB') AS FILES_PUBLISHED,(SELECT SUM(content_length) FROM LOG_RECORDS AS c WHERE c.FEEDID in("
+ + ") and c.FEEDID=e.FEEDID AND c.TYPE='PUB') AS FILES_PUBLISHED,(SELECT SUM(content_length)"
+ + " FROM LOG_RECORDS AS c WHERE c.FEEDID in("
+ feedids
- + ") and c.FEEDID=e.FEEDID AND c.TYPE='PUB') AS PUBLISH_LENGTH, COUNT(e.EVENT_TIME) as FILES_DELIVERED, sum(m.content_length) as DELIVERED_LENGTH,SUBSTRING_INDEX(e.REQURI,'/',+3) as SUBSCRIBER_URL, e.DELIVERY_SUBID as SUBID, e.EVENT_TIME AS PUBLISH_TIME, m.EVENT_TIME AS DELIVERY_TIME, AVG(e.EVENT_TIME - m.EVENT_TIME)/1000 as AverageDelay FROM LOG_RECORDS e JOIN LOG_RECORDS m ON m.PUBLISH_ID = e.PUBLISH_ID AND e.FEEDID IN ("
+ + ") and c.FEEDID=e.FEEDID AND c.TYPE='PUB') AS PUBLISH_LENGTH, COUNT(e.EVENT_TIME) as FILES_DELIVERED,"
+ + "sum(m.content_length) as DELIVERED_LENGTH,SUBSTRING_INDEX(e.REQURI,'/',+3) as SUBSCRIBER_URL,"
+ + " e.DELIVERY_SUBID as SUBID, "
+ + "e.EVENT_TIME AS PUBLISH_TIME, m.EVENT_TIME AS DELIVERY_TIME, "
+ + " AVG(e.EVENT_TIME - m.EVENT_TIME)/1000 as AverageDelay FROM LOG_RECORDS"
+ + " e JOIN LOG_RECORDS m ON m.PUBLISH_ID = e.PUBLISH_ID AND e.FEEDID IN ("
+ feedids + ") " + subid + " AND m.STATUS=204 AND e.RESULT=204 group by SUBID";
return sql;
@@ -323,11 +337,18 @@ public class StatisticsServlet extends BaseServlet {
long compareTime = currentTimeInMilli - inputTimeInMilli;
sql = "SELECT (SELECT NAME FROM FEEDS AS f WHERE f.FEEDID in(" + feedids
- + ") and f.FEEDID=e.FEEDID) AS FEEDNAME, e.FEEDID as FEEDID, (SELECT COUNT(*) FROM LOG_RECORDS AS c WHERE c.FEEDID in("
+ + ") and f.FEEDID=e.FEEDID) AS FEEDNAME, e.FEEDID as FEEDID, "
+ + "(SELECT COUNT(*) FROM LOG_RECORDS AS c WHERE c.FEEDID in("
+ feedids
- + ") and c.FEEDID=e.FEEDID AND c.TYPE='PUB') AS FILES_PUBLISHED,(SELECT SUM(content_length) FROM LOG_RECORDS AS c WHERE c.FEEDID in("
+ + ") and c.FEEDID=e.FEEDID AND c.TYPE='PUB') AS FILES_PUBLISHED,"
+ + "(SELECT SUM(content_length) FROM LOG_RECORDS AS c WHERE c.FEEDID in("
+ feedids
- + ") and c.FEEDID=e.FEEDID AND c.TYPE='PUB') AS PUBLISH_LENGTH, COUNT(e.EVENT_TIME) as FILES_DELIVERED, sum(m.content_length) as DELIVERED_LENGTH,SUBSTRING_INDEX(e.REQURI,'/',+3) as SUBSCRIBER_URL, e.DELIVERY_SUBID as SUBID, e.EVENT_TIME AS PUBLISH_TIME, m.EVENT_TIME AS DELIVERY_TIME, AVG(e.EVENT_TIME - m.EVENT_TIME)/1000 as AverageDelay FROM LOG_RECORDS e JOIN LOG_RECORDS m ON m.PUBLISH_ID = e.PUBLISH_ID AND e.FEEDID IN ("
+ + ") and c.FEEDID=e.FEEDID AND c.TYPE='PUB') AS PUBLISH_LENGTH, COUNT(e.EVENT_TIME) as FILES_DELIVERED,"
+ + "sum(m.content_length) as DELIVERED_LENGTH,SUBSTRING_INDEX(e.REQURI,'/',+3) as SUBSCRIBER_URL,"
+ + " e.DELIVERY_SUBID as SUBID, "
+ + "e.EVENT_TIME AS PUBLISH_TIME, m.EVENT_TIME AS DELIVERY_TIME, "
+ + "AVG(e.EVENT_TIME - m.EVENT_TIME)/1000 as AverageDelay "
+ + "FROM LOG_RECORDS e JOIN LOG_RECORDS m ON m.PUBLISH_ID = e.PUBLISH_ID AND e.FEEDID IN ("
+ feedids + ") " + subid + " AND m.STATUS=204 AND e.RESULT=204 and e.event_time>="
+ compareTime + " group by SUBID";
@@ -342,12 +363,20 @@ public class StatisticsServlet extends BaseServlet {
long endInMillis = endDate.getTime();
sql = "SELECT (SELECT NAME FROM FEEDS AS f WHERE f.FEEDID in(" + feedids
- + ") and f.FEEDID=e.FEEDID) AS FEEDNAME, e.FEEDID as FEEDID, (SELECT COUNT(*) FROM LOG_RECORDS AS c WHERE c.FEEDID in("
+ + ") and f.FEEDID=e.FEEDID) AS FEEDNAME, e.FEEDID as FEEDID, "
+ + "(SELECT COUNT(*) FROM LOG_RECORDS AS c WHERE c.FEEDID in("
+ feedids
- + ") and c.FEEDID=e.FEEDID AND c.TYPE='PUB') AS FILES_PUBLISHED,(SELECT SUM(content_length) FROM LOG_RECORDS AS c WHERE c.FEEDID in("
+ + ") and c.FEEDID=e.FEEDID AND c.TYPE='PUB') AS FILES_PUBLISHED,"
+ + "(SELECT SUM(content_length) FROM LOG_RECORDS AS c WHERE c.FEEDID in("
+ feedids
- + ") and c.FEEDID=e.FEEDID AND c.TYPE='PUB') AS PUBLISH_LENGTH, COUNT(e.EVENT_TIME) as FILES_DELIVERED, sum(m.content_length) as DELIVERED_LENGTH,SUBSTRING_INDEX(e.REQURI,'/',+3) as SUBSCRIBER_URL, e.DELIVERY_SUBID as SUBID, e.EVENT_TIME AS PUBLISH_TIME, m.EVENT_TIME AS DELIVERY_TIME, AVG(e.EVENT_TIME - m.EVENT_TIME)/1000 as AverageDelay FROM LOG_RECORDS e JOIN LOG_RECORDS m ON m.PUBLISH_ID = e.PUBLISH_ID AND e.FEEDID IN ("
- + feedids + ") " + subid + " AND m.STATUS=204 AND e.RESULT=204 and e.event_time between " + startInMillis
+ + ") and c.FEEDID=e.FEEDID AND c.TYPE='PUB') AS PUBLISH_LENGTH, COUNT(e.EVENT_TIME) as FILES_DELIVERED,"
+ + "sum(m.content_length) as DELIVERED_LENGTH,"
+ + "SUBSTRING_INDEX(e.REQURI,'/',+3) as SUBSCRIBER_URL,"
+ + "e.DELIVERY_SUBID as SUBID, "
+ + "e.EVENT_TIME AS PUBLISH_TIME, m.EVENT_TIME AS DELIVERY_TIME, "
+ + "AVG(e.EVENT_TIME - m.EVENT_TIME)/1000 as AverageDelay FROM LOG_RECORDS"
+ + " e JOIN LOG_RECORDS m ON m.PUBLISH_ID = e.PUBLISH_ID AND e.FEEDID IN ("
+ + feedids + ")" + subid + " AND m.STATUS=204 AND e.RESULT=204 and e.event_time between " + startInMillis
+ " and " + endInMillis + " group by SUBID";
@@ -384,10 +413,10 @@ public class StatisticsServlet extends BaseServlet {
private Map<String, String> buildMapFromRequest(HttpServletRequest req) {
Map<String, String> map = new HashMap<>();
- String s = req.getParameter("type");
- if (s != null) {
- if ("pub".equals(s) || "del".equals(s) || "exp".equals(s)) {
- map.put("type", s);
+ String str = req.getParameter("type");
+ if (str != null) {
+ if ("pub".equals(str) || "del".equals(str) || "exp".equals(str)) {
+ map.put("type", str);
} else {
map.put("err", "bad type");
return map;
@@ -400,19 +429,19 @@ public class StatisticsServlet extends BaseServlet {
map.put("resultSQL", "");
map.put(REASON_SQL, "");
- s = req.getParameter("publishId");
- if (s != null) {
- if (s.indexOf("'") >= 0) {
+ str = req.getParameter("publishId");
+ if (str != null) {
+ if (str.indexOf("'") >= 0) {
map.put("err", "bad publishId");
return map;
}
- map.put("publishSQL", " AND PUBLISH_ID = '" + s + "'");
+ map.put("publishSQL", " AND PUBLISH_ID = '" + str + "'");
}
- s = req.getParameter("statusCode");
- if (s != null) {
+ str = req.getParameter("statusCode");
+ if (str != null) {
String sql = null;
- switch (s) {
+ switch (str) {
case "success":
sql = " AND STATUS >= 200 AND STATUS < 300";
break;
@@ -424,9 +453,9 @@ public class StatisticsServlet extends BaseServlet {
break;
default:
try {
- int n = Integer.parseInt(s);
- if ((n >= 100 && n < 600) || (n == -1)) {
- sql = " AND STATUS = " + n;
+ int statusCode = Integer.parseInt(str);
+ if ((statusCode >= 100 && statusCode < 600) || (statusCode == -1)) {
+ sql = " AND STATUS = " + statusCode;
}
} catch (NumberFormatException e) {
eventlogger.error("Failed to parse input", e);
@@ -441,10 +470,10 @@ public class StatisticsServlet extends BaseServlet {
map.put("resultSQL", sql.replaceAll("STATUS", "RESULT"));
}
- s = req.getParameter("expiryReason");
- if (s != null) {
+ str = req.getParameter("expiryReason");
+ if (str != null) {
map.put("type", "exp");
- switch (s) {
+ switch (str) {
case "notRetryable":
map.put(REASON_SQL, " AND REASON = 'notRetryable'");
break;
@@ -485,30 +514,31 @@ public class StatisticsServlet extends BaseServlet {
return map;
}
- private long getTimeFromParam(final String s) {
- if (s == null) {
+ private long getTimeFromParam(final String str) {
+ if (str == null) {
return 0;
}
try {
// First, look for an RFC 3339 date
- String fmt = (s.indexOf('.') > 0) ? FMT2 : FMT1;
+ String fmt = (str.indexOf('.') > 0) ? FMT2 : FMT1;
SimpleDateFormat sdf = new SimpleDateFormat(fmt);
- Date d = sdf.parse(s);
- return d.getTime();
+ Date date = sdf.parse(str);
+ return date.getTime();
} catch (ParseException e) {
intlogger.error("Exception in getting Time :- " + e.getMessage(), e);
}
try {
// Also allow a long (in ms); useful for testing
- return Long.parseLong(s);
+ return Long.parseLong(str);
} catch (NumberFormatException e) {
intlogger.error("Exception in getting Time :- " + e.getMessage(), e);
}
- intlogger.info("Error parsing time=" + s);
+ intlogger.info("Error parsing time=" + str);
return -1;
}
- private void getRecordsForSQL(Map<String, String> map, String outputType, ServletOutputStream out, HttpServletResponse resp) {
+ private void getRecordsForSQL(Map<String, String> map, String outputType, ServletOutputStream out,
+ HttpServletResponse resp) {
try {
String filterQuery = this.queryGeneretor(map);
eventlogger.debug("SQL Query for Statistics resultset. " + filterQuery);
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/SubscribeServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/SubscribeServlet.java
index 8e70e693..21b838de 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/SubscribeServlet.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/SubscribeServlet.java
@@ -24,14 +24,17 @@
package org.onap.dmaap.datarouter.provisioning;
+import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.sendResponseError;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import java.io.IOException;
import java.io.InvalidObjectException;
import java.util.Collection;
-
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
import org.json.JSONObject;
+
import org.onap.dmaap.datarouter.authz.AuthorizationResponse;
import org.onap.dmaap.datarouter.provisioning.beans.EventLogRecord;
import org.onap.dmaap.datarouter.provisioning.beans.Feed;
@@ -39,10 +42,6 @@ import org.onap.dmaap.datarouter.provisioning.beans.Subscription;
import org.onap.dmaap.datarouter.provisioning.eelf.EelfMsgs;
import org.onap.dmaap.datarouter.provisioning.utils.JSONUtilities;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.sendResponseError;
/**
* This servlet handles provisioning for the &lt;subscribeURL&gt; which is generated by the provisioning server to
@@ -52,6 +51,7 @@ import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.send
* @version $Id$
*/
@SuppressWarnings("serial")
+
public class SubscribeServlet extends ProxyServlet {
//Adding EELF Logger Rally:US664892
@@ -66,7 +66,8 @@ public class SubscribeServlet extends ProxyServlet {
setIpFqdnRequestIDandInvocationIDForEelf("doDelete", req);
eelfLogger.info(EelfMsgs.ENTRY);
try {
- eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_SUBID, req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
+ eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_SUBID,
+ req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
String message = "DELETE not allowed for the subscribeURL.";
EventLogRecord elr = new EventLogRecord(req);
elr.setMessage(message);
@@ -87,7 +88,8 @@ public class SubscribeServlet extends ProxyServlet {
setIpFqdnRequestIDandInvocationIDForEelf("doGet", req);
eelfLogger.info(EelfMsgs.ENTRY);
try {
- eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_SUBID, req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
+ eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_SUBID,
+ req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
EventLogRecord elr = new EventLogRecord(req);
String message = isAuthorizedForProvisioning(req);
if (message != null) {
@@ -130,7 +132,7 @@ public class SubscribeServlet extends ProxyServlet {
}
// Display a list of URLs
Collection<String> list = Subscription.getSubscriptionUrlList(feedid);
- String t = JSONUtilities.createJSONArray(list);
+ String strList = JSONUtilities.createJSONArray(list);
// send response
elr.setResult(HttpServletResponse.SC_OK);
@@ -138,7 +140,7 @@ public class SubscribeServlet extends ProxyServlet {
resp.setStatus(HttpServletResponse.SC_OK);
resp.setContentType(SUBLIST_CONTENT_TYPE);
try {
- resp.getOutputStream().print(t);
+ resp.getOutputStream().print(strList);
} catch (IOException ioe) {
eventlogger.error("PROV0181 SubscribeServlet.doGet: " + ioe.getMessage(), ioe);
}
@@ -155,7 +157,8 @@ public class SubscribeServlet extends ProxyServlet {
setIpFqdnRequestIDandInvocationIDForEelf("doPut", req);
eelfLogger.info(EelfMsgs.ENTRY);
try {
- eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_SUBID, req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
+ eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_SUBID,
+ req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
String message = "PUT not allowed for the subscribeURL.";
EventLogRecord elr = new EventLogRecord(req);
elr.setMessage(message);
@@ -271,7 +274,8 @@ public class SubscribeServlet extends ProxyServlet {
*/
String feedAafInstance = feed.getAafInstance();
String subAafInstance = sub.getAafInstance();
- boolean subAafLegacyEmptyOrNull = (subAafInstance == null || "".equals(subAafInstance) || "legacy".equalsIgnoreCase(subAafInstance));
+ boolean subAafLegacyEmptyOrNull = (subAafInstance == null
+ || "".equals(subAafInstance) || "legacy".equalsIgnoreCase(subAafInstance));
// This extra check added to verify AAF feed with AAF subscriber having empty aaf instance check
if (feedAafInstance == null || "".equals(feedAafInstance) || "legacy".equalsIgnoreCase(feedAafInstance)) {
@@ -327,7 +331,8 @@ public class SubscribeServlet extends ProxyServlet {
Subscription sub2 = Subscription.getSubscriptionMatching(sub);
if (sub2 != null) {
intlogger.warn(
- "PROV0011 Creating a duplicate subscription: new subid=" + sub.getSubid() + ", old subid=" + sub2.getSubid());
+ "PROV0011 Creating a duplicate subscription: new subid="
+ + sub.getSubid() + ", old subid=" + sub2.getSubid());
}
// Create SUBSCRIPTIONS table entries
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServlet.java
index 715c5e14..62c2f626 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServlet.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServlet.java
@@ -73,7 +73,8 @@ public class SubscriptionServlet extends ProxyServlet {
setIpFqdnRequestIDandInvocationIDForEelf("doDelete", req);
eelfLogger.info(EelfMsgs.ENTRY);
try {
- eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_SUBID, req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
+ eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_SUBID,
+ req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
EventLogRecord elr = new EventLogRecord(req);
String message = isAuthorizedForProvisioning(req);
if (message != null) {
@@ -174,7 +175,8 @@ public class SubscriptionServlet extends ProxyServlet {
setIpFqdnRequestIDandInvocationIDForEelf("doGet", req);
eelfLogger.info(EelfMsgs.ENTRY);
try {
- eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_SUBID, req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
+ eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_SUBID,
+ req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
EventLogRecord elr = new EventLogRecord(req);
String message = isAuthorizedForProvisioning(req);
if (message != null) {
@@ -250,7 +252,8 @@ public class SubscriptionServlet extends ProxyServlet {
setIpFqdnRequestIDandInvocationIDForEelf("doPut", req);
eelfLogger.info(EelfMsgs.ENTRY);
try {
- eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_SUBID, req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
+ eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_SUBID,
+ req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
EventLogRecord elr = new EventLogRecord(req);
String message = isAuthorizedForProvisioning(req);
if (message != null) {
@@ -360,8 +363,8 @@ public class SubscriptionServlet extends ProxyServlet {
sub.setSubid(oldsub.getSubid());
sub.setFeedid(oldsub.getFeedid());
sub.setSubscriber(bhdr); // set from X-DMAAP-DR-ON-BEHALF-OF header
-
- String subjectgroup = (req.getHeader("X-DMAAP-DR-ON-BEHALF-OF-GROUP")); //Adding for group feature:Rally US708115
+ //Adding for group feature:Rally US708115
+ String subjectgroup = (req.getHeader("X-DMAAP-DR-ON-BEHALF-OF-GROUP"));
if (!oldsub.getSubscriber().equals(sub.getSubscriber()) && subjectgroup == null) {
message = "This subscriber must be modified by the same subscriber that created it.";
elr.setMessage(message);
@@ -485,12 +488,12 @@ public class SubscriptionServlet extends ProxyServlet {
try {
// Only the active POD sends notifications
boolean active = SynchronizerTask.getSynchronizer().isActive();
- boolean b = jo.getBoolean("failed");
- if (active && !b) {
+ boolean bool = jo.getBoolean("failed");
+ if (active && !bool) {
// Notify all nodes to reset the subscription
- SubscriberNotifyThread t = new SubscriberNotifyThread();
- t.resetSubscription(subid);
- t.start();
+ SubscriberNotifyThread thread = new SubscriberNotifyThread();
+ thread.resetSubscription(subid);
+ thread.start();
}
// send response
elr.setResult(HttpServletResponse.SC_ACCEPTED);
@@ -523,8 +526,8 @@ public class SubscriptionServlet extends ProxyServlet {
void resetSubscription(int subid) {
for (String nodename : BaseServlet.getNodes()) {
- String u = String.format(URL_TEMPLATE, nodename, subid);
- urls.add(u);
+ String url = String.format(URL_TEMPLATE, nodename, subid);
+ urls.add(url);
}
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/SynchronizerTask.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/SynchronizerTask.java
index 8c5a49a4..5d0592c3 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/SynchronizerTask.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/SynchronizerTask.java
@@ -99,6 +99,7 @@ import org.onap.dmaap.datarouter.provisioning.utils.URLUtilities;
* @author Robert Eby
* @version $Id: SynchronizerTask.java,v 1.10 2014/03/21 13:50:10 eby Exp $
*/
+
public class SynchronizerTask extends TimerTask {
/**
@@ -186,8 +187,8 @@ public class SynchronizerTask extends TimerTask {
// Run once every 5 seconds to check DNS, etc.
long interval;
try {
- String s = props.getProperty("org.onap.dmaap.datarouter.provserver.sync_interval", "5000");
- interval = Long.parseLong(s);
+ String str = props.getProperty("org.onap.dmaap.datarouter.provserver.sync_interval", "5000");
+ interval = Long.parseLong(str);
} catch (NumberFormatException e) {
interval = 5000L;
}
@@ -342,8 +343,8 @@ public class SynchronizerTask extends TimerTask {
Collection<Syncable> coll = new ArrayList<>();
for (int n = 0; n < ja.length(); n++) {
try {
- Feed f = new Feed(ja.getJSONObject(n));
- coll.add(f);
+ Feed feed = new Feed(ja.getJSONObject(n));
+ coll.add(feed);
} catch (Exception e) {
logger.warn("PROV5004: Invalid object in feed: " + ja.optJSONObject(n), e);
}
@@ -361,10 +362,10 @@ public class SynchronizerTask extends TimerTask {
for (int n = 0; n < ja.length(); n++) {
try {
//Data Router Subscriber HTTPS Relaxation feature USERSTORYID:US674047.
- JSONObject j = ja.getJSONObject(n);
- j.put("sync", "true");
- Subscription s = new Subscription(j);
- coll.add(s);
+ JSONObject jsonObject = ja.getJSONObject(n);
+ jsonObject.put("sync", "true");
+ Subscription sub = new Subscription(jsonObject);
+ coll.add(sub);
} catch (Exception e) {
logger.warn("PROV5004: Invalid object in subscription: " + ja.optJSONObject(n), e);
}
@@ -381,8 +382,8 @@ public class SynchronizerTask extends TimerTask {
Collection<Syncable> coll = new ArrayList<>();
for (int n = 0; n < ja.length(); n++) {
try {
- Group g = new Group(ja.getJSONObject(n));
- coll.add(g);
+ Group group = new Group(ja.getJSONObject(n));
+ coll.add(group);
} catch (Exception e) {
logger.warn("PROV5004: Invalid object in group: " + ja.optJSONObject(n), e);
}
@@ -399,25 +400,25 @@ public class SynchronizerTask extends TimerTask {
private void syncParams(JSONObject jo) {
Collection<Syncable> coll = new ArrayList<>();
for (String k : jo.keySet()) {
- String v = "";
+ String val = "";
try {
- v = jo.getString(k);
+ val = jo.getString(k);
} catch (JSONException e) {
logger.warn("PROV5004: Invalid object in parameters: " + jo.optJSONObject(k), e);
try {
- v = "" + jo.getInt(k);
+ val = "" + jo.getInt(k);
} catch (JSONException e1) {
logger.warn("PROV5004: Invalid object in parameters: " + jo.optInt(k), e1);
JSONArray ja = jo.getJSONArray(k);
for (int i = 0; i < ja.length(); i++) {
if (i > 0) {
- v += "|";
+ val += "|";
}
- v += ja.getString(i);
+ val += ja.getString(i);
}
}
}
- coll.add(new Parameters(k, v));
+ coll.add(new Parameters(k, val));
}
if (sync(coll, Parameters.getParameterCollection())) {
BaseServlet.provisioningDataChanged();
@@ -526,9 +527,9 @@ public class SynchronizerTask extends TimerTask {
return newobj.doInsert(conn);
}
- private Map<String, Syncable> getMap(Collection<? extends Syncable> c) {
+ private Map<String, Syncable> getMap(Collection<? extends Syncable> coll) {
Map<String, Syncable> map = new HashMap<>();
- for (Syncable v : c) {
+ for (Syncable v : coll) {
map.put(v.getKey(), v);
}
return map;
@@ -650,11 +651,11 @@ public class SynchronizerTask extends TimerTask {
String url = URLUtilities.generatePeerLogsURL();
HttpPost post = new HttpPost(url);
try {
- String t = bs.toString();
- HttpEntity body = new ByteArrayEntity(t.getBytes(), ContentType.create(TEXT_CT));
+ String str = bs.toString();
+ HttpEntity body = new ByteArrayEntity(str.getBytes(), ContentType.create(TEXT_CT));
post.setEntity(body);
if (logger.isDebugEnabled()) {
- logger.debug("Requesting records: " + t);
+ logger.debug("Requesting records: " + str);
}
HttpResponse response = httpclient.execute(post);