2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
7 * Modifications Copyright © 2018 IBM.
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.
20 * ============LICENSE_END=========================================================
23 package org.onap.ccsdk.sli.northbound.uebclient;
26 import java.io.FileInputStream;
27 import java.io.FileNotFoundException;
28 import java.io.IOException;
29 import java.util.LinkedList;
30 import java.util.List;
31 import java.util.Properties;
33 import org.onap.ccsdk.sli.core.utils.common.EnvProperties;
34 import org.onap.sdc.api.consumer.IConfiguration;
35 import org.slf4j.Logger;
36 import org.slf4j.LoggerFactory;
38 public class SdncUebConfiguration implements IConfiguration{
40 private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR";
41 private static final Logger LOG = LoggerFactory
42 .getLogger(SdncUebConfiguration.class);
44 private String asdcAddress = null;
45 private String consumerGroup = null;
46 private String consumerID = null;
47 private String environmentName = null;
48 private String password = null;
49 private int pollingInterval = 30;
50 private int pollingTimeout = 15;
51 private int clientStartupTimeout = 900;
52 private List<String> relevantArtifactTypes = null;
53 private String user = null;
55 private String sdncUser = null;
56 private String sdncPasswd = null;
57 private String asdcApiBaseUrl = null;
58 private String asdcApiNamespace = null;
59 private String asdcUseHttps = null;
60 private List<String> msgBusAddress = null;
62 private SdncArtifactMap artifactMap = SdncArtifactMap.getInstance();
64 private String incomingDir = null;
66 private String archiveDir = null;
68 private String overrideFile = null;
70 private boolean activateServerTLSAuth;
71 private String keyStorePassword;
72 private String keyStorePath;
74 private String xsltPathList;
76 public SdncUebConfiguration() {
77 String propDir = System.getenv(SDNC_CONFIG_DIR);
78 if (propDir == null) {
80 propDir = "/opt/sdnc/data/properties";
84 } catch (Exception e) {
85 LOG.error("Cannot initialize SdncUebConfiguration", e);
89 public SdncUebConfiguration(String propDir) {
92 } catch (Exception e) {
93 LOG.error("Cannot initialize SdncUebConfiguration", e);
97 public String getAsdcApiNamespace() {
98 return asdcApiNamespace;
101 public String getXsltPathList() {
105 public String getOverrideFile() {
109 public void init(String propDir) throws IOException {
113 propPath = propDir + "/ueb-listener.properties";
114 File propFile = new File(propPath);
117 if (!propFile.exists()) {
119 throw new FileNotFoundException(
120 "Missing configuration properties file : "
124 Properties props = new EnvProperties();
125 props.load(new FileInputStream(propFile));
127 asdcAddress = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.asdc-address");
128 consumerGroup = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.consumer-group");
129 consumerID = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.consumer-id");
130 environmentName = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.environment-name");
131 password = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.password");
132 user = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.user");
133 asdcUseHttps = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.use-https", "true");
136 sdncUser = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.sdnc-user");
137 sdncPasswd = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.sdnc-passwd");
138 asdcApiBaseUrl = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.asdc-api-base-url");
139 asdcApiNamespace = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.asdc-api-namespace");
141 incomingDir = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.spool.incoming");
142 archiveDir = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.spool.archive");
143 overrideFile = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.override-file");
145 String curval = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.polling-interval");
146 if ((curval != null) && (curval.length() > 0)) {
148 pollingInterval = Integer.parseInt(curval);
149 } catch (Exception e) {
150 LOG.warn("Illegal value for org.onap.ccsdk.sli.northbound.uebclient.polling-interval ({}) ", curval, e);
154 curval = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.polling-timeout");
155 if ((curval != null) && (curval.length() > 0)) {
157 pollingTimeout = Integer.parseInt(curval);
158 } catch (Exception e) {
159 LOG.warn("Illegal value for org.onap.ccsdk.sli.northbound.uebclient.polling-timeout ({}) ", curval, e);
163 curval = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.client-startup-timeout");
164 if ((curval != null) && (curval.length() > 0)) {
166 clientStartupTimeout = Integer.parseInt(curval);
167 } catch (Exception e) {
168 LOG.warn("Illegal value for org.onap.ccsdk.sli.northbound.uebclient.polling-timeout ({}) ", curval, e);
171 curval = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.relevant-artifact-types");
172 if ((curval != null) && (curval.length() > 0)) {
173 String[] artifactTypes = curval.split(",");
175 relevantArtifactTypes = new LinkedList<>();
177 for (String artifactType : artifactTypes) {
179 relevantArtifactTypes.add(artifactType);
185 curval = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.activate-server-tls-auth", "false");
186 activateServerTLSAuth = "true".equalsIgnoreCase(curval);
187 keyStorePath = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.keystore-path");
188 keyStorePassword = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.keystore-password");
189 xsltPathList = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.xslt-path-list");
192 String artifactMapFile = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.artifact-map");
193 if (artifactMapFile != null) {
194 LOG.info("Loading artifactMapFile {}", artifactMapFile);
195 artifactMap.load(artifactMapFile);
197 LOG.warn("artifact-map is unset");
200 msgBusAddress = new LinkedList<>();
201 String msgBusAddressStr = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.msg-bus-address");
202 if (msgBusAddressStr != null) {
203 String[] msgBusAddressArray = msgBusAddressStr.split(",");
204 for (int i = 0 ; i < msgBusAddressArray.length ; i++) {
205 msgBusAddress.add(msgBusAddressArray[i]);
213 public String getAsdcAddress() {
218 public String getConsumerGroup() {
219 return consumerGroup;
223 public String getConsumerID() {
228 public String getEnvironmentName() {
229 return environmentName;
233 public String getPassword() {
238 public int getPollingInterval() {
239 return pollingInterval;
243 public int getPollingTimeout() {
244 return pollingTimeout;
248 public List<String> getRelevantArtifactTypes() {
249 return relevantArtifactTypes;
252 public int getClientStartupTimeout() {
253 return clientStartupTimeout;
257 public String getUser() {
262 public String getSdncUser() {
266 public String getSdncPasswd() {
270 public String getAsdcApiBaseUrl() {
271 return asdcApiBaseUrl;
275 public boolean activateServerTLSAuth() {
276 return activateServerTLSAuth;
280 public String getKeyStorePassword() {
281 return keyStorePassword;
285 public String getKeyStorePath() {
289 public String getIncomingDir() {
293 public String getArchiveDir() {
297 public int getMaxPasses() {
298 return artifactMap.getNumPasses();
301 public SdncArtifactMap.SdncArtifactType getMapping(String tag) {
302 return artifactMap.getMapping(tag);
306 public boolean isFilterInEmptyResources() {
311 public Boolean isUseHttpsWithDmaap() {
316 public Boolean isUseHttpsWithSDC() {
317 return Boolean.parseBoolean(asdcUseHttps);
321 public List<String> getMsgBusAddress() {
322 return msgBusAddress;