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.mountpointregistrar.impl;
20 import org.onap.ccsdk.features.sdnr.wt.common.configuration.Configuration;
21 import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
24 * Configuration of mountpoint-registrar, general section<br>
25 * - dmaapEnabled : Boolean disable/enable service depending on whether DMaaP is running or not
26 * Generates default Configuration properties if none exist or exist partially
27 * Generates Consumer properties only for 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 - https://wiki.onap.org/display/DW/Feature+configuration+requirements
30 public class GeneralConfig implements Configuration {
32 private static final String SECTION_MARKER = "general";
34 private static final String PROPERTY_KEY_ENABLED = "dmaapEnabled" ; //"enabled";
36 private static final String PROPERTY_KEY_USER = "sdnrUser";
37 private static final String DEFAULT_VALUE_USER = "admin";
39 private static final String PROPERTY_KEY_USERPASSWD = "sdnrPasswd";
40 private static final String DEFAULT_VALUE_USERPASSWD = "admin";
42 private static final String PROPERTY_KEY_BASEURL = "baseUrl";
43 private static final String DEFAULT_VALUE_BASEURL = "http://localhost:8181";
46 private static ConfigurationFileRepresentation configuration;
48 public GeneralConfig(ConfigurationFileRepresentation configuration) {
49 GeneralConfig.configuration = configuration;
50 GeneralConfig.configuration.addSection(SECTION_MARKER);
54 public Boolean getEnabled() {
55 Boolean enabled = configuration.getPropertyBoolean(SECTION_MARKER, PROPERTY_KEY_ENABLED);
59 public static String getBaseUrl() {
60 return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_BASEURL);
63 public static String getSDNRUser() {
64 return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_USER);
67 public static String getSDNRPasswd() {
68 return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_USERPASSWD);
72 public String getSectionName() {
73 return SECTION_MARKER;
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);