use constants keys from redback

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1417543 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-12-05 17:24:18 +00:00
parent 51f0f40aae
commit e64c232ac9
1 changed files with 13 additions and 9 deletions

View File

@ -29,6 +29,7 @@ import org.apache.archiva.configuration.IndeterminateConfigurationException;
import org.apache.archiva.configuration.RedbackRuntimeConfiguration; import org.apache.archiva.configuration.RedbackRuntimeConfiguration;
import org.apache.archiva.redback.components.registry.RegistryException; import org.apache.archiva.redback.components.registry.RegistryException;
import org.apache.archiva.redback.configuration.UserConfiguration; import org.apache.archiva.redback.configuration.UserConfiguration;
import org.apache.archiva.redback.configuration.UserConfigurationKeys;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -40,26 +41,27 @@ import javax.inject.Named;
* @author Olivier Lamy * @author Olivier Lamy
* @since 1.4-M4 * @since 1.4-M4
*/ */
@Service( "archivaRuntimeConfigurationAdmin#default" ) @Service("archivaRuntimeConfigurationAdmin#default")
public class DefaultArchivaRuntimeConfigurationAdmin public class DefaultArchivaRuntimeConfigurationAdmin
extends AbstractRepositoryAdmin extends AbstractRepositoryAdmin
implements ArchivaRuntimeConfigurationAdmin implements ArchivaRuntimeConfigurationAdmin
{ {
@Inject @Inject
@Named( value = "userConfiguration" ) @Named(value = "userConfiguration")
UserConfiguration userConfiguration; UserConfiguration userConfiguration;
@PostConstruct @PostConstruct
public void initialize() public void initialize()
throws RepositoryAdminException throws RepositoryAdminException
{ {
ArchivaRuntimeConfiguration archivaRuntimeConfiguration = getArchivaRuntimeConfiguration(); ArchivaRuntimeConfiguration archivaRuntimeConfiguration = getArchivaRuntimeConfiguration();
// migrate or not data from redback // migrate or not data from redback
if ( !archivaRuntimeConfiguration.isMigratedFromRedbackConfiguration() ) if ( !archivaRuntimeConfiguration.isMigratedFromRedbackConfiguration() )
{ {
// so migrate if available // so migrate if available
String userManagerImpl = userConfiguration.getString( "user.manager.impl" ); String userManagerImpl = userConfiguration.getString( UserConfigurationKeys.USER_MANAGER_IMPL );
if ( StringUtils.isNotEmpty( userManagerImpl ) ) if ( StringUtils.isNotEmpty( userManagerImpl ) )
{ {
archivaRuntimeConfiguration.setUserManagerImpl( userManagerImpl ); archivaRuntimeConfiguration.setUserManagerImpl( userManagerImpl );
@ -75,16 +77,18 @@ public class DefaultArchivaRuntimeConfigurationAdmin
archivaRuntimeConfiguration.setArchivaLdapConfiguration( archivaLdapConfiguration ); archivaRuntimeConfiguration.setArchivaLdapConfiguration( archivaLdapConfiguration );
} }
archivaLdapConfiguration.setHostName( userConfiguration.getString( "ldap.config.hostname", null ) ); archivaLdapConfiguration.setHostName(
archivaLdapConfiguration.setPort( userConfiguration.getInt( "ldap.config.port", -1 ) ); userConfiguration.getString( UserConfigurationKeys.LDAP_HOSTNAME, null ) );
archivaLdapConfiguration.setSsl( userConfiguration.getBoolean( "ldap.config.ssl", false ) ); archivaLdapConfiguration.setPort( userConfiguration.getInt( UserConfigurationKeys.LDAP_PORT, -1 ) );
archivaLdapConfiguration.setSsl( userConfiguration.getBoolean( UserConfigurationKeys.LDAP_SSL, false ) );
archivaLdapConfiguration.setBaseDn( userConfiguration.getConcatenatedList( "ldap.config.base.dn", null ) ); archivaLdapConfiguration.setBaseDn( userConfiguration.getConcatenatedList( "ldap.config.base.dn", null ) );
archivaLdapConfiguration.setContextFactory( archivaLdapConfiguration.setContextFactory(
userConfiguration.getString( "ldap.config.context.factory", null ) ); userConfiguration.getString( UserConfigurationKeys.LDAP_CONTEX_FACTORY, null ) );
archivaLdapConfiguration.setBindDn( userConfiguration.getConcatenatedList( "ldap.config.bind.dn", null ) ); archivaLdapConfiguration.setBindDn( userConfiguration.getConcatenatedList( "ldap.config.bind.dn", null ) );
archivaLdapConfiguration.setPassword( userConfiguration.getString( "ldap.config.password", null ) ); archivaLdapConfiguration.setPassword(
userConfiguration.getString( UserConfigurationKeys.LDAP_PASSWORD, null ) );
archivaLdapConfiguration.setAuthenticationMethod( archivaLdapConfiguration.setAuthenticationMethod(
userConfiguration.getString( "ldap.config.authentication.method", null ) ); userConfiguration.getString( UserConfigurationKeys.LDAP_AUTHENTICATION_METHOD, null ) );
archivaRuntimeConfiguration.setMigratedFromRedbackConfiguration( true ); archivaRuntimeConfiguration.setMigratedFromRedbackConfiguration( true );