aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/plugins-event
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@ericsson.com>2018-08-30 09:37:29 +0100
committerliamfallon <liam.fallon@ericsson.com>2018-08-31 19:23:41 +0100
commitf32508381ce0b555fc14978cbaa458aa4e2d91c5 (patch)
tree1cab66e5372b6467f288ae1351ce836e4eba2d03 /plugins/plugins-event
parent052038c7a7e0b385462b3b653b7d06094d472df3 (diff)
Use parameter service in apex
Switch parameter handling in apex to use the ONAP PF common parameter service Change-Id: Id318d19c726b18b1a69c630fa81ca7d695355e9c Issue-ID: POLICY-954 Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'plugins/plugins-event')
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSConsumer.java8
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSProducer.java16
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JMSCarrierTechnologyParameters.java87
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/KAFKACarrierTechnologyParameters.java109
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RESTClientCarrierTechnologyParameters.java13
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RESTRequestorCarrierTechnologyParameters.java12
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRESTRequestor.java2
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RESTServerCarrierTechnologyParameters.java34
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/WEBSOCKETCarrierTechnologyParameters.java17
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlEventProtocol.java5
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlPluginStability.java5
11 files changed, 165 insertions, 143 deletions
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSConsumer.java
index 878882d6b..93174b941 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSConsumer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSConsumer.java
@@ -96,7 +96,7 @@ public class ApexJMSConsumer implements MessageListener, ApexEventConsumer, Runn
InitialContext jmsContext = null;
ConnectionFactory connectionFactory = null;
try {
- jmsContext = new InitialContext(jmsConsumerProperties.getJMSConsumerProperties());
+ jmsContext = new InitialContext(jmsConsumerProperties.getJmsConsumerProperties());
connectionFactory = (ConnectionFactory) jmsContext.lookup(jmsConsumerProperties.getConnectionFactory());
// Check if we actually got a connection factory
@@ -107,7 +107,7 @@ public class ApexJMSConsumer implements MessageListener, ApexEventConsumer, Runn
} catch (final Exception e) {
final String errorMessage = "lookup of JMS connection factory \""
+ jmsConsumerProperties.getConnectionFactory() + "\" failed for JMS consumer properties \""
- + jmsConsumerProperties.getJMSConsumerProperties() + "\"";
+ + jmsConsumerProperties.getJmsConsumerProperties() + "\"";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
@@ -123,7 +123,7 @@ public class ApexJMSConsumer implements MessageListener, ApexEventConsumer, Runn
}
} catch (final Exception e) {
final String errorMessage = "lookup of JMS topic \"" + jmsConsumerProperties.getConsumerTopic()
- + "\" failed for JMS consumer properties \"" + jmsConsumerProperties.getJMSConsumerProperties()
+ + "\" failed for JMS consumer properties \"" + jmsConsumerProperties.getJmsConsumerProperties()
+ "\"";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
@@ -136,7 +136,7 @@ public class ApexJMSConsumer implements MessageListener, ApexEventConsumer, Runn
connection.start();
} catch (final Exception e) {
final String errorMessage = "connection to the JMS server failed for JMS properties \""
- + jmsConsumerProperties.getJMSConsumerProperties() + "\"";
+ + jmsConsumerProperties.getJmsConsumerProperties() + "\"";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSProducer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSProducer.java
index edf78637d..86e9555f9 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSProducer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSProducer.java
@@ -58,9 +58,6 @@ public class ApexJMSProducer implements ApexEventProducer {
// The connection to the JMS server
private Connection connection;
- // The topic on which we send events to JMS
- private Topic jmsOutgoingTopic;
-
// The JMS session on which we will send events
private Session jmsSession;
@@ -96,7 +93,7 @@ public class ApexJMSProducer implements ApexEventProducer {
InitialContext jmsContext = null;
ConnectionFactory connectionFactory = null;
try {
- jmsContext = new InitialContext(jmsProducerProperties.getJMSProducerProperties());
+ jmsContext = new InitialContext(jmsProducerProperties.getJmsProducerProperties());
connectionFactory = (ConnectionFactory) jmsContext.lookup(jmsProducerProperties.getConnectionFactory());
// Check if we actually got a connection factory
@@ -107,12 +104,13 @@ public class ApexJMSProducer implements ApexEventProducer {
} catch (final Exception e) {
final String errorMessage = "lookup of JMS connection factory \""
+ jmsProducerProperties.getConnectionFactory() + "\" failed for JMS producer properties \""
- + jmsProducerProperties.getJMSConsumerProperties() + "\" for producer (" + this.name + ")";
+ + jmsProducerProperties.getJmsConsumerProperties() + "\" for producer (" + this.name + ")";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
// Lookup the topic on which we will send events
+ Topic jmsOutgoingTopic;
try {
jmsOutgoingTopic = (Topic) jmsContext.lookup(jmsProducerProperties.getProducerTopic());
@@ -123,7 +121,7 @@ public class ApexJMSProducer implements ApexEventProducer {
}
} catch (final Exception e) {
final String errorMessage = "lookup of JMS topic \"" + jmsProducerProperties.getProducerTopic()
- + "\" failed for JMS producer properties \"" + jmsProducerProperties.getJMSProducerProperties()
+ + "\" failed for JMS producer properties \"" + jmsProducerProperties.getJmsProducerProperties()
+ "\" for producer (" + this.name + ")";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
@@ -136,7 +134,7 @@ public class ApexJMSProducer implements ApexEventProducer {
connection.start();
} catch (final Exception e) {
final String errorMessage = "connection to JMS server failed for JMS properties \""
- + jmsProducerProperties.getJMSConsumerProperties() + "\" for producer (" + this.name + ")";
+ + jmsProducerProperties.getJmsConsumerProperties() + "\" for producer (" + this.name + ")";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
@@ -146,7 +144,7 @@ public class ApexJMSProducer implements ApexEventProducer {
jmsSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
} catch (final Exception e) {
final String errorMessage = "creation of session to JMS server failed for JMS properties \""
- + jmsProducerProperties.getJMSConsumerProperties() + "\" for producer (" + this.name + ")";
+ + jmsProducerProperties.getJmsConsumerProperties() + "\" for producer (" + this.name + ")";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
@@ -157,7 +155,7 @@ public class ApexJMSProducer implements ApexEventProducer {
} catch (final Exception e) {
final String errorMessage =
"creation of producer for sending events to JMS server failed for JMS properties \""
- + jmsProducerProperties.getJMSConsumerProperties() + "\"";
+ + jmsProducerProperties.getJmsConsumerProperties() + "\"";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JMSCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JMSCarrierTechnologyParameters.java
index dfa8dc28a..80977b5d8 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JMSCarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JMSCarrierTechnologyParameters.java
@@ -25,6 +25,8 @@ import java.util.Properties;
import javax.naming.Context;
import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationStatus;
/**
* Apex parameters for JMS as an event carrier technology.
@@ -99,7 +101,7 @@ public class JMSCarrierTechnologyParameters extends CarrierTechnologyParameters
// JMS carrier parameters
private String connectionFactory = DEFAULT_CONNECTION_FACTORY;
private String initialContextFactory = DEFAULT_INITIAL_CONTEXT_FACTORY;
- private String providerURL = DEFAULT_PROVIDER_URL;
+ private String providerUrl = DEFAULT_PROVIDER_URL;
private String securityPrincipal = DEFAULT_SECURITY_PRINCIPAL;
private String securityCredentials = DEFAULT_SECURITY_CREDENTIALS;
private String producerTopic = DEFAULT_PRODUCER_TOPIC;
@@ -113,7 +115,7 @@ public class JMSCarrierTechnologyParameters extends CarrierTechnologyParameters
* service.
*/
public JMSCarrierTechnologyParameters() {
- super(JMSCarrierTechnologyParameters.class.getCanonicalName());
+ super();
// Set the carrier technology properties for the JMS carrier technology
this.setLabel(JMS_CARRIER_TECHNOLOGY_LABEL);
@@ -126,15 +128,8 @@ public class JMSCarrierTechnologyParameters extends CarrierTechnologyParameters
*
* @return the JMS producer properties
*/
- public Properties getJMSProducerProperties() {
- final Properties jmsProperties = new Properties();
-
- jmsProperties.put(PROPERTY_INITIAL_CONTEXT_FACTORY, initialContextFactory);
- jmsProperties.put(PROPERTY_PROVIDER_URL, providerURL);
- jmsProperties.put(PROPERTY_SECURITY_PRINCIPAL, securityPrincipal);
- jmsProperties.put(PROPERTY_SECURITY_CREDENTIALS, securityCredentials);
-
- return jmsProperties;
+ public Properties getJmsProducerProperties() {
+ return getJmsProperties();
}
/**
@@ -142,11 +137,20 @@ public class JMSCarrierTechnologyParameters extends CarrierTechnologyParameters
*
* @return the jms consumer properties
*/
- public Properties getJMSConsumerProperties() {
+ public Properties getJmsConsumerProperties() {
+ return getJmsProperties();
+ }
+
+ /**
+ * Gets the JMS consumer properties.
+ *
+ * @return the jms consumer properties
+ */
+ private Properties getJmsProperties() {
final Properties jmsProperties = new Properties();
jmsProperties.put(PROPERTY_INITIAL_CONTEXT_FACTORY, initialContextFactory);
- jmsProperties.put(PROPERTY_PROVIDER_URL, providerURL);
+ jmsProperties.put(PROPERTY_PROVIDER_URL, providerUrl);
jmsProperties.put(PROPERTY_SECURITY_PRINCIPAL, securityPrincipal);
jmsProperties.put(PROPERTY_SECURITY_CREDENTIALS, securityCredentials);
@@ -176,8 +180,8 @@ public class JMSCarrierTechnologyParameters extends CarrierTechnologyParameters
*
* @return the provider URL
*/
- public String getProviderURL() {
- return providerURL;
+ public String getProviderUrl() {
+ return providerUrl;
}
/**
@@ -246,10 +250,10 @@ public class JMSCarrierTechnologyParameters extends CarrierTechnologyParameters
/**
* Sets the provider URL.
*
- * @param providerURL the provider URL
+ * @param providerUrl the provider URL
*/
- public void setProviderURL(final String providerURL) {
- this.providerURL = providerURL;
+ public void setProviderUrl(final String providerUrl) {
+ this.providerUrl = providerUrl;
}
/**
@@ -321,48 +325,51 @@ public class JMSCarrierTechnologyParameters extends CarrierTechnologyParameters
* @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate()
*/
@Override
- public String validate() {
- final StringBuilder errorMessageBuilder = new StringBuilder();
-
- errorMessageBuilder.append(super.validate());
+ public GroupValidationResult validate() {
+ final GroupValidationResult result = super.validate();
if (initialContextFactory == null || initialContextFactory.trim().length() == 0) {
- errorMessageBuilder
- .append(" initialContextFactory not specified, must be specified as a string that is a class"
- + " that implements the interface org.jboss.naming.remote.client.InitialContextFactory\n");
+ result.setResult("initialContextFactory", ValidationStatus.INVALID,
+ "initialContextFactory must be specified as a string that is a class that implements the "
+ + "interface org.jboss.naming.remote.client.InitialContextFactory");
}
- if (providerURL == null || providerURL.trim().length() == 0) {
- errorMessageBuilder.append(
- " providerURL not specified, must be specified as a URL string that specifies the location of "
- + "configuration information for the service provider to use such as remote://localhost:4447\n");
+ if (providerUrl == null || providerUrl.trim().length() == 0) {
+ result.setResult("providerUrl", ValidationStatus.INVALID,
+ "providerUrl must be specified as a URL string that specifies the location of "
+ + "configuration information for the service provider to use "
+ + "such as remote://localhost:4447");
}
if (securityPrincipal == null || securityPrincipal.trim().length() == 0) {
- errorMessageBuilder.append(
- " securityPrincipal not specified, must be specified the identity of the principal for authenticating the caller to the service\n");
+ result.setResult("securityPrincipal", ValidationStatus.INVALID,
+ "securityPrincipal must be specified the identity of the principal for authenticating "
+ + "the caller to the service");
}
if (securityCredentials == null || securityCredentials.trim().length() == 0) {
- errorMessageBuilder.append(" securityCredentials not specified, must be specified as "
- + "the credentials of the principal for authenticating the caller to the service\n");
+ result.setResult("securityCredentials", ValidationStatus.INVALID,
+ " securityCredentials must be specified as the credentials of the "
+ + "principal for authenticating the caller to the service");
}
if (producerTopic == null || producerTopic.trim().length() == 0) {
- errorMessageBuilder.append(
- " producerTopic not specified, must be a string that identifies the JMS topic on which Apex will send events\n");
+ result.setResult("producerTopic", ValidationStatus.INVALID,
+ " producerTopic must be a string that identifies the JMS topic "
+ + "on which Apex will send events");
}
if (consumerTopic == null || consumerTopic.trim().length() == 0) {
- errorMessageBuilder.append(
- " consumerTopic not specified, must be a string that identifies the JMS topic on which Apex will recieve events\n");
+ result.setResult("consumerTopic", ValidationStatus.INVALID,
+ " consumerTopic must be a string that identifies the JMS topic "
+ + "on which Apex will recieve events");
}
if (consumerWaitTime < 0) {
- errorMessageBuilder.append(" consumerWaitTime [" + consumerWaitTime
- + "] invalid, must be specified as consumerWaitTime >= 0\n");
+ result.setResult("consumerWaitTime", ValidationStatus.INVALID,
+ "[" + consumerWaitTime + "] invalid, must be specified as consumerWaitTime >= 0");
}
- return errorMessageBuilder.toString();
+ return result;
}
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/KAFKACarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/KAFKACarrierTechnologyParameters.java
index 2357b1807..5ce96662e 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/KAFKACarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/KAFKACarrierTechnologyParameters.java
@@ -25,6 +25,8 @@ import java.util.Collection;
import java.util.Properties;
import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationStatus;
/**
* Apex parameters for Kafka as an event carrier technology.
@@ -42,6 +44,9 @@ public class KAFKACarrierTechnologyParameters extends CarrierTechnologyParameter
/** The consumer plugin class for the Kafka carrier technology. */
public static final String KAFKA_EVENT_CONSUMER_PLUGIN_CLASS = ApexKafkaConsumer.class.getCanonicalName();
+ // Repeated strings in messages
+ private static final String SPECIFY_AS_STRING_MESSAGE = "not specified, must be specified as a string";
+
// Default parameter values
private static final String DEFAULT_ACKS = "all";
private static final String DEFAULT_BOOTSTRAP_SERVERS = "localhost:9092";
@@ -102,7 +107,7 @@ public class KAFKACarrierTechnologyParameters extends CarrierTechnologyParameter
* service.
*/
public KAFKACarrierTechnologyParameters() {
- super(KAFKACarrierTechnologyParameters.class.getCanonicalName());
+ super();
// Set the carrier technology properties for the kafka carrier technology
this.setLabel(KAFKA_CARRIER_TECHNOLOGY_LABEL);
@@ -308,89 +313,107 @@ public class KAFKACarrierTechnologyParameters extends CarrierTechnologyParameter
* @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate()
*/
@Override
- public String validate() {
- final StringBuilder errorMessageBuilder = new StringBuilder();
-
- errorMessageBuilder.append(super.validate());
+ public GroupValidationResult validate() {
+ final GroupValidationResult result = super.validate();
- if (bootstrapServers == null || bootstrapServers.trim().length() == 0) {
- errorMessageBuilder
- .append(" bootstrapServers not specified, must be specified as a string of form host:port\n");
+ if (isNullOrBlank(bootstrapServers)) {
+ result.setResult("bootstrapServers", ValidationStatus.INVALID,
+ "not specified, must be specified as a string of form host:port");
}
- if (acks == null || acks.trim().length() == 0) {
- errorMessageBuilder.append(" acks not specified, must be specified as a string with values [0|1|all]\n");
+ if (isNullOrBlank(acks)) {
+ result.setResult("acks", ValidationStatus.INVALID,
+ "not specified, must be specified as a string with values [0|1|all]");
}
if (retries < 0) {
- errorMessageBuilder.append(" retries [" + retries + "] invalid, must be specified as retries >= 0\n");
+ result.setResult(PROPERTY_RETRIES, ValidationStatus.INVALID,
+ "[" + retries + "] invalid, must be specified as retries >= 0");
}
if (batchSize < 0) {
- errorMessageBuilder
- .append(" batchSize [" + batchSize + "] invalid, must be specified as batchSize >= 0\n");
+ result.setResult("batchSize", ValidationStatus.INVALID,
+ "[" + batchSize + "] invalid, must be specified as batchSize >= 0");
}
if (lingerTime < 0) {
- errorMessageBuilder
- .append(" lingerTime [" + lingerTime + "] invalid, must be specified as lingerTime >= 0\n");
+ result.setResult("lingerTime", ValidationStatus.INVALID,
+ "[" + lingerTime + "] invalid, must be specified as lingerTime >= 0");
}
if (bufferMemory < 0) {
- errorMessageBuilder
- .append(" bufferMemory [" + bufferMemory + "] invalid, must be specified as bufferMemory >= 0\n");
+ result.setResult("bufferMemory", ValidationStatus.INVALID,
+ "[" + bufferMemory + "] invalid, must be specified as bufferMemory >= 0");
}
- if (groupId == null || groupId.trim().length() == 0) {
- errorMessageBuilder.append(" groupId not specified, must be specified as a string\n");
+ if (isNullOrBlank(groupId)) {
+ result.setResult("groupId", ValidationStatus.INVALID, SPECIFY_AS_STRING_MESSAGE);
}
if (autoCommitTime < 0) {
- errorMessageBuilder.append(
- " autoCommitTime [" + autoCommitTime + "] invalid, must be specified as autoCommitTime >= 0\n");
+ result.setResult("autoCommitTime", ValidationStatus.INVALID,
+ "[" + autoCommitTime + "] invalid, must be specified as autoCommitTime >= 0");
}
if (sessionTimeout < 0) {
- errorMessageBuilder.append(
- " sessionTimeout [" + sessionTimeout + "] invalid, must be specified as sessionTimeout >= 0\n");
+ result.setResult("sessionTimeout", ValidationStatus.INVALID,
+ "[" + sessionTimeout + "] invalid, must be specified as sessionTimeout >= 0");
}
- if (producerTopic == null || producerTopic.trim().length() == 0) {
- errorMessageBuilder.append(" producerTopic not specified, must be specified as a string\n");
+ if (isNullOrBlank(producerTopic)) {
+ result.setResult("producerTopic", ValidationStatus.INVALID,
+ SPECIFY_AS_STRING_MESSAGE);
}
if (consumerPollTime < 0) {
- errorMessageBuilder.append(" consumerPollTime [" + consumerPollTime
- + "] invalid, must be specified as consumerPollTime >= 0\n");
+ result.setResult("consumerPollTime", ValidationStatus.INVALID,
+ "[" + consumerPollTime + "] invalid, must be specified as consumerPollTime >= 0");
}
- if (consumerTopicList == null || consumerTopicList.length == 0) {
- errorMessageBuilder.append(" consumerTopicList not specified, must be specified as a list of strings\n");
+ validateConsumerTopicList(result);
+
+ if (isNullOrBlank(keySerializer)) {
+ result.setResult("keySerializer", ValidationStatus.INVALID,
+ SPECIFY_AS_STRING_MESSAGE);
}
- for (final String consumerTopic : consumerTopicList) {
- if (consumerTopic == null || consumerTopic.trim().length() == 0) {
- errorMessageBuilder.append(" invalid consumer topic \"" + consumerTopic
- + "\" specified on consumerTopicList, consumer topics must be specified as strings\n");
- }
+ if (isNullOrBlank(valueSerializer)) {
+ result.setResult("valueSerializer", ValidationStatus.INVALID,
+ SPECIFY_AS_STRING_MESSAGE);
}
- if (keySerializer == null || keySerializer.trim().length() == 0) {
- errorMessageBuilder.append(" keySerializer not specified, must be specified as a string\n");
+ if (isNullOrBlank(keyDeserializer)) {
+ result.setResult("keyDeserializer", ValidationStatus.INVALID,
+ SPECIFY_AS_STRING_MESSAGE);
}
- if (valueSerializer == null || valueSerializer.trim().length() == 0) {
- errorMessageBuilder.append(" valueSerializer not specified, must be specified as a string\n");
+ if (isNullOrBlank(valueDeserializer)) {
+ result.setResult("valueDeserializer", ValidationStatus.INVALID,
+ SPECIFY_AS_STRING_MESSAGE);
}
- if (keyDeserializer == null || keyDeserializer.trim().length() == 0) {
- errorMessageBuilder.append(" keyDeserializer not specified, must be specified as a string\n");
+ return result;
+ }
+
+ private void validateConsumerTopicList(final GroupValidationResult result) {
+ if (consumerTopicList == null || consumerTopicList.length == 0) {
+ result.setResult("consumerTopicList", ValidationStatus.INVALID,
+ "not specified, must be specified as a list of strings");
}
- if (valueDeserializer == null || valueDeserializer.trim().length() == 0) {
- errorMessageBuilder.append(" valueDeserializer not specified, must be specified as a string\n");
+ StringBuilder consumerTopicStringBuilder = new StringBuilder();
+ for (final String consumerTopic : consumerTopicList) {
+ if (consumerTopic == null || consumerTopic.trim().length() == 0) {
+ consumerTopicStringBuilder.append(consumerTopic + "/");
+ }
+ }
+ if (consumerTopicStringBuilder.length() > 0) {
+ result.setResult("consumerTopicList", ValidationStatus.INVALID,
+ "invalid consumer topic list entries found: /" + consumerTopicStringBuilder.toString());
}
+ }
- return errorMessageBuilder.toString();
+ private boolean isNullOrBlank(final String stringValue) {
+ return stringValue == null || stringValue.trim().length() == 0;
}
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RESTClientCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RESTClientCarrierTechnologyParameters.java
index e07593c55..59d19f76b 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RESTClientCarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RESTClientCarrierTechnologyParameters.java
@@ -21,6 +21,8 @@
package org.onap.policy.apex.plugins.event.carrier.restclient;
import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationStatus;
/**
* Apex parameters for REST as an event carrier technology with Apex as a REST client.
@@ -60,7 +62,7 @@ public class RESTClientCarrierTechnologyParameters extends CarrierTechnologyPara
* service.
*/
public RESTClientCarrierTechnologyParameters() {
- super(RESTClientCarrierTechnologyParameters.class.getCanonicalName());
+ super();
// Set the carrier technology properties for the web socket carrier technology
this.setLabel(RESTCLIENT_CARRIER_TECHNOLOGY_LABEL);
@@ -115,20 +117,19 @@ public class RESTClientCarrierTechnologyParameters extends CarrierTechnologyPara
return "RESTClientCarrierTechnologyParameters [url=" + url + ", httpMethod=" + httpMethod + "]";
}
-
/*
*
* @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate()
*/
@Override
- public String validate() {
- final StringBuilder errorMessageBuilder = new StringBuilder();
+ public GroupValidationResult validate() {
+ final GroupValidationResult result = super.validate();
// Check if the URL has been set for event output
if (getURL() == null) {
- errorMessageBuilder.append(" no URL has been set for event sending on REST client");
+ result.setResult("url", ValidationStatus.INVALID, "no URL has been set for event sending on REST client");
}
- return errorMessageBuilder.toString();
+ return result;
}
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RESTRequestorCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RESTRequestorCarrierTechnologyParameters.java
index eb5870058..9b841d768 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RESTRequestorCarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RESTRequestorCarrierTechnologyParameters.java
@@ -68,7 +68,7 @@ public class RESTRequestorCarrierTechnologyParameters extends CarrierTechnologyP
* service.
*/
public RESTRequestorCarrierTechnologyParameters() {
- super(RESTRequestorCarrierTechnologyParameters.class.getCanonicalName());
+ super();
// Set the carrier technology properties for the web socket carrier technology
this.setLabel(RESTREQUESTOR_CARRIER_TECHNOLOGY_LABEL);
@@ -122,14 +122,4 @@ public class RESTRequestorCarrierTechnologyParameters extends CarrierTechnologyP
public String toString() {
return "RESTRequestorCarrierTechnologyParameters [url=" + url + ", httpMethod=" + httpMethod + "]";
}
-
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate()
- */
- @Override
- public String validate() {
- return "";
- }
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRESTRequestor.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRESTRequestor.java
index d4eb434c7..70d567b0d 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRESTRequestor.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRESTRequestor.java
@@ -286,6 +286,6 @@ public class TestRESTRequestor {
System.setErr(stderr);
assertTrue(outString.contains(
- "event input for peered mode \"REQUESTOR\": peer \"RestRequestorProducer\" for event handler \"RestRequestorConsumer\" does not exist or is not defined as being synchronous"));
+ "peer \"RestRequestorProducer for peered mode REQUESTOR does not exist or is not defined with the same peered mode"));
}
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RESTServerCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RESTServerCarrierTechnologyParameters.java
index 47e31fffa..cd7f388f2 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RESTServerCarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RESTServerCarrierTechnologyParameters.java
@@ -21,6 +21,8 @@
package org.onap.policy.apex.plugins.event.carrier.restserver;
import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationStatus;
/**
* Apex parameters for REST as an event carrier technology with Apex as a REST client.
@@ -63,7 +65,7 @@ public class RESTServerCarrierTechnologyParameters extends CarrierTechnologyPara
* service.
*/
public RESTServerCarrierTechnologyParameters() {
- super(RESTServerCarrierTechnologyParameters.class.getCanonicalName());
+ super();
// Set the carrier technology properties for the web socket carrier technology
this.setLabel(RESTSERVER_CARRIER_TECHNOLOGY_LABEL);
@@ -105,32 +107,30 @@ public class RESTServerCarrierTechnologyParameters extends CarrierTechnologyPara
* @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate()
*/
@Override
- public String validate() {
- final StringBuilder errorMessageBuilder = new StringBuilder();
-
- errorMessageBuilder.append(super.validate());
+ public GroupValidationResult validate() {
+ final GroupValidationResult result = super.validate();
// Check if host is defined, it is only defined on REST server consumers
if (standalone) {
- if (host != null) {
- if (host.trim().length() == 0) {
- errorMessageBuilder.append(" host not specified, must be host as a string\n");
- }
+ if (host != null && host.trim().length() == 0) {
+ result.setResult("host", ValidationStatus.INVALID,
+ "host not specified, host must be specified as a string");
}
// Check if port is defined, it is only defined on REST server consumers
- if (port != -1) {
- if (port < MIN_USER_PORT || port > MAX_USER_PORT) {
- errorMessageBuilder
- .append(" port [" + port + "] invalid, must be specified as 1024 <= port <= 6535\n");
- }
+ if (port != -1 && port < MIN_USER_PORT || port > MAX_USER_PORT) {
+ result.setResult("port", ValidationStatus.INVALID,
+ "[" + port + "] invalid, must be specified as 1024 <= port <= 65535");
}
} else {
- if (host != null || port != -1) {
- errorMessageBuilder.append(" host and port are specified only in standalone mode\n");
+ if (host != null) {
+ result.setResult("host", ValidationStatus.INVALID, "host is specified only in standalone mode");
+ }
+ if (port != -1) {
+ result.setResult("port", ValidationStatus.INVALID, "port is specified only in standalone mode");
}
}
- return errorMessageBuilder.toString();
+ return result;
}
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/WEBSOCKETCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/WEBSOCKETCarrierTechnologyParameters.java
index e8009a5d8..e04a81d1d 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/WEBSOCKETCarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/WEBSOCKETCarrierTechnologyParameters.java
@@ -21,6 +21,8 @@
package org.onap.policy.apex.plugins.event.carrier.websocket;
import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationStatus;
/**
* Apex parameters for Kafka as an event carrier technology.
@@ -56,7 +58,7 @@ public class WEBSOCKETCarrierTechnologyParameters extends CarrierTechnologyParam
* parameter service.
*/
public WEBSOCKETCarrierTechnologyParameters() {
- super(WEBSOCKETCarrierTechnologyParameters.class.getCanonicalName());
+ super();
// Set the carrier technology properties for the web socket carrier technology
this.setLabel(WEB_SCOKET_CARRIER_TECHNOLOGY_LABEL);
@@ -97,19 +99,18 @@ public class WEBSOCKETCarrierTechnologyParameters extends CarrierTechnologyParam
* @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate()
*/
@Override
- public String validate() {
- final StringBuilder errorMessageBuilder = new StringBuilder();
-
- errorMessageBuilder.append(super.validate());
+ public GroupValidationResult validate() {
+ final GroupValidationResult result = super.validate();
if (wsClient && (host == null || host.trim().length() == 0)) {
- errorMessageBuilder.append(" host not specified, must be host as a string\n");
+ result.setResult("host", ValidationStatus.INVALID, "host not specified, must be host as a string");
}
if (port < MIN_USER_PORT || port > MAX_USER_PORT) {
- errorMessageBuilder.append(" port [" + port + "] invalid, must be specified as 1024 <= port <= 6535\n");
+ result.setResult("port", ValidationStatus.INVALID,
+ "[" + port + "] invalid, must be specified as 1024 <= port <= 65535");
}
- return errorMessageBuilder.toString();
+ return result;
}
}
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlEventProtocol.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlEventProtocol.java
index 40196eb8a..c5f6cb781 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlEventProtocol.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlEventProtocol.java
@@ -37,7 +37,6 @@ import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.apex.model.eventmodel.concepts.AxEvent;
@@ -48,13 +47,14 @@ import org.onap.policy.apex.service.engine.event.ApexEvent;
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.consumer.HeaderDelimitedTextBlockReader;
import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.consumer.TextBlock;
+import org.onap.policy.common.parameters.ParameterService;
public class TestYamlEventProtocol {
@BeforeClass
public static void registerTestEventsAndSchemas() throws IOException {
SchemaParameters schemaParameters = new SchemaParameters();
schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
- ParameterService.registerParameters(SchemaParameters.class, schemaParameters);
+ ParameterService.register(schemaParameters, true);
AxContextSchemas schemas = new AxContextSchemas();
@@ -199,6 +199,7 @@ public class TestYamlEventProtocol {
@AfterClass
public static void unregisterTestEventsAndSchemas() {
ModelService.clear();
+ ParameterService.clear();
}
@Test
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlPluginStability.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlPluginStability.java
index 126a01df7..57b4b72d6 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlPluginStability.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlPluginStability.java
@@ -34,7 +34,6 @@ import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.apex.model.eventmodel.concepts.AxEvent;
@@ -43,6 +42,7 @@ import org.onap.policy.apex.model.eventmodel.concepts.AxField;
import org.onap.policy.apex.service.engine.event.ApexEvent;
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException;
+import org.onap.policy.common.parameters.ParameterService;
public class TestYamlPluginStability {
static AxEvent testEvent;
@@ -51,7 +51,7 @@ public class TestYamlPluginStability {
public static void registerTestEventsAndSchemas() throws IOException {
SchemaParameters schemaParameters = new SchemaParameters();
schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
- ParameterService.registerParameters(SchemaParameters.class, schemaParameters);
+ ParameterService.register(schemaParameters);
AxContextSchemas schemas = new AxContextSchemas();
@@ -89,6 +89,7 @@ public class TestYamlPluginStability {
@AfterClass
public static void unregisterTestEventsAndSchemas() {
ModelService.clear();
+ ParameterService.clear();
}
@Test