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 /** set to true if VES Collector is installed and configured */
33 private static final String PROPERTY_KEY_VES_COLLECTOR_ENABLED = "VES_COLLECTOR_ENABLED";
34 private static final boolean DEFAULT_VALUE_VES_COLLECTOR_ENABLED = false;
36 private static final String PROPERTY_KEY_VES_COLLECTOR_IP = "VES_COLLECTOR_IP";
37 private static final String DEFAULT_VALUE_VES_COLLECTOR_IP = "127.0.0.1";
39 private static final String PROPERTY_KEY_VES_COLLECTOR_PORT = "VES_COLLECTOR_PORT";
40 private static final String DEFAULT_VALUE_VES_COLLECTOR_PORT = "8080";
42 private static final String PROPERTY_KEY_VES_COLLECTOR_TLS_ENABLED = "VES_COLLECTOR_TLS_ENABLED";
44 private static final String PROPERTY_KEY_VES_COLLECTOR_USERNAME = "VES_COLLECTOR_USERNAME";
45 private static final String DEFAULT_VALUE_VES_COLLECTOR_USERNAME = "sample1";
47 private static final String PROPERTY_KEY_VES_COLLECTOR_PASSWORD = "VES_COLLECTOR_PASSWORD";
48 private static final String DEFAULT_VALUE_VES_COLLECTOR_PASSWORD = "sample1";
50 private static final String PROPERTY_KEY_VES_COLLECTOR_VERSION = "VES_COLLECTOR_VERSION";
51 private static final String DEFAULT_VALUE_VES_COLLECTOR_VERSION = "v7";
53 private static final String PROPERTY_KEY_REPORTING_ENTITY_NAME = "REPORTING_ENTITY_NAME";
54 private static final String DEFAULT_VALUE_REPORTING_ENTITY_NAME = "ONAP SDN-R";
56 private static final String PROPERTY_KEY_EVENTLOG_DETAIL = "EVENTLOG_MSG_DETAIL";
57 private static final String DEFAULT_VALUE_EVENTLOG_DETAIL = "SHORT"; // "SHORT", "MEDIUM", "LONG"
60 private static ConfigurationFileRepresentation configuration;
62 public VESCollectorCfgImpl(ConfigurationFileRepresentation configuration) {
63 VESCollectorCfgImpl.configuration = configuration;
64 VESCollectorCfgImpl.configuration.addSection(SECTION_MARKER);
69 public String getSectionName() {
70 return SECTION_MARKER;
74 public String getReportingEntityName() {
75 return configuration != null ? configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_REPORTING_ENTITY_NAME) : "ONAP SDN-R";
79 public String getEventLogMsgDetail() {
80 return configuration != null ?configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_EVENTLOG_DETAIL) : DEFAULT_VALUE_EVENTLOG_DETAIL;
84 public boolean isVESCollectorEnabled() {
85 return configuration.getPropertyBoolean(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_ENABLED);
88 public boolean getTLSEnabled() {
89 return configuration.getPropertyBoolean(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_TLS_ENABLED);
92 public String getUsername() {
93 return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_USERNAME);
96 public String getPassword() {
97 return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_PASSWORD);
100 public String getIP() {
101 return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_IP);
104 public String getPort() {
105 return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_PORT);
108 public String getVersion() {
109 return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_VERSION);
113 public synchronized void defaults() {
114 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_ENABLED, DEFAULT_VALUE_VES_COLLECTOR_ENABLED);
115 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_TLS_ENABLED, Boolean.FALSE);
116 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_USERNAME,
117 DEFAULT_VALUE_VES_COLLECTOR_USERNAME);
118 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_PASSWORD,
119 DEFAULT_VALUE_VES_COLLECTOR_PASSWORD);
120 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_IP,
121 DEFAULT_VALUE_VES_COLLECTOR_IP);
122 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_PORT,
123 DEFAULT_VALUE_VES_COLLECTOR_PORT);
124 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_VERSION,
125 DEFAULT_VALUE_VES_COLLECTOR_VERSION);
126 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_REPORTING_ENTITY_NAME,
127 DEFAULT_VALUE_REPORTING_ENTITY_NAME);
128 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_EVENTLOG_DETAIL,
129 DEFAULT_VALUE_EVENTLOG_DETAIL);