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.sdc.api.consumer.IConfiguration;
34 import org.slf4j.Logger;
35 import org.slf4j.LoggerFactory;
37 public class SdncUebConfiguration implements IConfiguration{
39 private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR";
40 private static final Logger LOG = LoggerFactory
41 .getLogger(SdncUebConfiguration.class);
43 private String asdcAddress = null;
44 private String consumerGroup = null;
45 private String consumerID = null;
46 private String environmentName = null;
47 private String password = null;
48 private int pollingInterval = 30;
49 private int pollingTimeout = 15;
50 private int clientStartupTimeout = 900;
51 private List<String> relevantArtifactTypes = null;
52 private String user = null;
54 private String sdncUser = null;
55 private String sdncPasswd = null;
56 private String asdcApiBaseUrl = null;
57 private String asdcApiNamespace = null;
58 private List<String> msgBusAddress = null;
60 private SdncArtifactMap artifactMap = SdncArtifactMap.getInstance();
62 private String incomingDir = null;
64 private String archiveDir = null;
66 private String overrideFile = null;
68 private boolean activateServerTLSAuth;
69 private String keyStorePassword;
70 private String keyStorePath;
72 private String xsltPathList;
74 public SdncUebConfiguration() {
75 String propDir = System.getenv(SDNC_CONFIG_DIR);
76 if (propDir == null) {
78 propDir = "/opt/sdnc/data/properties";
82 } catch (Exception e) {
83 LOG.error("Cannot initialize SdncUebConfiguration", e);
87 public SdncUebConfiguration(String propDir) {
90 } catch (Exception e) {
91 LOG.error("Cannot initialize SdncUebConfiguration", e);
95 public String getAsdcApiNamespace() {
96 return asdcApiNamespace;
99 public String getXsltPathList() {
103 public String getOverrideFile() {
107 public void init(String propDir) throws IOException {
111 propPath = propDir + "/ueb-listener.properties";
112 File propFile = new File(propPath);
115 if (!propFile.exists()) {
117 throw new FileNotFoundException(
118 "Missing configuration properties file : "
122 Properties props = new Properties();
123 props.load(new FileInputStream(propFile));
125 asdcAddress = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.asdc-address");
126 consumerGroup = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.consumer-group");
127 consumerID = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.consumer-id");
128 environmentName = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.environment-name");
129 password = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.password");
130 user = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.user");
132 sdncUser = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.sdnc-user");
133 sdncPasswd = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.sdnc-passwd");
134 asdcApiBaseUrl = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.asdc-api-base-url");
135 asdcApiNamespace = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.asdc-api-namespace");
137 incomingDir = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.spool.incoming");
138 archiveDir = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.spool.archive");
139 overrideFile = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.override-file");
141 String curval = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.polling-interval");
142 if ((curval != null) && (curval.length() > 0)) {
144 pollingInterval = Integer.parseInt(curval);
145 } catch (Exception e) {
146 LOG.warn("Illegal value for org.onap.ccsdk.sli.northbound.uebclient.polling-interval ({}) ", curval, e);
150 curval = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.polling-timeout");
151 if ((curval != null) && (curval.length() > 0)) {
153 pollingTimeout = Integer.parseInt(curval);
154 } catch (Exception e) {
155 LOG.warn("Illegal value for org.onap.ccsdk.sli.northbound.uebclient.polling-timeout ({}) ", curval, e);
159 curval = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.client-startup-timeout");
160 if ((curval != null) && (curval.length() > 0)) {
162 clientStartupTimeout = Integer.parseInt(curval);
163 } catch (Exception e) {
164 LOG.warn("Illegal value for org.onap.ccsdk.sli.northbound.uebclient.polling-timeout ({}) ", curval, e);
167 curval = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.relevant-artifact-types");
168 if ((curval != null) && (curval.length() > 0)) {
169 String[] artifactTypes = curval.split(",");
171 relevantArtifactTypes = new LinkedList<>();
173 for (String artifactType : artifactTypes) {
175 relevantArtifactTypes.add(artifactType);
181 curval = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.activate-server-tls-auth", "false");
182 activateServerTLSAuth = "true".equalsIgnoreCase(curval);
183 keyStorePath = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.keystore-path");
184 keyStorePassword = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.keystore-password");
185 xsltPathList = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.xslt-path-list");
188 String artifactMapFile = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.artifact-map");
189 if (artifactMapFile != null) {
190 LOG.info("Loading artifactMapFile {}", artifactMapFile);
191 artifactMap.load(artifactMapFile);
193 LOG.warn("artifact-map is unset");
196 msgBusAddress = new LinkedList<>();
197 String msgBusAddressStr = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.msg-bus-address");
198 if (msgBusAddressStr != null) {
199 String[] msgBusAddressArray = msgBusAddressStr.split(",");
200 for (int i = 0 ; i < msgBusAddressArray.length ; i++) {
201 msgBusAddress.add(msgBusAddressArray[i]);
209 public String getAsdcAddress() {
214 public String getConsumerGroup() {
215 return consumerGroup;
219 public String getConsumerID() {
224 public String getEnvironmentName() {
225 return environmentName;
229 public String getPassword() {
234 public int getPollingInterval() {
235 return pollingInterval;
239 public int getPollingTimeout() {
240 return pollingTimeout;
244 public List<String> getRelevantArtifactTypes() {
245 return relevantArtifactTypes;
248 public int getClientStartupTimeout() {
249 return clientStartupTimeout;
253 public String getUser() {
258 public String getSdncUser() {
262 public String getSdncPasswd() {
266 public String getAsdcApiBaseUrl() {
267 return asdcApiBaseUrl;
271 public boolean activateServerTLSAuth() {
272 return activateServerTLSAuth;
276 public String getKeyStorePassword() {
277 return keyStorePassword;
281 public String getKeyStorePath() {
285 public String getIncomingDir() {
289 public String getArchiveDir() {
293 public int getMaxPasses() {
294 return artifactMap.getNumPasses();
297 public SdncArtifactMap.SdncArtifactType getMapping(String tag) {
298 return artifactMap.getMapping(tag);
302 public boolean isFilterInEmptyResources() {
307 public Boolean isUseHttpsWithDmaap() {
312 public List<String> getMsgBusAddress() {
313 return msgBusAddress;