[MRM-1807] Archiva wrapper fail to start

This commit is contained in:
Olivier Lamy 2014-11-05 21:39:00 +11:00
parent ae9b109306
commit 021bbaf5a1
3 changed files with 37 additions and 18 deletions

View File

@ -27,6 +27,11 @@ import org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration;
*/ */
public interface RedbackRuntimeConfigurationAdmin public interface RedbackRuntimeConfigurationAdmin
{ {
static final String DEFAULT_RBAC_MANAGER_IMPL = "jdo";
static final String DEFAULT_USER_MANAGER_IMPL = "jdo";
RedbackRuntimeConfiguration getRedbackRuntimeConfiguration() RedbackRuntimeConfiguration getRedbackRuntimeConfiguration()
throws RepositoryAdminException; throws RepositoryAdminException;

View File

@ -52,7 +52,7 @@ import java.util.Set;
* @author Olivier Lamy * @author Olivier Lamy
* @since 1.4-M4 * @since 1.4-M4
*/ */
@Service("redbackRuntimeConfigurationAdmin#default") @Service( "redbackRuntimeConfigurationAdmin#default" )
public class DefaultRedbackRuntimeConfigurationAdmin public class DefaultRedbackRuntimeConfigurationAdmin
extends AbstractRepositoryAdmin extends AbstractRepositoryAdmin
implements RedbackRuntimeConfigurationAdmin, UserConfiguration implements RedbackRuntimeConfigurationAdmin, UserConfiguration
@ -68,9 +68,9 @@ public class DefaultRedbackRuntimeConfigurationAdmin
@Inject @Inject
public DefaultRedbackRuntimeConfigurationAdmin( ArchivaConfiguration archivaConfiguration,// public DefaultRedbackRuntimeConfigurationAdmin( ArchivaConfiguration archivaConfiguration,//
@Named(value = "userConfiguration#redback") // @Named( value = "userConfiguration#redback" ) //
UserConfiguration userConfiguration, UserConfiguration userConfiguration,
@Named(value = "cache#users") Cache usersCache ) @Named( value = "cache#users" ) Cache usersCache )
{ {
this.archivaConfiguration = archivaConfiguration; this.archivaConfiguration = archivaConfiguration;
this.userConfiguration = userConfiguration; this.userConfiguration = userConfiguration;
@ -92,7 +92,8 @@ public class DefaultRedbackRuntimeConfigurationAdmin
redbackRuntimeConfiguration = new RedbackRuntimeConfiguration(); redbackRuntimeConfiguration = new RedbackRuntimeConfiguration();
// so migrate if available // so migrate if available
String userManagerImpl = String userManagerImpl =
userConfiguration.getConcatenatedList( UserConfigurationKeys.USER_MANAGER_IMPL, "jdo" ); userConfiguration.getConcatenatedList( UserConfigurationKeys.USER_MANAGER_IMPL, //
DEFAULT_USER_MANAGER_IMPL );
if ( StringUtils.isNotEmpty( userManagerImpl ) ) if ( StringUtils.isNotEmpty( userManagerImpl ) )
{ {
String[] impls = StringUtils.split( userManagerImpl, ',' ); String[] impls = StringUtils.split( userManagerImpl, ',' );
@ -101,9 +102,14 @@ public class DefaultRedbackRuntimeConfigurationAdmin
redbackRuntimeConfiguration.getUserManagerImpls().add( impl ); redbackRuntimeConfiguration.getUserManagerImpls().add( impl );
} }
} }
else
{
redbackRuntimeConfiguration.getUserManagerImpls().add( DEFAULT_USER_MANAGER_IMPL );
}
String rbacManagerImpls = String rbacManagerImpls =
userConfiguration.getConcatenatedList( UserConfigurationKeys.RBAC_MANAGER_IMPL, "jdo" ); userConfiguration.getConcatenatedList( UserConfigurationKeys.RBAC_MANAGER_IMPL, //
DEFAULT_RBAC_MANAGER_IMPL );
if ( StringUtils.isNotEmpty( rbacManagerImpls ) ) if ( StringUtils.isNotEmpty( rbacManagerImpls ) )
{ {
@ -113,6 +119,10 @@ public class DefaultRedbackRuntimeConfigurationAdmin
redbackRuntimeConfiguration.getRbacManagerImpls().add( impl ); redbackRuntimeConfiguration.getRbacManagerImpls().add( impl );
} }
} }
else
{
redbackRuntimeConfiguration.getRbacManagerImpls().add( DEFAULT_RBAC_MANAGER_IMPL );
}
// now ldap // now ldap
@ -132,16 +142,13 @@ public class DefaultRedbackRuntimeConfigurationAdmin
ldapConfiguration.setBaseGroupsDn( ldapConfiguration.setBaseGroupsDn(
userConfiguration.getConcatenatedList( UserConfigurationKeys.LDAP_GROUPS_BASEDN, userConfiguration.getConcatenatedList( UserConfigurationKeys.LDAP_GROUPS_BASEDN,
ldapConfiguration.getBaseDn() ) ldapConfiguration.getBaseDn() ) );
);
ldapConfiguration.setContextFactory( ldapConfiguration.setContextFactory(
userConfiguration.getString( UserConfigurationKeys.LDAP_CONTEX_FACTORY, userConfiguration.getString( UserConfigurationKeys.LDAP_CONTEX_FACTORY,
isSunContextFactoryAvailable() isSunContextFactoryAvailable()
? "com.sun.jndi.ldap.LdapCtxFactory" ? "com.sun.jndi.ldap.LdapCtxFactory"
: "" : "" ) );
)
);
ldapConfiguration.setBindDn( ldapConfiguration.setBindDn(
userConfiguration.getConcatenatedList( UserConfigurationKeys.LDAP_BINDDN, null ) ); userConfiguration.getConcatenatedList( UserConfigurationKeys.LDAP_BINDDN, null ) );
ldapConfiguration.setPassword( ldapConfiguration.setPassword(

View File

@ -98,6 +98,11 @@ public class ArchivaRbacManager
List<String> rbacManagerIds = List<String> rbacManagerIds =
redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration().getRbacManagerImpls(); redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration().getRbacManagerImpls();
if ( rbacManagerIds.isEmpty() )
{
rbacManagerIds.add( RedbackRuntimeConfigurationAdmin.DEFAULT_RBAC_MANAGER_IMPL );
}
log.info( "use rbacManagerIds: '{}'", rbacManagerIds ); log.info( "use rbacManagerIds: '{}'", rbacManagerIds );
this.rbacManagersPerId = new LinkedHashMap<>( rbacManagerIds.size() ); this.rbacManagersPerId = new LinkedHashMap<>( rbacManagerIds.size() );
@ -111,7 +116,7 @@ public class ArchivaRbacManager
} }
catch ( RepositoryAdminException e ) catch ( RepositoryAdminException e )
{ {
// revert to a default one ?
log.error( e.getMessage(), e ); log.error( e.getMessage(), e );
throw new RuntimeException( e.getMessage(), e ); throw new RuntimeException( e.getMessage(), e );
} }
@ -126,7 +131,9 @@ public class ArchivaRbacManager
return rbacManager; return rbacManager;
} }
} }
return this.rbacManagersPerId.values().iterator().next(); return this.rbacManagersPerId.isEmpty() ? applicationContext.getBean(
"rbacManager#" + RedbackRuntimeConfigurationAdmin.DEFAULT_RBAC_MANAGER_IMPL, RBACManager.class ) //
: this.rbacManagersPerId.values().iterator().next();
} }
@Override @Override