Migrate websocketmanager and netconfnode-state-service
[ccsdk/features.git] / sdnr / wt / netconfnode-state-service / provider / src / main / java / org / onap / ccsdk / features / sdnr / wt / netconfnodestateservice / impl / conf / NetconfStateConfig.java
1 /*
2  * ============LICENSE_START=======================================================
3  * ONAP : ccsdk features
4  * ================================================================================
5  * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
6  * All rights reserved.
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
11  *
12  *     http://www.apache.org/licenses/LICENSE-2.0
13  *
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=========================================================
20  *
21  */
22 package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.conf;
23
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.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
28
29 public class NetconfStateConfig implements Configuration {
30
31     @SuppressWarnings("unused")
32     private static final Logger LOG = LoggerFactory.getLogger(NetconfStateConfig.class);
33
34     public static final String SECTION_MARKER_NCSTATE = "netconfstate";
35
36     private static final String PROPERTY_KEY_HANDLEASYNC = "asynchandling";
37
38     private static final Object DEFAULT_VALUE_TRUSTALLCERTS = false;
39
40
41
42     private final ConfigurationFileRepresentation configuration;
43
44     public NetconfStateConfig(ConfigurationFileRepresentation configuration) {
45
46         this.configuration = configuration;
47         this.configuration.addSection(SECTION_MARKER_NCSTATE);
48         defaults();
49     }
50
51
52     public boolean handleAsync() {
53         return configuration.getPropertyBoolean(SECTION_MARKER_NCSTATE, PROPERTY_KEY_HANDLEASYNC);
54     }
55
56     @Override
57     public String getSectionName() {
58         return SECTION_MARKER_NCSTATE;
59     }
60
61     @Override
62     public synchronized void defaults() {
63         // Add default if not available
64         configuration.setPropertyIfNotAvailable(SECTION_MARKER_NCSTATE, PROPERTY_KEY_HANDLEASYNC,
65                 DEFAULT_VALUE_TRUSTALLCERTS);
66
67     }
68 }