summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb')
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/Consumer.java71
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/FunctionalMenu.java9
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/Helper.java30
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/Publisher.java29
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/PublisherList.java26
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/TopicManager.java31
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/UebException.java31
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/UebManager.java66
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/UebMsg.java13
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/UebMsgTypes.java4
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/WaitingRequestersQueueList.java14
11 files changed, 154 insertions, 170 deletions
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/Consumer.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/Consumer.java
index 6f76d1aa..be8e71f8 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/Consumer.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/Consumer.java
@@ -6,7 +6,7 @@
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
- * under the Apache License, Version 2.0 (the “License”);
+ * under the Apache License, Version 2.0 (the "License");
* you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -19,7 +19,7 @@
* limitations under the License.
*
* Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
* you may not use this documentation except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -39,9 +39,9 @@ package org.onap.portalsdk.core.onboarding.ueb;
import java.io.IOException;
import java.security.GeneralSecurityException;
-import java.util.LinkedList;
+import java.util.List;
+import java.util.Queue;
import java.util.UUID;
-import java.util.concurrent.ConcurrentLinkedQueue;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -60,14 +60,17 @@ public class Consumer implements Runnable {
private final Log logger = LogFactory.getLog(getClass());
- private final LinkedList<String> urlList = Helper.uebUrlList();
- private final ConcurrentLinkedQueue<UebMsg> queue;
+ private final List<String> urlList = Helper.uebUrlList();
+ private final Queue<UebMsg> queue;
private final WaitingRequestersQueueList waitingRequestersList;
- private final String consumerKey, consumerSecret, topicName, consumerGroupName;
+ private final String consumerKey;
+ private final String consumerSecret;
+ private final String topicName;
+ private final String consumerGroupName;
/**
- * Accepts coordinates needed to subscribe to a UEB topic, as well as the
- * queues for passing along messages that arrive.
+ * Accepts coordinates needed to subscribe to a UEB topic, as well as the queues
+ * for passing along messages that arrive.
*
* @param consumerKey
* UEB key used to subscribe to the topic
@@ -75,16 +78,18 @@ public class Consumer implements Runnable {
* UEB secret used to subscribe to the topic
* @param topicName
* UEB topic name
+ * @param consumerGroupName
+ * consumer group name
* @param queue
- * Queue to receive UEB messages. All inbound messages are
- * enqueued here; ignored if null.
+ * Queue to receive UEB messages. All inbound messages are enqueued
+ * here; ignored if null.
* @param waitingRequestersList
* Collection of queues to receive UEB messages that arrive in
- * response to requests; i.e., emulating a synchronous request
- * via pub/sub.
+ * response to requests; i.e., emulating a synchronous request via
+ * pub/sub.
*/
public Consumer(String consumerKey, String consumerSecret, String topicName, String consumerGroupName,
- ConcurrentLinkedQueue<UebMsg> queue, WaitingRequestersQueueList waitingRequestersList) {
+ Queue<UebMsg> queue, WaitingRequestersQueueList waitingRequestersList) {
this.consumerKey = consumerKey;
this.consumerSecret = consumerSecret;
this.topicName = topicName;
@@ -98,28 +103,21 @@ public class Consumer implements Runnable {
* Distributes messages appropriately as they arrive:
* <UL>
* <LI>If the queue is not null, adds the message to the queue.
- * <LI>If the message's getMsgId() method returns non-null and the ID is
- * found in the collection of waiting requesters, adds the message in that
- * requester's queue.
+ * <LI>If the message's getMsgId() method returns non-null and the ID is found
+ * in the collection of waiting requesters, adds the message in that requester's
+ * queue.
* </UL>
*
- * This is intended to be called in a long running thread as a listener for
- * any published messages on a topic. Typical async pub/sub model. We use a
- * filter of "0" to prevent collisions with P2P messages with unique filter
- * ids.
+ * This is intended to be called in a long running thread as a listener for any
+ * published messages on a topic. Typical async pub/sub model. We use a filter
+ * of "0" to prevent collisions with P2P messages with unique filter ids.
*/
protected void consume() throws IOException, UebException, GeneralSecurityException {
final String id = UUID.randomUUID().toString();
- CambriaConsumer cc = null;
- cc = new CambriaClientBuilders.ConsumerBuilder()
- .usingHosts(urlList)
- .authenticatedBy(consumerKey, consumerSecret)
- .onTopic (topicName)
- .knownAs (consumerGroupName,id)
- .waitAtServer (15*1000)
- .receivingAtMost (1000)
- .build();
+ CambriaConsumer cc = new CambriaClientBuilders.ConsumerBuilder().usingHosts(urlList)
+ .authenticatedBy(consumerKey, consumerSecret).onTopic(topicName).knownAs(consumerGroupName, id)
+ .waitAtServer(15 * 1000).receivingAtMost(1000).build();
while (true) {
for (String msg : cc.fetch()) {
@@ -133,17 +131,16 @@ public class Consumer implements Runnable {
// listener queue.
queue.add(uebMsg);
if (logger.isDebugEnabled())
- logger.debug("Added msg to queue " + this.queue + " queue count = " + queue.size() + " msg :"
- + uebMsg.getPayload());
+ logger.debug("Added msg to queue " + this.queue + " msg :" + uebMsg.getPayload());
}
- if (waitingRequestersList != null && uebMsg.getMsgId() != null) {
+ if (waitingRequestersList != null //
+ && uebMsg.getMsgId() != null //
+ && !(uebMsg.getMsgId()
+ .equals(PortalApiProperties.getProperty(PortalApiConstants.ECOMP_DEFAULT_MSG_ID)))) {
// If a msgId is present, this could be a synchronous
// reply. Here we add it to the waiting requester's
// queue if we find a requester waiting for this msgId.
- if (!(uebMsg.getMsgId()
- .equals(PortalApiProperties.getProperty(PortalApiConstants.ECOMP_DEFAULT_MSG_ID)))) {
- waitingRequestersList.addMsg(uebMsg.getMsgId(), uebMsg);
- }
+ waitingRequestersList.addMsg(uebMsg.getMsgId(), uebMsg);
}
}
if (Thread.interrupted()) {
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/FunctionalMenu.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/FunctionalMenu.java
index 29a3b567..6f9ffd4a 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/FunctionalMenu.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/FunctionalMenu.java
@@ -6,7 +6,7 @@
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
- * under the Apache License, Version 2.0 (the “License”);
+ * under the Apache License, Version 2.0 (the "License");
* you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -19,7 +19,7 @@
* limitations under the License.
*
* Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
* you may not use this documentation except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -61,18 +61,17 @@ public class FunctionalMenu {
public static String get(String userId) throws UebException {
String returnString = null;
logger.info("Making use of UEB communication and Requesting functional menu for user " + userId);
- UebMsg funcMenuUebMsg = null;
UebMsg msg = new UebMsg();
msg.putMsgType(UebMsgTypes.UEB_MSG_TYPE_GET_FUNC_MENU);
msg.putUserId(userId);
- funcMenuUebMsg = UebManager.getInstance().requestReply(msg);
+ UebMsg funcMenuUebMsg = UebManager.getInstance().requestReply(msg);
if (funcMenuUebMsg != null) {
if (funcMenuUebMsg.getPayload().startsWith("Error:")) {
logger.error("getFunctionalMenu received an error in UEB msg = " + funcMenuUebMsg.getPayload());
} else {
returnString = funcMenuUebMsg.getPayload();
}
- }
+ }
return returnString;
}
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/Helper.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/Helper.java
index 02f64bd4..be1a686b 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/Helper.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/Helper.java
@@ -6,7 +6,7 @@
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
- * under the Apache License, Version 2.0 (the “License”);
+ * under the Apache License, Version 2.0 (the "License");
* you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -19,7 +19,7 @@
* limitations under the License.
*
* Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
* you may not use this documentation except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -38,6 +38,7 @@
package org.onap.portalsdk.core.onboarding.ueb;
import java.util.LinkedList;
+import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -45,7 +46,7 @@ import org.onap.portalsdk.core.onboarding.util.PortalApiConstants;
import org.onap.portalsdk.core.onboarding.util.PortalApiProperties;
/**
- * Provides utility methods.
+ * Provides utility methods.
*/
public class Helper {
@@ -57,17 +58,16 @@ public class Helper {
*
* @return List of UEB server names
*/
- public static LinkedList<String> uebUrlList() {
- LinkedList<String> urlList = null;
- String url = PortalApiProperties.getProperty(PortalApiConstants.UEB_URL_LIST);
- if (url == null) {
- logger.error("uebUrlList: failed to get property " + PortalApiConstants.UEB_URL_LIST);
- return null;
- }
- urlList = new LinkedList<String>();
- for (String u : url.split(",")) {
- urlList.add(u.trim());
- }
+ public static List<String> uebUrlList() {
+ String url = PortalApiProperties.getProperty(PortalApiConstants.UEB_URL_LIST);
+ if (url == null) {
+ logger.error("uebUrlList: failed to get property " + PortalApiConstants.UEB_URL_LIST);
+ return new LinkedList<String>();
+ }
+ LinkedList<String> urlList = new LinkedList<>();
+ for (String u : url.split(",")) {
+ urlList.add(u.trim());
+ }
return urlList;
}
@@ -75,7 +75,7 @@ public class Helper {
try {
Thread.sleep(milliseconds);
} catch (InterruptedException e) {
- e.printStackTrace();
+ logger.warn("sleep was interrupted", e);
}
}
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/Publisher.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/Publisher.java
index 9536fee8..b73b0110 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/Publisher.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/Publisher.java
@@ -6,7 +6,7 @@
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
- * under the Apache License, Version 2.0 (the “License”);
+ * under the Apache License, Version 2.0 (the "License");
* you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -19,7 +19,7 @@
* limitations under the License.
*
* Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
* you may not use this documentation except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -40,7 +40,7 @@ package org.onap.portalsdk.core.onboarding.ueb;
import java.io.IOException;
import java.net.MalformedURLException;
import java.security.GeneralSecurityException;
-import java.util.LinkedList;
+import java.util.List;
import java.util.concurrent.TimeUnit;
import org.apache.commons.logging.Log;
@@ -56,13 +56,13 @@ import com.fasterxml.jackson.databind.ObjectWriter;
/**
* Provides a publisher that sends messages to a UEB topic.
*
- * Utilizes AT&T's UEB/Cambria subscriber/publisher messaging service.
+ * Utilizes AT&T's UEB/Cambria subscriber/publisher messaging service.
*/
public class Publisher {
private final Log logger = LogFactory.getLog(getClass());
- protected final LinkedList<String> urlList = Helper.uebUrlList();
+ protected final List<String> urlList = Helper.uebUrlList();
private final String topicName;
private final String publisherKey;
@@ -86,11 +86,11 @@ public class Publisher {
}
/**
- * Creates a publisher, subscribes to the topic, sends the specified message
- * to the topic, then closes the publisher. This ensures that the single
- * message goes immediately. UEB is designed for high throughput and tries
- * to batch up multiple messages in each send, but this method wants the
- * single message to go immediately.
+ * Creates a publisher, subscribes to the topic, sends the specified message to
+ * the topic, then closes the publisher. This ensures that the single message
+ * goes immediately. UEB is designed for high throughput and tries to batch up
+ * multiple messages in each send, but this method wants the single message to
+ * go immediately.
*
* @param uebMsg
* Message object to send as the payload.
@@ -103,12 +103,9 @@ public class Publisher {
CambriaBatchingPublisher pub;
try {
- pub = new CambriaClientBuilders.PublisherBuilder()
- .authenticatedBy(publisherKey, publisherSecret).usingHosts(urlList).onTopic(topicName).build();
- } catch (MalformedURLException e1) {
- logger.error("pub.build Exception ", e1);
- throw new UebException(PortalApiConstants.ECOMP_UEB_UNKNOWN_PUBLISH_ERROR, e1, topicName, null, msg);
- } catch (GeneralSecurityException e1) {
+ pub = new CambriaClientBuilders.PublisherBuilder().authenticatedBy(publisherKey, publisherSecret)
+ .usingHosts(urlList).onTopic(topicName).build();
+ } catch (MalformedURLException | GeneralSecurityException e1) {
logger.error("pub.build Exception ", e1);
throw new UebException(PortalApiConstants.ECOMP_UEB_UNKNOWN_PUBLISH_ERROR, e1, topicName, null, msg);
}
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/PublisherList.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/PublisherList.java
index 0556e045..d7dbb323 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/PublisherList.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/PublisherList.java
@@ -6,7 +6,7 @@
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
- * under the Apache License, Version 2.0 (the “License”);
+ * under the Apache License, Version 2.0 (the "License");
* you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -19,7 +19,7 @@
* limitations under the License.
*
* Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
* you may not use this documentation except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -56,17 +56,16 @@ public class PublisherList {
private final Log logger = LogFactory.getLog(getClass());
private final Map<String, Publisher> map;
-
+
public PublisherList() {
- map = new ConcurrentHashMap<>();
+ map = new ConcurrentHashMap<>();
}
-
+
public void addPublisherToMap(String topicName, Publisher publisher) {
- if (this.map.containsKey(topicName)) {
+ if (this.map.containsKey(topicName))
logger.error("Publisher already exists for " + topicName);
- } else {
+ else
this.map.put(topicName, publisher);
- }
}
public Publisher getPublisher(String topicName) {
@@ -77,14 +76,13 @@ public class PublisherList {
this.map.remove(topicName);
}
+ @Override
public String toString() {
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append("Map contains " + this.map.size() + " Publishers.");
- for (Map.Entry<String, Publisher> entry : this.map.entrySet()) {
- String key = entry.getKey().toString();
- Publisher pub = entry.getValue();
- sb.append("Entry msgId, " + key + " publisher" + pub);
- }
+ for (Map.Entry<String, Publisher> entry : this.map.entrySet())
+ sb.append("Entry msgId, " + entry.getKey() + " publisher" + entry.getValue());
+
return sb.toString();
}
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/TopicManager.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/TopicManager.java
index a19e2de6..36f259e8 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/TopicManager.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/TopicManager.java
@@ -6,7 +6,7 @@
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
- * under the Apache License, Version 2.0 (the “License”);
+ * under the Apache License, Version 2.0 (the "License");
* you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -19,7 +19,7 @@
* limitations under the License.
*
* Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
* you may not use this documentation except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -39,7 +39,7 @@ package org.onap.portalsdk.core.onboarding.ueb;
import java.io.IOException;
import java.security.GeneralSecurityException;
-import java.util.LinkedList;
+import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -55,7 +55,7 @@ import com.att.nsa.cambria.client.CambriaTopicManager;
* Provides methods to facilitate creating topics, and adding publishers and
* subscribers to existing topics.
*
- * Utilizes UEB/Cambria subscriber/publisher messaging service.
+ * Utilizes UEB/Cambria subscriber/publisher messaging service.
*/
public class TopicManager {
@@ -78,25 +78,24 @@ public class TopicManager {
*/
public void createTopic(String key, String secret, String topicName, String topicDescription)
throws HttpException, CambriaApiException, IOException {
- final LinkedList<String> urlList = Helper.uebUrlList();
+ final List<String> urlList = Helper.uebUrlList();
if (logger.isInfoEnabled()) {
logger.info("==> createTopic");
logger.info("topicName: " + topicName);
logger.info("topicDescription: " + topicDescription);
}
- CambriaTopicManager tm =null;
+ CambriaTopicManager tm = null;
try {
tm = CambriaClientFactory.createTopicManager(null, urlList, key, secret);
} catch (GeneralSecurityException e) {
- logger.error("pub.build Exception ", e);
+ logger.error("pub.build Exception ", e);
throw new CambriaApiException(topicName);
}
tm.createTopic(topicName, topicDescription, 1, 1);
}
/**
- * Modifies the specified topic to accept a subscriber using the specified
- * key.
+ * Modifies the specified topic to accept a subscriber using the specified key.
*
* @param topicOwnerKey
* @param topicOwnerSecret
@@ -109,10 +108,11 @@ public class TopicManager {
public void addSubscriber(String topicOwnerKey, String topicOwnerSecret, String subscriberKey, String topicName)
throws HttpException, CambriaApiException, IOException {
logger.info("==> addSubscriber to topic " + topicName);
- final LinkedList<String> urlList = Helper.uebUrlList();
+ final List<String> urlList = Helper.uebUrlList();
CambriaTopicManager tm = null;
try {
- tm = new CambriaClientBuilders.TopicManagerBuilder().usingHosts(urlList).authenticatedBy(topicOwnerKey, topicOwnerSecret).build();
+ tm = new CambriaClientBuilders.TopicManagerBuilder().usingHosts(urlList)
+ .authenticatedBy(topicOwnerKey, topicOwnerSecret).build();
tm.allowConsumer(topicName, subscriberKey);
} catch (Exception e) {
// TODO Auto-generated catch block
@@ -121,8 +121,7 @@ public class TopicManager {
}
/**
- * Modifies the specified topic to accept a publisher using the specified
- * key.
+ * Modifies the specified topic to accept a publisher using the specified key.
*
* @param topicOwnerKey
* @param topicOwnerSecret
@@ -137,13 +136,13 @@ public class TopicManager {
public void addPublisher(String topicOwnerKey, String topicOwnerSecret, String publisherKey, String topicName)
throws HttpException, CambriaApiException, IOException {
logger.info("==> addPublisher to topic " + topicName);
- final LinkedList<String> urlList = Helper.uebUrlList();
- CambriaTopicManager tm =null;
+ final List<String> urlList = Helper.uebUrlList();
+ CambriaTopicManager tm = null;
try {
tm = CambriaClientFactory.createTopicManager(HttpClient.ConnectionType.HTTPS, urlList, topicOwnerKey,
topicOwnerSecret);
} catch (GeneralSecurityException e) {
- logger.error("pub.build Exception ", e);
+ logger.error("pub.build Exception ", e);
throw new CambriaApiException(topicName);
}
tm.allowProducer(topicName, publisherKey);
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/UebException.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/UebException.java
index 462345ee..61d67295 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/UebException.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/UebException.java
@@ -6,7 +6,7 @@
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
- * under the Apache License, Version 2.0 (the “License”);
+ * under the Apache License, Version 2.0 (the "License");
* you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -19,7 +19,7 @@
* limitations under the License.
*
* Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
* you may not use this documentation except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -43,15 +43,20 @@ package org.onap.portalsdk.core.onboarding.ueb;
public class UebException extends Exception {
private static final long serialVersionUID = 1L;
- private String topicName = null;
- private String msgId = null;
- private String msg = null;
+ private final String topicName;
+ private final String msgId;
+ private final String msg;
+
+ public UebException(Throwable ex) {
+ this(null, ex);
+ }
+
+ public UebException(String msg, Throwable ex) {
+ this(null, ex, null, null, msg);
+ }
public UebException(String errorMsg, String topicName, String msgId, String msg) {
- super(errorMsg);
- this.topicName = topicName;
- this.msgId = msgId;
- this.msg = msg;
+ this(errorMsg, null, topicName, msgId, msg);
}
public UebException(String errorMsg, Throwable ex, String topicName, String msgId, String msg) {
@@ -61,14 +66,6 @@ public class UebException extends Exception {
this.msg = msg;
}
- public UebException(String msg, Throwable ex) {
- super(msg, ex);
- }
-
- public UebException(Throwable ex) {
- super(ex);
- }
-
public String getUebMsg() {
return this.msg;
}
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/UebManager.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/UebManager.java
index 1608add1..235746e5 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/UebManager.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/UebManager.java
@@ -6,7 +6,7 @@
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
- * under the Apache License, Version 2.0 (the “License”);
+ * under the Apache License, Version 2.0 (the "License");
* you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -19,7 +19,7 @@
* limitations under the License.
*
* Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
* you may not use this documentation except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -39,8 +39,8 @@ package org.onap.portalsdk.core.onboarding.ueb;
import java.io.IOException;
import java.util.List;
+import java.util.Queue;
import java.util.UUID;
-import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.LinkedBlockingQueue;
import org.apache.commons.logging.Log;
@@ -68,11 +68,9 @@ public class UebManager {
private Publisher appPublisher;
private Thread listenerThread;
- private boolean bThisIsEcompPortalServer = false;
/**
- * Constructor initializes fields and validates values obtained from
- * properties.
+ * Constructor initializes fields and validates values obtained from properties.
*
* The picture below is a simplified view of the relationships among ECOMP
* Portal and applications communicating via UEB:
@@ -115,11 +113,12 @@ public class UebManager {
if (appUebSecret == null || appUebSecret.length() == 0)
throw new UebException("Failed to get property " + PortalApiConstants.UEB_APP_SECRET, null, null, null);
List<String> uebUrlList = Helper.uebUrlList();
- if (uebUrlList == null || uebUrlList.size() == 0)
+ if (uebUrlList == null || uebUrlList.isEmpty())
throw new UebException("Failed to get property" + PortalApiConstants.UEB_URL_LIST, null, null, null);
// A bit of magic: if consumer group is a magic token, generate one.
- consumerGroupName = (PortalApiConstants.UEB_APP_CONSUMER_GROUP_NAME_GENERATOR.equals(consGrp)
- ? UUID.randomUUID().toString() : consGrp);
+ consumerGroupName = PortalApiConstants.UEB_APP_CONSUMER_GROUP_NAME_GENERATOR.equals(consGrp)
+ ? UUID.randomUUID().toString()
+ : consGrp;
}
/**
@@ -152,8 +151,9 @@ public class UebManager {
* @param inboxQueue
* Queue supplied to the consumer. If not null, the consumer will
* enqueue every message it receives.
+ * @throws UebException
*/
- public void initListener(ConcurrentLinkedQueue<UebMsg> inboxQueue) throws UebException {
+ public void initListener(Queue<UebMsg> inboxQueue) throws UebException {
waitingRequestersQueueList = new WaitingRequestersQueueList();
Consumer runnable = new Consumer(appUebKey, appUebSecret, inTopicName, consumerGroupName, inboxQueue,
waitingRequestersQueueList);
@@ -167,13 +167,13 @@ public class UebManager {
/*
* ECOMP Portal manages a dynamic list of outbound topics and so the
- * outTopicName is initialized in this logic with the same value as the
- * inbound topic. The real outbound topics name will be added to the
- * publisher list for ECOMP Portal. For an SDK/App instance only one
- * publisher is needed, appPublisher.
+ * outTopicName is initialized in this logic with the same value as the inbound
+ * topic. The real outbound topics name will be added to the publisher list for
+ * ECOMP Portal. For an SDK/App instance only one publisher is needed,
+ * appPublisher.
*/
if (inTopicName.equalsIgnoreCase(outTopicName)) {
- this.bThisIsEcompPortalServer = true;
+ // This is ECOMP POrtal server.1
} else {
appPublisher = new Publisher(appUebKey, appUebSecret, outTopicName);
Helper.sleep(400);
@@ -181,9 +181,9 @@ public class UebManager {
}
/**
- * Creates and adds a publisher to the list for the specified topic. This
- * should only be called by the ECOMP Portal App, other Apps have just one
- * publisher and use appPublisher
+ * Creates and adds a publisher to the list for the specified topic. This should
+ * only be called by the ECOMP Portal App, other Apps have just one publisher
+ * and use appPublisher
*
* @param topicName
*/
@@ -196,8 +196,8 @@ public class UebManager {
/**
* Removes a publisher from the list for the specified topic.
*
- * This should only be called by the ECOMP Portal App, other Apps have just
- * one publisher and use appPublisher
+ * This should only be called by the ECOMP Portal App, other Apps have just one
+ * publisher and use appPublisher
*
* @param topicName
*/
@@ -207,8 +207,8 @@ public class UebManager {
}
/**
- * Adds the default ECOMP message ID to the message and sends the message to
- * the topic.
+ * Adds the default ECOMP message ID to the message and sends the message to the
+ * topic.
*
* @param msg
* @throws UebException
@@ -230,8 +230,7 @@ public class UebManager {
}
/**
- * Sends the message using the appropriate publisher for the specified
- * topic.
+ * Sends the message using the appropriate publisher for the specified topic.
*
* @param msg
* @param topicName
@@ -246,8 +245,7 @@ public class UebManager {
}
/**
- * Publishes a reply using the appropriate publisher for the specified
- * topic.
+ * Publishes a reply using the appropriate publisher for the specified topic.
*
* @param msg
* @param topicName
@@ -262,9 +260,9 @@ public class UebManager {
}
/**
- * Sends the specified message using the specified publisher, and waits for
- * a reply. Retransmits if no reply is received in 5 seconds; gives up after
- * 3 retries.
+ * Sends the specified message using the specified publisher, and waits for a
+ * reply. Retransmits if no reply is received in 5 seconds; gives up after 3
+ * retries.
*
* @param msg
* @param publisher
@@ -281,10 +279,10 @@ public class UebManager {
msg.putMsgId(UUID.randomUUID().toString());
/*
- * Create a queue for this request, the consumer thread will insert
- * the reply on this queue
+ * Create a queue for this request, the consumer thread will insert the reply on
+ * this queue
*/
- LinkedBlockingQueue<UebMsg> replyQueue = new LinkedBlockingQueue<UebMsg>();
+ LinkedBlockingQueue<UebMsg> replyQueue = new LinkedBlockingQueue<>();
waitingRequestersQueueList.addQueueToMap(msg.getMsgId(), replyQueue);
/*
@@ -332,8 +330,8 @@ public class UebManager {
}
/**
- * Sends the specified message using the publisher appropriate for the
- * specified topic name, and waits for a reply.
+ * Sends the specified message using the publisher appropriate for the specified
+ * topic name, and waits for a reply.
*
* @param msg
* @param topicName
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/UebMsg.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/UebMsg.java
index b05fae68..a393823a 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/UebMsg.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/UebMsg.java
@@ -6,7 +6,7 @@
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
- * under the Apache License, Version 2.0 (the “License”);
+ * under the Apache License, Version 2.0 (the "License");
* you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -19,7 +19,7 @@
* limitations under the License.
*
* Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
* you may not use this documentation except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -63,17 +63,16 @@ public class UebMsg {
private String sourceHostName;
/**
- * Creates a new object and populates the fields source IP, source topic,
- * time stamp, version, and message id.
+ * Creates a new object and populates the fields source IP, source topic, time
+ * stamp, version, and message id.
*/
public UebMsg() {
InetAddress ip;
try {
ip = InetAddress.getLocalHost();
- // Do not attempt to get name, why wait on DNS every time?
- // sourceHostName = ip.getHostName();
sourceIP = ip.getHostAddress();
} catch (UnknownHostException e) {
+ logger.warn("UebMsg::ctor failed", e);
sourceHostName = "unknown";
sourceIP = "unknown";
}
@@ -82,7 +81,7 @@ public class UebMsg {
this.version = "1.0";
this.msgId = PortalApiConstants.ECOMP_DEFAULT_MSG_ID;
this.payload = "empty payload content";
- this.sourceTopicName = PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_INBOUND_MAILBOX_NAME);
+ this.sourceTopicName = PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_INBOUND_MAILBOX_NAME);
if (this.sourceTopicName == null)
logger.error("Failed to get property " + PortalApiConstants.UEB_APP_INBOUND_MAILBOX_NAME);
}
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/UebMsgTypes.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/UebMsgTypes.java
index ba94cdc9..da4f4f0e 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/UebMsgTypes.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/UebMsgTypes.java
@@ -6,7 +6,7 @@
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
- * under the Apache License, Version 2.0 (the “License”);
+ * under the Apache License, Version 2.0 (the "License");
* you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -19,7 +19,7 @@
* limitations under the License.
*
* Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
* you may not use this documentation except in compliance with the License.
* You may obtain a copy of the License at
*
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/WaitingRequestersQueueList.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/WaitingRequestersQueueList.java
index 768f1beb..5e2ee5d6 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/WaitingRequestersQueueList.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/onboarding/ueb/WaitingRequestersQueueList.java
@@ -6,7 +6,7 @@
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
- * under the Apache License, Version 2.0 (the “License”);
+ * under the Apache License, Version 2.0 (the "License");
* you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -19,7 +19,7 @@
* limitations under the License.
*
* Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
* you may not use this documentation except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -52,6 +52,7 @@ import org.apache.commons.logging.LogFactory;
* Primarily for the UebManager to track requests while it waits for responses.
*/
public class WaitingRequestersQueueList {
+
private final Log logger = LogFactory.getLog(getClass());
private final Map<String, LinkedBlockingQueue<UebMsg>> map;
@@ -59,7 +60,7 @@ public class WaitingRequestersQueueList {
public WaitingRequestersQueueList() {
map = new ConcurrentHashMap<>();
}
-
+
public void addQueueToMap(String msgId, LinkedBlockingQueue<UebMsg> queue) {
this.map.put(msgId, queue);
}
@@ -77,13 +78,12 @@ public class WaitingRequestersQueueList {
this.map.remove(msgId);
}
+ @Override
public String toString() {
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append("Map contains " + this.map.size() + " Publishers.");
for (Map.Entry<String, LinkedBlockingQueue<UebMsg>> entry : this.map.entrySet()) {
- String key = entry.getKey().toString();
- LinkedBlockingQueue<UebMsg> queue = entry.getValue();
- sb.append("Entry msgId, " + key + " queue " + queue);
+ sb.append("Entry msgId, " + entry.getKey() + " queue " + entry.getValue());
}
return sb.toString();
}