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==========================================================================
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] SeverityConnectionlossNeOAM=minor
27 * SeverityConnectionlossOAM=major SeverityConnectionlossMediator=critical
29 public class DmConfig implements Configuration {
31 private static final String SECTION_MARKER_TA = "devicemonitor";
33 private static final String PROPERTY_KEY_PREFIX_Severity = "Severity";
35 private final ConfigurationFileRepresentation configuration;
37 public DmConfig(ConfigurationFileRepresentation configuration) {
38 this.configuration = configuration;
39 this.configuration.addSection(SECTION_MARKER_TA);
43 public InternalSeverity getSeverity(DeviceMonitorProblems problem) {
44 String severityString = configuration.getProperty(SECTION_MARKER_TA, getPropertyName(problem));
45 InternalSeverity result = InternalSeverity.valueOfString(severityString);
46 return result != null ? result : InternalSeverity.Major;
50 public String getSectionName() {
51 return SECTION_MARKER_TA;
55 public void defaults() {
56 for (DeviceMonitorProblems problem : DeviceMonitorProblems.values()) {
57 configuration.setPropertyIfNotAvailable(SECTION_MARKER_TA, getPropertyName(problem),
58 problem.getSeverity().name());
62 private String getPropertyName(DeviceMonitorProblems problem) {
63 return PROPERTY_KEY_PREFIX_Severity + problem.name();