]> source.dussan.org Git - archiva.git/commitdiff
take care of already existing group so do not fail
authorOlivier Lamy <olamy@apache.org>
Wed, 16 Jan 2013 17:29:39 +0000 (17:29 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 16 Jan 2013 17:29:39 +0000 (17:29 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1434059 13f79535-47bb-0310-9956-ffa450edef68

redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/role/DefaultLdapRoleMapper.java

index a21f093a0cc655dcf491112b7fd750e47f8e349d..e426859a067a6cc35b2ea3d54cc1cc7c0b5ab8be 100644 (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 );