2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.common.endpoints.event.comm.bus.internal;
23 import java.util.List;
27 * Member variables of this Params class are as follows.
29 * <p>servers DMaaP servers
30 * topic DMaaP Topic to be monitored
31 * apiKey DMaaP API Key (optional)
32 * apiSecret DMaaP API Secret (optional)
33 * consumerGroup DMaaP Reader Consumer Group
34 * consumerInstance DMaaP Reader Instance
35 * fetchTimeout DMaaP fetch timeout
36 * fetchLimit DMaaP fetch limit
37 * environment DME2 Environment
38 * aftEnvironment DME2 AFT Environment
39 * partner DME2 Partner
40 * latitude DME2 Latitude
41 * longitude DME2 Longitude
42 * additionalProps Additional properties to pass to DME2
43 * useHttps does connection use HTTPS?
44 * allowSelfSignedCerts are self-signed certificates allow
46 public class BusTopicParams {
48 public static TopicParamsBuilder builder() {
49 return new TopicParamsBuilder();
52 private List<String> servers;
54 private String apiKey;
55 private String apiSecret;
56 private String consumerGroup;
57 private String consumerInstance;
58 private int fetchTimeout;
59 private int fetchLimit;
60 private boolean useHttps;
61 private boolean allowSelfSignedCerts;
63 private String userName;
64 private String password;
65 private String environment;
66 private String aftEnvironment;
67 private String partner;
68 private String latitude;
69 private String longitude;
70 private Map<String, String> additionalProps;
71 private String partitionId;
73 String getPartitionId() {
77 String getUserName() {
81 String getPassword() {
85 String getEnvironment() {
89 String getAftEnvironment() {
90 return aftEnvironment;
97 String getLatitude() {
101 String getLongitude() {
105 Map<String, String> getAdditionalProps() {
106 return additionalProps;
109 List<String> getServers() {
121 String getApiSecret() {
125 String getConsumerGroup() {
126 return consumerGroup;
129 String getConsumerInstance() {
130 return consumerInstance;
133 int getFetchTimeout() {
137 int getFetchLimit() {
141 boolean isUseHttps() {
145 boolean isAllowSelfSignedCerts() {
146 return allowSelfSignedCerts;
149 boolean isEnvironmentNullOrEmpty() {
150 return (environment == null || environment.trim().isEmpty());
153 boolean isAftEnvironmentNullOrEmpty() {
154 return (aftEnvironment == null || aftEnvironment.trim().isEmpty());
157 boolean isLatitudeNullOrEmpty() {
158 return (latitude == null || latitude.trim().isEmpty());
161 boolean isLongitudeNullOrEmpty() {
162 return (longitude == null || longitude.trim().isEmpty());
165 boolean isConsumerInstanceNullOrEmpty() {
166 return (consumerInstance == null || consumerInstance.trim().isEmpty());
169 boolean isConsumerGroupNullOrEmpty() {
170 return (consumerGroup == null || consumerGroup.trim().isEmpty());
173 boolean isApiKeyValid() {
174 return !(apiKey == null || apiKey.trim().isEmpty());
177 boolean isApiSecretValid() {
178 return !(apiSecret == null || apiSecret.trim().isEmpty());
181 boolean isUserNameValid() {
182 return !(userName == null || userName.trim().isEmpty());
185 boolean isPasswordValid() {
186 return !(password == null || password.trim().isEmpty());
189 boolean isPartnerNullOrEmpty() {
190 return (partner == null || partner.trim().isEmpty());
193 boolean isServersNullOrEmpty() {
194 return (servers == null || servers.isEmpty()
195 || (servers.size() == 1 && ("".equals(servers.get(0)))));
198 boolean isAdditionalPropsValid() {
199 return additionalProps != null;
202 boolean isTopicNullOrEmpty() {
203 return (topic == null || topic.trim().isEmpty());
206 boolean isPartitionIdNullOrEmpty() {
207 return (partitionId == null || partitionId.trim().isEmpty());
210 public static class TopicParamsBuilder {
211 BusTopicParams m = new BusTopicParams();
213 private TopicParamsBuilder() {
216 public TopicParamsBuilder servers(List<String> servers) {
217 this.m.servers = servers;
221 public TopicParamsBuilder topic(String topic) {
222 this.m.topic = topic;
226 public TopicParamsBuilder apiKey(String apiKey) {
227 this.m.apiKey = apiKey;
231 public TopicParamsBuilder apiSecret(String apiSecret) {
232 this.m.apiSecret = apiSecret;
236 public TopicParamsBuilder consumerGroup(String consumerGroup) {
237 this.m.consumerGroup = consumerGroup;
241 public TopicParamsBuilder consumerInstance(String consumerInstance) {
242 this.m.consumerInstance = consumerInstance;
246 public TopicParamsBuilder fetchTimeout(int fetchTimeout) {
247 this.m.fetchTimeout = fetchTimeout;
251 public TopicParamsBuilder fetchLimit(int fetchLimit) {
252 this.m.fetchLimit = fetchLimit;
256 public TopicParamsBuilder useHttps(boolean useHttps) {
257 this.m.useHttps = useHttps;
261 public TopicParamsBuilder allowSelfSignedCerts(boolean allowSelfSignedCerts) {
262 this.m.allowSelfSignedCerts = allowSelfSignedCerts;
266 public TopicParamsBuilder userName(String userName) {
267 this.m.userName = userName;
271 public TopicParamsBuilder password(String password) {
272 this.m.password = password;
276 public TopicParamsBuilder environment(String environment) {
277 this.m.environment = environment;
281 public TopicParamsBuilder aftEnvironment(String aftEnvironment) {
282 this.m.aftEnvironment = aftEnvironment;
286 public TopicParamsBuilder partner(String partner) {
287 this.m.partner = partner;
291 public TopicParamsBuilder latitude(String latitude) {
292 this.m.latitude = latitude;
296 public TopicParamsBuilder longitude(String longitude) {
297 this.m.longitude = longitude;
301 public TopicParamsBuilder additionalProps(Map<String, String> additionalProps) {
302 this.m.additionalProps = additionalProps;
306 public TopicParamsBuilder partitionId(String partitionId) {
307 this.m.partitionId = partitionId;
311 public BusTopicParams build() {