use a better method name

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1448651 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2013-02-21 14:35:43 +00:00
parent cf74f4eee2
commit a2c520430f

View File

@ -44,7 +44,7 @@
* @author Olivier Lamy * @author Olivier Lamy
* @since 1.4-M4 * @since 1.4-M4
*/ */
@Service("rbacManager#archiva") @Service( "rbacManager#archiva" )
public class ArchivaRbacManager public class ArchivaRbacManager
extends AbstractRBACManager extends AbstractRBACManager
implements RBACManager implements RBACManager
@ -85,26 +85,33 @@ public void initialize()
} }
} }
protected RBACManager getRbacManagerForCommon() protected RBACManager getRbacManagerForWrite()
{ {
for ( RBACManager rbacManager : this.rbacManagersPerId.values() )
{
if ( !rbacManager.isReadOnly() )
{
return rbacManager;
}
}
return this.rbacManagersPerId.values().iterator().next(); return this.rbacManagersPerId.values().iterator().next();
} }
public Role createRole( String name ) public Role createRole( String name )
{ {
return getRbacManagerForCommon().createRole( name ); return getRbacManagerForWrite().createRole( name );
} }
public Role saveRole( Role role ) public Role saveRole( Role role )
throws RbacObjectInvalidException, RbacManagerException throws RbacObjectInvalidException, RbacManagerException
{ {
return getRbacManagerForCommon().saveRole( role ); return getRbacManagerForWrite().saveRole( role );
} }
public void saveRoles( Collection<Role> roles ) public void saveRoles( Collection<Role> roles )
throws RbacObjectInvalidException, RbacManagerException throws RbacObjectInvalidException, RbacManagerException
{ {
getRbacManagerForCommon().saveRoles( roles ); getRbacManagerForWrite().saveRoles( roles );
} }
public Role getRole( String roleName ) public Role getRole( String roleName )
@ -126,180 +133,159 @@ public List<Role> getAllRoles()
throws RbacManagerException throws RbacManagerException
{ {
// iterate and aggregate results ? // iterate and aggregate results ?
return getRbacManagerForCommon().getAllRoles(); return getRbacManagerForWrite().getAllRoles();
} }
public void removeRole( Role role ) public void removeRole( Role role )
throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException
{ {
// iterate remove ? getRbacManagerForWrite().removeRole( role );
getRbacManagerForCommon().removeRole( role );
} }
public Permission createPermission( String name ) public Permission createPermission( String name )
throws RbacManagerException throws RbacManagerException
{ {
// iterate ? return getRbacManagerForWrite().createPermission( name );
return getRbacManagerForCommon().createPermission( name );
} }
public Permission createPermission( String name, String operationName, String resourceIdentifier ) public Permission createPermission( String name, String operationName, String resourceIdentifier )
throws RbacManagerException throws RbacManagerException
{ {
// iterate ? return getRbacManagerForWrite().createPermission( name, operationName, resourceIdentifier );
return getRbacManagerForCommon().createPermission( name, operationName, resourceIdentifier );
} }
public Permission savePermission( Permission permission ) public Permission savePermission( Permission permission )
throws RbacObjectInvalidException, RbacManagerException throws RbacObjectInvalidException, RbacManagerException
{ {
// iterate ? return getRbacManagerForWrite().savePermission( permission );
return getRbacManagerForCommon().savePermission( permission );
} }
public Permission getPermission( String permissionName ) public Permission getPermission( String permissionName )
throws RbacObjectNotFoundException, RbacManagerException throws RbacObjectNotFoundException, RbacManagerException
{ {
// iterate ? return getRbacManagerForWrite().getPermission( permissionName );
return getRbacManagerForCommon().getPermission( permissionName );
} }
public List<Permission> getAllPermissions() public List<Permission> getAllPermissions()
throws RbacManagerException throws RbacManagerException
{ {
// iterate and aggregate ? return getRbacManagerForWrite().getAllPermissions();
return getRbacManagerForCommon().getAllPermissions();
} }
public void removePermission( Permission permission ) public void removePermission( Permission permission )
throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException
{ {
// iterate remove ? getRbacManagerForWrite().removePermission( permission );
getRbacManagerForCommon().removePermission( permission );
} }
public Operation createOperation( String name ) public Operation createOperation( String name )
throws RbacManagerException throws RbacManagerException
{ {
// iterate ? return getRbacManagerForWrite().createOperation( name );
return getRbacManagerForCommon().createOperation( name );
} }
public Operation saveOperation( Operation operation ) public Operation saveOperation( Operation operation )
throws RbacObjectInvalidException, RbacManagerException throws RbacObjectInvalidException, RbacManagerException
{ {
// iterate ? return getRbacManagerForWrite().saveOperation( operation );
return getRbacManagerForCommon().saveOperation( operation );
} }
public Operation getOperation( String operationName ) public Operation getOperation( String operationName )
throws RbacObjectNotFoundException, RbacManagerException throws RbacObjectNotFoundException, RbacManagerException
{ {
// iterate ? return getRbacManagerForWrite().getOperation( operationName );
return getRbacManagerForCommon().getOperation( operationName );
} }
public List<Operation> getAllOperations() public List<Operation> getAllOperations()
throws RbacManagerException throws RbacManagerException
{ {
// iterate and aggregate ? return getRbacManagerForWrite().getAllOperations();
return getRbacManagerForCommon().getAllOperations();
} }
public void removeOperation( Operation operation ) public void removeOperation( Operation operation )
throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException
{ {
// iterate ? getRbacManagerForWrite().removeOperation( operation );
getRbacManagerForCommon().removeOperation( operation );
} }
public Resource createResource( String identifier ) public Resource createResource( String identifier )
throws RbacManagerException throws RbacManagerException
{ {
// iterate ? return getRbacManagerForWrite().createResource( identifier );
return getRbacManagerForCommon().createResource( identifier );
} }
public Resource saveResource( Resource resource ) public Resource saveResource( Resource resource )
throws RbacObjectInvalidException, RbacManagerException throws RbacObjectInvalidException, RbacManagerException
{ {
// iterate ? return getRbacManagerForWrite().saveResource( resource );
return getRbacManagerForCommon().saveResource( resource );
} }
public Resource getResource( String resourceIdentifier ) public Resource getResource( String resourceIdentifier )
throws RbacObjectNotFoundException, RbacManagerException throws RbacObjectNotFoundException, RbacManagerException
{ {
// iterate ? return getRbacManagerForWrite().getResource( resourceIdentifier );
return getRbacManagerForCommon().getResource( resourceIdentifier );
} }
public List<Resource> getAllResources() public List<Resource> getAllResources()
throws RbacManagerException throws RbacManagerException
{ {
// iterate and aggregate ? return getRbacManagerForWrite().getAllResources();
return getRbacManagerForCommon().getAllResources();
} }
public void removeResource( Resource resource ) public void removeResource( Resource resource )
throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException
{ {
// iterate getRbacManagerForWrite().removeResource( resource );
getRbacManagerForCommon().removeResource( resource );
} }
public UserAssignment createUserAssignment( String principal ) public UserAssignment createUserAssignment( String principal )
throws RbacManagerException throws RbacManagerException
{ {
// iterate ? return getRbacManagerForWrite().createUserAssignment( principal );
return getRbacManagerForCommon().createUserAssignment( principal );
} }
public UserAssignment saveUserAssignment( UserAssignment userAssignment ) public UserAssignment saveUserAssignment( UserAssignment userAssignment )
throws RbacObjectInvalidException, RbacManagerException throws RbacObjectInvalidException, RbacManagerException
{ {
// iterate ? return getRbacManagerForWrite().saveUserAssignment( userAssignment );
return getRbacManagerForCommon().saveUserAssignment( userAssignment );
} }
public UserAssignment getUserAssignment( String principal ) public UserAssignment getUserAssignment( String principal )
throws RbacObjectNotFoundException, RbacManagerException throws RbacObjectNotFoundException, RbacManagerException
{ {
// iterate ? return getRbacManagerForWrite().getUserAssignment( principal );
return getRbacManagerForCommon().getUserAssignment( principal );
} }
@Override @Override
public boolean userAssignmentExists( String principal ) public boolean userAssignmentExists( String principal )
{ {
return getRbacManagerForCommon().userAssignmentExists( principal ); return getRbacManagerForWrite().userAssignmentExists( principal );
} }
@Override @Override
public boolean userAssignmentExists( UserAssignment assignment ) public boolean userAssignmentExists( UserAssignment assignment )
{ {
return getRbacManagerForCommon().userAssignmentExists( assignment ); return getRbacManagerForWrite().userAssignmentExists( assignment );
} }
public List<UserAssignment> getAllUserAssignments() public List<UserAssignment> getAllUserAssignments()
throws RbacManagerException throws RbacManagerException
{ {
// iterate // iterate
return getRbacManagerForCommon().getAllUserAssignments(); return getRbacManagerForWrite().getAllUserAssignments();
} }
public List<UserAssignment> getUserAssignmentsForRoles( Collection<String> roleNames ) public List<UserAssignment> getUserAssignmentsForRoles( Collection<String> roleNames )
throws RbacManagerException throws RbacManagerException
{ {
// iterate ? // iterate ?
return getRbacManagerForCommon().getUserAssignmentsForRoles( roleNames ); return getRbacManagerForWrite().getUserAssignmentsForRoles( roleNames );
} }
public void removeUserAssignment( UserAssignment userAssignment ) public void removeUserAssignment( UserAssignment userAssignment )
throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException
{ {
// iterate ? getRbacManagerForWrite().removeUserAssignment( userAssignment );
getRbacManagerForCommon().removeUserAssignment( userAssignment );
} }
@Override @Override