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

View File

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