From 06a86fa387e05f57bb1cec4295901e6d7786aa98 Mon Sep 17 00:00:00 2001 From: HelenaLydon Date: Mon, 9 Sep 2019 10:50:53 +0100 Subject: Continued clean up of code smells Issue-ID: DMAAP-1195 Change-Id: I7a4c22f6c6a93f32590f97bbf006b7bea1761e3c Signed-off-by: HelenaLydon --- .../org/onap/dmaap/datarouter/provisioning/BaseServlet.java | 7 ------- .../org/onap/dmaap/datarouter/provisioning/GroupServlet.java | 2 +- .../org/onap/dmaap/datarouter/provisioning/ProxyServlet.java | 6 ++---- .../onap/dmaap/datarouter/provisioning/StatisticsServlet.java | 8 +------- .../dmaap/datarouter/provisioning/beans/BaseLogRecord.java | 4 ++-- .../onap/dmaap/datarouter/provisioning/beans/ExpiryRecord.java | 2 +- .../org/onap/dmaap/datarouter/provisioning/beans/Feed.java | 2 +- .../dmaap/datarouter/provisioning/utils/DRProvCadiFilter.java | 10 +++++----- 8 files changed, 13 insertions(+), 28 deletions(-) (limited to 'datarouter-prov/src') diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/BaseServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/BaseServlet.java index 7a7167d2..f8b5934e 100755 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/BaseServlet.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/BaseServlet.java @@ -130,7 +130,6 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider { private static final int DEFAULT_MAX_SUBS = 100000; private static final int DEFAULT_POKETIMER1 = 5; private static final int DEFAULT_POKETIMER2 = 30; - private static final String DEFAULT_DOMAIN = "onap"; private static final String DEFAULT_PROVSRVR_NAME = "dmaap-dr-prov"; //Common Errors @@ -228,11 +227,6 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider { */ static int activeSubs = 0; - /** - * The domain used to generate a FQDN from the "bare" node names. - */ - private static String provDomain = "web.att.com"; - /** * The standard FQDN of the provisioning server in this Data Router ecosystem. */ @@ -539,7 +533,6 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider { pokeTimer2 = getInt(map, Parameters.PROV_POKETIMER2, DEFAULT_POKETIMER2); // The domain used to generate a FQDN from the "bare" node names - provDomain = getString(map, Parameters.PROV_DOMAIN, DEFAULT_DOMAIN); provName = getString(map, Parameters.PROV_NAME, DEFAULT_PROVSRVR_NAME); activeProvName = getString(map, Parameters.PROV_ACTIVE_NAME, provName); initialActivePod = getString(map, Parameters.ACTIVE_POD, ""); diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/GroupServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/GroupServlet.java index c3cf8876..73f859ac 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/GroupServlet.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/GroupServlet.java @@ -257,7 +257,7 @@ public class GroupServlet extends ProxyServlet { // check content type is SUB_CONTENT_TYPE, version 1.0 ContentHeader ch = getContentHeader(req); String ver = ch.getAttribute("version"); - if (!ch.getType().equals(GROUP_BASECONTENT_TYPE) || !(ver.equals("1.0") || ver.equals("2.0"))) { + if (!ch.getType().equals(GROUP_BASECONTENT_TYPE) || !("1.0".equals(ver) || "2.0".equals(ver))) { intlogger.debug("Content-type is: " + req.getHeader("Content-Type")); message = "Incorrect content-type"; elr.setMessage(message); diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/ProxyServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/ProxyServlet.java index 9a8037a8..c9075b0c 100755 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/ProxyServlet.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/ProxyServlet.java @@ -81,10 +81,8 @@ public class ProxyServlet extends BaseServlet { try { // Set up keystore Properties props = (new DB()).getProperties(); - String store = props.getProperty(Main.KEYSTORE_PATH_PROPERTY); - String pass = props.getProperty(Main.KEYSTORE_PASS_PROPERTY); - store = props.getProperty(Main.TRUSTSTORE_PATH_PROPERTY); - pass = props.getProperty(Main.TRUSTSTORE_PASS_PROPERTY); + String store = props.getProperty(Main.TRUSTSTORE_PATH_PROPERTY); + String pass = props.getProperty(Main.TRUSTSTORE_PASS_PROPERTY); if (store == null || store.length() == 0) { store = Main.DEFAULT_TRUSTSTORE; pass = "changeit"; diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/StatisticsServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/StatisticsServlet.java index aba230b9..9f113efd 100755 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/StatisticsServlet.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/StatisticsServlet.java @@ -300,14 +300,11 @@ public class StatisticsServlet extends BaseServlet { private String queryGeneretor(Map map) throws ParseException { String sql; - String eventType = null; String feedids = null; String startTime = null; String endTime = null; String subid = " "; - if (map.get(EVENT_TYPE) != null) { - eventType = map.get(EVENT_TYPE); - } + if (map.get(FEEDIDS) != null) { feedids = map.get(FEEDIDS); } @@ -317,9 +314,6 @@ public class StatisticsServlet extends BaseServlet { if (map.get(END_TIME) != null) { endTime = map.get(END_TIME); } - if ("all".equalsIgnoreCase(eventType)) { - eventType = "PUB','DEL, EXP, PBF"; - } if (map.get(SUBID) != null) { subid = map.get(SUBID); } diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/BaseLogRecord.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/BaseLogRecord.java index 8cb4c153..2d3aacf2 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/BaseLogRecord.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/BaseLogRecord.java @@ -58,12 +58,12 @@ public class BaseLogRecord implements LOGJSONable, Loadable { this.eventTime = dt.getTime(); this.publishId = pp[2]; this.feedid = Integer.parseInt(pp[3]); - if (pp[1].equals("DLX")) { + if ("DLX".equals(pp[1])) { this.requestUri = ""; this.method = "GET"; // Note: we need a valid value in this field, even though unused this.contentType = ""; this.contentLength = Long.parseLong(pp[5]); - } else if (pp[1].equals("PUB") || pp[1].equals("LOG") || pp[1].equals("PBF")) { + } else if ("PUB".equals(pp[1]) || "LOG".equals(pp[1]) || "PBF".equals(pp[1])) { this.requestUri = pp[4]; this.method = pp[5]; this.contentType = pp[6]; diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/ExpiryRecord.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/ExpiryRecord.java index 4c7fffaa..2b4e5a3d 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/ExpiryRecord.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/ExpiryRecord.java @@ -64,7 +64,7 @@ public class ExpiryRecord extends BaseLogRecord { this.fileid = thisFileid; this.deliveryAttempts = Integer.parseInt(pp[10]); this.reason = pp[9]; - if (!reason.equals("notRetryable") && !reason.equals("retriesExhausted") && !reason.equals("diskFull")) { + if (!"notRetryable".equals(reason) && !"retriesExhausted".equals(reason) && !"diskFull".equals(reason)) { this.reason = "other"; } } diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java index d38681f5..3dccc02c 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java @@ -150,7 +150,7 @@ public class Feed extends Syncable { this.groupid = jo.optInt("groupid"); this.name = jo.getString("name"); this.aafInstance = jo.optString("aaf_instance", "legacy"); - if (!(aafInstance.equalsIgnoreCase("legacy")) && aafInstance.length() > 255) { + if (!("legacy".equalsIgnoreCase(aafInstance)) && aafInstance.length() > 255) { throw new InvalidObjectException("aaf_instance field is too long"); } if (name.length() > 255) { diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/DRProvCadiFilter.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/DRProvCadiFilter.java index 8b3d4eb3..526bfd54 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/DRProvCadiFilter.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/DRProvCadiFilter.java @@ -66,9 +66,9 @@ public class DRProvCadiFilter extends CadiFilter { || pathUrl.contains("group"))) { String method = httpRequest.getMethod().toUpperCase(); - if (!(method.equals("POST"))) { + if (!("POST".equals(method))) { // if request method is PUT method (publish or Feed update) Needs to check for DELETE - if (method.equals("PUT") || method.equals("DELETE")) { + if ("PUT".equals(method) || "DELETE".equals(method)) { if ((pathUrl.contains("subs"))) { //edit subscriber int subId = BaseServlet.getIdFromPath(httpRequest); if (subId <= 0) { @@ -209,7 +209,7 @@ public class DRProvCadiFilter extends CadiFilter { try { Feed feed = Feed.getFeedById(feedId); if (feed != null) { - if (!((feed.getAafInstance().equalsIgnoreCase("legacy")) || feed.getAafInstance() == null + if (!(("legacy".equalsIgnoreCase(feed.getAafInstance())) || feed.getAafInstance() == null || feed.getAafInstance().equals(""))) { //also apply null check and empty check too aafInstance = feed.getAafInstance(); String message = "DRProvCadiFilter.isAAFFeed: aafInstance-:" + aafInstance + "; feedId:- " + feedId; @@ -241,9 +241,9 @@ public class DRProvCadiFilter extends CadiFilter { try { Subscription subscriber = Subscription.getSubscriptionById(subId); if (subscriber != null) { - if (!((subscriber.getAafInstance().equalsIgnoreCase("legacy")) + if (!(("legacy".equalsIgnoreCase(subscriber.getAafInstance())) || subscriber.getAafInstance() == null - || subscriber.getAafInstance().equals(""))) { //also apply null check and empty check too + || "".equals(subscriber.getAafInstance()))) { //also apply null check and empty check too aafInstance = subscriber.getAafInstance(); String message = "DRProvCadiFilter.isAAFSubscriber: aafInstance-:" + aafInstance + "; subId:- " + subId; -- cgit 1.2.3-korg