2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 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.onap.policy.common.endpoints.event.comm.bus.internal;
23 import java.util.List;
26 import org.onap.policy.common.endpoints.event.comm.Topic;
27 import org.onap.policy.common.endpoints.event.comm.bus.DmaapTopicSink;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
32 * This implementation publishes events for the associated DMAAP topic, inline with the calling
35 public class InlineDmaapTopicSink extends InlineBusTopicSink implements DmaapTopicSink {
37 protected static Logger logger = LoggerFactory.getLogger(InlineDmaapTopicSink.class);
39 protected final String userName;
40 protected final String password;
42 protected String environment = null;
43 protected String aftEnvironment = null;
44 protected String partner = null;
45 protected String latitude = null;
46 protected String longitude = null;
48 protected Map<String, String> additionalProps = null;
52 * @param servers DMaaP servers
53 * @param topic DMaaP Topic to be monitored
54 * @param apiKey DMaaP API Key (optional)
55 * @param apiSecret DMaaP API Secret (optional)
56 * @param consumerGroup DMaaP Reader Consumer Group
57 * @param consumerInstance DMaaP Reader Instance
58 * @param fetchTimeout DMaaP fetch timeout
59 * @param fetchLimit DMaaP fetch limit
60 * @param environment DME2 Environment
61 * @param aftEnvironment DME2 AFT Environment
62 * @param partner DME2 Partner
63 * @param latitude DME2 Latitude
64 * @param longitude DME2 Longitude
65 * @param additionalProps Additional properties to pass to DME2
66 * @param useHttps does connection use HTTPS?
67 * @param allowSelfSignedCerts are self-signed certificates allow
69 * @throws IllegalArgumentException An invalid parameter passed in
71 public InlineDmaapTopicSink(List<String> servers, String topic, String apiKey, String apiSecret, String userName,
72 String password, String partitionKey, String environment, String aftEnvironment, String partner,
73 String latitude, String longitude, Map<String, String> additionalProps, boolean useHttps,
74 boolean allowSelfSignedCerts) {
76 super(servers, topic, apiKey, apiSecret, partitionKey, useHttps, allowSelfSignedCerts);
78 this.userName = userName;
79 this.password = password;
81 this.environment = environment;
82 this.aftEnvironment = aftEnvironment;
83 this.partner = partner;
85 this.latitude = latitude;
86 this.longitude = longitude;
88 this.additionalProps = additionalProps;
91 public InlineDmaapTopicSink(List<String> servers, String topic, String apiKey, String apiSecret, String userName,
92 String password, String partitionKey, boolean useHttps, boolean allowSelfSignedCerts) {
94 super(servers, topic, apiKey, apiSecret, partitionKey, useHttps, allowSelfSignedCerts);
96 this.userName = userName;
97 this.password = password;
103 if (allNullOrEmpty(this.environment, this.aftEnvironment, this.latitude, this.longitude, this.partner)) {
104 this.publisher = new BusPublisher.CambriaPublisherWrapper(this.servers, this.topic, this.apiKey,
105 this.apiSecret, this.userName, this.password, this.useHttps, this.allowSelfSignedCerts);
107 this.publisher = new BusPublisher.DmaapDmePublisherWrapper(this.servers, this.topic, this.userName,
108 this.password, this.environment, this.aftEnvironment, this.partner, this.latitude, this.longitude,
109 this.additionalProps, this.useHttps);
112 logger.info("{}: DMAAP SINK created", this);
119 public CommInfrastructure getTopicCommInfrastructure() {
120 return Topic.CommInfrastructure.DMAAP;
125 public String toString() {
126 return "InlineDmaapTopicSink [userName=" + userName + ", password=" + password
127 + ", getTopicCommInfrastructure()=" + getTopicCommInfrastructure() + ", toString()=" + super.toString()