Search in sources :

Example 16 with RedbackRuntimeConfiguration

use of org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration in project archiva by apache.

the class DefaultRedbackRuntimeConfigurationAdmin method build.

private RedbackRuntimeConfiguration build(org.apache.archiva.configuration.RedbackRuntimeConfiguration runtimeConfiguration) {
    RedbackRuntimeConfiguration redbackRuntimeConfiguration = getModelMapper().map(runtimeConfiguration, RedbackRuntimeConfiguration.class);
    if (runtimeConfiguration.getLdapConfiguration() != null) {
        redbackRuntimeConfiguration.setLdapConfiguration(getModelMapper().map(runtimeConfiguration.getLdapConfiguration(), LdapConfiguration.class));
    }
    if (runtimeConfiguration.getUsersCacheConfiguration() != null) {
        redbackRuntimeConfiguration.setUsersCacheConfiguration(getModelMapper().map(runtimeConfiguration.getUsersCacheConfiguration(), CacheConfiguration.class));
    }
    if (redbackRuntimeConfiguration.getLdapConfiguration() == null) {
        // prevent NPE
        redbackRuntimeConfiguration.setLdapConfiguration(new LdapConfiguration());
    }
    if (redbackRuntimeConfiguration.getUsersCacheConfiguration() == null) {
        redbackRuntimeConfiguration.setUsersCacheConfiguration(new CacheConfiguration());
    }
    List<org.apache.archiva.configuration.LdapGroupMapping> mappings = runtimeConfiguration.getLdapGroupMappings();
    if (mappings != null && mappings.size() > 0) {
        List<LdapGroupMapping> ldapGroupMappings = new ArrayList<>(mappings.size());
        for (org.apache.archiva.configuration.LdapGroupMapping mapping : mappings) {
            ldapGroupMappings.add(new LdapGroupMapping(mapping.getGroup(), mapping.getRoleNames()));
        }
        redbackRuntimeConfiguration.setLdapGroupMappings(ldapGroupMappings);
    }
    cleanupProperties(redbackRuntimeConfiguration);
    return redbackRuntimeConfiguration;
}
Also used : LdapGroupMapping(org.apache.archiva.admin.model.beans.LdapGroupMapping) ArrayList(java.util.ArrayList) LdapConfiguration(org.apache.archiva.admin.model.beans.LdapConfiguration) RedbackRuntimeConfiguration(org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration) CacheConfiguration(org.apache.archiva.admin.model.beans.CacheConfiguration)

Example 17 with RedbackRuntimeConfiguration

use of org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration in project archiva by apache.

the class DefaultRedbackRuntimeConfigurationAdmin method getBoolean.

@Override
public boolean getBoolean(String key) {
    RedbackRuntimeConfiguration conf = getRedbackRuntimeConfiguration();
    if (UserConfigurationKeys.LDAP_WRITABLE.equals(key)) {
        return conf.getLdapConfiguration().isWritable();
    }
    if (UserConfigurationKeys.LDAP_GROUPS_USE_ROLENAME.equals(key)) {
        return conf.getLdapConfiguration().isUseRoleNameAsGroup();
    }
    if (UserConfigurationKeys.LDAP_BIND_AUTHENTICATOR_ENABLED.equals(key)) {
        return conf.getLdapConfiguration().isBindAuthenticatorEnabled();
    }
    if (conf.getConfigurationProperties().containsKey(key)) {
        return Boolean.valueOf(conf.getConfigurationProperties().get(key));
    }
    boolean value = userConfiguration.getBoolean(key);
    conf.getConfigurationProperties().put(key, Boolean.toString(value));
    try {
        updateRedbackRuntimeConfiguration(conf);
    } catch (RepositoryAdminException e) {
        log.error("fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e);
        throw new RuntimeException(e.getMessage(), e);
    }
    return value;
}
Also used : RedbackRuntimeConfiguration(org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException)

Example 18 with RedbackRuntimeConfiguration

use of org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration in project archiva by apache.

the class DefaultRedbackRuntimeConfigurationAdmin method getList.

@Override
public List<String> getList(String key) {
    RedbackRuntimeConfiguration conf = getRedbackRuntimeConfiguration();
    if (conf.getConfigurationProperties().containsKey(key)) {
        return Arrays.asList(conf.getConfigurationProperties().get(key).split(","));
    }
    List<String> value = userConfiguration.getList(key);
    conf.getConfigurationProperties().put(key, "");
    try {
        updateRedbackRuntimeConfiguration(conf);
    } catch (RepositoryAdminException e) {
        log.error("fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e);
        throw new RuntimeException(e.getMessage(), e);
    }
    return value;
}
Also used : RedbackRuntimeConfiguration(org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException)

Aggregations

RedbackRuntimeConfiguration (org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration)18 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)14 LdapGroupMapping (org.apache.archiva.admin.model.beans.LdapGroupMapping)7 MappingException (org.apache.archiva.redback.common.ldap.MappingException)5 ArrayList (java.util.ArrayList)3 CacheConfiguration (org.apache.archiva.admin.model.beans.CacheConfiguration)3 LdapConfiguration (org.apache.archiva.admin.model.beans.LdapConfiguration)3 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 SimpleDateFormat (java.text.SimpleDateFormat)1 Collection (java.util.Collection)1 Date (java.util.Date)1 List (java.util.List)1 Locale (java.util.Locale)1 Map (java.util.Map)1 PostConstruct (javax.annotation.PostConstruct)1 ArchivaConfiguration (org.apache.archiva.configuration.ArchivaConfiguration)1 Configuration (org.apache.archiva.configuration.Configuration)1 IndeterminateConfigurationException (org.apache.archiva.configuration.IndeterminateConfigurationException)1 RegistryException (org.apache.archiva.redback.components.registry.RegistryException)1