196b7911ea72f2b6111a44582c6c5ceea21b5433
[dcaegen2/analytics/tca-gen2.git] / dcae-analytics / dcae-analytics-model / src / main / java / org / onap / dcae / analytics / model / configbindingservice / ConfigBindingServiceConstants.java
1 /*
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
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
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=========================================================
17  *
18  */
19
20 package org.onap.dcae.analytics.model.configbindingservice;
21
22 import java.util.Map;
23 import java.util.Set;
24 import java.util.function.Predicate;
25 import java.util.stream.Collectors;
26 import java.util.stream.Stream;
27
28 import org.onap.dcae.analytics.model.configbindingservice.BaseConfigBindingServiceProperties.PubSubCommonDetails;
29
30 /**
31  * @author Rajiv Singla
32  */
33 public abstract class ConfigBindingServiceConstants {
34
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 = "SERVICE_NAME";
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";
46
47
48     public static final String CONFIG_BINDING_SERVICE_PROPERTIES_KEY = "config-binding-service";
49
50
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 = ".";
56
57     // ============== CONFIG BINDING SERVICE UTILS ========================= //
58     /**
59      * Predicate which can be used to filter message router publisher or subscriber details
60      */
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);
64
65     private ConfigBindingServiceConstants() {
66         // private constructor
67     }
68 }