eec4e7a9e94db99434940edda72f93e8ddf4fff6
[ccsdk/features.git] /
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
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
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
15  * the License.
16  * ============LICENSE_END==========================================================================
17  */
18 package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl;
19
20 import org.onap.ccsdk.features.sdnr.wt.common.configuration.Configuration;
21 import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
22
23 /**
24  * Configuration of mountpoint-registrar, general section<br>
25  * - dmaapEnabled : Boolean disable/enable service depending on whether DMaaP is running or not Generates default
26  * Configuration properties if none exist or exist partially Generates Consumer properties only for
27  * TransportType=HTTPNOAUTH. Other TransportTypes like HTTP, AUTH_KEY and DME2 have additional properties and are not
28  * generated by default. For a list of applicable properties for the different TranportType values, please see -
29  * https://wiki.onap.org/display/DW/Feature+configuration+requirements
30  */
31 public class GeneralConfig implements Configuration {
32
33     private static final String SECTION_MARKER = "general";
34
35     private static final String PROPERTY_KEY_ENABLED = "dmaapEnabled";
36
37     private static final String PROPERTY_KEY_USER = "sdnrUser";
38     private static final String DEFAULT_VALUE_USER = "${SDNRUSERNAME}";
39
40     private static final String PROPERTY_KEY_USERPASSWD = "sdnrPasswd";
41     private static final String DEFAULT_VALUE_USERPASSWD = "${SDNRPASSWORD}";
42
43     private static final String PROPERTY_KEY_BASEURL = "baseUrl";
44     private static final String DEFAULT_VALUE_BASEURL = "http://localhost:8181";
45
46
47     private ConfigurationFileRepresentation configuration;
48
49     public GeneralConfig(ConfigurationFileRepresentation configuration) {
50         this.configuration = configuration;
51         configuration.addSection(SECTION_MARKER);
52         defaults();
53     }
54
55     public Boolean getEnabled() {
56         return configuration.getPropertyBoolean(SECTION_MARKER, PROPERTY_KEY_ENABLED);
57     }
58
59     public String getBaseUrl() {
60         return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_BASEURL);
61     }
62
63     public String getSDNRUser() {
64         return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_USER);
65     }
66
67     public String getSDNRPasswd() {
68         return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_USERPASSWD);
69     }
70
71     @Override
72     public String getSectionName() {
73         return SECTION_MARKER;
74     }
75
76     @Override
77     public void defaults() {
78         // The default value should be "false" given that SDNR can be run in environments where DMaaP is not used
79         configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_ENABLED, Boolean.FALSE);
80         configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_BASEURL, DEFAULT_VALUE_BASEURL);
81         configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_USER, DEFAULT_VALUE_USER);
82         configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_USERPASSWD, DEFAULT_VALUE_USERPASSWD);
83     }
84
85
86
87 }