Class GroupDAO
- java.lang.Object
-
- org.silverpeas.core.admin.user.dao.GroupDAO
-
@Repository public class GroupDAO extends Object
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
GroupDAO()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
addGroup(Connection connection, GroupDetail group)
void
addUserInGroup(Connection connection, String userId, String groupId)
void
addUsersInGroup(Connection connection, List<String> userIds, String groupId)
long
deleteGroup(Connection connection, GroupDetail group)
void
deleteUserInGroup(Connection connection, String userId, String groupdId)
List<GroupDetail>
getAllGroups(Connection connection)
Gets allGroupState.VALID
groups available in Silverpeas whatever the user domain they belongs to.List<GroupDetail>
getAllGroupsByDomainId(Connection connection, String domainId, boolean includeRemoved)
Returns all the Groups having a given domain id.List<GroupDetail>
getAllRootGroups(Connection connection)
Gets allGroupState.VALID
root groups available in Silverpeas whatever the user domain they belongs to.List<GroupDetail>
getAllRootGroupsByDomainId(Connection connection, String domainId)
Returns all the Root Groups having a given domain id.List<String>
getDirectGroupIdsByGroupUserRole(Connection connection, String groupUserRoleId, boolean includeRemoved)
List<String>
getDirectGroupIdsBySpaceUserRole(Connection connection, String spaceUserRoleId, boolean includeRemoved)
List<String>
getDirectGroupIdsByUserRole(Connection connection, String userRoleId, boolean includeRemoved)
Returns all the identifiers of the groups that are in the specified user role (not recursive).List<GroupDetail>
getDirectGroupsOfUser(Connection connection, String userId, boolean includeRemoved)
Returns all the groups of a given user (not recursive).List<GroupDetail>
getDirectSubGroups(Connection con, String groupId, boolean includeRemoved)
GroupDetail
getGroup(Connection con, String groupId)
GroupDetail
getGroupBySpecificId(Connection connection, String domainId, String specificId)
ListSlice<GroupDetail>
getGroupsByCriteria(Connection connection, GroupsSearchCriteria criteria)
Gets the user groups that match the specified criteria.List<String>
getManageableGroupIds(Connection con, String userId, List<String> groupIds)
int
getNBUsersDirectlyInGroup(Connection con, String groupId)
List<GroupDetail>
getRemovedGroups(Connection connection, String... domainIds)
Gets all the groups that were removed in the specified domains.GroupDetail
getSuperGroup(Connection connection, String groupId)
Returns the parent of the given group if any.List<GroupDetail>
getSynchronizedGroups(Connection connection)
List<String>
getUsersDirectlyInGroup(Connection con, String groupId)
boolean
isGroupByNameExists(Connection connection, String name)
Optional<GroupDetail>
removeGroup(Connection connection, GroupDetail group)
Optional<GroupDetail>
restoreGroup(Connection connection, GroupDetail group)
void
updateGroup(Connection connection, GroupDetail group)
-
-
-
Method Detail
-
addGroup
public String addGroup(Connection connection, GroupDetail group) throws SQLException
- Throws:
SQLException
-
restoreGroup
public Optional<GroupDetail> restoreGroup(Connection connection, GroupDetail group) throws SQLException
- Throws:
SQLException
-
removeGroup
public Optional<GroupDetail> removeGroup(Connection connection, GroupDetail group) throws SQLException
- Throws:
SQLException
-
deleteGroup
public long deleteGroup(Connection connection, GroupDetail group) throws SQLException
- Throws:
SQLException
-
getRemovedGroups
public List<GroupDetail> getRemovedGroups(Connection connection, String... domainIds) throws SQLException
Gets all the groups that were removed in the specified domains.- Parameters:
connection
- a connection to the data source.domainIds
- zero, one or more unique identifiers of Silverpeas domains. If no domains are passed, then all the domains are taken by the request.- Returns:
- a list of group details.
- Throws:
SQLException
- if an error while requesting the groups.
-
addUserInGroup
public void addUserInGroup(Connection connection, String userId, String groupId) throws SQLException
- Throws:
SQLException
-
addUsersInGroup
public void addUsersInGroup(Connection connection, List<String> userIds, String groupId) throws SQLException
- Throws:
SQLException
-
updateGroup
public void updateGroup(Connection connection, GroupDetail group) throws SQLException
- Throws:
SQLException
-
deleteUserInGroup
public void deleteUserInGroup(Connection connection, String userId, String groupdId) throws SQLException
- Throws:
SQLException
-
isGroupByNameExists
public boolean isGroupByNameExists(Connection connection, String name) throws SQLException
- Throws:
SQLException
-
getAllGroups
public List<GroupDetail> getAllGroups(Connection connection) throws SQLException
Gets allGroupState.VALID
groups available in Silverpeas whatever the user domain they belongs to.- Parameters:
connection
- the connection with the data source to use.- Returns:
- a list of user groups.
- Throws:
SQLException
- if an error occurs while getting the user groups from the data source.
-
getAllRootGroups
public List<GroupDetail> getAllRootGroups(Connection connection) throws SQLException
Gets allGroupState.VALID
root groups available in Silverpeas whatever the user domain they belongs to.- Parameters:
connection
- the connection with the data source to use.- Returns:
- a list of user groups.
- Throws:
SQLException
- if an error occurs while getting the user groups from the data source.
-
getAllRootGroupsByDomainId
public List<GroupDetail> getAllRootGroupsByDomainId(Connection connection, String domainId) throws SQLException
Returns all the Root Groups having a given domain id.- Parameters:
domainId
- domain id- Returns:
- all the Root Groups having a given domain id.
- Throws:
SQLException
-
getAllGroupsByDomainId
public List<GroupDetail> getAllGroupsByDomainId(Connection connection, String domainId, boolean includeRemoved) throws SQLException
Returns all the Groups having a given domain id.- Parameters:
connection
- connection to the data source.domainId
- domain idincludeRemoved
- true to include REMOVED from the result, false otherwise- Returns:
- all the Groups having a given domain id.
- Throws:
SQLException
-
getSuperGroup
public GroupDetail getSuperGroup(Connection connection, String groupId) throws SQLException
Returns the parent of the given group if any.- Parameters:
connection
- connection to the data source.groupId
- a group id- Returns:
- the parent of the specified group or null.
- Throws:
SQLException
-
getGroupsByCriteria
public ListSlice<GroupDetail> getGroupsByCriteria(Connection connection, GroupsSearchCriteria criteria) throws SQLException
Gets the user groups that match the specified criteria. The criteria are provided by a SearchCriteriaBuilder instance that was used to create them.IMPORTANT: returned groups are
GroupState.VALID
ones.- Parameters:
connection
- the connetion with a data source to use.criteria
- a builder with which the criteria the user groups must satisfy has been built.- Returns:
- a list slice of user groups matching the criteria or an empty list if no such user groups are found. The slice is set by the pagination criteriion. If no such criterion is provided, then it is the whole list of groups matching the other criteria.
- Throws:
SQLException
-
getGroupBySpecificId
public GroupDetail getGroupBySpecificId(Connection connection, String domainId, String specificId) throws SQLException
- Throws:
SQLException
-
getGroup
public GroupDetail getGroup(Connection con, String groupId) throws SQLException
- Throws:
SQLException
-
getDirectSubGroups
public List<GroupDetail> getDirectSubGroups(Connection con, String groupId, boolean includeRemoved) throws SQLException
- Throws:
SQLException
-
getNBUsersDirectlyInGroup
public int getNBUsersDirectlyInGroup(Connection con, String groupId) throws SQLException
- Throws:
SQLException
-
getUsersDirectlyInGroup
public List<String> getUsersDirectlyInGroup(Connection con, String groupId) throws SQLException
- Throws:
SQLException
-
getManageableGroupIds
public List<String> getManageableGroupIds(Connection con, String userId, List<String> groupIds) throws SQLException
- Throws:
SQLException
-
getSynchronizedGroups
public List<GroupDetail> getSynchronizedGroups(Connection connection) throws SQLException
- Throws:
SQLException
-
getDirectGroupsOfUser
public List<GroupDetail> getDirectGroupsOfUser(Connection connection, String userId, boolean includeRemoved) throws SQLException
Returns all the groups of a given user (not recursive).- Parameters:
userId
- user idincludeRemoved
- true to include REMOVED from the result, false otherwise- Returns:
- all the groups of a given user (not recursive).
- Throws:
SQLException
- on technical error with database.
-
getDirectGroupIdsByUserRole
public List<String> getDirectGroupIdsByUserRole(Connection connection, String userRoleId, boolean includeRemoved) throws SQLException
Returns all the identifiers of the groups that are in the specified user role (not recursive).- Parameters:
userRoleId
- user role idincludeRemoved
- true to take into account removed groups, false otherwise.- Returns:
- all the group identifiers.
- Throws:
SQLException
- on technical error with database.
-
getDirectGroupIdsBySpaceUserRole
public List<String> getDirectGroupIdsBySpaceUserRole(Connection connection, String spaceUserRoleId, boolean includeRemoved) throws SQLException
- Throws:
SQLException
-
getDirectGroupIdsByGroupUserRole
public List<String> getDirectGroupIdsByGroupUserRole(Connection connection, String groupUserRoleId, boolean includeRemoved) throws SQLException
- Throws:
SQLException
-
-