@ThreadSafe public final class RoleManager extends AbstractSimpleDAO implements IRoleManager, IReloadableDAO
IDAO.EMode| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEFAULT_CREATE_DEFAULTS |
DEFAULT_AUTO_SAVE_ENABLED, m_aRWLock| Constructor and Description |
|---|
RoleManager(String sFilename) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
containsAllRolesWithID(Collection<String> aRoleIDs)
Check if all passed role IDs are contained
|
boolean |
containsRoleWithID(String sRoleID)
Check if the role with the specified ID is contained
|
IRole |
createNewRole(String sName,
String sDescription,
Map<String,?> aCustomAttrs)
Create a new role.
|
IRole |
createPredefinedRole(String sID,
String sName,
String sDescription,
Map<String,?> aCustomAttrs)
Create a predefined role.
|
protected com.helger.commons.microdom.IMicroDocument |
createWriteData()
Create the XML document that should be saved to the file.
|
com.helger.commons.state.EChange |
deleteRole(String sRoleID)
Delete the role with the passed ID
|
Collection<? extends IRole> |
getAllRoles() |
com.helger.commons.callback.CallbackList<IRoleModificationCallback> |
getRoleModificationCallbacks() |
Role |
getRoleOfID(String sRoleID)
Get the role with the specified ID
|
static boolean |
isCreateDefaults() |
protected com.helger.commons.state.EChange |
onInit()
Custom initialization routine.
|
protected com.helger.commons.state.EChange |
onRead(com.helger.commons.microdom.IMicroDocument aDoc)
Fill the internal structures with from the passed XML document.
|
void |
reload()
Call this method to reload the content from the original source.
|
com.helger.commons.state.EChange |
renameRole(String sRoleID,
String sNewName)
Rename the role with the passed ID
|
static void |
setCreateDefaults(boolean bCreateDefaults) |
com.helger.commons.state.EChange |
setRoleData(String sRoleID,
String sNewName,
String sNewDescription,
Map<String,?> aNewCustomAttrs)
Change the modifiable data of a user group
|
beforeWriteToFile, getDAOIO, getFilenameProvider, getInitCount, getLastFilename, getLastInitDateTime, getLastReadDateTime, getLastWriteDateTime, getReadCount, getSafeFile, getWriteCount, getXMLWriterSettings, initialRead, markAsChanged, modifyWriteData, onFilenameChange, toString, triggerExceptionHandlersRead, triggerExceptionHandlersWrite, writeToFileOnPendingChangesbeginWithoutAutoSave, endWithoutAutoSave, getExceptionHandlersRead, getExceptionHandlersWrite, hasPendingChanges, internalHasPendingChanges, internalIsAutoSaveEnabled, internalSetPendingChanges, isAutoSaveEnabled, performWithoutAutoSave, performWithoutAutoSave, performWithoutAutoSave, performWithoutAutoSaveclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetInitCount, getLastInitDateTime, getLastReadDateTime, getLastWriteDateTime, getReadCount, getWriteCount, writeToFileOnPendingChangeshasPendingChangesbeginWithoutAutoSave, endWithoutAutoSave, isAutoSaveEnabled, performWithoutAutoSave, performWithoutAutoSavepublic static final boolean DEFAULT_CREATE_DEFAULTS
public RoleManager(@Nonnull@Nonempty String sFilename) throws DAOException
DAOExceptionpublic static boolean isCreateDefaults()
true if the default built-in roles should be created
if no roles are present, false if not.public static void setCreateDefaults(boolean bCreateDefaults)
public void reload()
throws DAOException
IReloadableDAOreload in interface IReloadableDAODAOException - in case reloading fails@Nonnull protected com.helger.commons.state.EChange onInit()
AbstractSimpleDAOonInit in class AbstractSimpleDAOEChange.CHANGED if something was modified inside this
method@Nonnull protected com.helger.commons.state.EChange onRead(@Nonnull com.helger.commons.microdom.IMicroDocument aDoc)
AbstractSimpleDAOonRead in class AbstractSimpleDAOaDoc - The XML document to read from. Never null.EChange.CHANGED if reading the data changed something in
the internal structures that requires a writing.@Nonnull protected com.helger.commons.microdom.IMicroDocument createWriteData()
AbstractSimpleDAOcreateWriteData in class AbstractSimpleDAOnull document to write to the file.@Nonnull @ReturnsMutableObject(reason="design") public com.helger.commons.callback.CallbackList<IRoleModificationCallback> getRoleModificationCallbacks()
getRoleModificationCallbacks in interface IRoleManagernull.@Nonnull public IRole createNewRole(@Nonnull@Nonempty String sName, @Nullable String sDescription, @Nullable Map<String,?> aCustomAttrs)
IRoleManagercreateNewRole in interface IRoleManagersName - The name of the new role. May neither be null nor
empty.sDescription - Optional description text. May be null.aCustomAttrs - A set of custom attributes. May be null.null.@Nonnull public IRole createPredefinedRole(@Nonnull@Nonempty String sID, @Nonnull@Nonempty String sName, @Nullable String sDescription, @Nullable Map<String,?> aCustomAttrs)
IRoleManagercreatePredefinedRole in interface IRoleManagersID - The ID of the new rolesName - The name of the new rolesDescription - Optional description text. May be null.aCustomAttrs - A set of custom attributes. May be null.null.public boolean containsRoleWithID(@Nullable String sRoleID)
IRoleManagercontainsRoleWithID in interface IRoleManagersRoleID - The role ID to be checktrue if such role exists, false otherwisepublic boolean containsAllRolesWithID(@Nullable Collection<String> aRoleIDs)
IRoleManagercontainsAllRolesWithID in interface IRoleManageraRoleIDs - The role IDs to be checked. May be null.true if the collection is empty or if all contained
role IDs are contained@Nullable public Role getRoleOfID(@Nullable String sRoleID)
IRoleManagergetRoleOfID in interface IRoleManagersRoleID - The role ID to be resolvednull if no such role exists.@Nonnull @ReturnsMutableCopy public Collection<? extends IRole> getAllRoles()
getAllRoles in interface IRoleManagernull collection of all available roles@Nonnull public com.helger.commons.state.EChange deleteRole(@Nullable String sRoleID)
IRoleManagerdeleteRole in interface IRoleManagersRoleID - The role ID to be deletedEChange.CHANGED if the passed role ID was found and deleted@Nonnull public com.helger.commons.state.EChange renameRole(@Nullable String sRoleID, @Nonnull@Nonempty String sNewName)
IRoleManagerrenameRole in interface IRoleManagersRoleID - The ID of the role to be renamed. May be null.sNewName - The new name of the role. May neither be null nor
empty.EChange.CHANGED if the passed role ID was found, and the
new name is different from the old name of he role@Nonnull public com.helger.commons.state.EChange setRoleData(@Nullable String sRoleID, @Nonnull@Nonempty String sNewName, @Nullable String sNewDescription, @Nullable Map<String,?> aNewCustomAttrs)
IRoleManagersetRoleData in interface IRoleManagersRoleID - The ID of the role to be renamed. May be null.sNewName - The new name of the role. May neither be null nor
empty.sNewDescription - The new description text. May be null.aNewCustomAttrs - Custom attributes. May be null.EChangeCopyright © 2014–2015 Philip Helger. All rights reserved.