summaryrefslogtreecommitdiffstats
path: root/datarouter-prov
diff options
context:
space:
mode:
authorRam Koya <rk541m@att.com>2018-12-14 17:01:56 +0000
committerGerrit Code Review <gerrit@onap.org>2018-12-14 17:01:56 +0000
commit45ac8c967dfc9a5c760a264803f99c04466e3936 (patch)
treeff27e5f53b713fef24483b4a18dcfb56612bbaee /datarouter-prov
parent83451c45ebefdd59b9052d47b03ba8bc0d5f2669 (diff)
parent6e74f6b7b372353637711d69c6940c787c0373ce (diff)
Merge "Allow publishing while DB is down"
Diffstat (limited to 'datarouter-prov')
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/PublishServlet.java36
1 files changed, 20 insertions, 16 deletions
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 8229ee5a..3ae63bb2 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
@@ -35,10 +35,10 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONArray;
+import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;
import org.onap.dmaap.datarouter.provisioning.beans.EventLogRecord;
-import org.onap.dmaap.datarouter.provisioning.beans.Feed;
import org.onap.dmaap.datarouter.provisioning.beans.IngressRoute;
import org.onap.dmaap.datarouter.provisioning.eelf.EelfMsgs;
import org.onap.dmaap.datarouter.provisioning.utils.DB;
@@ -54,7 +54,7 @@ import org.onap.dmaap.datarouter.provisioning.utils.DB;
@SuppressWarnings("serial")
public class PublishServlet extends BaseServlet {
- private int next_node;
+ private int nextNode;
private String provstring;
private List<IngressRoute> irt;
//Adding EELF Logger Rally:US664892
@@ -66,35 +66,35 @@ public class PublishServlet extends BaseServlet {
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
- next_node = 0;
+ nextNode = 0;
provstring = "";
- irt = new ArrayList<IngressRoute>();
+ irt = new ArrayList<>();
}
@Override
- public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws IOException {
+ public void doDelete(HttpServletRequest req, HttpServletResponse resp) {
setIpAndFqdnForEelf("doDelete");
eelflogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
redirect(req, resp);
}
@Override
- public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
+ public void doGet(HttpServletRequest req, HttpServletResponse resp) {
setIpAndFqdnForEelf("doGet");
eelflogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
redirect(req, resp);
}
@Override
- public void doPut(HttpServletRequest req, HttpServletResponse resp) throws IOException {
+ public void doPut(HttpServletRequest req, HttpServletResponse resp) {
setIpAndFqdnForEelf("doPut");
eelflogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
redirect(req, resp);
}
@Override
- public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
+ public void doPost(HttpServletRequest req, HttpServletResponse resp) {
setIpAndFqdnForEelf("doPost");
eelflogger.info(EelfMsgs.MESSAGE_WITH_BEHALF, req.getHeader(BEHALF_HEADER));
redirect(req, resp);
@@ -155,7 +155,7 @@ public class PublishServlet extends BaseServlet {
provstring = s;
JSONObject jo = new JSONObject(new JSONTokener(provstring));
JSONArray ja = jo.getJSONArray("ingress");
- List<IngressRoute> newlist = new ArrayList<IngressRoute>();
+ List<IngressRoute> newlist = new ArrayList<>();
for (int i = 0; i < ja.length(); i++) {
IngressRoute iroute = new IngressRoute(ja.getJSONObject(i));
newlist.add(iroute);
@@ -179,11 +179,11 @@ public class PublishServlet extends BaseServlet {
// No IRT rule matches, do round robin of all active nodes
String[] nodes = getNodes();
- if (next_node >= nodes.length) // The list of nodes may have grown/shrunk
+ if (nextNode >= nodes.length) // The list of nodes may have grown/shrunk
{
- next_node = 0;
+ nextNode = 0;
}
- return nodes[next_node++];
+ return nodes[nextNode++];
}
private int checkPath(HttpServletRequest req) {
@@ -198,11 +198,15 @@ public class PublishServlet extends BaseServlet {
}
try {
int feedid = Integer.parseInt(path.substring(0, ix));
- if (!Feed.isFeedValid(feedid)) {
- return -1;
+ String provData = Poker.getPoker().getProvisioningString();
+ JSONArray feeds = new JSONObject(provData).getJSONArray("feeds");
+ for (int n = 0; n < feeds.length(); ++n) {
+ if (feeds.getJSONObject(n).getInt("feedid") == feedid) {
+ return feedid;
+ }
}
- return feedid;
- } catch (NumberFormatException e) {
+ return -1;
+ } catch (NumberFormatException | JSONException e) {
return -1;
}
}