Search in sources :

Example 6 with Configuration

use of org.jbei.ice.storage.model.Configuration 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();
}
Also used : PermissionException(org.jbei.ice.lib.access.PermissionException) ConfigurationKey(org.jbei.ice.lib.dto.ConfigurationKey) Configuration(org.jbei.ice.storage.model.Configuration) WoRController(org.jbei.ice.lib.net.WoRController) AccountController(org.jbei.ice.lib.account.AccountController)

Example 7 with Configuration

use of org.jbei.ice.storage.model.Configuration 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());
    }
}
Also used : ConfigurationKey(org.jbei.ice.lib.dto.ConfigurationKey) Configuration(org.jbei.ice.storage.model.Configuration)

Example 8 with Configuration

use of org.jbei.ice.storage.model.Configuration in project ice by JBEI.

the class ConfigurationDAO method get.

public Configuration get(String key) {
    try {
        CriteriaQuery<Configuration> query = getBuilder().createQuery(Configuration.class);
        Root<Configuration> root = query.from(Configuration.class);
        query.where(getBuilder().equal(root.get("key"), key));
        return currentSession().createQuery(query).uniqueResult();
    } catch (HibernateException e) {
        Logger.error(e);
        throw new DAOException("Failed to get Configuration using key: " + key, e);
    }
}
Also used : DAOException(org.jbei.ice.storage.DAOException) Configuration(org.jbei.ice.storage.model.Configuration) HibernateException(org.hibernate.HibernateException)

Aggregations

Configuration (org.jbei.ice.storage.model.Configuration)8 AccountController (org.jbei.ice.lib.account.AccountController)3 ConfigurationKey (org.jbei.ice.lib.dto.ConfigurationKey)3 PermissionException (org.jbei.ice.lib.access.PermissionException)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URL (java.net.URL)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 HibernateException (org.hibernate.HibernateException)1 Setting (org.jbei.ice.lib.dto.Setting)1 WoRController (org.jbei.ice.lib.net.WoRController)1 DAOException (org.jbei.ice.storage.DAOException)1 Archiver (org.rauschig.jarchivelib.Archiver)1