return null;
}
+ @Override
+ public Role createRole( String id, String name )
+ {
+ return null;
+ }
+
@Override
public boolean roleExists( String name )
{
return false;
}
+ @Override
+ public boolean roleExistsById( String id ) throws RbacManagerException
+ {
+ return false;
+ }
+
@Override
public boolean roleExists( Role role )
{
return null;
}
+ @Override
+ public Role getRoleById( String id ) throws RbacObjectNotFoundException, RbacManagerException
+ {
+ return null;
+ }
+
@Override
public Map<String, Role> getRoles( Collection<String> roleNames )
throws RbacObjectNotFoundException, RbacManagerException
//To change body of implemented methods use File | Settings | File Templates.
}
+ @Override
+ public void removeRoleById( String id ) throws RbacObjectNotFoundException, RbacManagerException
+ {
+
+ }
+
@Override
public Permission createPermission( String name )
throws RbacManagerException
@Named( value = "cache#roles" )
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;
operationsCache.clear();
permissionsCache.clear();
rolesCache.clear();
+ rolesByIdCache.clear();
userAssignmentsCache.clear();
userPermissionsCache.clear();
effectiveRoleSetCache.clear();
return getRbacManagerForWrite().createRole( name );
}
+ @Override
+ public Role createRole( String id, String name )
+ {
+ return getRbacManagerForWrite( ).createRole( id, name );
+ }
+
@Override
public Role saveRole( Role role )
throws RbacObjectInvalidException, RbacManagerException
if ( role != null )
{
rolesCache.put( role.getName(), role );
+ rolesByIdCache.put( role.getId( ), role );
return role;
}
}
{
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
{
rbacManager.removeRole( role );
rolesCache.remove( role.getName() );
+ rolesByIdCache.remove( role.getId( ) );
allFailed = false;
}
catch ( Exception e )