summaryrefslogtreecommitdiffstats
path: root/policy-endpoints/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'policy-endpoints/src/main')
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicParams.java105
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/TopicParameterGroup.java28
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/TopicParameters.java8
3 files changed, 36 insertions, 105 deletions
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicParams.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicParams.java
index b9817abf..9df7221f 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicParams.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicParams.java
@@ -4,6 +4,7 @@
* ================================================================================
* Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
* Modifications Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +24,8 @@ package org.onap.policy.common.endpoints.event.comm.bus.internal;
import java.util.List;
import java.util.Map;
+import lombok.Getter;
+import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
/**
@@ -45,6 +48,8 @@ import org.apache.commons.lang3.StringUtils;
* useHttps does connection use HTTPS?
* allowSelfSignedCerts are self-signed certificates allow
*/
+@Getter
+@Setter
public class BusTopicParams {
private int port;
@@ -79,106 +84,6 @@ public class BusTopicParams {
return new TopicParamsBuilder();
}
- public String getPartitionId() {
- return partitionId;
- }
-
- public String getUserName() {
- return userName;
- }
-
- public String getPassword() {
- return password;
- }
-
- public String getEnvironment() {
- return environment;
- }
-
- public String getAftEnvironment() {
- return aftEnvironment;
- }
-
- public String getPartner() {
- return partner;
- }
-
- public String getLatitude() {
- return latitude;
- }
-
- public String getLongitude() {
- return longitude;
- }
-
- public Map<String, String> getAdditionalProps() {
- return additionalProps;
- }
-
- public List<String> getServers() {
- return servers;
- }
-
- public String getTopic() {
- return topic;
- }
-
- public String getEffectiveTopic() {
- return effectiveTopic;
- }
-
- public String getApiKey() {
- return apiKey;
- }
-
- public String getApiSecret() {
- return apiSecret;
- }
-
- public String getConsumerGroup() {
- return consumerGroup;
- }
-
- public String getConsumerInstance() {
- return consumerInstance;
- }
-
- public int getFetchTimeout() {
- return fetchTimeout;
- }
-
- public int getFetchLimit() {
- return fetchLimit;
- }
-
- public String getClientName() {
- return clientName;
- }
-
- public String getHostname() {
- return hostname;
- }
-
- public int getPort() {
- return port;
- }
-
- public String getBasePath() {
- return basePath;
- }
-
- public boolean isManaged() {
- return managed;
- }
-
- public boolean isUseHttps() {
- return useHttps;
- }
-
- public boolean isAllowSelfSignedCerts() {
- return allowSelfSignedCerts;
- }
-
/**
* Methods to Check if the property is INVALID.
*/
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/TopicParameterGroup.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/TopicParameterGroup.java
index 3cc2503a..70a06036 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/TopicParameterGroup.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/TopicParameterGroup.java
@@ -23,7 +23,10 @@ package org.onap.policy.common.endpoints.parameters;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.policy.common.parameters.GroupValidationResult;
import org.onap.policy.common.parameters.ParameterGroupImpl;
+import org.onap.policy.common.parameters.ValidationStatus;
import org.onap.policy.common.parameters.annotations.NotBlank;
import org.onap.policy.common.parameters.annotations.NotNull;
@@ -44,4 +47,29 @@ public class TopicParameterGroup extends ParameterGroupImpl {
public TopicParameterGroup() {
super(TopicParameterGroup.class.getSimpleName());
}
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public GroupValidationResult validate() {
+ GroupValidationResult result = super.validate();
+ if (result.isValid() && (checkMissingMandatoryParams(topicSources)
+ || checkMissingMandatoryParams(topicSinks))) {
+ result.setResult(ValidationStatus.INVALID, "Mandatory parameters are missing. topic, servers "
+ + "and topicCommInfrastructure must be specified.");
+ }
+ return result;
+ }
+
+ private boolean checkMissingMandatoryParams(List<TopicParameters> topicParametersList) {
+ for (TopicParameters topicParameters : topicParametersList) {
+ if (StringUtils.isBlank(topicParameters.getTopic())
+ || StringUtils.isBlank(topicParameters.getTopicCommInfrastructure())
+ || topicParameters.getServers().isEmpty()) {
+ return true;
+ }
+ }
+ return false;
+ }
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/TopicParameters.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/TopicParameters.java
index 82c75d35..d525aafc 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/TopicParameters.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/TopicParameters.java
@@ -20,10 +20,10 @@
package org.onap.policy.common.endpoints.parameters;
-import java.util.List;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
+import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.parameters.annotations.NotBlank;
import org.onap.policy.common.parameters.annotations.NotNull;
@@ -36,9 +36,7 @@ import org.onap.policy.common.parameters.annotations.NotNull;
@NotBlank
@Getter
@Setter
-@EqualsAndHashCode
-public class TopicParameters {
- private String topic;
- private List<String> servers;
+@EqualsAndHashCode(callSuper = false)
+public class TopicParameters extends BusTopicParams {
private String topicCommInfrastructure;
}