X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=datarouter-prov%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdatarouter%2Fprovisioning%2FInternalServlet.java;h=efa1c1028b55fd01f5e94cb32a8f8f8884038f93;hb=0ad65c47b4fbddd5d1b653c5e38dcdf84884de9f;hp=12bd6ef4719203594830db1810b5477200f2a59c;hpb=f94a3f35ccf9f95455b2840e4465a71b0bb5c71d;p=dmaap%2Fdatarouter.git
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 12bd6ef4..efa1c102 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
@@ -39,18 +39,17 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.Properties;
-
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
import org.json.JSONArray;
import org.onap.dmaap.datarouter.provisioning.beans.EventLogRecord;
import org.onap.dmaap.datarouter.provisioning.beans.LogRecord;
import org.onap.dmaap.datarouter.provisioning.beans.Parameters;
import org.onap.dmaap.datarouter.provisioning.eelf.EelfMsgs;
-import org.onap.dmaap.datarouter.provisioning.utils.DB;
import org.onap.dmaap.datarouter.provisioning.utils.LogfileLoader;
+import org.onap.dmaap.datarouter.provisioning.utils.Poker;
import org.onap.dmaap.datarouter.provisioning.utils.RLEBitSet;
+import org.onap.dmaap.datarouter.provisioning.utils.SynchronizerTask;
@@ -130,7 +129,7 @@ import org.onap.dmaap.datarouter.provisioning.utils.RLEBitSet;
*
/internal/route/* |
* * |
* URLs under this path are handled via the
- * {@link org.onap.dmaap.datarouter.provisioning.RouteServlet} |
+ * {@link RouteServlet}
*
*
*
@@ -231,14 +230,14 @@ public class InternalServlet extends ProxyServlet {
eelfLogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID,
req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
String path = req.getPathInfo();
- Properties props = (new DB()).getProperties();
+ Properties props = ProvRunner.getProvProperties();
if ("/halt".equals(path) && !req.isSecure()) {
// request to halt the server - can ONLY come from localhost
String remote = req.getRemoteAddr();
if (remote.equals(props.getProperty("org.onap.dmaap.datarouter.provserver.localhost"))) {
intlogger.info("PROV0009 Request to HALT received.");
resp.setStatus(HttpServletResponse.SC_OK);
- Main.shutdown();
+ ProvRunner.shutdown();
} else {
intlogger.info("PROV0010 Disallowed request to HALT received from " + remote);
resp.setStatus(HttpServletResponse.SC_FORBIDDEN);
@@ -293,7 +292,7 @@ public class InternalServlet extends ProxyServlet {
String logdir = props.getProperty("org.onap.dmaap.datarouter.provserver.accesslog.dir");
String logfile = path.substring(6);
if (logdir != null && logfile != null && logfile.indexOf('/') < 0) {
- File log = new File(logdir + "/" + logfile);
+ File log = new File(logdir + File.separator + logfile);
if (log.exists() && log.isFile()) {
resp.setStatus(HttpServletResponse.SC_OK);
resp.setContentType(TEXT_CT);
@@ -453,7 +452,7 @@ public class InternalServlet extends ProxyServlet {
if ("/logs".equals(path) || LOGS.equals(path)) {
String ctype = req.getHeader("Content-Type");
- if (ctype == null || !TEXT_CT.equals(ctype)) {
+ if (!TEXT_CT.equals(ctype)) {
elr.setResult(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
elr.setMessage("Bad media type: " + ctype);
resp.setStatus(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
@@ -461,7 +460,7 @@ public class InternalServlet extends ProxyServlet {
return;
}
String spooldir =
- (new DB()).getProperties().getProperty("org.onap.dmaap.datarouter.provserver.spooldir");
+ ProvRunner.getProvProperties().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
@@ -493,10 +492,10 @@ public class InternalServlet extends ProxyServlet {
}
try {
fs.close();
- } catch (Exception e) {
+ } catch (UnsupportedOperationException | IOException e) {
intlogger.error("PROV0137 InternalServlet.doPost: " + e.getMessage(), e);
}
- if (((avail * 100) / total) < 5) {
+ if (total != 0 && ((avail * 100) / total) < 5) {
elr.setResult(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
resp.setStatus(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
eventlogger.error(elr.toString());
@@ -521,7 +520,7 @@ public class InternalServlet extends ProxyServlet {
if ("/drlogs".equals(path) || "/drlogs/".equals(path)) {
// Receive post request and generate log entries
String ctype = req.getHeader("Content-Type");
- if (ctype == null || !TEXT_CT.equals(ctype)) {
+ if (!TEXT_CT.equals(ctype)) {
elr.setResult(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
elr.setMessage("Bad media type: " + ctype);
resp.setStatus(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
@@ -570,7 +569,7 @@ public class InternalServlet extends ProxyServlet {
private JSONArray generateLogfileList() {
JSONArray ja = new JSONArray();
- Properties prop = (new DB()).getProperties();
+ Properties prop = ProvRunner.getProvProperties();
String str = prop.getProperty("org.onap.dmaap.datarouter.provserver.accesslog.dir");
if (str != null) {
String[] dirs = str.split(",");