2  * ============LICENSE_START======================================================================
 
   3  * Copyright (C) 2019-2020 China Mobile.  All rights reserved.
 
   4  * ===============================================================================================
 
   5  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 
   6  * in compliance with the License. You may obtain a copy of the License at
 
   8  * http://www.apache.org/licenses/LICENSE-2.0
 
  10  * Unless required by applicable law or agreed to in writing, software distributed under the License
 
  11  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 
  12  * or implied. See the License for the specific language governing permissions and limitations under
 
  14  * ============LICENSE_END========================================================================
 
  17 package org.onap.dcae.analytics.web.config;
 
  19 import java.util.Optional;
 
  21 import org.onap.dcae.analytics.model.configbindingservice.ConfigBindingServiceConstants;
 
  22 import org.onap.dcae.analytics.web.exception.EnvironmentLoaderException;
 
  26  * get consul config and cbs config.
 
  30 public class SystemConfig {
 
  34      * private constructor.
 
  37     private SystemConfig() {
 
  43      * @return consulHost consulHost
 
  46     public static String getConsulHost() throws EnvironmentLoaderException {
 
  47         return Optional.ofNullable(ConfigBindingServiceConstants.CONSUL_HOST_ENV_VARIABLE_VALUE)
 
  48                 .orElseThrow(() -> new EnvironmentLoaderException("$CONSUL_HOST environment has not been defined"));
 
  54      * @return consulPort consulPort
 
  57     public static Integer getConsultPort() {
 
  58         return ConfigBindingServiceConstants.DEFAULT_CONSUL_PORT_ENV_VARIABLE_VALUE;
 
  62      * getConfigBindingService.
 
  64      * @return configBindingService configBindingService
 
  67     public static String getConfigBindingService() throws EnvironmentLoaderException {
 
  68         return Optional.ofNullable(ConfigBindingServiceConstants.CONFIG_BINDING_SERVICE_ENV_VARIABLE_VALUE) //
 
  69                 .orElseThrow(() -> new EnvironmentLoaderException(
 
  70                         "$CONFIG_BINDING_SERVICE environment has not been defined"));
 
  76      * @return service service
 
  79     public static String getService() throws EnvironmentLoaderException {
 
  80         return Optional.ofNullable(ConfigBindingServiceConstants.SERVICE_NAME_ENV_VARIABLE_VALUE).orElseThrow(
 
  81                 () -> new EnvironmentLoaderException("$HOSTNAME have not been defined as system environment"));