Package org.silverpeas.core.admin.user
Class GroupManager
- java.lang.Object
-
- org.silverpeas.core.admin.user.GroupManager
-
-
Field Summary
Fields Modifier and Type Field Description static String
GROUP
static String
GROUP_MANAGER_ADD_GROUP
static String
GROUP_MANAGER_DELETE_GROUP
static String
GROUP_MANAGER_GET_GROUPS_OF_DOMAIN
static String
GROUP_MANAGER_UPDATE_GROUP
static String
IN_GROUP
static String
IN_SILVERPEAS_MESSAGE
-
Constructor Summary
Constructors Modifier Constructor Description protected
GroupManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
addGroup(GroupDetail group, boolean onlyInSilverpeas, boolean indexation)
Add the given group in Silverpeasvoid
addUserInGroup(String sUserId, String sGroupId)
Add a user to a groupvoid
addUsersInGroup(List<String> userIds, String groupId)
List<GroupDetail>
deleteGroup(GroupDetail group, boolean onlyInSilverpeas)
Delete the group with the given id.static GroupManager
get()
List<GroupDetail>
getAllDirectGroupsOfUser(String sUserId)
Get the direct group ids, whatever theirGroupState
, containing a user.List<GroupDetail>
getAllGroups()
List<String>
getAllGroupsOfUser(String userId)
Get allGroupState.VALID
group ids containing a user.List<GroupDetail>
getAllRootGroups()
Gets all the root user groups in Silverpeas.List<String>
getAllSubGroupIdsRecursively(String superGroupId)
Get the all theGroupState.VALID
subgroup ids of a given group.List<String>
getDirectGroupIdsInRole(String roleId, boolean includeRemoved)
List<String>
getDirectGroupIdsInSpaceRole(String spaceRoleId, boolean includeRemoved)
List<GroupDetail>
getDirectGroupsOfUser(String userId)
Get the directGroupState.VALID
group ids containing a user.GroupDetail
getGroup(String groupId)
Get group information with the given id from SilverpeasGroupDetail
getGroupByNameInDomain(String sGroupName, String sDomainFatherId)
Get group information with the given name and in the specified domain.String
getGroupIdBySpecificIdAndDomainId(String sSpecificId, String sDomainId)
Get the Silverpeas identifier of the group by its identifier specific to the specified domain.SilverpeasList<GroupDetail>
getGroupsMatchingCriteria(GroupsSearchCriteria criteria)
Gets theGroupState.VALID
groups that match the specified criteria.List<GroupDetail>
getGroupsOfDomain(String domainId)
Get the groups of domain, including these withGroupState.REMOVED
state.List<String>
getManageableGroupIds(String userId, List<String> groupIds)
List<String>
getPathToGroup(String groupId)
Get the path from root to the given group.List<GroupDetail>
getRecursivelySubGroups(String groupId)
List<GroupDetail>
getRemovedGroupsOfDomains(String... domainIds)
Gets all the removed groups in the specified domains.GroupDetail[]
getRootGroupsOfDomain(String sDomainId)
Gets all the root groups of the specified domain.List<GroupDetail>
getSubGroups(String groupId)
List<GroupDetail>
getSynchronizedGroups()
int
getTotalUserCountInGroup(String domainId, String groupId)
Gets the total number of users in the specified group, that is to say the number of distinct users in the specified group and in its subgroups.boolean
isGroupExist(String sName)
/** Check if there is at least one group in Silverpeas having the specified name.List<GroupDetail>
removeGroup(GroupDetail group, boolean indexation)
Removes the given group in Silverpeas.void
removeUserFromGroup(String sUserId, String sGroupId)
Remove a user from a groupvoid
removeUsersFromGroup(List<String> userIds, String groupId)
List<GroupDetail>
restoreGroup(GroupDetail group, boolean indexation)
Restores the given group in Silverpeas.String
updateGroup(GroupDetail group, boolean onlyInSilverpeas)
Update the given group
-
-
-
Field Detail
-
GROUP
public static final String GROUP
- See Also:
- Constant Field Values
-
GROUP_MANAGER_GET_GROUPS_OF_DOMAIN
public static final String GROUP_MANAGER_GET_GROUPS_OF_DOMAIN
- See Also:
- Constant Field Values
-
GROUP_MANAGER_ADD_GROUP
public static final String GROUP_MANAGER_ADD_GROUP
- See Also:
- Constant Field Values
-
GROUP_MANAGER_UPDATE_GROUP
public static final String GROUP_MANAGER_UPDATE_GROUP
- See Also:
- Constant Field Values
-
IN_GROUP
public static final String IN_GROUP
- See Also:
- Constant Field Values
-
GROUP_MANAGER_DELETE_GROUP
public static final String GROUP_MANAGER_DELETE_GROUP
- See Also:
- Constant Field Values
-
IN_SILVERPEAS_MESSAGE
public static final String IN_SILVERPEAS_MESSAGE
- See Also:
- Constant Field Values
-
-
Method Detail
-
get
public static GroupManager get()
-
getGroupsMatchingCriteria
public SilverpeasList<GroupDetail> getGroupsMatchingCriteria(GroupsSearchCriteria criteria) throws AdminException
Gets theGroupState.VALID
groups that match the specified criteria.- Parameters:
criteria
- the criteria in searching of user groups.- Returns:
- a slice of the list of user groups matching the criteria or an empty list of no ones are found.
- Throws:
AdminException
- if an error occurs while getting the user groups.
-
getTotalUserCountInGroup
public int getTotalUserCountInGroup(String domainId, String groupId) throws AdminException
Gets the total number of users in the specified group, that is to say the number of distinct users in the specified group and in its subgroups.- Parameters:
domainId
- the unique identifier to which the group belong.groupId
- the unique identifier of the group.- Returns:
- the total users count in the specified group.
- Throws:
AdminException
- if an error occurs while computing the user count.
-
addUserInGroup
public void addUserInGroup(String sUserId, String sGroupId) throws AdminException
Add a user to a group- Parameters:
sUserId
- the unique identifier of the user.sGroupId
- the unique identifier of the group.- Throws:
AdminException
- if the user cannot be added into the group.
-
addUsersInGroup
public void addUsersInGroup(List<String> userIds, String groupId) throws AdminException
- Throws:
AdminException
-
removeUserFromGroup
public void removeUserFromGroup(String sUserId, String sGroupId) throws AdminException
Remove a user from a group- Parameters:
sUserId
- the unique identifier of the user.sGroupId
- the unique identifier of the group.- Throws:
AdminException
- if the removing of the user from the group fails.
-
removeUsersFromGroup
public void removeUsersFromGroup(List<String> userIds, String groupId) throws AdminException
- Throws:
AdminException
-
getDirectGroupIdsInSpaceRole
public List<String> getDirectGroupIdsInSpaceRole(String spaceRoleId, boolean includeRemoved) throws AdminException
- Throws:
AdminException
-
getDirectGroupsOfUser
public List<GroupDetail> getDirectGroupsOfUser(String userId) throws AdminException
Get the directGroupState.VALID
group ids containing a user. Groups that the user is linked to by transitivity are not returned.- Parameters:
userId
- an identifier of a user.- Returns:
- a list of
GroupDetail
instance. - Throws:
AdminException
- in any technical error.
-
getAllDirectGroupsOfUser
public List<GroupDetail> getAllDirectGroupsOfUser(String sUserId) throws AdminException
Get the direct group ids, whatever theirGroupState
, containing a user. Groups that the user is linked to by transitivity are not returned.- Parameters:
sUserId
- an identifier of a user.- Returns:
- a list of
GroupDetail
instance. - Throws:
AdminException
- in any technical error.
-
getAllGroupsOfUser
public List<String> getAllGroupsOfUser(String userId) throws AdminException
Get allGroupState.VALID
group ids containing a user. So, groups that the user is linked to by transitivity are returned too (recursive treatment).- Parameters:
userId
- identifier of a user.- Returns:
- list of group identifiers.
- Throws:
AdminException
- on any technical error.
-
getGroupIdBySpecificIdAndDomainId
public String getGroupIdBySpecificIdAndDomainId(String sSpecificId, String sDomainId) throws AdminException
Get the Silverpeas identifier of the group by its identifier specific to the specified domain.- Parameters:
sSpecificId
- the specific identifier of the group in the user domain it belongs to.sDomainId
- the unique identifier of the domain in which the group is defined.- Returns:
- the unique identifier of the group in Silverpeas.
- Throws:
AdminException
- if an error occurs while getting the unique identifier of the group.
-
getAllGroups
public List<GroupDetail> getAllGroups() throws AdminException
- Throws:
AdminException
-
getAllRootGroups
public List<GroupDetail> getAllRootGroups() throws AdminException
Gets all the root user groups in Silverpeas.- Returns:
- a list of root user groups.
- Throws:
AdminException
- if an error occurs while getting the root groups.
-
getSubGroups
public List<GroupDetail> getSubGroups(String groupId) throws AdminException
- Throws:
AdminException
-
getRecursivelySubGroups
public List<GroupDetail> getRecursivelySubGroups(String groupId) throws AdminException
- Throws:
AdminException
-
getPathToGroup
public List<String> getPathToGroup(String groupId) throws AdminException
Get the path from root to the given group.- Parameters:
groupId
- the unique identifier of a group.- Returns:
- a list of hierachical parent groups, from the root one to the direct parent of the specified group.
- Throws:
AdminException
- if an error occurs while getting the path of the specified group.
-
isGroupExist
public boolean isGroupExist(String sName) throws AdminException
/** Check if there is at least one group in Silverpeas having the specified name.- Parameters:
sName
- the name of a group.- Returns:
- true if at least one group with the given name exists in Silverpeas. False otherwise.
- Throws:
AdminException
- if an error occurs while checking the name.
-
getGroup
public GroupDetail getGroup(String groupId) throws AdminException
Get group information with the given id from Silverpeas- Parameters:
groupId
- the unique identifier of a group.- Returns:
- the group with the given identifier.
- Throws:
AdminException
- if an error occurs while getting the group and setting its direct users.
-
getAllSubGroupIdsRecursively
public List<String> getAllSubGroupIdsRecursively(String superGroupId) throws AdminException
Get the all theGroupState.VALID
subgroup ids of a given group.- Parameters:
superGroupId
- the identifier of the parent group.- Returns:
- a list of group identifier.
- Throws:
AdminException
- in case of any technical error.
-
getGroupByNameInDomain
public GroupDetail getGroupByNameInDomain(String sGroupName, String sDomainFatherId) throws AdminException
Get group information with the given name and in the specified domain.- Parameters:
sGroupName
- the name of a group.sDomainFatherId
- the unique identifier of a domain.- Returns:
- the group or null if no such group exists.
- Throws:
AdminException
- if an error occurs while getting the group details.
-
getRootGroupsOfDomain
public GroupDetail[] getRootGroupsOfDomain(String sDomainId) throws AdminException
Gets all the root groups of the specified domain.- Parameters:
sDomainId
- the unique identifier of a domain.- Returns:
- an array with all the root groups details.
- Throws:
AdminException
- if an error occurs while getting the root groups of the given domain.
-
getSynchronizedGroups
public List<GroupDetail> getSynchronizedGroups() throws AdminException
- Throws:
AdminException
-
getGroupsOfDomain
public List<GroupDetail> getGroupsOfDomain(String domainId) throws AdminException
Get the groups of domain, including these withGroupState.REMOVED
state.- Parameters:
domainId
- the identifier of the domain.- Returns:
- a list of
GroupDetail
instance. - Throws:
AdminException
- if any technical occurs.
-
getDirectGroupIdsInRole
public List<String> getDirectGroupIdsInRole(String roleId, boolean includeRemoved) throws AdminException
- Throws:
AdminException
-
addGroup
public String addGroup(GroupDetail group, boolean onlyInSilverpeas, boolean indexation) throws AdminException
Add the given group in Silverpeas- Parameters:
group
- the group to add.onlyInSilverpeas
- a flag indicating if the group has to be added in Silverpeas only and not also in the domain. The mixed domain is a specific domain of Silverpeas and the flag should be true for a group to add into this domain.indexation
- a flag indicating if the group has to be indexed once added.- Returns:
- the unique identifier of the added group.
- Throws:
AdminException
- if an error occurs while adding the group in Silverpeas.
-
restoreGroup
public List<GroupDetail> restoreGroup(GroupDetail group, boolean indexation) throws AdminException
Restores the given group in Silverpeas.- Parameters:
group
- the group to restore.indexation
- true to perform indexation.- Returns:
- all parent group ids (including given group at first position).
- Throws:
AdminException
- if the restore fails.
-
removeGroup
public List<GroupDetail> removeGroup(GroupDetail group, boolean indexation) throws AdminException
Removes the given group in Silverpeas.- Parameters:
group
- the group to remove.indexation
- true to perform indexation.- Returns:
- all removed subgroup ids (including given group at first position).
- Throws:
AdminException
- if the remove fails.
-
deleteGroup
public List<GroupDetail> deleteGroup(GroupDetail group, boolean onlyInSilverpeas) throws AdminException
Delete the group with the given id. The delete is apply recursively to the sub-groups.- Parameters:
group
- the group to delete.onlyInSilverpeas
- a flag indicating if the group has to be delete in Silverpeas only and not also in the domain. The mixed domain is a specific domain of Silverpeas and the flag should be true for a group of this domain.- Returns:
- a list of all the deleted groups (the group itself and its children groups).
- Throws:
AdminException
- if an error occurs while deleting the group and its children groups.
-
updateGroup
public String updateGroup(GroupDetail group, boolean onlyInSilverpeas) throws AdminException
Update the given group- Parameters:
group
- the new details of the group.onlyInSilverpeas
- a flag indicating if the group has to be updated in Silverpeas only and not also in the domain. The mixed domain is a specific domain of Silverpeas and the flag should be true for a group of this domain.- Returns:
- the unique identifier of the updated group.
- Throws:
AdminException
- if an error occurs while updating the group with the given details.
-
getManageableGroupIds
public List<String> getManageableGroupIds(String userId, List<String> groupIds) throws AdminException
- Throws:
AdminException
-
getRemovedGroupsOfDomains
public List<GroupDetail> getRemovedGroupsOfDomains(String... domainIds) throws AdminException
Gets all the removed groups in the specified domains. If no domains are given, then all the removed groups in Silverpeas are returned.- Parameters:
domainIds
- zero, one or more unique identifiers of group domains in Silverpeas.- Returns:
- a list of the removed groups in Silverpeas. If no groups are removed in the specified domains, then an empty list is returned.
- Throws:
AdminException
- if the removed groups cannot be fetched or if an unexpected exception is thrown.
-
-