2 * ============LICENSE_START=======================================================
3 * ONAP : ccsdk features
4 * ================================================================================
5 * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.ccsdk.features.sdnr.wt.devicemanager.vescollectorconnector.impl.config;
24 import org.onap.ccsdk.features.sdnr.wt.common.configuration.Configuration;
25 import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
26 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorCfgService;
28 public class VESCollectorCfgImpl implements VESCollectorCfgService, Configuration {
30 private static final String SECTION_MARKER = "VESCollector";
32 private static final String PROPERTY_KEY_VES_COLLECTOR_IP = "VES_COLLECTOR_IP";
33 private static final String DEFAULT_VALUE_VES_COLLECTOR_IP = "127.0.0.1";
35 private static final String PROPERTY_KEY_VES_COLLECTOR_PORT = "VES_COLLECTOR_PORT";
36 private static final String DEFAULT_VALUE_VES_COLLECTOR_PORT = "8080";
38 private static final String PROPERTY_KEY_VES_COLLECTOR_TLS_ENABLED = "VES_COLLECTOR_TLS_ENABLED";
40 private static final String PROPERTY_KEY_VES_COLLECTOR_USERNAME = "VES_COLLECTOR_USERNAME";
41 private static final String DEFAULT_VALUE_VES_COLLECTOR_USERNAME = "sample1";
43 private static final String PROPERTY_KEY_VES_COLLECTOR_PASSWORD = "VES_COLLECTOR_PASSWORD";
44 private static final String DEFAULT_VALUE_VES_COLLECTOR_PASSWORD = "sample1";
46 private static final String PROPERTY_KEY_VES_COLLECTOR_VERSION = "VES_COLLECTOR_VERSION";
47 private static final String DEFAULT_VALUE_VES_COLLECTOR_VERSION = "v7";
49 private static final String PROPERTY_KEY_REPORTING_ENTITY_NAME = "REPORTING_ENTITY_NAME";
50 private static final String DEFAULT_VALUE_REPORTING_ENTITY_NAME = "ONAP SDN-R";
52 private static final String PROPERTY_KEY_EVENTLOG_DETAIL = "EVENTLOG_MSG_DETAIL";
53 private static final String DEFAULT_VALUE_EVENTLOG_DETAIL = "SHORT"; // "SHORT", "MEDIUM", "LONG"
56 private static ConfigurationFileRepresentation configuration;
58 public VESCollectorCfgImpl(ConfigurationFileRepresentation configuration) {
59 VESCollectorCfgImpl.configuration = configuration;
60 VESCollectorCfgImpl.configuration.addSection(SECTION_MARKER);
65 public String getSectionName() {
66 return SECTION_MARKER;
70 public String getReportingEntityName() {
71 return configuration != null ? configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_REPORTING_ENTITY_NAME) : "ONAP SDN-R";
75 public String getEventLogMsgDetail() {
76 return configuration != null ?configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_EVENTLOG_DETAIL) : DEFAULT_VALUE_EVENTLOG_DETAIL;
79 public boolean getTLSEnabled() {
80 return configuration.getPropertyBoolean(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_TLS_ENABLED);
83 public String getUsername() {
84 return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_USERNAME);
87 public String getPassword() {
88 return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_PASSWORD);
91 public String getIP() {
92 return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_IP);
95 public String getPort() {
96 return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_PORT);
99 public String getVersion() {
100 return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_VERSION);
104 public synchronized void defaults() {
105 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_TLS_ENABLED, Boolean.FALSE);
106 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_USERNAME,
107 DEFAULT_VALUE_VES_COLLECTOR_USERNAME);
108 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_PASSWORD,
109 DEFAULT_VALUE_VES_COLLECTOR_PASSWORD);
110 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_IP,
111 DEFAULT_VALUE_VES_COLLECTOR_IP);
112 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_PORT,
113 DEFAULT_VALUE_VES_COLLECTOR_PORT);
114 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_VERSION,
115 DEFAULT_VALUE_VES_COLLECTOR_VERSION);
116 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_REPORTING_ENTITY_NAME,
117 DEFAULT_VALUE_REPORTING_ENTITY_NAME);
118 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_EVENTLOG_DETAIL,
119 DEFAULT_VALUE_EVENTLOG_DETAIL);