aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-web/archiva-web-common
diff options
context:
space:
mode:
authorMartin Stockhammer <martin_s@apache.org>2020-11-16 17:26:53 +0100
committerMartin Stockhammer <martin_s@apache.org>2020-11-16 17:26:53 +0100
commita2442befca1e7b9c9f81cc434d86cf7b7ed8cd41 (patch)
treececd5d6dcf98358a25508f0e14c6080ac35cd4a7 /archiva-modules/archiva-web/archiva-web-common
parent1c28c3ea58eba6a2a5128ad067b16c7a4567d59d (diff)
downloadarchiva-a2442befca1e7b9c9f81cc434d86cf7b7ed8cd41.tar.gz
archiva-a2442befca1e7b9c9f81cc434d86cf7b7ed8cd41.zip
Update after redback API changes
Diffstat (limited to 'archiva-modules/archiva-web/archiva-web-common')
-rw-r--r--archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java50
-rw-r--r--archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/RoleManagerStub.java2
2 files changed, 50 insertions, 2 deletions
diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java
index 67dc4b7a4..d0995b735 100644
--- a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java
+++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java
@@ -80,6 +80,10 @@ public class ArchivaRbacManager
private Cache<String, Role> rolesCache;
@Inject
+ @Named( value = "cache#rolesById" )
+ private Cache<String, Role> rolesByIdCache;
+
+ @Inject
@Named( value = "cache#userAssignments" )
private Cache<String, UserAssignment> userAssignmentsCache;
@@ -134,6 +138,7 @@ public class ArchivaRbacManager
operationsCache.clear();
permissionsCache.clear();
rolesCache.clear();
+ rolesByIdCache.clear();
userAssignmentsCache.clear();
userPermissionsCache.clear();
effectiveRoleSetCache.clear();
@@ -161,6 +166,12 @@ public class ArchivaRbacManager
}
@Override
+ public Role createRole( String id, String name )
+ {
+ return getRbacManagerForWrite( ).createRole( id, name );
+ }
+
+ @Override
public Role saveRole( Role role )
throws RbacObjectInvalidException, RbacManagerException
{
@@ -235,6 +246,7 @@ public class ArchivaRbacManager
if ( role != null )
{
rolesCache.put( role.getName(), role );
+ rolesByIdCache.put( role.getId( ), role );
return role;
}
}
@@ -248,7 +260,42 @@ public class ArchivaRbacManager
{
throw new RbacManagerException( lastException.getMessage(), lastException );
}
- return null;
+ throw new RbacObjectNotFoundException( "Role not found " + roleName );
+ }
+
+ @Override
+ public Role getRoleById( String id ) throws RbacObjectNotFoundException, RbacManagerException
+ {
+ Role el = rolesByIdCache.get( id );
+ if ( el != null )
+ {
+ return el;
+ }
+
+ Exception lastException = null;
+ for ( RBACManager rbacManager : rbacManagersPerId.values() )
+ {
+ try
+ {
+ Role role = rbacManager.getRoleById( id );
+ if ( role != null )
+ {
+ rolesCache.put( role.getName(), role );
+ rolesByIdCache.put( role.getId( ), role );
+ return role;
+ }
+ }
+ catch ( Exception e )
+ {
+ lastException = e;
+ }
+ }
+ log.debug( "cannot find role for id: ‘{}", id );
+ if ( lastException != null )
+ {
+ throw new RbacManagerException( lastException.getMessage(), lastException );
+ }
+ throw new RbacObjectNotFoundException( "Role not found " + id );
}
@Override
@@ -295,6 +342,7 @@ public class ArchivaRbacManager
{
rbacManager.removeRole( role );
rolesCache.remove( role.getName() );
+ rolesByIdCache.remove( role.getId( ) );
allFailed = false;
}
catch ( Exception e )
diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/RoleManagerStub.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/RoleManagerStub.java
index 7b3e31200..442f21d37 100644
--- a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/RoleManagerStub.java
+++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/RoleManagerStub.java
@@ -61,7 +61,7 @@ public class RoleManagerStub
}
@Override
- public void updateRole( String templateId, String oldResource, String newResource )
+ public void moveTemplatedRole( String templateId, String oldResource, String newResource )
throws RoleManagerException
{
//To change body of implemented methods use File | Settings | File Templates.