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: AbstractRoleManager.java 1884710 2020-12-22 16:16:40Z gk $
- Author:
- Eric Pugh
- See Also:
- Serialized Form
-
Field Summary
-
Constructor Summary
Constructors Constructor Description AbstractRoleManager() -
Method Summary
Modifier and Type Method Description <T extends Role>
TaddRole(T role)Creates a new role with specified attributes.booleancheckExists(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, setClassNameMethods inherited from class org.apache.fulcrum.security.spi.AbstractManager
dispose, getGroupManager, getPermissionManager, getRoleManager, getServiceManager, getUserManager, release, resolve, serviceMethods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLoggerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.fulcrum.security.RoleManager
checkExists, getAllRoles, removeRole, renameRole
-
Constructor Details
-
AbstractRoleManager
public AbstractRoleManager()
-
-
Method Details
-
persistNewRole
- Type Parameters:
T- role type- Parameters:
role- to persist- Returns:
- the Role object
- Throws:
DataBackendException- if fail to connect to datasource
-
getRoleInstance
Construct a blank Role object. This method calls getRoleClass, and then creates a new object using the default constructor.- Specified by:
getRoleInstancein interfaceRoleManager- Type Parameters:
T- role type- Returns:
- an object implementing Role interface.
- Throws:
DataBackendException- if the object could not be instantiated.
-
getRoleInstance
Construct a blank Role object. This method calls getRoleClass, and then creates a new object using the default constructor.- Specified by:
getRoleInstancein 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, UnknownEntityExceptionRetrieve a Role object with specified name.- Specified by:
getRoleByNamein 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, UnknownEntityExceptionRetrieve a Role object with specified Id.- Specified by:
getRoleByIdin 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
Creates a new role with specified attributes.- Specified by:
addRolein 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
Check whether a specified role exists. The name is used for looking up the role- Specified by:
checkExistsin 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.
-