1 /*******************************************************************************
2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt
4 * =================================================================================================
5 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6 * =================================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software distributed under the License
13 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing permissions and limitations under
16 * ============LICENSE_END==========================================================================
17 ******************************************************************************/
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.devicemonitor.impl.config;
20 import org.onap.ccsdk.features.sdnr.wt.common.configuration.Configuration;
21 import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
22 import org.onap.ccsdk.features.sdnr.wt.devicemanager.devicemonitor.impl.DeviceMonitorProblems;
23 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalSeverity;
26 * Configuration of devicemonitor, section [devicemonitor]
27 * SeverityConnectionlossNeOAM=minor
28 * SeverityConnectionlossOAM=major
29 * SeverityConnectionlossMediator=critical
31 public class DmConfig implements Configuration {
33 private static final String SECTION_MARKER_TA = "devicemonitor";
35 private static final String PROPERTY_KEY_PREFIX_Severity = "Severity";
37 private final ConfigurationFileRepresentation configuration;
39 public DmConfig(ConfigurationFileRepresentation configuration) {
40 this.configuration = configuration;
41 this.configuration.addSection(SECTION_MARKER_TA);
45 public InternalSeverity getSeverity(DeviceMonitorProblems problem) {
46 String severityString = configuration.getProperty(SECTION_MARKER_TA, getPropertyName(problem));
47 InternalSeverity result = InternalSeverity.valueOfString(severityString);
48 return result != null ? result : InternalSeverity.Major;
52 public String getSectionName() {
53 return SECTION_MARKER_TA;
57 public void defaults() {
58 for (DeviceMonitorProblems problem : DeviceMonitorProblems.values()) {
59 configuration.setPropertyIfNotAvailable(SECTION_MARKER_TA, getPropertyName(problem), problem.getSeverity().name());
63 private String getPropertyName(DeviceMonitorProblems problem) {
64 return PROPERTY_KEY_PREFIX_Severity+problem.name();