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 {
217 BusTopicParams params = new BusTopicParams();
219 private TopicParamsBuilder() {
222 public TopicParamsBuilder servers(List<String> servers) {
223 this.params.servers = servers;
227 public TopicParamsBuilder topic(String topic) {
228 this.params.topic = topic;
232 public TopicParamsBuilder apiKey(String apiKey) {
233 this.params.apiKey = apiKey;
237 public TopicParamsBuilder apiSecret(String apiSecret) {
238 this.params.apiSecret = apiSecret;
242 public TopicParamsBuilder consumerGroup(String consumerGroup) {
243 this.params.consumerGroup = consumerGroup;
247 public TopicParamsBuilder consumerInstance(String consumerInstance) {
248 this.params.consumerInstance = consumerInstance;
252 public TopicParamsBuilder fetchTimeout(int fetchTimeout) {
253 this.params.fetchTimeout = fetchTimeout;
257 public TopicParamsBuilder fetchLimit(int fetchLimit) {
258 this.params.fetchLimit = fetchLimit;
262 public TopicParamsBuilder useHttps(boolean useHttps) {
263 this.params.useHttps = useHttps;
267 public TopicParamsBuilder allowSelfSignedCerts(boolean allowSelfSignedCerts) {
268 this.params.allowSelfSignedCerts = allowSelfSignedCerts;
272 public TopicParamsBuilder userName(String userName) {
273 this.params.userName = userName;
277 public TopicParamsBuilder password(String password) {
278 this.params.password = password;
282 public TopicParamsBuilder environment(String environment) {
283 this.params.environment = environment;
287 public TopicParamsBuilder aftEnvironment(String aftEnvironment) {
288 this.params.aftEnvironment = aftEnvironment;
292 public TopicParamsBuilder partner(String partner) {
293 this.params.partner = partner;
297 public TopicParamsBuilder latitude(String latitude) {
298 this.params.latitude = latitude;
302 public TopicParamsBuilder longitude(String longitude) {
303 this.params.longitude = longitude;
307 public TopicParamsBuilder additionalProps(Map<String, String> additionalProps) {
308 this.params.additionalProps = additionalProps;
312 public TopicParamsBuilder partitionId(String partitionId) {
313 this.params.partitionId = partitionId;
317 public BusTopicParams build() {
321 public TopicParamsBuilder managed(boolean managed) {
322 this.params.managed = managed;