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;
72 private boolean managed;
74 public String getPartitionId() {
78 public String getUserName() {
82 public String getPassword() {
86 public String getEnvironment() {
90 public String getAftEnvironment() {
91 return aftEnvironment;
94 public String getPartner() {
98 public String getLatitude() {
102 public String getLongitude() {
106 public Map<String, String> getAdditionalProps() {
107 return additionalProps;
110 public List<String> getServers() {
114 public String getTopic() {
118 public String getApiKey() {
122 public String getApiSecret() {
126 public String getConsumerGroup() {
127 return consumerGroup;
130 public String getConsumerInstance() {
131 return consumerInstance;
134 public int getFetchTimeout() {
138 public int getFetchLimit() {
142 public boolean isUseHttps() {
146 public boolean isAllowSelfSignedCerts() {
147 return allowSelfSignedCerts;
150 boolean isEnvironmentNullOrEmpty() {
151 return (environment == null || environment.trim().isEmpty());
154 boolean isAftEnvironmentNullOrEmpty() {
155 return (aftEnvironment == null || aftEnvironment.trim().isEmpty());
158 boolean isLatitudeNullOrEmpty() {
159 return (latitude == null || latitude.trim().isEmpty());
162 boolean isLongitudeNullOrEmpty() {
163 return (longitude == null || longitude.trim().isEmpty());
166 boolean isConsumerInstanceNullOrEmpty() {
167 return (consumerInstance == null || consumerInstance.trim().isEmpty());
170 boolean isConsumerGroupNullOrEmpty() {
171 return (consumerGroup == null || consumerGroup.trim().isEmpty());
174 boolean isApiKeyValid() {
175 return !(apiKey == null || apiKey.trim().isEmpty());
178 boolean isApiSecretValid() {
179 return !(apiSecret == null || apiSecret.trim().isEmpty());
182 boolean isUserNameValid() {
183 return !(userName == null || userName.trim().isEmpty());
186 boolean isPasswordValid() {
187 return !(password == null || password.trim().isEmpty());
190 boolean isPartnerNullOrEmpty() {
191 return (partner == null || partner.trim().isEmpty());
194 boolean isServersNullOrEmpty() {
195 return (servers == null || servers.isEmpty()
196 || (servers.size() == 1 && ("".equals(servers.get(0)))));
199 boolean isAdditionalPropsValid() {
200 return additionalProps != null;
203 boolean isTopicNullOrEmpty() {
204 return (topic == null || topic.trim().isEmpty());
207 boolean isPartitionIdNullOrEmpty() {
208 return (partitionId == null || partitionId.trim().isEmpty());
211 public boolean isManaged() {
215 public static class TopicParamsBuilder {
216 BusTopicParams m = new BusTopicParams();
218 private TopicParamsBuilder() {
221 public TopicParamsBuilder servers(List<String> servers) {
222 this.m.servers = servers;
226 public TopicParamsBuilder topic(String topic) {
227 this.m.topic = topic;
231 public TopicParamsBuilder apiKey(String apiKey) {
232 this.m.apiKey = apiKey;
236 public TopicParamsBuilder apiSecret(String apiSecret) {
237 this.m.apiSecret = apiSecret;
241 public TopicParamsBuilder consumerGroup(String consumerGroup) {
242 this.m.consumerGroup = consumerGroup;
246 public TopicParamsBuilder consumerInstance(String consumerInstance) {
247 this.m.consumerInstance = consumerInstance;
251 public TopicParamsBuilder fetchTimeout(int fetchTimeout) {
252 this.m.fetchTimeout = fetchTimeout;
256 public TopicParamsBuilder fetchLimit(int fetchLimit) {
257 this.m.fetchLimit = fetchLimit;
261 public TopicParamsBuilder useHttps(boolean useHttps) {
262 this.m.useHttps = useHttps;
266 public TopicParamsBuilder allowSelfSignedCerts(boolean allowSelfSignedCerts) {
267 this.m.allowSelfSignedCerts = allowSelfSignedCerts;
271 public TopicParamsBuilder userName(String userName) {
272 this.m.userName = userName;
276 public TopicParamsBuilder password(String password) {
277 this.m.password = password;
281 public TopicParamsBuilder environment(String environment) {
282 this.m.environment = environment;
286 public TopicParamsBuilder aftEnvironment(String aftEnvironment) {
287 this.m.aftEnvironment = aftEnvironment;
291 public TopicParamsBuilder partner(String partner) {
292 this.m.partner = partner;
296 public TopicParamsBuilder latitude(String latitude) {
297 this.m.latitude = latitude;
301 public TopicParamsBuilder longitude(String longitude) {
302 this.m.longitude = longitude;
306 public TopicParamsBuilder additionalProps(Map<String, String> additionalProps) {
307 this.m.additionalProps = additionalProps;
311 public TopicParamsBuilder partitionId(String partitionId) {
312 this.m.partitionId = partitionId;
316 public BusTopicParams build() {
320 public TopicParamsBuilder managed(boolean managed) {
321 this.m.managed = managed;