summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pom.xml6
-rw-r--r--src/main/java/org/onap/dcae/commonFunction/DmaapPropertyReader.java58
-rw-r--r--src/main/java/org/onap/dcae/commonFunction/EventProcessor.java13
3 files changed, 41 insertions, 36 deletions
diff --git a/pom.xml b/pom.xml
index 723e7922..fcd7ae04 100644
--- a/pom.xml
+++ b/pom.xml
@@ -102,17 +102,17 @@ limitations under the License.
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
- <version>8.0.51</version>
+ <version>8.5.23</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-catalina</artifactId>
- <version>8.0.51</version>
+ <version>8.5.23</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-coyote</artifactId>
- <version>8.0.51</version>
+ <version>8.5.23</version>
</dependency>
<!-- NSA server library -->
<dependency>
diff --git a/src/main/java/org/onap/dcae/commonFunction/DmaapPropertyReader.java b/src/main/java/org/onap/dcae/commonFunction/DmaapPropertyReader.java
index 6ff24abf..dabd2b15 100644
--- a/src/main/java/org/onap/dcae/commonFunction/DmaapPropertyReader.java
+++ b/src/main/java/org/onap/dcae/commonFunction/DmaapPropertyReader.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -38,11 +38,19 @@ import com.google.gson.JsonSyntaxException;
public class DmaapPropertyReader {
+ private static final String HOST_URL = " HOST-URL:";
+ private static final String TOPIC = "TOPIC:";
+ private static final String CAMBRIA_URL = "cambria.url";
+ private static final String CAMBRIA_HOSTS = "cambria.hosts";
+ private static final String PWD = " PWD:";
+ private static final String USER = " USER:";
+ private static final String BASIC_AUTH_PASSWORD = "basicAuthPassword";
+ private static final String BASIC_AUTH_USER_NAME = "basicAuthUsername";
private static DmaapPropertyReader instance = null;
private static final Logger log = LoggerFactory.getLogger(DmaapPropertyReader.class);
- public HashMap<String, String> dmaap_hash = new HashMap<String, String>();
+ public HashMap<String, String> dmaap_hash = new HashMap<>();
public DmaapPropertyReader(String CambriaConfigFile) {
@@ -58,32 +66,32 @@ public class DmaapPropertyReader {
JsonArray jsonObject = (JsonArray) root.getAsJsonObject().get("channels");
for (int i = 0; i < jsonObject.size(); i++) {
- log.debug("TOPIC:" + jsonObject.get(i).getAsJsonObject().get("cambria.topic") + " HOST-URL:"
- + jsonObject.get(i).getAsJsonObject().get("cambria.url") + " HOSTS:"
- + jsonObject.get(i).getAsJsonObject().get("cambria.hosts") + " PWD:"
- + jsonObject.get(i).getAsJsonObject().get("basicAuthPassword") + " USER:"
- + jsonObject.get(i).getAsJsonObject().get("basicAuthUsername") + " NAME:"
+ log.debug(TOPIC + jsonObject.get(i).getAsJsonObject().get("cambria.topic") + HOST_URL
+ + jsonObject.get(i).getAsJsonObject().get(CAMBRIA_URL) + " HOSTS:"
+ + jsonObject.get(i).getAsJsonObject().get(CAMBRIA_HOSTS) + PWD
+ + jsonObject.get(i).getAsJsonObject().get(BASIC_AUTH_PASSWORD) + USER
+ + jsonObject.get(i).getAsJsonObject().get(BASIC_AUTH_USER_NAME) + " NAME:"
+ jsonObject.get(i).getAsJsonObject().get("name"));
String convertedname = jsonObject.get(i).getAsJsonObject().get("name").toString().replace("\"", "");
dmaap_hash.put(convertedname + ".cambria.topic",
jsonObject.get(i).getAsJsonObject().get("cambria.topic").toString().replace("\"", ""));
- if (jsonObject.get(i).getAsJsonObject().get("cambria.hosts") != null) {
+ if (jsonObject.get(i).getAsJsonObject().get(CAMBRIA_HOSTS) != null) {
dmaap_hash.put(convertedname + ".cambria.hosts",
- jsonObject.get(i).getAsJsonObject().get("cambria.hosts").toString().replace("\"", ""));
+ jsonObject.get(i).getAsJsonObject().get(CAMBRIA_HOSTS).toString().replace("\"", ""));
}
- if (jsonObject.get(i).getAsJsonObject().get("cambria.url") != null) {
+ if (jsonObject.get(i).getAsJsonObject().get(CAMBRIA_URL) != null) {
dmaap_hash.put(convertedname + ".cambria.url",
- jsonObject.get(i).getAsJsonObject().get("cambria.url").toString().replace("\"", ""));
+ jsonObject.get(i).getAsJsonObject().get(CAMBRIA_URL).toString().replace("\"", ""));
}
- if (jsonObject.get(i).getAsJsonObject().get("basicAuthPassword") != null) {
+ if (jsonObject.get(i).getAsJsonObject().get(BASIC_AUTH_PASSWORD) != null) {
dmaap_hash.put(convertedname + ".basicAuthPassword", jsonObject.get(i).getAsJsonObject()
- .get("basicAuthPassword").toString().replace("\"", ""));
+ .get(BASIC_AUTH_PASSWORD).toString().replace("\"", ""));
}
- if (jsonObject.get(i).getAsJsonObject().get("basicAuthUsername") != null) {
+ if (jsonObject.get(i).getAsJsonObject().get(BASIC_AUTH_USER_NAME) != null) {
dmaap_hash.put(convertedname + ".basicAuthUsername", jsonObject.get(i).getAsJsonObject()
- .get("basicAuthUsername").toString().replace("\"", ""));
+ .get(BASIC_AUTH_USER_NAME).toString().replace("\"", ""));
}
}
@@ -111,7 +119,7 @@ public class DmaapPropertyReader {
mrUrl = urlParts[2];
// DCAE internal dmaap topic convention
- if (urlParts[3].equals("events")) {
+ if ("events".equals(urlParts[3])) {
mrTopic = urlParts[4];
} else {
// ONAP dmaap topic convention
@@ -132,10 +140,10 @@ public class DmaapPropertyReader {
userpwd = entry.getValue().getAsJsonObject().get("aaf_password").toString().replace("\"", "");
}
if (hostport == null) {
- log.debug("TOPIC:" + mrTopic + " HOST-URL:" + mrUrl + " PWD:" + userpwd + " USER:" + username);
+ log.debug(TOPIC + mrTopic + HOST_URL + mrUrl + PWD + userpwd + USER + username);
} else {
- log.debug("TOPIC:" + mrTopic + " HOST-URL:" + mrUrl + " HOSTS:" + hostport[0] + " PWD:"
- + userpwd + " USER:" + username + " NAME:" + entry.getKey());
+ log.debug(TOPIC + mrTopic + HOST_URL + mrUrl + " HOSTS:" + hostport[0] + PWD
+ + userpwd + USER + username + " NAME:" + entry.getKey());
}
dmaap_hash.put(entry.getKey() + ".cambria.topic", mrTopic);
@@ -190,7 +198,7 @@ public class DmaapPropertyReader {
String[] multUrls = dmUrl.split(",");
StringBuffer newUrls = new StringBuffer();
- String urlParts[] = null;
+ String[] urlParts = null;
for (int i = 0; i < multUrls.length; i++) {
urlParts = multUrls[i].split("/");
if (i == 0) {
@@ -202,14 +210,14 @@ public class DmaapPropertyReader {
return urlParts;
}
- public static synchronized DmaapPropertyReader getInstance(String ChannelConfig) {
+ public static synchronized DmaapPropertyReader getInstance(String channelConfig) {
if (instance == null) {
- instance = new DmaapPropertyReader(ChannelConfig);
+ instance = new DmaapPropertyReader(channelConfig);
}
return instance;
}
- public String getKeyValue(String HashKey) {
- return this.dmaap_hash.get(HashKey);
+ public String getKeyValue(String hashKey) {
+ return this.dmaap_hash.get(hashKey);
}
}
diff --git a/src/main/java/org/onap/dcae/commonFunction/EventProcessor.java b/src/main/java/org/onap/dcae/commonFunction/EventProcessor.java
index d41cb23a..c7c052f9 100644
--- a/src/main/java/org/onap/dcae/commonFunction/EventProcessor.java
+++ b/src/main/java/org/onap/dcae/commonFunction/EventProcessor.java
@@ -46,7 +46,7 @@ public class EventProcessor implements Runnable {
private static final String EVENT_LITERAL = "event";
private static final String COMMON_EVENT_HEADER = "commonEventHeader";
- private static HashMap<String, String[]> streamid_hash = new HashMap<String, String[]>();
+ private static HashMap<String, String[]> streamidHash = new HashMap<>();
public JSONObject event;
public EventProcessor() {
@@ -55,11 +55,11 @@ public class EventProcessor implements Runnable {
String[] list = CommonStartup.streamid.split("\\|");
for (String aList : list) {
String domain = aList.split("=")[0];
- // String streamIdList[] = list[i].split("=")[1].split(",");
+
String[] streamIdList = aList.substring(aList.indexOf('=') + 1).split(",");
log.debug(String.format("Domain: %s streamIdList:%s", domain, Arrays.toString(streamIdList)));
- streamid_hash.put(domain, streamIdList);
+ streamidHash.put(domain, streamIdList);
}
}
@@ -70,9 +70,7 @@ public class EventProcessor implements Runnable {
try {
event = CommonStartup.fProcessingInputQueue.take();
-
- // EventPublisher Ep=new EventPublisher();
while (event != null) {
// As long as the producer is running we remove elements from
// the queue.
@@ -84,7 +82,7 @@ public class EventProcessor implements Runnable {
log.debug("event.VESuniqueId" + event.get("VESuniqueId") + "event.commonEventHeader.domain:"
+ event.getJSONObject(EVENT_LITERAL).getJSONObject(COMMON_EVENT_HEADER).getString("domain"));
- String[] streamIdList = streamid_hash
+ String[] streamIdList = streamidHash
.get(event.getJSONObject(EVENT_LITERAL).getJSONObject(COMMON_EVENT_HEADER).getString("domain"));
log.debug("streamIdList:" + streamIdList);
@@ -94,7 +92,7 @@ public class EventProcessor implements Runnable {
for (String aStreamIdList : streamIdList) {
log.info("Invoking publisher for streamId:" + aStreamIdList);
this.overrideEvent();
- //EventPublisher.getInstance(aStreamIdList).sendEvent(event);
+
EventPublisherHash.getInstance().sendEvent(event, aStreamIdList);
}
@@ -133,7 +131,6 @@ public class EventProcessor implements Runnable {
// now convert to org.json
final String jsonText = jo.toString();
final JSONArray topLevel = new JSONArray(jsonText);
- // log.info("topLevel == " + topLevel);
Class[] paramJSONObject = new Class[1];
paramJSONObject[0] = JSONObject.class;