use of org.jbei.ice.lib.dto.ConfigurationKey in project ice by JBEI.
the class ConfigurationController method retrieveSystemSettings.
public ArrayList<Setting> retrieveSystemSettings(String userId) {
ArrayList<Setting> settings = new ArrayList<>();
if (!new AccountController().isAdministrator(userId))
return settings;
for (ConfigurationKey key : ConfigurationKey.values()) {
Configuration configuration = dao.get(key);
Setting setting;
if (configuration == null)
setting = new Setting(key.name(), "");
else
setting = new Setting(configuration.getKey(), configuration.getValue());
settings.add(setting);
}
return settings;
}
use of org.jbei.ice.lib.dto.ConfigurationKey in project ice by JBEI.
the class ConfigurationController method updateSetting.
public Setting updateSetting(String userId, Setting setting, String url) {
AccountController accountController = new AccountController();
if (!accountController.isAdministrator(userId))
throw new PermissionException("Cannot update system setting without admin privileges");
ConfigurationKey key = ConfigurationKey.valueOf(setting.getKey());
if (key == null)
throw new IllegalArgumentException("Invalid system key " + setting.getKey());
Configuration configuration = setPropertyValue(key, setting.getValue());
// check if the setting being updated is related to the web of registries
if (key == ConfigurationKey.JOIN_WEB_OF_REGISTRIES) {
WoRController woRController = new WoRController();
boolean enable = "yes".equalsIgnoreCase(setting.getValue()) || "true".equalsIgnoreCase(setting.getValue());
woRController.setEnable(userId, enable, url);
}
return configuration.toDataTransferObject();
}
use of org.jbei.ice.lib.dto.ConfigurationKey in project ice by JBEI.
the class ConfigurationController method initPropertyValues.
/**
* Initializes the database on new install
*/
public void initPropertyValues() {
for (ConfigurationKey key : ConfigurationKey.values()) {
Configuration config = dao.get(key);
if (config != null || key.getDefaultValue().isEmpty())
continue;
Logger.info("Setting value for " + key.name() + " to " + key.getDefaultValue());
setPropertyValue(key, key.getDefaultValue());
}
}
Aggregations