@ThreadSafe public class UserGroupManager extends AbstractSimpleDAO implements IUserGroupManager, IReloadableDAO
IDAO.EMode| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEFAULT_CREATE_DEFAULTS |
DEFAULT_AUTO_SAVE_ENABLED, m_aRWLock| Constructor and Description |
|---|
UserGroupManager(String sFilename,
IUserManager aUserMgr,
IRoleManager aRoleMgr) |
| Modifier and Type | Method and Description |
|---|---|
com.helger.commons.state.EChange |
assignRoleToUserGroup(String sUserGroupID,
String sRoleID)
Assign the passed role ID to the user group with the passed ID.
|
com.helger.commons.state.EChange |
assignUserToUserGroup(String sUserGroupID,
String sUserID)
Assign the passed user ID to the passed user group.
|
boolean |
containsAllUserGroupsWithID(Collection<String> aUserGroupIDs)
Check if all passed user group IDs are contained
|
boolean |
containsUserGroupWithID(String sUserGroupID)
Check if a user group with the specified ID is contained
|
IUserGroup |
createNewUserGroup(String sName,
String sDescription,
Map<String,?> aCustomAttrs)
Create a new user group.
|
IUserGroup |
createPredefinedUserGroup(String sID,
String sName,
String sDescription,
Map<String,?> aCustomAttrs)
Create a predefined user group.
|
protected com.helger.commons.microdom.IMicroDocument |
createWriteData()
Create the XML document that should be saved to the file.
|
com.helger.commons.state.EChange |
deleteUserGroup(String sUserGroupID)
Delete the user group with the specified ID
|
List<String> |
getAllUserGroupIDsWithAssignedRole(String sRoleID)
Get a collection of all user group IDs to which a certain role is assigned
to.
|
List<String> |
getAllUserGroupIDsWithAssignedUser(String sUserID)
Get a collection of all user group IDs to which a certain user is assigned
to.
|
List<? extends IUserGroup> |
getAllUserGroups() |
List<IUserGroup> |
getAllUserGroupsWithAssignedRole(String sRoleID)
Get a collection of all user groups to which a certain role is assigned to.
|
List<IUserGroup> |
getAllUserGroupsWithAssignedUser(String sUserID)
Get a collection of all user groups to which a certain user is assigned to.
|
IRoleManager |
getRoleManager() |
com.helger.commons.callback.CallbackList<IUserGroupModificationCallback> |
getUserGroupModificationCallbacks() |
UserGroup |
getUserGroupOfID(String sUserGroupID)
Get the user group with the specified ID
|
IUserManager |
getUserManager() |
static boolean |
isCreateDefaults() |
boolean |
isUserAssignedToUserGroup(String sUserGroupID,
String sUserID)
Check if the passed user is assigned to the specified user group
|
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 |
renameUserGroup(String sUserGroupID,
String sNewName)
Rename the user group with the specified ID
|
static void |
setCreateDefaults(boolean bCreateDefaults) |
com.helger.commons.state.EChange |
setUserGroupData(String sUserGroupID,
String sNewName,
String sNewDescription,
Map<String,?> aNewCustomAttrs)
Change the modifiable data of a user group
|
com.helger.commons.state.EChange |
unassignRoleFromAllUserGroups(String sRoleID)
Unassign the passed role ID from existing user groups.
|
com.helger.commons.state.EChange |
unassignRoleFromUserGroup(String sUserGroupID,
String sRoleID)
Unassign the passed role ID from the passed user group ID
|
com.helger.commons.state.EChange |
unassignUserFromAllUserGroups(String sUserID)
Unassign the passed user ID from all user groups.
|
com.helger.commons.state.EChange |
unassignUserFromUserGroup(String sUserGroupID,
String sUserID)
Unassign the specified user ID from the passed user group ID.
|
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 UserGroupManager(@Nonnull@Nonempty String sFilename, @Nonnull IUserManager aUserMgr, @Nonnull IRoleManager aRoleMgr) throws DAOException
DAOExceptionpublic static boolean isCreateDefaults()
public static void setCreateDefaults(boolean bCreateDefaults)
@Nonnull public final IUserManager getUserManager()
@Nonnull public final IRoleManager getRoleManager()
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<IUserGroupModificationCallback> getUserGroupModificationCallbacks()
getUserGroupModificationCallbacks in interface IUserGroupManagernull.@Nonnull public IUserGroup createNewUserGroup(@Nonnull@Nonempty String sName, @Nullable String sDescription, @Nullable Map<String,?> aCustomAttrs)
IUserGroupManagercreateNewUserGroup in interface IUserGroupManagersName - The name of the user group to create. May neither be
null nor empty.sDescription - The optional description of the user group. May be null
.aCustomAttrs - A set of custom attributes. May be null.@Nonnull public IUserGroup createPredefinedUserGroup(@Nonnull@Nonempty String sID, @Nonnull@Nonempty String sName, @Nullable String sDescription, @Nullable Map<String,?> aCustomAttrs)
IUserGroupManagercreatePredefinedUserGroup in interface IUserGroupManagersID - The ID to usesName - The name of the user group to create. May neither be
null nor empty.sDescription - The optional description of the user group. May be null
.aCustomAttrs - A set of custom attributes. May be null.public boolean containsUserGroupWithID(@Nullable String sUserGroupID)
IUserGroupManagercontainsUserGroupWithID in interface IUserGroupManagersUserGroupID - The ID of the user group to checktrue if no user group exists, false
otherwise.public boolean containsAllUserGroupsWithID(@Nullable Collection<String> aUserGroupIDs)
IUserGroupManagercontainsAllUserGroupsWithID in interface IUserGroupManageraUserGroupIDs - The user group IDs to be checked. May be null.true if the collection is empty or if all contained
user group IDs are contained@Nullable public UserGroup getUserGroupOfID(@Nullable String sUserGroupID)
IUserGroupManagergetUserGroupOfID in interface IUserGroupManagersUserGroupID - The ID of the user group to searchnull if no such user group exists@Nonnull @ReturnsMutableCopy public List<? extends IUserGroup> getAllUserGroups()
getAllUserGroups in interface IUserGroupManagernull list of all user groups@Nonnull public com.helger.commons.state.EChange deleteUserGroup(@Nullable String sUserGroupID)
IUserGroupManagerdeleteUserGroup in interface IUserGroupManagersUserGroupID - The ID of the user group to be deleted. May be null.EChange.CHANGED if the user group was deleted,
EChange.UNCHANGED otherwise@Nonnull public com.helger.commons.state.EChange renameUserGroup(@Nullable String sUserGroupID, @Nonnull@Nonempty String sNewName)
IUserGroupManagerrenameUserGroup in interface IUserGroupManagersUserGroupID - The ID of the user group. May be null.sNewName - The new name of the user group. May neither be null nor
empty.EChange.CHANGED if the user group ID was valid, and the new
name was different from the old name@Nonnull public com.helger.commons.state.EChange setUserGroupData(@Nullable String sUserGroupID, @Nonnull@Nonempty String sNewName, @Nullable String sNewDescription, @Nullable Map<String,?> aNewCustomAttrs)
IUserGroupManagersetUserGroupData in interface IUserGroupManagersUserGroupID - The ID of the user group. May be null.sNewName - The new name of the user group. May neither be null nor
empty.sNewDescription - The optional new description of the user group. May be
null .aNewCustomAttrs - Custom attributes. May be null.EChange@Nonnull public com.helger.commons.state.EChange assignUserToUserGroup(@Nullable String sUserGroupID, @Nonnull@Nonempty String sUserID)
IUserGroupManagerassignUserToUserGroup in interface IUserGroupManagersUserGroupID - ID of the user group to assign tosUserID - ID of the user to be assigned.EChange.CHANGED if the user group ID was valid, and the
specified user ID was not already contained.@Nonnull public com.helger.commons.state.EChange unassignUserFromUserGroup(@Nullable String sUserGroupID, @Nullable String sUserID)
IUserGroupManagerunassignUserFromUserGroup in interface IUserGroupManagersUserGroupID - The ID of the user group to unassign the user ID fromsUserID - The user ID to be unassignedEChange.CHANGED if the user group ID was resolved, and the
passed user ID was assigned to the user group@Nonnull public com.helger.commons.state.EChange unassignUserFromAllUserGroups(@Nullable String sUserID)
IUserGroupManagerunassignUserFromAllUserGroups in interface IUserGroupManagersUserID - ID of the user to be unassigned.EChange.CHANGED if the passed user ID was at least assigned
to one user group.public boolean isUserAssignedToUserGroup(@Nullable String sUserGroupID, @Nullable String sUserID)
IUserGroupManagerisUserAssignedToUserGroup in interface IUserGroupManagersUserGroupID - ID of the user group to checksUserID - ID of the user to be checked.true if the specified user is assigned to the
specified user group.@Nonnull @ReturnsMutableCopy public List<IUserGroup> getAllUserGroupsWithAssignedUser(@Nullable String sUserID)
IUserGroupManagergetAllUserGroupsWithAssignedUser in interface IUserGroupManagersUserID - The user ID to searchnullbut may be empty collection with all
matching user groups.@Nonnull @ReturnsMutableCopy public List<String> getAllUserGroupIDsWithAssignedUser(@Nullable String sUserID)
IUserGroupManagergetAllUserGroupIDsWithAssignedUser in interface IUserGroupManagersUserID - The user ID to searchnullbut may be empty collection with all
matching user group IDs.@Nonnull public com.helger.commons.state.EChange assignRoleToUserGroup(@Nullable String sUserGroupID, @Nonnull@Nonempty String sRoleID)
IUserGroupManagerassignRoleToUserGroup in interface IUserGroupManagersUserGroupID - The ID of the user group to assign the role to.sRoleID - The ID of the role to be assignedEChange.CHANGED if the passed user group ID was resolved,
and the role ID was not already previously contained@Nonnull public com.helger.commons.state.EChange unassignRoleFromUserGroup(@Nullable String sUserGroupID, @Nullable String sRoleID)
IUserGroupManagerunassignRoleFromUserGroup in interface IUserGroupManagersUserGroupID - The ID of the user group to unassign the role ID fromsRoleID - The role ID to be unassigned.EChange.CHANGED if the user group ID was resolved and the
passed role ID was contained@Nonnull public com.helger.commons.state.EChange unassignRoleFromAllUserGroups(@Nullable String sRoleID)
IUserGroupManagerunassignRoleFromAllUserGroups in interface IUserGroupManagersRoleID - The role ID to be unassignedEChange.CHANGED if the passed role ID was contained in at
least one user group@Nonnull @ReturnsMutableCopy public List<IUserGroup> getAllUserGroupsWithAssignedRole(@Nullable String sRoleID)
IUserGroupManagergetAllUserGroupsWithAssignedRole in interface IUserGroupManagersRoleID - The role ID to searchnullbut may be empty collection with all
matching user groups.@Nonnull @ReturnsMutableCopy public List<String> getAllUserGroupIDsWithAssignedRole(@Nullable String sRoleID)
IUserGroupManagergetAllUserGroupIDsWithAssignedRole in interface IUserGroupManagersRoleID - The role ID to searchnullbut may be empty collection with all
matching user group IDs.Copyright © 2014–2015 Philip Helger. All rights reserved.