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.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 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
 
  31 public class GeneralConfig implements Configuration {
 
  33     private static final String SECTION_MARKER = "general";
 
  35     private static final String PROPERTY_KEY_ENABLED = "dmaapEnabled";
 
  37     private static final String PROPERTY_KEY_USER = "sdnrUser";
 
  38     private static final String DEFAULT_VALUE_USER = "${SDNRUSERNAME}";
 
  40     private static final String PROPERTY_KEY_USERPASSWD = "sdnrPasswd";
 
  41     private static final String DEFAULT_VALUE_USERPASSWD = "${SDNRPASSWORD}";
 
  43     private static final String PROPERTY_KEY_BASEURL = "baseUrl";
 
  44     private static final String DEFAULT_VALUE_BASEURL = "http://localhost:8181";
 
  47     private ConfigurationFileRepresentation configuration;
 
  49     public GeneralConfig(ConfigurationFileRepresentation configuration) {
 
  50         this.configuration = configuration;
 
  51         configuration.addSection(SECTION_MARKER);
 
  55     public Boolean getEnabled() {
 
  56         return configuration.getPropertyBoolean(SECTION_MARKER, PROPERTY_KEY_ENABLED);
 
  59     public String getBaseUrl() {
 
  60         return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_BASEURL);
 
  63     public String getSDNRUser() {
 
  64         return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_USER);
 
  67     public 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);