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
28 * servers DMaaP servers
29 * topic DMaaP Topic to be monitored
30 * apiKey DMaaP API Key (optional)
31 * apiSecret DMaaP API Secret (optional)
32 * consumerGroup DMaaP Reader Consumer Group
33 * consumerInstance DMaaP Reader Instance
34 * fetchTimeout DMaaP fetch timeout
35 * fetchLimit DMaaP fetch limit
36 * environment DME2 Environment
37 * aftEnvironment DME2 AFT Environment
38 * partner DME2 Partner
39 * latitude DME2 Latitude
40 * longitude DME2 Longitude
41 * additionalProps Additional properties to pass to DME2
42 * useHttps does connection use HTTPS?
43 * allowSelfSignedCerts are self-signed certificates allow
45 public class BusTopicParams {
47 public static TopicParamsBuilder builder() {
48 return new TopicParamsBuilder();
51 private List<String> servers;
53 private String apiKey;
54 private String apiSecret;
55 private String consumerGroup;
56 private String consumerInstance;
57 private int fetchTimeout;
58 private int fetchLimit;
59 private boolean useHttps;
60 private boolean allowSelfSignedCerts;
62 private String userName;
63 private String password;
64 private String environment;
65 private String aftEnvironment;
66 private String partner;
67 private String latitude;
68 private String longitude;
69 private Map<String, String> additionalProps;
70 private String partitionId;
72 String getPartitionId() {
76 String getUserName() {
80 String getPassword() {
84 String getEnvironment() {
88 String getAftEnvironment() {
89 return aftEnvironment;
96 String getLatitude() {
100 String getLongitude() {
104 Map<String, String> getAdditionalProps() {
105 return additionalProps;
108 List<String> getServers() {
120 String getApiSecret() {
124 String getConsumerGroup() {
125 return consumerGroup;
128 String getConsumerInstance() {
129 return consumerInstance;
132 int getFetchTimeout() {
136 int getFetchLimit() {
140 boolean isUseHttps() {
144 boolean isAllowSelfSignedCerts() {
145 return allowSelfSignedCerts;
148 boolean isEnvironmentNullOrEmpty() {
149 return (environment == null || environment.trim().isEmpty());
152 boolean isAftEnvironmentNullOrEmpty() {
153 return (aftEnvironment == null || aftEnvironment.trim().isEmpty());
156 boolean isLatitudeNullOrEmpty() {
157 return (latitude == null || latitude.trim().isEmpty());
160 boolean isLongitudeNullOrEmpty() {
161 return (longitude == null || longitude.trim().isEmpty());
164 boolean isConsumerInstanceNullOrEmpty() {
165 return (consumerInstance == null || consumerInstance.trim().isEmpty());
168 boolean isConsumerGroupNullOrEmpty() {
169 return (consumerGroup == null || consumerGroup.trim().isEmpty());
172 boolean isApiKeyValid() {
173 return !(apiKey == null || apiKey.trim().isEmpty());
176 boolean isApiSecretValid() {
177 return !(apiSecret == null || apiSecret.trim().isEmpty());
180 boolean isUserNameValid() {
181 return !(userName == null || userName.trim().isEmpty());
184 boolean isPasswordValid() {
185 return !(password == null || password.trim().isEmpty());
188 boolean isPartnerNullOrEmpty() {
189 return (partner == null || partner.trim().isEmpty());
192 boolean isServersNullOrEmpty() {
193 return (servers == null || servers.isEmpty()
194 || (servers.size() == 1 && ("".equals(servers.get(0)))));
197 boolean isAdditionalPropsValid() {
198 return additionalProps != null;
201 boolean isTopicNullOrEmpty() {
202 return (topic == null || topic.trim().isEmpty());
205 boolean isPartitionIdNullOrEmpty() {
206 return (partitionId == null || partitionId.trim().isEmpty());
209 public static class TopicParamsBuilder {
210 BusTopicParams m = new BusTopicParams();
212 private TopicParamsBuilder() {
215 public TopicParamsBuilder servers(List<String> servers) {
216 this.m.servers = servers;
220 public TopicParamsBuilder topic(String topic) {
221 this.m.topic = topic;
225 public TopicParamsBuilder apiKey(String apiKey) {
226 this.m.apiKey = apiKey;
230 public TopicParamsBuilder apiSecret(String apiSecret) {
231 this.m.apiSecret = apiSecret;
235 public TopicParamsBuilder consumerGroup(String consumerGroup) {
236 this.m.consumerGroup = consumerGroup;
240 public TopicParamsBuilder consumerInstance(String consumerInstance) {
241 this.m.consumerInstance = consumerInstance;
245 public TopicParamsBuilder fetchTimeout(int fetchTimeout) {
246 this.m.fetchTimeout = fetchTimeout;
250 public TopicParamsBuilder fetchLimit(int fetchLimit) {
251 this.m.fetchLimit = fetchLimit;
255 public TopicParamsBuilder useHttps(boolean useHttps) {
256 this.m.useHttps = useHttps;
260 public TopicParamsBuilder allowSelfSignedCerts(boolean allowSelfSignedCerts) {
261 this.m.allowSelfSignedCerts = allowSelfSignedCerts;
265 public TopicParamsBuilder userName(String userName) {
266 this.m.userName = userName;
270 public TopicParamsBuilder password(String password) {
271 this.m.password = password;
275 public TopicParamsBuilder environment(String environment) {
276 this.m.environment = environment;
280 public TopicParamsBuilder aftEnvironment(String aftEnvironment) {
281 this.m.aftEnvironment = aftEnvironment;
285 public TopicParamsBuilder partner(String partner) {
286 this.m.partner = partner;
290 public TopicParamsBuilder latitude(String latitude) {
291 this.m.latitude = latitude;
295 public TopicParamsBuilder longitude(String longitude) {
296 this.m.longitude = longitude;
300 public TopicParamsBuilder additionalProps(Map<String, String> additionalProps) {
301 this.m.additionalProps = additionalProps;
305 public TopicParamsBuilder partitionId(String partitionId) {
306 this.m.partitionId = partitionId;
310 public BusTopicParams build() {