import com.att.eelf.configuration.EELFManager;\r
\r
/**\r
- * This servlet handles provisioning for the <subscriptionURL> which is generated by the provisioning\r
- * server to handle the inspection, modification, and deletion of a particular subscription to a feed.\r
- * It supports DELETE to delete a subscription, GET to retrieve information about the subscription,\r
- * and PUT to modify the subscription. In DR 3.0, POST is also supported in order to reset the subscription\r
- * timers for individual subscriptions.\r
+ * This servlet handles provisioning for the <subscriptionURL> which is generated by the provisioning server to\r
+ * handle the inspection, modification, and deletion of a particular subscription to a feed. It supports DELETE to\r
+ * delete a subscription, GET to retrieve information about the subscription, and PUT to modify the subscription. In DR\r
+ * 3.0, POST is also supported in order to reset the subscription timers for individual subscriptions.\r
*\r
* @author Robert Eby\r
* @version $Id$\r
*/\r
@SuppressWarnings("serial")\r
public class SubscriptionServlet extends ProxyServlet {\r
+\r
public static final String SUBCNTRL_CONTENT_TYPE = "application/vnd.att-dr.subscription-control";\r
//Adding EELF Logger Rally:US664892\r
- private static EELFLogger eelflogger = EELFManager.getInstance().getLogger("org.onap.dmaap.datarouter.provisioning.SubscriptionServlet");\r
+ private static EELFLogger eelflogger = EELFManager.getInstance()\r
+ .getLogger("org.onap.dmaap.datarouter.provisioning.SubscriptionServlet");\r
\r
/**\r
- * DELETE on the <subscriptionUrl> -- delete a subscription.\r
- * See the <i>Deleting a Subscription</i> section in the <b>Provisioning API</b>\r
- * document for details on how this method should be invoked.\r
+ * DELETE on the <subscriptionUrl> -- delete a subscription. See the <i>Deleting a Subscription</i> section in\r
+ * the <b>Provisioning API</b> document for details on how this method should be invoked.\r
*/\r
@Override\r
public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws IOException {\r
setIpAndFqdnForEelf("doDelete");\r
- eelflogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_SUBID, req.getHeader(BEHALF_HEADER),getIdFromPath(req)+"");\r
+ eelflogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_SUBID, req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");\r
EventLogRecord elr = new EventLogRecord(req);\r
String message = isAuthorizedForProvisioning(req);\r
if (message != null) {\r
}\r
String bhdr = req.getHeader(BEHALF_HEADER);\r
if (bhdr == null) {\r
- message = "Missing "+BEHALF_HEADER+" header.";\r
+ message = "Missing " + BEHALF_HEADER + " header.";\r
elr.setMessage(message);\r
elr.setResult(HttpServletResponse.SC_BAD_REQUEST);\r
eventlogger.info(elr);\r
}\r
// Check with the Authorizer\r
AuthorizationResponse aresp = authz.decide(req);\r
- if (! aresp.isAuthorized()) {\r
+ if (!aresp.isAuthorized()) {\r
message = "Policy Engine disallows access.";\r
elr.setMessage(message);\r
elr.setResult(HttpServletResponse.SC_FORBIDDEN);\r
\r
// Delete Subscription\r
if (doDelete(sub)) {\r
- active_subs--;\r
+ activeSubs--;\r
// send response\r
elr.setResult(HttpServletResponse.SC_NO_CONTENT);\r
eventlogger.info(elr);\r
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, DB_PROBLEM_MSG);\r
}\r
}\r
+\r
/**\r
- * GET on the <subscriptionUrl> -- get information about a subscription.\r
- * See the <i>Retreiving Information about a Subscription</i> section in the <b>Provisioning API</b>\r
- * document for details on how this method should be invoked.\r
+ * GET on the <subscriptionUrl> -- get information about a subscription. See the <i>Retreiving Information\r
+ * about a Subscription</i> section in the <b>Provisioning API</b> document for details on how this method should be\r
+ * invoked.\r
*/\r
@Override\r
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {\r
setIpAndFqdnForEelf("doGet");\r
- eelflogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_SUBID, req.getHeader(BEHALF_HEADER),getIdFromPath(req)+"");\r
+ eelflogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_SUBID, req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");\r
EventLogRecord elr = new EventLogRecord(req);\r
String message = isAuthorizedForProvisioning(req);\r
if (message != null) {\r
}\r
String bhdr = req.getHeader(BEHALF_HEADER);\r
if (bhdr == null) {\r
- message = "Missing "+BEHALF_HEADER+" header.";\r
+ message = "Missing " + BEHALF_HEADER + " header.";\r
elr.setMessage(message);\r
elr.setResult(HttpServletResponse.SC_BAD_REQUEST);\r
eventlogger.info(elr);\r
}\r
// Check with the Authorizer\r
AuthorizationResponse aresp = authz.decide(req);\r
- if (! aresp.isAuthorized()) {\r
+ if (!aresp.isAuthorized()) {\r
message = "Policy Engine disallows access.";\r
elr.setMessage(message);\r
elr.setResult(HttpServletResponse.SC_FORBIDDEN);\r
resp.setContentType(SUBFULL_CONTENT_TYPE);\r
resp.getOutputStream().print(sub.asJSONObject(true).toString());\r
}\r
+\r
/**\r
- * PUT on the <subscriptionUrl> -- modify a subscription.\r
- * See the <i>Modifying a Subscription</i> section in the <b>Provisioning API</b>\r
- * document for details on how this method should be invoked.\r
+ * PUT on the <subscriptionUrl> -- modify a subscription. See the <i>Modifying a Subscription</i> section in\r
+ * the <b>Provisioning API</b> document for details on how this method should be invoked.\r
*/\r
@Override\r
public void doPut(HttpServletRequest req, HttpServletResponse resp) throws IOException {\r
setIpAndFqdnForEelf("doPut");\r
- eelflogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_SUBID, req.getHeader(BEHALF_HEADER),getIdFromPath(req)+"");\r
+ eelflogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_SUBID, req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");\r
EventLogRecord elr = new EventLogRecord(req);\r
String message = isAuthorizedForProvisioning(req);\r
if (message != null) {\r
}\r
String bhdr = req.getHeader(BEHALF_HEADER);\r
if (bhdr == null) {\r
- message = "Missing "+BEHALF_HEADER+" header.";\r
+ message = "Missing " + BEHALF_HEADER + " header.";\r
elr.setMessage(message);\r
elr.setResult(HttpServletResponse.SC_BAD_REQUEST);\r
eventlogger.info(elr);\r
}\r
// Check with the Authorizer\r
AuthorizationResponse aresp = authz.decide(req);\r
- if (! aresp.isAuthorized()) {\r
+ if (!aresp.isAuthorized()) {\r
message = "Policy Engine disallows access.";\r
elr.setMessage(message);\r
elr.setResult(HttpServletResponse.SC_FORBIDDEN);\r
resp.sendError(HttpServletResponse.SC_BAD_REQUEST, message);\r
return;\r
}\r
- if (intlogger.isDebugEnabled())\r
+ if (intlogger.isDebugEnabled()) {\r
intlogger.debug(jo.toString());\r
+ }\r
Subscription sub = null;\r
try {\r
sub = new Subscription(jo);\r
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, DB_PROBLEM_MSG);\r
}\r
}\r
+\r
/**\r
- * POST on the <subscriptionUrl> -- control a subscription.\r
- * See the <i>Resetting a Subscription's Retry Schedule</i> section in the <b>Provisioning API</b>\r
- * document for details on how this method should be invoked.\r
+ * POST on the <subscriptionUrl> -- control a subscription. See the <i>Resetting a Subscription's Retry\r
+ * Schedule</i> section in the <b>Provisioning API</b> document for details on how this method should be invoked.\r
*/\r
@Override\r
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {\r
}\r
String bhdr = req.getHeader(BEHALF_HEADER);\r
if (bhdr == null) {\r
- message = "Missing "+BEHALF_HEADER+" header.";\r
+ message = "Missing " + BEHALF_HEADER + " header.";\r
elr.setMessage(message);\r
elr.setResult(HttpServletResponse.SC_BAD_REQUEST);\r
eventlogger.info(elr);\r
}\r
// Check with the Authorizer\r
AuthorizationResponse aresp = authz.decide(req);\r
- if (! aresp.isAuthorized()) {\r
+ if (!aresp.isAuthorized()) {\r
message = "Policy Engine disallows access.";\r
elr.setMessage(message);\r
elr.setResult(HttpServletResponse.SC_FORBIDDEN);\r
}\r
\r
/**\r
- * A Thread class used to serially send reset notifications to all nodes in the DR network,\r
- * when a POST is received for a subscription.\r
+ * A Thread class used to serially send reset notifications to all nodes in the DR network, when a POST is received\r
+ * for a subscription.\r
*/\r
public class SubscriberNotifyThread extends Thread {\r
+\r
public static final String URL_TEMPLATE = "http://%s/internal/resetSubscription/%d";\r
private List<String> urls = new Vector<String>();\r
\r
public SubscriberNotifyThread() {\r
setName("SubscriberNotifyThread");\r
}\r
+\r
public void resetSubscription(int subid) {\r
for (String nodename : BaseServlet.getNodes()) {\r
String u = String.format(URL_TEMPLATE, nodename, subid);\r
urls.add(u);\r
}\r
}\r
+\r
public void run() {\r
try {\r
while (!urls.isEmpty()) {\r
conn.getContentLength(); // Force the GET through\r
conn.disconnect();\r
} catch (IOException e) {\r
- intlogger.info("IOException Error accessing URL: "+u+": " + e.getMessage());\r
+ intlogger.info("IOException Error accessing URL: " + u + ": " + e.getMessage());\r
}\r
}\r
} catch (Exception e) {\r
- intlogger.warn("Caught exception in SubscriberNotifyThread: "+e);\r
+ intlogger.warn("Caught exception in SubscriberNotifyThread: " + e);\r
e.printStackTrace();\r
}\r
}\r