archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1437806 - /archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/main/java/org/apache/archiva/redback/rbac/ldap/LdapRbacManager.java
Date Wed, 23 Jan 2013 23:51:59 GMT
Author: olamy
Date: Wed Jan 23 23:51:59 2013
New Revision: 1437806

URL: http://svn.apache.org/viewvc?rev=1437806&view=rev
Log:
remove duplicate code

Modified:
    archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/main/java/org/apache/archiva/redback/rbac/ldap/LdapRbacManager.java

Modified: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/main/java/org/apache/archiva/redback/rbac/ldap/LdapRbacManager.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/main/java/org/apache/archiva/redback/rbac/ldap/LdapRbacManager.java?rev=1437806&r1=1437805&r2=1437806&view=diff
==============================================================================
--- archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/main/java/org/apache/archiva/redback/rbac/ldap/LdapRbacManager.java
(original)
+++ archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/main/java/org/apache/archiva/redback/rbac/ldap/LdapRbacManager.java
Wed Jan 23 23:51:59 2013
@@ -364,32 +364,15 @@ public class LdapRbacManager
             {
                 for ( String roleName : roleNames )
                 {
-                    Role role = this.rbacImpl.getRole( roleName );
-                    role = ( role == null ) ? new RoleImpl( roleName ) : role;
-                    if ( role != null )
-                    {
-                        rolesCache.put( role.getName(), role );
-                        roles.add( role );
-                    }
+                    Role role = buildRole( roleName );
+                    roles.add( role );
                 }
             }
             else if ( this.ldapRoleMapper.isUseDefaultRoleName() )
             {
-                Role role = null;
-                try
-                {
-                    role = this.rbacImpl.getRole( group );
-                }
-                catch ( RbacObjectNotFoundException e )
-                {
-                    // if it's mapped role to a group it doesn't exist in jdo
-                }
-                role = ( role == null ) ? new RoleImpl( group ) : role;
-                if ( role != null )
-                {
-                    rolesCache.put( role.getName(), role );
-                    roles.add( role );
-                }
+                Role role = buildRole( group );
+                roles.add( role );
+
 
             }
         }
@@ -397,6 +380,27 @@ public class LdapRbacManager
 
     }
 
+    private Role buildRole( String group )
+        throws RbacManagerException
+    {
+        Role role = null;
+        try
+        {
+            role = this.rbacImpl.getRole( group );
+        }
+        catch ( RbacObjectNotFoundException e )
+        {
+            // if it's mapped role to a group it doesn't exist in jdo
+        }
+        role = ( role == null ) ? new RoleImpl( group ) : role;
+        if ( role != null )
+        {
+            rolesCache.put( role.getName(), role );
+
+        }
+        return role;
+    }
+
     protected List<String> getRealRoles()
         throws RbacManagerException
     {



Mime
View raw message