2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
25 package org.onap.appc.sdc.listener;
27 import com.att.eelf.configuration.EELFLogger;
28 import com.att.eelf.configuration.EELFManager;
29 import org.openecomp.sdc.api.consumer.IConfiguration;
32 import java.util.ArrayList;
33 import java.util.HashMap;
34 import java.util.List;
36 import java.util.Properties;
37 import org.apache.commons.lang.StringUtils;
39 public class SdcConfig implements IConfiguration {
42 private String consumer;
43 private String consumerId;
45 private String keystorePath;
46 private String keystorePass;
47 /** Polling internal is time between listening sessions */
48 private int pollingInterval;
49 /** Polling timeout is the time to listen for (dmaap timeout url param)/1000 */
50 private int pollingTimeout;
51 private List<String> types = new ArrayList<>();
55 private Properties props;
56 private final EELFLogger logger = EELFManager.getInstance().getLogger(SdcConfig.class);
58 SdcConfig(Properties props) throws Exception {
63 private void init() throws Exception {
65 logger.error("SdcConfig init is skipped due to properties is null");
68 // Keystore for ca cert
69 keystorePath = props.getProperty("appc.sdc.keystore.path");
70 keystorePass = props.getProperty("appc.sdc.keystore.pass");
73 host = props.getProperty("appc.sdc.host");
74 env = props.getProperty("appc.sdc.env");
75 user = props.getProperty("appc.sdc.user");
76 pass = props.getProperty("appc.sdc.pass");
79 consumer = props.getProperty("appc.sdc.consumer");
80 consumerId = props.getProperty("appc.sdc.consumer.id");
82 pollingInterval = Integer.valueOf(props.getProperty("interval", "60"));
84 // Client uses cambriaClient-0.2.4 which throws non relevant (wrong)
85 // exceptions with times > 30s
86 pollingTimeout = Integer.valueOf(props.getProperty("timeout", "25"));
88 // Anything less than 60 and we risk 429 Too Many Requests
89 if (pollingInterval < 60) {
93 if (pollingInterval > pollingTimeout) {
94 logger.warn(String.format(
95 "Message acknowledgement may be delayed by %ds in the ADSC listener. [Listening Time: %s, Poll Period: %s]",
96 pollingInterval - pollingTimeout, pollingTimeout, pollingInterval));
103 This types seems redundant, as it looks from the code that they are not being used anywhere
105 types.add("APPC_CONFIG");
106 types.add("VF_LICENSE");
107 // types.add("TOSCA_CSAR"); commenting it out as we are not listening to TOSCA_CSAR
109 storeOp = new URI(props.getProperty("appc.sdc.provider.url"));
113 public boolean activateServerTLSAuth() {
117 public boolean isFilterInEmptyResources() {
122 public String getAsdcAddress() {
127 public String getConsumerGroup() {
132 public String getConsumerID() {
137 public String getEnvironmentName() {
142 public String getKeyStorePassword() {
147 public String getKeyStorePath() {
152 public String getPassword() {
157 public int getPollingInterval() {
158 return pollingInterval;
162 public int getPollingTimeout() {
163 return pollingTimeout;
167 public List<String> getRelevantArtifactTypes() {
172 public String getUser() {
177 public Boolean isUseHttpsWithDmaap(){
182 public List <String> getMsgBusAddress() {
183 return (getMsgBusProperties());
186 public List<String> getMsgBusProperties() {
187 List<String> uebAddresses = new ArrayList<String>();
188 String uebAddressesList=null;
189 if (null != this.props)
190 uebAddressesList = this.props.getProperty("appc.ClosedLoop.poolMembers");
192 logger.info("SdcConfig:SdcConfig:getMsgBusProperties()::props is null for SdcConfig");
195 if (null == uebAddressesList) {
196 logger.info("SdcConfig:SdcConfig:getMsgBusProperties()::uebAddressesList is null for SdcConfig");
199 logger.debug("SdcConfig:SdcConfig:getMsgBusProperties()::uebAddressesList is="+ uebAddressesList);
200 String[] sList = uebAddressesList.split(",");
201 uebAddresses= formatAddresses(sList);
202 logger.debug("SdcConfig:getMsgBusProperties:::Returning addresses as "+uebAddresses.toString());
206 URI getStoreOpURI() {
211 * Logs the relevant parameters
213 private void logParams() {
214 Map<String, String> params = new HashMap<>();
215 params.put("SDC Host", getAsdcAddress());
216 params.put("SDC Environment", getEnvironmentName());
217 params.put("Consumer Name", getConsumerGroup());
218 params.put("Consumer ID", getConsumerID());
219 params.put("Poll Active Wait", String.valueOf(getPollingInterval()));
220 params.put("Poll Timeout", String.valueOf(getPollingTimeout()));
222 logger.info(String.format("SDC Params: %s", params));
225 protected List<String> formatAddresses(String[] sList) {
226 List<String> uebAddresses = new ArrayList<String>();
227 for (String fqdnPort:sList) {
228 if (fqdnPort.startsWith("http")) {
229 fqdnPort=StringUtils.substringAfter(fqdnPort, "://");
231 if (null != fqdnPort && fqdnPort.contains(":")) {
232 fqdnPort=StringUtils.substringBefore(fqdnPort,":");
234 logger.debug("SdcConfig:formatAddresses:: "+fqdnPort);
235 uebAddresses.add(fqdnPort);