mirror of https://github.com/apache/archiva.git
add some caching in the chained rbac manager
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1448661 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ea7cd81727
commit
c8adb4d673
|
@ -185,6 +185,13 @@ public class ArchivaRbacManager
|
||||||
public Role getRole( String roleName )
|
public Role getRole( String roleName )
|
||||||
throws RbacObjectNotFoundException, RbacManagerException
|
throws RbacObjectNotFoundException, RbacManagerException
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Role el = rolesCache.get( roleName );
|
||||||
|
if ( el != null )
|
||||||
|
{
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
|
||||||
Exception lastException = null;
|
Exception lastException = null;
|
||||||
for ( RBACManager rbacManager : rbacManagersPerId.values() )
|
for ( RBACManager rbacManager : rbacManagersPerId.values() )
|
||||||
{
|
{
|
||||||
|
@ -193,6 +200,7 @@ public class ArchivaRbacManager
|
||||||
Role role = rbacManager.getRole( roleName );
|
Role role = rbacManager.getRole( roleName );
|
||||||
if ( role != null )
|
if ( role != null )
|
||||||
{
|
{
|
||||||
|
rolesCache.put( role.getName(), role );
|
||||||
return role;
|
return role;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -250,6 +258,7 @@ public class ArchivaRbacManager
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
rbacManager.removeRole( role );
|
rbacManager.removeRole( role );
|
||||||
|
rolesCache.remove( role.getName() );
|
||||||
allFailed = false;
|
allFailed = false;
|
||||||
}
|
}
|
||||||
catch ( Exception e )
|
catch ( Exception e )
|
||||||
|
@ -305,6 +314,13 @@ public class ArchivaRbacManager
|
||||||
public Permission getPermission( String permissionName )
|
public Permission getPermission( String permissionName )
|
||||||
throws RbacObjectNotFoundException, RbacManagerException
|
throws RbacObjectNotFoundException, RbacManagerException
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Permission el = permissionsCache.get( permissionName );
|
||||||
|
if ( el != null )
|
||||||
|
{
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
|
||||||
Exception lastException = null;
|
Exception lastException = null;
|
||||||
for ( RBACManager rbacManager : rbacManagersPerId.values() )
|
for ( RBACManager rbacManager : rbacManagersPerId.values() )
|
||||||
{
|
{
|
||||||
|
@ -313,6 +329,7 @@ public class ArchivaRbacManager
|
||||||
Permission p = rbacManager.getPermission( permissionName );
|
Permission p = rbacManager.getPermission( permissionName );
|
||||||
if ( p != null )
|
if ( p != null )
|
||||||
{
|
{
|
||||||
|
permissionsCache.put( permissionName, p );
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -369,6 +386,7 @@ public class ArchivaRbacManager
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
rbacManager.removePermission( permission );
|
rbacManager.removePermission( permission );
|
||||||
|
permissionsCache.remove( permission.getName() );
|
||||||
allFailed = false;
|
allFailed = false;
|
||||||
}
|
}
|
||||||
catch ( Exception e )
|
catch ( Exception e )
|
||||||
|
@ -417,6 +435,13 @@ public class ArchivaRbacManager
|
||||||
public Operation getOperation( String operationName )
|
public Operation getOperation( String operationName )
|
||||||
throws RbacObjectNotFoundException, RbacManagerException
|
throws RbacObjectNotFoundException, RbacManagerException
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Operation el = operationsCache.get( operationName );
|
||||||
|
if ( el != null )
|
||||||
|
{
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
|
||||||
Exception lastException = null;
|
Exception lastException = null;
|
||||||
for ( RBACManager rbacManager : rbacManagersPerId.values() )
|
for ( RBACManager rbacManager : rbacManagersPerId.values() )
|
||||||
{
|
{
|
||||||
|
@ -425,6 +450,7 @@ public class ArchivaRbacManager
|
||||||
Operation o = rbacManager.getOperation( operationName );
|
Operation o = rbacManager.getOperation( operationName );
|
||||||
if ( o != null )
|
if ( o != null )
|
||||||
{
|
{
|
||||||
|
operationsCache.put( operationName, o );
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -481,6 +507,7 @@ public class ArchivaRbacManager
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
rbacManager.removeOperation( operation );
|
rbacManager.removeOperation( operation );
|
||||||
|
operationsCache.remove( operation.getName() );
|
||||||
allFailed = false;
|
allFailed = false;
|
||||||
}
|
}
|
||||||
catch ( Exception e )
|
catch ( Exception e )
|
||||||
|
@ -531,6 +558,12 @@ public class ArchivaRbacManager
|
||||||
throws RbacObjectNotFoundException, RbacManagerException
|
throws RbacObjectNotFoundException, RbacManagerException
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Resource el = resourcesCache.get( resourceIdentifier );
|
||||||
|
if ( el != null )
|
||||||
|
{
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
|
||||||
Exception lastException = null;
|
Exception lastException = null;
|
||||||
for ( RBACManager rbacManager : rbacManagersPerId.values() )
|
for ( RBACManager rbacManager : rbacManagersPerId.values() )
|
||||||
{
|
{
|
||||||
|
@ -539,6 +572,7 @@ public class ArchivaRbacManager
|
||||||
Resource r = rbacManager.getResource( resourceIdentifier );
|
Resource r = rbacManager.getResource( resourceIdentifier );
|
||||||
if ( r != null )
|
if ( r != null )
|
||||||
{
|
{
|
||||||
|
resourcesCache.put( resourceIdentifier, r );
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -595,6 +629,7 @@ public class ArchivaRbacManager
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
rbacManager.removeResource( resource );
|
rbacManager.removeResource( resource );
|
||||||
|
resourcesCache.remove( resource.getIdentifier() );
|
||||||
allFailed = false;
|
allFailed = false;
|
||||||
}
|
}
|
||||||
catch ( Exception e )
|
catch ( Exception e )
|
||||||
|
@ -643,6 +678,11 @@ public class ArchivaRbacManager
|
||||||
public UserAssignment getUserAssignment( String principal )
|
public UserAssignment getUserAssignment( String principal )
|
||||||
throws RbacObjectNotFoundException, RbacManagerException
|
throws RbacObjectNotFoundException, RbacManagerException
|
||||||
{
|
{
|
||||||
|
UserAssignment el = userAssignmentsCache.get( principal );
|
||||||
|
if ( el != null )
|
||||||
|
{
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
|
||||||
Exception lastException = null;
|
Exception lastException = null;
|
||||||
for ( RBACManager rbacManager : rbacManagersPerId.values() )
|
for ( RBACManager rbacManager : rbacManagersPerId.values() )
|
||||||
|
@ -652,6 +692,7 @@ public class ArchivaRbacManager
|
||||||
UserAssignment ua = rbacManager.getUserAssignment( principal );
|
UserAssignment ua = rbacManager.getUserAssignment( principal );
|
||||||
if ( ua != null )
|
if ( ua != null )
|
||||||
{
|
{
|
||||||
|
userAssignmentsCache.put( principal, ua );
|
||||||
return ua;
|
return ua;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -782,6 +823,7 @@ public class ArchivaRbacManager
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
rbacManager.removeUserAssignment( userAssignment );
|
rbacManager.removeUserAssignment( userAssignment );
|
||||||
|
userAssignmentsCache.remove( userAssignment.getPrincipal() );
|
||||||
allFailed = false;
|
allFailed = false;
|
||||||
}
|
}
|
||||||
catch ( Exception e )
|
catch ( Exception e )
|
||||||
|
@ -800,6 +842,12 @@ public class ArchivaRbacManager
|
||||||
public boolean roleExists( String name )
|
public boolean roleExists( String name )
|
||||||
throws RbacManagerException
|
throws RbacManagerException
|
||||||
{
|
{
|
||||||
|
Role r = rolesCache.get( name );
|
||||||
|
if ( r != null )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
boolean allFailed = true;
|
boolean allFailed = true;
|
||||||
Exception lastException = null;
|
Exception lastException = null;
|
||||||
for ( RBACManager rbacManager : rbacManagersPerId.values() )
|
for ( RBACManager rbacManager : rbacManagersPerId.values() )
|
||||||
|
|
Loading…
Reference in New Issue