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 List<String> msgBusAddress = null;
61 private SdncArtifactMap artifactMap = SdncArtifactMap.getInstance();
63 private String incomingDir = null;
65 private String archiveDir = null;
67 private String overrideFile = null;
69 private boolean activateServerTLSAuth;
70 private String keyStorePassword;
71 private String keyStorePath;
73 private String xsltPathList;
75 public SdncUebConfiguration() {
76 String propDir = System.getenv(SDNC_CONFIG_DIR);
77 if (propDir == null) {
79 propDir = "/opt/sdnc/data/properties";
83 } catch (Exception e) {
84 LOG.error("Cannot initialize SdncUebConfiguration", e);
88 public SdncUebConfiguration(String propDir) {
91 } catch (Exception e) {
92 LOG.error("Cannot initialize SdncUebConfiguration", e);
96 public String getAsdcApiNamespace() {
97 return asdcApiNamespace;
100 public String getXsltPathList() {
104 public String getOverrideFile() {
108 public void init(String propDir) throws IOException {
112 propPath = propDir + "/ueb-listener.properties";
113 File propFile = new File(propPath);
116 if (!propFile.exists()) {
118 throw new FileNotFoundException(
119 "Missing configuration properties file : "
123 Properties props = new EnvProperties();
124 props.load(new FileInputStream(propFile));
126 asdcAddress = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.asdc-address");
127 consumerGroup = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.consumer-group");
128 consumerID = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.consumer-id");
129 environmentName = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.environment-name");
130 password = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.password");
131 user = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.user");
133 sdncUser = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.sdnc-user");
134 sdncPasswd = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.sdnc-passwd");
135 asdcApiBaseUrl = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.asdc-api-base-url");
136 asdcApiNamespace = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.asdc-api-namespace");
138 incomingDir = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.spool.incoming");
139 archiveDir = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.spool.archive");
140 overrideFile = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.override-file");
142 String curval = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.polling-interval");
143 if ((curval != null) && (curval.length() > 0)) {
145 pollingInterval = Integer.parseInt(curval);
146 } catch (Exception e) {
147 LOG.warn("Illegal value for org.onap.ccsdk.sli.northbound.uebclient.polling-interval ({}) ", curval, e);
151 curval = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.polling-timeout");
152 if ((curval != null) && (curval.length() > 0)) {
154 pollingTimeout = Integer.parseInt(curval);
155 } catch (Exception e) {
156 LOG.warn("Illegal value for org.onap.ccsdk.sli.northbound.uebclient.polling-timeout ({}) ", curval, e);
160 curval = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.client-startup-timeout");
161 if ((curval != null) && (curval.length() > 0)) {
163 clientStartupTimeout = Integer.parseInt(curval);
164 } catch (Exception e) {
165 LOG.warn("Illegal value for org.onap.ccsdk.sli.northbound.uebclient.polling-timeout ({}) ", curval, e);
168 curval = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.relevant-artifact-types");
169 if ((curval != null) && (curval.length() > 0)) {
170 String[] artifactTypes = curval.split(",");
172 relevantArtifactTypes = new LinkedList<>();
174 for (String artifactType : artifactTypes) {
176 relevantArtifactTypes.add(artifactType);
182 curval = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.activate-server-tls-auth", "false");
183 activateServerTLSAuth = "true".equalsIgnoreCase(curval);
184 keyStorePath = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.keystore-path");
185 keyStorePassword = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.keystore-password");
186 xsltPathList = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.xslt-path-list");
189 String artifactMapFile = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.artifact-map");
190 if (artifactMapFile != null) {
191 LOG.info("Loading artifactMapFile {}", artifactMapFile);
192 artifactMap.load(artifactMapFile);
194 LOG.warn("artifact-map is unset");
197 msgBusAddress = new LinkedList<>();
198 String msgBusAddressStr = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.msg-bus-address");
199 if (msgBusAddressStr != null) {
200 String[] msgBusAddressArray = msgBusAddressStr.split(",");
201 for (int i = 0 ; i < msgBusAddressArray.length ; i++) {
202 msgBusAddress.add(msgBusAddressArray[i]);
210 public String getAsdcAddress() {
215 public String getConsumerGroup() {
216 return consumerGroup;
220 public String getConsumerID() {
225 public String getEnvironmentName() {
226 return environmentName;
230 public String getPassword() {
235 public int getPollingInterval() {
236 return pollingInterval;
240 public int getPollingTimeout() {
241 return pollingTimeout;
245 public List<String> getRelevantArtifactTypes() {
246 return relevantArtifactTypes;
249 public int getClientStartupTimeout() {
250 return clientStartupTimeout;
254 public String getUser() {
259 public String getSdncUser() {
263 public String getSdncPasswd() {
267 public String getAsdcApiBaseUrl() {
268 return asdcApiBaseUrl;
272 public boolean activateServerTLSAuth() {
273 return activateServerTLSAuth;
277 public String getKeyStorePassword() {
278 return keyStorePassword;
282 public String getKeyStorePath() {
286 public String getIncomingDir() {
290 public String getArchiveDir() {
294 public int getMaxPasses() {
295 return artifactMap.getNumPasses();
298 public SdncArtifactMap.SdncArtifactType getMapping(String tag) {
299 return artifactMap.getMapping(tag);
303 public boolean isFilterInEmptyResources() {
308 public Boolean isUseHttpsWithDmaap() {
313 public List<String> getMsgBusAddress() {
314 return msgBusAddress;