2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
7 * Modifications Copyright © 2018 IBM.
8 * Modifications Copyright © 2022 Nordix Foundation.
9 * ================================================================================
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 * ============LICENSE_END=========================================================
24 package org.onap.ccsdk.sli.northbound.uebclient;
27 import java.io.FileInputStream;
28 import java.io.FileNotFoundException;
29 import java.io.IOException;
30 import java.util.Collections;
31 import java.util.LinkedList;
32 import java.util.List;
33 import java.util.Properties;
35 import org.onap.ccsdk.sli.core.utils.common.EnvProperties;
36 import org.onap.sdc.api.consumer.IConfiguration;
37 import org.slf4j.Logger;
38 import org.slf4j.LoggerFactory;
40 public class SdncUebConfiguration implements IConfiguration {
42 private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR";
43 private static final Logger LOG = LoggerFactory
44 .getLogger(SdncUebConfiguration.class);
46 private String sdcAddress = null;
47 private String consumerGroup = null;
48 private String consumerID = null;
49 private String environmentName = null;
50 private String password = null;
51 private int pollingInterval = 30;
52 private int pollingTimeout = 15;
53 private int clientStartupTimeout = 900;
54 private List<String> relevantArtifactTypes = null;
55 private String user = null;
57 private String sdncUser = null;
58 private String sdncPasswd = null;
59 private String asdcApiBaseUrl = null;
60 private String asdcApiNamespace = null;
61 private String asdcUseHttps = null;
63 private final SdncArtifactMap artifactMap = SdncArtifactMap.getInstance();
65 private String incomingDir = null;
67 private String archiveDir = null;
69 private String overrideFile = null;
71 private boolean activateServerTLSAuth;
72 private String keyStorePassword;
73 private String keyStorePath;
75 private String xsltPathList;
77 public SdncUebConfiguration() {
78 String propDir = System.getenv(SDNC_CONFIG_DIR);
79 if (propDir == null) {
81 propDir = "/opt/sdnc/data/properties";
85 } catch (Exception e) {
86 LOG.error("Cannot initialize SdncUebConfiguration", e);
90 public SdncUebConfiguration(String propDir) {
93 } catch (Exception e) {
94 LOG.error("Cannot initialize SdncUebConfiguration", e);
98 public String getAsdcApiNamespace() {
99 return asdcApiNamespace;
102 public String getXsltPathList() {
106 public String getOverrideFile() {
110 public void init(String propDir) throws IOException {
114 propPath = propDir + "/ueb-listener.properties";
115 File propFile = new File(propPath);
118 if (!propFile.exists()) {
120 throw new FileNotFoundException(
121 "Missing configuration properties file : "
125 Properties props = new EnvProperties();
126 props.load(new FileInputStream(propFile));
128 sdcAddress = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.sdc-address");
129 consumerGroup = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.consumer-group");
130 consumerID = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.consumer-id");
131 environmentName = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.environment-name");
132 password = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.password");
133 user = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.user");
134 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);
172 curval = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.relevant-artifact-types");
173 if ((curval != null) && (curval.length() > 0)) {
174 String[] artifactTypes = curval.split(",");
175 relevantArtifactTypes = new LinkedList<>();
176 Collections.addAll(relevantArtifactTypes, artifactTypes);
179 curval = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.activate-server-tls-auth", "false");
180 activateServerTLSAuth = "true".equalsIgnoreCase(curval);
181 keyStorePath = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.keystore-path");
182 keyStorePassword = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.keystore-password");
183 xsltPathList = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.xslt-path-list");
185 String artifactMapFile = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.artifact-map");
186 if (artifactMapFile != null) {
187 LOG.info("Loading artifactMapFile {}", artifactMapFile);
188 artifactMap.load(artifactMapFile);
190 LOG.warn("artifact-map is unset");
195 public String getSdcAddress() {
200 public String getConsumerGroup() {
201 return consumerGroup;
205 public String getConsumerID() {
210 public String getEnvironmentName() {
211 return environmentName;
215 public String getPassword() {
220 public int getPollingInterval() {
221 return pollingInterval;
225 public int getPollingTimeout() {
226 return pollingTimeout;
230 public List<String> getRelevantArtifactTypes() {
231 return relevantArtifactTypes;
234 public int getClientStartupTimeout() {
235 return clientStartupTimeout;
239 public String getUser() {
243 public String getSdncUser() {
247 public String getSdncPasswd() {
251 public String getAsdcApiBaseUrl() {
252 return asdcApiBaseUrl;
256 public boolean activateServerTLSAuth() {
257 return activateServerTLSAuth;
261 public String getKeyStorePassword() {
262 return keyStorePassword;
266 public String getKeyStorePath() {
270 public String getIncomingDir() {
274 public String getArchiveDir() {
278 public int getMaxPasses() {
279 return artifactMap.getNumPasses();
282 public SdncArtifactMap.SdncArtifactType getMapping(String tag) {
283 return artifactMap.getMapping(tag);
287 public boolean isFilterInEmptyResources() {
292 public String getHttpProxyHost() {
297 public int getHttpProxyPort() {
302 public String getHttpsProxyHost() {
307 public int getHttpsProxyPort() {
312 public Boolean isUseHttpsWithSDC() {
313 return Boolean.parseBoolean(asdcUseHttps);