117e0892f77f5efc37218c1a34a26f1f2e73cb64
[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 /**
25  * @author Michael Dürre
26  *
27  */
28
29 import java.net.MalformedURLException;
30 import java.net.URL;
31 import java.util.ArrayList;
32 import java.util.Arrays;
33 import java.util.List;
34
35 import org.onap.ccsdk.features.sdnr.wt.common.configuration.Configuration;
36 import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
37 import org.onap.ccsdk.features.sdnr.wt.common.configuration.filechange.IConfigChangedListener;
38 import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo;
39 import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo.Protocol;
40 import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.IEsConfig;
41 import org.slf4j.Logger;
42 import org.slf4j.LoggerFactory;
43
44 public class NetconfStateConfig implements Configuration {
45
46     private static final Logger LOG = LoggerFactory.getLogger(NetconfStateConfig.class);
47
48     public static final String SECTION_MARKER_NCSTATE = "netconfstate";
49
50     private static final String PROPERTY_KEY_HANDLEASYNC = "asynchandling";
51
52     private static final Object DEFAULT_VALUE_TRUSTALLCERTS = false;
53
54
55
56     private final ConfigurationFileRepresentation configuration;
57
58     public NetconfStateConfig(ConfigurationFileRepresentation configuration) {
59
60         this.configuration = configuration;
61         this.configuration.addSection(SECTION_MARKER_NCSTATE);
62         defaults();
63     }
64
65
66     public boolean handleAsync() {
67         return configuration.getPropertyBoolean(SECTION_MARKER_NCSTATE, PROPERTY_KEY_HANDLEASYNC);
68     }
69
70     @Override
71     public String getSectionName() {
72         return SECTION_MARKER_NCSTATE;
73     }
74
75     @Override
76     public synchronized void defaults() {
77         // Add default if not available  
78         configuration.setPropertyIfNotAvailable(SECTION_MARKER_NCSTATE, PROPERTY_KEY_HANDLEASYNC,
79                 DEFAULT_VALUE_TRUSTALLCERTS);
80
81     }
82 }