better generic

git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1373647 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-08-15 21:55:43 +00:00
parent f2d0b3edc6
commit 9fb355ff92
1 changed files with 6 additions and 7 deletions

View File

@ -21,6 +21,8 @@ package org.apache.archiva.redback.rbac.cached;
import org.apache.archiva.redback.components.cache.Cache; import org.apache.archiva.redback.components.cache.Cache;
import org.apache.archiva.redback.rbac.Operation; import org.apache.archiva.redback.rbac.Operation;
import org.apache.archiva.redback.rbac.Permission;
import org.apache.archiva.redback.rbac.RBACManager;
import org.apache.archiva.redback.rbac.RBACManagerListener; import org.apache.archiva.redback.rbac.RBACManagerListener;
import org.apache.archiva.redback.rbac.RbacManagerException; import org.apache.archiva.redback.rbac.RbacManagerException;
import org.apache.archiva.redback.rbac.RbacObjectInvalidException; import org.apache.archiva.redback.rbac.RbacObjectInvalidException;
@ -28,8 +30,6 @@ import org.apache.archiva.redback.rbac.RbacObjectNotFoundException;
import org.apache.archiva.redback.rbac.Resource; import org.apache.archiva.redback.rbac.Resource;
import org.apache.archiva.redback.rbac.Role; import org.apache.archiva.redback.rbac.Role;
import org.apache.archiva.redback.rbac.UserAssignment; import org.apache.archiva.redback.rbac.UserAssignment;
import org.apache.archiva.redback.rbac.Permission;
import org.apache.archiva.redback.rbac.RBACManager;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -45,7 +45,6 @@ import java.util.Set;
* CachedRbacManager is a wrapped RBACManager with caching. * CachedRbacManager is a wrapped RBACManager with caching.
* *
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a> * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
*
*/ */
@Service( "rBACManager#cached" ) @Service( "rBACManager#cached" )
public class CachedRbacManager public class CachedRbacManager
@ -211,17 +210,17 @@ public class CachedRbacManager
public synchronized Map<String, List<Permission>> getAssignedPermissionMap( String principal ) public synchronized Map<String, List<Permission>> getAssignedPermissionMap( String principal )
throws RbacObjectNotFoundException, RbacManagerException throws RbacObjectNotFoundException, RbacManagerException
{ {
Object el = userPermissionsCache.get( principal ); Map<String, List<Permission>> el = (Map<String, List<Permission>>) userPermissionsCache.get( principal );
if ( el != null ) if ( el != null )
{ {
//log.debug( "using cached user permission map" ); log.debug( "using cached user permission map" );
return (Map<String, List<Permission>>) el; return el;
} }
else else
{ {
log.debug( "building user permission map" ); log.debug( "building user permission map" );
Map userPermMap = this.rbacImpl.getAssignedPermissionMap( principal ); Map<String, List<Permission>> userPermMap = this.rbacImpl.getAssignedPermissionMap( principal );
userPermissionsCache.put( principal, userPermMap ); userPermissionsCache.put( principal, userPermMap );
return userPermMap; return userPermMap;
} }