take care of already existing group so do not fail

git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1434059 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2013-01-16 17:29:39 +00:00
parent 8ca421a01e
commit 83928256b5
1 changed files with 11 additions and 0 deletions

View File

@ -33,6 +33,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
import javax.naming.NameAlreadyBoundException;
import javax.naming.NameNotFoundException;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
@ -482,6 +483,11 @@ public class DefaultLdapRoleMapper
throws MappingException
{
if ( hasRole( context, roleName ) )
{
return true;
}
String groupName = findGroupName( roleName );
if ( groupName == null )
@ -527,6 +533,11 @@ public class DefaultLdapRoleMapper
return true;
}
catch ( NameAlreadyBoundException e )
{
log.info( "skip group '{}' creation as already exists", groupName );
return true;
}
catch ( LdapException e )
{
throw new MappingException( e.getMessage(), e );