2  * ================================================================================
 
   3  * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
 
   4  * ================================================================================
 
   5  * Licensed under the Apache License, Version 2.0 (the "License");
 
   6  * you may not use this file except in compliance with the License.
 
   7  * You may obtain a copy of the License at
 
   9  *      http://www.apache.org/licenses/LICENSE-2.0
 
  11  * Unless required by applicable law or agreed to in writing, software
 
  12  * distributed under the License is distributed on an "AS IS" BASIS,
 
  13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  14  * See the License for the specific language governing permissions and
 
  15  * limitations under the License.
 
  16  * ============LICENSE_END=========================================================
 
  20 package org.onap.dcae.analytics.model.configbindingservice;
 
  24 import java.util.function.Predicate;
 
  25 import java.util.stream.Collectors;
 
  26 import java.util.stream.Stream;
 
  28 import org.onap.dcae.analytics.model.configbindingservice.BaseConfigBindingServiceProperties.PubSubCommonDetails;
 
  31  * @author Rajiv Singla
 
  33 public abstract class ConfigBindingServiceConstants {
 
  35     // ================== CONFIG SERVICE CONSTANTS ============================== //
 
  36     public static final String CONSUL_HOST_ENV_VARIABLE_KEY = "CONSUL_HOST";
 
  37     public static final String CONSUL_HOST_ENV_VARIABLE_VALUE = System.getenv(CONSUL_HOST_ENV_VARIABLE_KEY);
 
  38     public static final String CONFIG_BINDING_SERVICE_ENV_VARIABLE_KEY = "CONFIG_BINDING_SERVICE";
 
  39     public static final String CONFIG_BINDING_SERVICE_ENV_VARIABLE_VALUE =
 
  40             System.getenv(CONFIG_BINDING_SERVICE_ENV_VARIABLE_KEY);
 
  41     public static final String SERVICE_NAME_ENV_VARIABLE_KEY = "HOSTNAME";
 
  42     public static final String SERVICE_NAME_ENV_VARIABLE_VALUE = System.getenv(SERVICE_NAME_ENV_VARIABLE_KEY);
 
  43     public static final String CONSUL_QUERY_URL_STRING = String.format("http://%s:8500/v1/catalog/service/%s",
 
  44             CONSUL_HOST_ENV_VARIABLE_VALUE, CONFIG_BINDING_SERVICE_ENV_VARIABLE_VALUE);
 
  45     public static final String CONFIG_SERVICE_QUERY_URL_STRING = "http://%s:%s/service_component/%s";
 
  48     public static final String CONFIG_BINDING_SERVICE_PROPERTIES_KEY = "config-binding-service";
 
  51     public static final Set<String> SPRING_RESERVED_PROPERTIES_KEY_PREFIXES =
 
  52             Stream.of("spring", "endpoints", "server", "logging", "management").collect(Collectors.toSet());
 
  53     public static final String CONFIG_SERVICE_MESSAGE_ROUTER_VALUE = "message_router";
 
  54     // CONVERT JSON TO MAP
 
  55     public static final String KEY_SEPARATOR = ".";
 
  57     // ============== CONFIG BINDING SERVICE UTILS ========================= //
 
  59      * Predicate which can be used to filter message router publisher or subscriber details
 
  61     public static final Predicate<Map.Entry<String, ? extends PubSubCommonDetails>> MESSAGE_ROUTER_PREDICATE =
 
  62             e -> e.getValue().getType() != null &&
 
  63                     e.getValue().getType().equalsIgnoreCase(CONFIG_SERVICE_MESSAGE_ROUTER_VALUE);
 
  65     private ConfigBindingServiceConstants() {
 
  66         // private constructor