use of io.datarouter.storage.setting.DatarouterSettingTag in project datarouter by hotpads.
the class ClusterSettingsHandler method customSettings.
@Handler
public Mav customSettings(OptionalString prefix) {
Mav mav = new Mav(files.jsp.admin.datarouter.setting.editSettingsJsp);
mav.put("serverTypeOptions", serverTypes.getHtmlSelectOptionsVarNames());
mav.put("validities", buildLegend());
clusterSettingService.scanClusterSettingAndValidityWithPrefix(prefix.orElse(null)).flush(settings -> mav.put("rows", settings));
boolean mightBeDevelopment = datarouterServerTypeDetector.mightBeDevelopment();
mav.put("mightBeDevelopment", mightBeDevelopment);
if (mightBeDevelopment) {
mav.put("settingTagFilePath", CachedClusterSettingTags.getConfigFilePath());
List<DatarouterSettingTag> tags = cachedClusterSettingTags.get();
mav.put("settingTagValues", tags.stream().map(DatarouterSettingTag::getPersistentString).collect(Collectors.joining(",")));
}
return mav;
}
use of io.datarouter.storage.setting.DatarouterSettingTag in project datarouter by hotpads.
the class ClusterSettingService method getSettingValueForWebappInstance.
public <T> T getSettingValueForWebappInstance(CachedSetting<T> memorySetting, WebappInstance webappInstance) {
// try database first
List<ClusterSetting> settingsWithName = clusterSettingFinder.getAllSettingsWithName(memorySetting.getName());
Optional<ClusterSetting> mostSpecificSetting = ClusterSettingComparisonTool.getMostSpecificSettingForWebappInstance(settingsWithName, webappInstance);
if (mostSpecificSetting.isPresent()) {
return ClusterSettingComparisonTool.getTypedValueOrUseDefaultFrom(mostSpecificSetting, memorySetting);
}
// use default
var environmentType = environmentTypeSupplier.getDatarouterEnvironmentType();
DefaultSettingValue<T> defaultSettingValue = memorySetting.getDefaultSettingValue();
ServerType serverType = serverTypes.fromPersistentString(webappInstance.getServerType());
List<DatarouterSettingTag> settingTags = cachedClusterSettingTags.get();
return defaultSettingValue.getValue(environmentType, environmentName.get(), serverType, serverName.get(), settingTags);
}
Aggregations