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;
}
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;
}
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;
}
Aggregations