return new SystemSettings(cachedObfuscatedSystemSettings);
}
private void fillCache(Collection<SystemConfiguration> configs) {
SystemSettings settings = new SystemSettings();
for (SystemConfiguration config : configs) {
SystemSetting prop = SystemSetting.getByInternalName(config.getPropertyKey());
if (prop == null) {
LOG.warn("The database contains unknown system configuration setting [" + config.getPropertyKey()
+ "].");
continue;
}
if (config.getPropertyValue() == null) {
// for some reason, the configuration is not found in the DB, so fallback to the persisted default.
// if there isn't even a persisted default, just use an empty string.
String defaultValue = config.getDefaultPropertyValue();
defaultValue = transformSystemConfigurationPropertyFromDb(prop, defaultValue, true);
settings.put(prop, defaultValue);
} else {
String value = config.getPropertyValue();
value = transformSystemConfigurationPropertyFromDb(prop, value, true);
settings.put(prop, value);
}
}
settings.setDriftPlugins(getDriftServerPlugins());
synchronized (this) {
//only update the caches if the settings were actually changed
if (cachedSystemSettings == null
|| !safeEquals(cachedSystemSettings.get(SystemSetting.LAST_SYSTEM_CONFIG_UPDATE_TIME),
settings.get(SystemSetting.LAST_SYSTEM_CONFIG_UPDATE_TIME))) {
cachedSystemSettings = settings;
cachedObfuscatedSystemSettings = new SystemSettings(settings);
for (Map.Entry<SystemSetting, String> entry : cachedObfuscatedSystemSettings.entrySet()) {
String value = entry.getValue();
if (value != null && entry.getKey().getType() == PropertySimpleType.PASSWORD) {
entry.setValue(PicketBoxObfuscator.encode(value));
}