
org.sunbird.common.Platform Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of platform-common Show documentation
Show all versions of platform-common Show documentation
platform-common provides the common pojos and utils for sunbird.
The newest version!
package org.sunbird.common;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
/**
*
* @author Mahesh Kumar Gangula
*
*/
public class Platform {
private static Config defaultConf = ConfigFactory.load();
private static Config envConf = ConfigFactory.systemEnvironment();
public static Config config = defaultConf.withFallback(envConf);
private static int requestTimeout = 30;
private static Map> graphIds = new HashMap<>();
public static void loadProperties(Config conf) {
config = config.withFallback(conf);
}
public static int getTimeout() {
return requestTimeout;
}
public static List getGraphIds(String... services) {
List ids = new ArrayList<>();
for (String service: services) {
ids.addAll(getGraphIds(service));
}
return ids;
}
private static List getGraphIds(String service) {
service = service.toLowerCase();
if (!graphIds.containsKey(service)) {
String key = service + ".graph_ids";
if (config.hasPath(key)) {
graphIds.put(service, config.getStringList(key));
} else
return Arrays.asList();
}
return graphIds.get(service);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy