2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. 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.openecomp.policy.drools.event.comm.bus.internal;
23 import java.util.List;
25 import org.apache.commons.collections4.queue.CircularFifoQueue;
26 import org.openecomp.policy.drools.event.comm.Topic;
27 import org.openecomp.policy.drools.event.comm.bus.BusTopic;
29 public abstract class BusTopicBase implements BusTopic, Topic {
31 protected List<String> servers;
33 protected String topic;
35 protected String apiKey;
36 protected String apiSecret;
37 protected boolean useHttps;
38 protected boolean allowSelfSignedCerts;
40 protected CircularFifoQueue<String> recentEvents = new CircularFifoQueue<String>(10);
43 * Instantiates a new Bus Topic Base
45 * @param servers list of servers
46 * @param topic topic name
47 * @param apiKey API Key
48 * @param apiSecret API Secret
49 * @param useHttps does connection use HTTPS?
50 * @param allowSelfSignedCerts are self-signed certificates allow
52 * @return a Bus Topic Base
53 * @throws IllegalArgumentException if invalid parameters are present
55 public BusTopicBase(List<String> servers,
60 boolean allowSelfSignedCerts)
61 throws IllegalArgumentException {
63 if (servers == null || servers.isEmpty()) {
64 throw new IllegalArgumentException("UEB Server(s) must be provided");
67 if (topic == null || topic.isEmpty()) {
68 throw new IllegalArgumentException("An UEB Topic must be provided");
71 this.servers = servers;
75 this.apiSecret = apiSecret;
76 this.useHttps = useHttps;
77 this.allowSelfSignedCerts = allowSelfSignedCerts;
84 public String getTopic() {
92 public List<String> getServers() {
100 public String getApiKey() {
108 public String getApiSecret() {
115 public boolean isUseHttps(){
120 * @return allowSelfSignedCerts
122 public boolean isAllowSelfSignedCerts(){
123 return allowSelfSignedCerts;
127 * @return the recentEvents
130 public synchronized String[] getRecentEvents() {
131 String[] events = new String[recentEvents.size()];
132 return recentEvents.toArray(events);
137 public String toString() {
138 StringBuilder builder = new StringBuilder();
139 builder.append("UebTopicBase [servers=").append(servers)
140 .append(", topic=").append(topic)
141 .append(", apiKey=").append(apiKey)
142 .append(", apiSecret=").append(apiSecret)
143 .append(", useHttps=").append(useHttps)
144 .append(", allowSelfSignedCerts=").append(allowSelfSignedCerts)
146 return builder.toString();