Search in sources :

Example 1 with ConfigurationBean

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);
}
Also used : ConfigurationBean(org.akaza.openclinica.domain.technicaladmin.ConfigurationBean)

Example 2 with ConfigurationBean

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());
}
Also used : ConfigurationDao(org.akaza.openclinica.dao.hibernate.ConfigurationDao) ConfigurationBean(org.akaza.openclinica.domain.technicaladmin.ConfigurationBean)

Example 3 with ConfigurationBean

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());
}
Also used : ConfigurationDao(org.akaza.openclinica.dao.hibernate.ConfigurationDao) ConfigurationBean(org.akaza.openclinica.domain.technicaladmin.ConfigurationBean)

Example 4 with ConfigurationBean

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);
        }
    }
}
Also used : ConfigurationBean(org.akaza.openclinica.domain.technicaladmin.ConfigurationBean) HashMap(java.util.HashMap) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) Validator(org.akaza.openclinica.control.form.Validator)

Example 5 with ConfigurationBean

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;
}
Also used : ConfigurationBean(org.akaza.openclinica.domain.technicaladmin.ConfigurationBean) HashMap(java.util.HashMap)

Aggregations

ConfigurationBean (org.akaza.openclinica.domain.technicaladmin.ConfigurationBean)8 ConfigurationDao (org.akaza.openclinica.dao.hibernate.ConfigurationDao)3 HashMap (java.util.HashMap)2 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)1 Validator (org.akaza.openclinica.control.form.Validator)1