use of org.akaza.openclinica.domain.technicaladmin.ConfigurationBean in project OpenClinica by OpenClinica.
the class PasswordRequirementsDao method setValue.
private void setValue(String key, int value) {
ConfigurationBean bean = this.configurationDao.findByKey(key);
bean.setValue(Integer.toString(value));
this.configurationDao.saveOrUpdate(bean);
}
use of org.akaza.openclinica.domain.technicaladmin.ConfigurationBean in project OpenClinica by OpenClinica.
the class ConfigurationDaoTest method testSaveOrUpdate.
public void testSaveOrUpdate() {
ConfigurationDao configurationDao = (ConfigurationDao) getContext().getBean("configurationDao");
ConfigurationBean configurationBean = new ConfigurationBean();
configurationBean.setKey("user.test");
configurationBean.setValue("test");
configurationBean.setDescription("Testing attention please");
configurationBean = configurationDao.saveOrUpdate(configurationBean);
assertNotNull("Persistant id is null", configurationBean.getId());
}
use of org.akaza.openclinica.domain.technicaladmin.ConfigurationBean in project OpenClinica by OpenClinica.
the class ConfigurationDaoTest method testfindById.
public void testfindById() {
ConfigurationDao configurationDao = (ConfigurationDao) getContext().getBean("configurationDao");
ConfigurationBean configurationBean = configurationDao.findById(-1);
assertEquals("Key should be test.test", "test.test", configurationBean.getKey());
}
use of org.akaza.openclinica.domain.technicaladmin.ConfigurationBean in project OpenClinica by OpenClinica.
the class ConfigureServlet method processRequest.
@SuppressWarnings("unchecked")
@Override
protected void processRequest() throws Exception {
FormProcessor fp = new FormProcessor(request);
if (!fp.isSubmitted()) {
loadPresetValuesFromBean(fp);
setPresetValues(fp.getPresetValues());
forwardPage(Page.CONFIGURATION);
} else {
Validator v = new Validator(request);
v.addValidation("lockcount", Validator.IS_AN_INTEGER);
v.addValidation("lockcount", Validator.NO_BLANKS);
v.addValidation("lockcount", Validator.IS_IN_RANGE, 1, 25);
HashMap errors = v.validate();
if (!errors.isEmpty()) {
loadPresetValuesFromForm(fp);
setPresetValues(fp.getPresetValues());
setInputMessages(errors);
forwardPage(Page.CONFIGURATION);
} else {
ConfigurationBean userLockSwitch = getConfigurationDao().findByKey("user.lock.switch");
ConfigurationBean userLockAllowedFailedConsecutiveLoginAttempts = getConfigurationDao().findByKey("user.lock.allowedFailedConsecutiveLoginAttempts");
userLockSwitch.setValue(fp.getString("lockswitch"));
userLockAllowedFailedConsecutiveLoginAttempts.setValue(fp.getString("lockcount"));
getConfigurationDao().saveOrUpdate(userLockSwitch);
getConfigurationDao().saveOrUpdate(userLockAllowedFailedConsecutiveLoginAttempts);
addPageMessage(respage.getString("lockout_changes_have_been_saved"));
forwardPage(Page.LIST_USER_ACCOUNTS_SERVLET);
}
}
}
use of org.akaza.openclinica.domain.technicaladmin.ConfigurationBean in project OpenClinica by OpenClinica.
the class PasswordRequirementsDao method configs.
public Map<String, Object> configs() {
HashMap<String, Object> map = new HashMap<String, Object>();
List<ConfigurationBean> beans = this.configurationDao.findAll();
for (ConfigurationBean bean : beans) {
String key = bean.getKey(), value = bean.getValue();
if (boolConfigKeys.contains(key)) {
map.put(key, Boolean.valueOf(value));
} else if (intConfigKeys.contains(key)) {
try {
map.put(key, Integer.valueOf(value));
} catch (NumberFormatException ex) {
logger.warn("Invalid configuration key: " + key + "." + " Should be an integer, but is: " + value, ex);
}
}
}
return map;
}
Aggregations