| 
									
										
										
										
											2021-07-08 15:11:40 -07:00
										 |  |  | package utils;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-22 16:33:14 -08:00
										 |  |  | import com.linkedin.util.Configuration;
 | 
					
						
							| 
									
										
										
										
											2021-07-08 15:11:40 -07:00
										 |  |  | import com.typesafe.config.Config;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public class ConfigUtil {
 | 
					
						
							| 
									
										
										
										
											2021-11-22 16:33:14 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-06 11:02:42 +05:30
										 |  |  |   private ConfigUtil() {}
 | 
					
						
							| 
									
										
										
										
											2022-05-10 18:15:53 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-22 16:33:14 -08:00
										 |  |  |   // New configurations, provided via application.conf file.
 | 
					
						
							|  |  |  |   public static final String METADATA_SERVICE_HOST_CONFIG_PATH = "metadataService.host";
 | 
					
						
							|  |  |  |   public static final String METADATA_SERVICE_PORT_CONFIG_PATH = "metadataService.port";
 | 
					
						
							|  |  |  |   public static final String METADATA_SERVICE_USE_SSL_CONFIG_PATH = "metadataService.useSsl";
 | 
					
						
							| 
									
										
										
										
											2023-12-06 11:02:42 +05:30
										 |  |  |   public static final String METADATA_SERVICE_SSL_PROTOCOL_CONFIG_PATH =
 | 
					
						
							|  |  |  |       "metadataService.sslProtocol";
 | 
					
						
							| 
									
										
										
										
											2021-11-22 16:33:14 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // Legacy env-var based config values, for backwards compatibility:
 | 
					
						
							|  |  |  |   public static final String GMS_HOST_ENV_VAR = "DATAHUB_GMS_HOST";
 | 
					
						
							|  |  |  |   public static final String GMS_PORT_ENV_VAR = "DATAHUB_GMS_PORT";
 | 
					
						
							|  |  |  |   public static final String GMS_USE_SSL_ENV_VAR = "DATAHUB_GMS_USE_SSL";
 | 
					
						
							|  |  |  |   public static final String GMS_SSL_PROTOCOL_VAR = "DATAHUB_GMS_SSL_PROTOCOL";
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Default values
 | 
					
						
							|  |  |  |   public static final String DEFAULT_GMS_HOST = "localhost";
 | 
					
						
							|  |  |  |   public static final String DEFAULT_GMS_PORT = "8080";
 | 
					
						
							|  |  |  |   public static final String DEFAULT_GMS_USE_SSL = "False";
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-06 11:02:42 +05:30
										 |  |  |   public static final String DEFAULT_METADATA_SERVICE_HOST =
 | 
					
						
							|  |  |  |       Configuration.getEnvironmentVariable(GMS_HOST_ENV_VAR, "localhost");
 | 
					
						
							|  |  |  |   public static final Integer DEFAULT_METADATA_SERVICE_PORT =
 | 
					
						
							|  |  |  |       Integer.parseInt(Configuration.getEnvironmentVariable(GMS_PORT_ENV_VAR, "8080"));
 | 
					
						
							|  |  |  |   public static final Boolean DEFAULT_METADATA_SERVICE_USE_SSL =
 | 
					
						
							|  |  |  |       Boolean.parseBoolean(Configuration.getEnvironmentVariable(GMS_USE_SSL_ENV_VAR, "False"));
 | 
					
						
							|  |  |  |   public static final String DEFAULT_METADATA_SERVICE_SSL_PROTOCOL =
 | 
					
						
							|  |  |  |       Configuration.getEnvironmentVariable(GMS_SSL_PROTOCOL_VAR);
 | 
					
						
							| 
									
										
										
										
											2021-11-22 16:33:14 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-08 15:11:40 -07:00
										 |  |  |   public static boolean getBoolean(Config config, String key) {
 | 
					
						
							|  |  |  |     return config.hasPath(key) && config.getBoolean(key);
 | 
					
						
							|  |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-22 16:33:14 -08:00
										 |  |  |   public static boolean getBoolean(Config config, String key, boolean defaultValue) {
 | 
					
						
							|  |  |  |     return config.hasPath(key) ? config.getBoolean(key) : defaultValue;
 | 
					
						
							|  |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-08 15:11:40 -07:00
										 |  |  |   public static int getInt(Config config, String key, int defaultValue) {
 | 
					
						
							|  |  |  |     return config.hasPath(key) ? config.getInt(key) : defaultValue;
 | 
					
						
							|  |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   public static String getString(Config config, String key, String defaultValue) {
 | 
					
						
							|  |  |  |     return config.hasPath(key) ? config.getString(key) : defaultValue;
 | 
					
						
							|  |  |  |   }
 | 
					
						
							|  |  |  | }
 |