aboutsummaryrefslogtreecommitdiffstats
path: root/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/ParameterUtils.java
diff options
context:
space:
mode:
Diffstat (limited to 'policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/ParameterUtils.java')
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/ParameterUtils.java30
1 files changed, 21 insertions, 9 deletions
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/ParameterUtils.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/ParameterUtils.java
index 9e7c69a4..40ce8fa5 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/ParameterUtils.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/ParameterUtils.java
@@ -25,6 +25,7 @@ import java.util.Properties;
import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
import org.onap.policy.common.endpoints.parameters.TopicParameters;
+import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
/**
* This is common utility class with utility methods for parameters.
@@ -54,24 +55,35 @@ public abstract class ParameterUtils {
// for each topicCommInfrastructure, there could be multiple topics (specified as comma separated string)
// for each such topics, there could be multiple servers (specified as comma separated string)
for (TopicParameters source : topicSources) {
- addTopicProperties(topicProperties, ".source.topics", source);
+ updateTopicProperties(topicProperties, "source", source.getTopicCommInfrastructure(), source.getTopic(),
+ source.getServers());
}
for (TopicParameters sink : topicSinks) {
- addTopicProperties(topicProperties, ".sink.topics", sink);
+ updateTopicProperties(topicProperties, "sink", sink.getTopicCommInfrastructure(), sink.getTopic(),
+ sink.getServers());
}
return topicProperties;
}
- private static void addTopicProperties(Properties topicProperties, String keyName, TopicParameters topicParameter) {
- String propKey = topicParameter.getTopicCommInfrastructure() + keyName;
+ /**
+ * Common method to update topic properties object using the parameters passed.
+ *
+ * @param topicProperties the topic properties object which is to be updated
+ * @param keyName either it is source or sink
+ * @param topicCommInfra the infra such as dmaap, ueb or noop
+ * @param topicName the topic
+ * @param servers the list of server names for the topic
+ */
+ public static void updateTopicProperties(Properties topicProperties, String keyName, String topicCommInfra,
+ String topicName, List<String> servers) {
+ String propKey = topicCommInfra + "." + keyName + PolicyEndPointProperties.PROPERTY_TOPIC_TOPICS_SUFFIX;
if (topicProperties.containsKey(propKey)) {
- topicProperties.setProperty(propKey,
- topicProperties.getProperty(propKey) + "," + topicParameter.getTopic());
+ topicProperties.setProperty(propKey, topicProperties.getProperty(propKey) + "," + topicName);
} else {
- topicProperties.setProperty(propKey, topicParameter.getTopic());
+ topicProperties.setProperty(propKey, topicName);
}
- topicProperties.setProperty(propKey + "." + topicParameter.getTopic() + ".servers",
- String.join(",", topicParameter.getServers()));
+ topicProperties.setProperty(propKey + "." + topicName + PolicyEndPointProperties.PROPERTY_TOPIC_SERVERS_SUFFIX,
+ String.join(",", servers));
}
}