X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=datarouter-prov%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdatarouter%2Fprovisioning%2FSubscriptionServlet.java;h=1851d03a61879ae93a8bbcbb31ef96fd79307bdf;hb=bda6aeaa60607ab4fe5af508156019d7bd5c0ce4;hp=715c5e140421e2e95d5daf2527f2a8edb347dbb5;hpb=0645ccf674f388cc989ef43d2ce24f359915e453;p=dmaap%2Fdatarouter.git
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..1851d03a 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
@@ -34,14 +34,15 @@ import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.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.Subscription;
import org.onap.dmaap.datarouter.provisioning.eelf.EelfMsgs;
+import org.onap.dmaap.datarouter.provisioning.utils.SynchronizerTask;
/**
* This servlet handles provisioning for the <subscriptionURL> which is generated by the provisioning server to
@@ -52,18 +53,13 @@ import org.onap.dmaap.datarouter.provisioning.eelf.EelfMsgs;
* @author Robert Eby
* @version $Id$
*/
-@SuppressWarnings("serial")
public class SubscriptionServlet extends ProxyServlet {
private static final String SUBCNTRL_CONTENT_TYPE = "application/vnd.dmaap-dr.subscription-control";
//Adding EELF Logger Rally:US664892
- private static EELFLogger eelfLogger = EELFManager.getInstance()
+ private static final EELFLogger eelfLogger = EELFManager.getInstance()
.getLogger(SubscriptionServlet.class);
-
-
-
-
/**
* DELETE on the <subscriptionUrl> -- delete a subscription. See the Deleting a Subscription section in
* the Provisioning API document for details on how this method should be invoked.
@@ -73,7 +69,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 +171,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 +248,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) {
@@ -311,10 +310,7 @@ public class SubscriptionServlet extends ProxyServlet {
sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST, message, eventlogger);
return;
}
- if (intlogger.isDebugEnabled()) {
- intlogger.debug(jo.toString());
- }
- Subscription sub = null;
+ Subscription sub;
try {
sub = new Subscription(jo);
} catch (InvalidObjectException e) {
@@ -360,8 +356,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);
@@ -384,7 +380,7 @@ public class SubscriptionServlet extends ProxyServlet {
eventlogger.error("PROV0192 SubscriptionServlet.doPut: " + ioe.getMessage(), ioe);
}
- /**Change Owner ship of Subscriber Adding for group feature:Rally US708115*/
+ /**Change Owner ship of Subscriber. Adding for group feature:Rally US708115*/
if (jo.has("changeowner") && subjectgroup != null) {
try {
Boolean changeowner = (Boolean) jo.get("changeowner");
@@ -396,7 +392,7 @@ public class SubscriptionServlet extends ProxyServlet {
eventlogger.error("PROV0193 SubscriptionServlet.doPut: " + je.getMessage(), je);
}
}
- /***End of change ownership*/
+ /***End of change ownership.*/
provisioningDataChanged();
} else {
@@ -485,12 +481,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 +519,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);
}
}