From 0392abb2610bff7fcb9f9de5a4a46957240b1d8a Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 23 Jan 2013 23:51:59 +0000 Subject: [PATCH] remove duplicate code git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1437806 13f79535-47bb-0310-9956-ffa450edef68 --- .../redback/rbac/ldap/LdapRbacManager.java | 48 ++++++++++--------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/main/java/org/apache/archiva/redback/rbac/ldap/LdapRbacManager.java b/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/main/java/org/apache/archiva/redback/rbac/ldap/LdapRbacManager.java index 868df6cda..f37221354 100644 --- a/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/main/java/org/apache/archiva/redback/rbac/ldap/LdapRbacManager.java +++ b/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/main/java/org/apache/archiva/redback/rbac/ldap/LdapRbacManager.java @@ -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 getRealRoles() throws RbacManagerException { -- 2.39.5