import com.att.eelf.configuration.EELFManager;
/**
- * This servlet handles provisioning for the <subscribeURL> which is generated by the provisioning
- * server to handle the creation and inspection of subscriptions to a specific feed.
+ * This servlet handles provisioning for the <subscribeURL> which is generated by the provisioning server to
+ * handle the creation and inspection of subscriptions to a specific feed.
*
* @author Robert Eby
* @version $Id$
public class SubscribeServlet extends ProxyServlet {
//Adding EELF Logger Rally:US664892
- private static EELFLogger eelflogger = EELFManager.getInstance().getLogger("org.onap.dmaap.datarouter.provisioning.SubscribeServlet");
+ private static EELFLogger eelflogger = EELFManager.getInstance()
+ .getLogger("org.onap.dmaap.datarouter.provisioning.SubscribeServlet");
/**
* DELETE on the <subscribeUrl> -- not supported.
@Override
public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws IOException {
setIpAndFqdnForEelf("doDelete");
- 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);
eventlogger.info(elr);
resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, message);
}
+
/**
- * GET on the <subscribeUrl> -- get the list of subscriptions to a feed.
- * See the <i>Subscription Collection Query</i> section in the <b>Provisioning API</b>
- * document for details on how this method should be invoked.
+ * GET on the <subscribeUrl> -- get the list of subscriptions to a feed. See the <i>Subscription Collection
+ * Query</i> section in the <b>Provisioning API</b> document for details on how this method should be invoked.
*/
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
setIpAndFqdnForEelf("doGet");
- 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) {
}
String bhdr = req.getHeader(BEHALF_HEADER);
if (bhdr == null) {
- message = "Missing "+BEHALF_HEADER+" header.";
+ message = "Missing " + BEHALF_HEADER + " header.";
elr.setMessage(message);
elr.setResult(HttpServletResponse.SC_BAD_REQUEST);
eventlogger.info(elr);
}
// Check with the Authorizer
AuthorizationResponse aresp = authz.decide(req);
- if (! aresp.isAuthorized()) {
+ if (!aresp.isAuthorized()) {
message = "Policy Engine disallows access.";
elr.setMessage(message);
elr.setResult(HttpServletResponse.SC_FORBIDDEN);
resp.setContentType(SUBLIST_CONTENT_TYPE);
resp.getOutputStream().print(t);
}
+
/**
* PUT on the <subscribeUrl> -- not supported.
*/
@Override
public void doPut(HttpServletRequest req, HttpServletResponse resp) throws IOException {
setIpAndFqdnForEelf("doPut");
- 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);
eventlogger.info(elr);
resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, message);
}
+
/**
- * POST on the <subscribeUrl> -- create a new subscription to a feed.
- * See the <i>Creating a Subscription</i> section in the <b>Provisioning API</b>
- * document for details on how this method should be invoked.
+ * POST on the <subscribeUrl> -- create a new subscription to a feed. See the <i>Creating a Subscription</i>
+ * section in the <b>Provisioning API</b> document for details on how this method should be invoked.
*/
@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
}
String bhdr = req.getHeader(BEHALF_HEADER);
if (bhdr == null) {
- message = "Missing "+BEHALF_HEADER+" header.";
+ message = "Missing " + BEHALF_HEADER + " header.";
elr.setMessage(message);
elr.setResult(HttpServletResponse.SC_BAD_REQUEST);
eventlogger.info(elr);
}
// Check with the Authorizer
AuthorizationResponse aresp = authz.decide(req);
- if (! aresp.isAuthorized()) {
+ if (!aresp.isAuthorized()) {
message = "Policy Engine disallows access.";
elr.setMessage(message);
elr.setResult(HttpServletResponse.SC_FORBIDDEN);
ContentHeader ch = getContentHeader(req);
String ver = ch.getAttribute("version");
if (!ch.getType().equals(SUB_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);
resp.sendError(HttpServletResponse.SC_BAD_REQUEST, message);
return;
}
- if (intlogger.isDebugEnabled())
+ if (intlogger.isDebugEnabled()) {
intlogger.debug(jo.toString());
- if (++active_subs > max_subs) {
- active_subs--;
+ }
+ if (++activeSubs > maxSubs) {
+ activeSubs--;
message = "Cannot create subscription; the maximum number of subscriptions has been configured.";
elr.setMessage(message);
elr.setResult(HttpServletResponse.SC_CONFLICT);
try {
sub = new Subscription(jo);
} catch (InvalidObjectException e) {
- active_subs--;
+ activeSubs--;
message = e.getMessage();
elr.setMessage(message);
elr.setResult(HttpServletResponse.SC_BAD_REQUEST);
// Check if this subscription already exists; not an error (yet), just warn
Subscription sub2 = Subscription.getSubscriptionMatching(sub);
- if (sub2 != null)
- intlogger.warn("PROV0011 Creating a duplicate subscription: new subid="+sub.getSubid()+", old subid="+sub2.getSubid());
+ if (sub2 != null) {
+ intlogger.warn(
+ "PROV0011 Creating a duplicate subscription: new subid=" + sub.getSubid() + ", old subid=" + sub2
+ .getSubid());
+ }
// Create SUBSCRIPTIONS table entries
if (doInsert(sub)) {
provisioningDataChanged();
} else {
// Something went wrong with the INSERT
- active_subs--;
+ activeSubs--;
elr.setResult(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
eventlogger.info(elr);
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, DB_PROBLEM_MSG);