Package org.apache.fulcrum.security.spi
Class AbstractRoleManager
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.apache.fulcrum.security.spi.AbstractManager
-
- org.apache.fulcrum.security.spi.AbstractEntityManager
-
- org.apache.fulcrum.security.spi.AbstractRoleManager
-
- All Implemented Interfaces:
Serializable
,org.apache.avalon.framework.activity.Disposable
,org.apache.avalon.framework.configuration.Configurable
,org.apache.avalon.framework.logger.LogEnabled
,org.apache.avalon.framework.service.Serviceable
,org.apache.avalon.framework.thread.ThreadSafe
,RoleManager
public abstract class AbstractRoleManager extends AbstractEntityManager implements RoleManager
This implementation keeps all objects in memory. This is mostly meant to help with testing and prototyping of ideas.- Version:
- $Id$
- Author:
- Eric Pugh
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.apache.fulcrum.security.spi.AbstractManager
manager
-
Fields inherited from interface org.apache.fulcrum.security.RoleManager
ROLE
-
-
Constructor Summary
Constructors Constructor Description AbstractRoleManager()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <T extends Role>
TaddRole(T role)
Creates a new role with specified attributes.boolean
checkExists(Role role)
Check whether a specified role exists.<T extends Role>
TgetRoleById(Object id)
Retrieve a Role object with specified Id.<T extends Role>
TgetRoleByName(String name)
Retrieve a Role object with specified name.<T extends Role>
TgetRoleInstance()
Construct a blank Role object.<T extends Role>
TgetRoleInstance(String roleName)
Construct a blank Role object.protected abstract <T extends Role>
TpersistNewRole(T role)
-
Methods inherited from class org.apache.fulcrum.security.spi.AbstractEntityManager
configure, getClassName, setClassName
-
Methods inherited from class org.apache.fulcrum.security.spi.AbstractManager
dispose, getGroupManager, getPermissionManager, getRoleManager, getServiceManager, getUserManager, release, resolve, service
-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.fulcrum.security.RoleManager
checkExists, getAllRoles, removeRole, renameRole
-
-
-
-
Constructor Detail
-
AbstractRoleManager
public AbstractRoleManager()
-
-
Method Detail
-
persistNewRole
protected abstract <T extends Role> T persistNewRole(T role) throws DataBackendException
- Type Parameters:
T
- role type- Parameters:
role
- to persist- Returns:
- the Role object
- Throws:
DataBackendException
- if fail to connect to datasource
-
getRoleInstance
public <T extends Role> T getRoleInstance() throws DataBackendException
Construct a blank Role object. This method calls getRoleClass, and then creates a new object using the default constructor.- Specified by:
getRoleInstance
in interfaceRoleManager
- Type Parameters:
T
- role type- Returns:
- an object implementing Role interface.
- Throws:
DataBackendException
- if the object could not be instantiated.
-
getRoleInstance
public <T extends Role> T getRoleInstance(String roleName) throws DataBackendException
Construct a blank Role object. This method calls getRoleClass, and then creates a new object using the default constructor.- Specified by:
getRoleInstance
in interfaceRoleManager
- Type Parameters:
T
- type of role- Parameters:
roleName
- The name of the role.- Returns:
- an object implementing Role interface.
- Throws:
DataBackendException
- if the object could not be instantiated.
-
getRoleByName
public <T extends Role> T getRoleByName(String name) throws DataBackendException, UnknownEntityException
Retrieve a Role object with specified name.- Specified by:
getRoleByName
in interfaceRoleManager
- Type Parameters:
T
- type of role- Parameters:
name
- the name of the Role.- Returns:
- an object representing the Role with specified name.
- Throws:
DataBackendException
- if there was an error accessing the data backend.UnknownEntityException
- if the role does not exist.- See Also:
RoleManager.getRoleByName(java.lang.String)
-
getRoleById
public <T extends Role> T getRoleById(Object id) throws DataBackendException, UnknownEntityException
Retrieve a Role object with specified Id.- Specified by:
getRoleById
in interfaceRoleManager
- Type Parameters:
T
- the role type- Parameters:
id
- the ID of the Role.- Returns:
- an object representing the Role with specified name.
- Throws:
UnknownEntityException
- if the permission does not exist in the database.DataBackendException
- if there is a problem accessing the storage.
-
addRole
public <T extends Role> T addRole(T role) throws DataBackendException, EntityExistsException
Creates a new role with specified attributes.- Specified by:
addRole
in interfaceRoleManager
- Type Parameters:
T
- role type- Parameters:
role
- the object describing the role to be created.- Returns:
- a new Role object that has id set up properly.
- Throws:
DataBackendException
- if there was an error accessing the data backend.EntityExistsException
- if the role already exists.
-
checkExists
public boolean checkExists(Role role) throws DataBackendException
Check whether a specified role exists. The name is used for looking up the role- Specified by:
checkExists
in interfaceRoleManager
- Parameters:
role
- The role to be checked.- Returns:
- true if the specified role exists
- Throws:
DataBackendException
- if there was an error accessing the data backend.
-
-