Package org.ametys.plugins.core.group
Class GroupDAO
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.ametys.plugins.core.group.GroupDAO
-
- All Implemented Interfaces:
Component
,LogEnabled
,Serviceable
public class GroupDAO extends AbstractLogEnabled implements Serviceable, Component
DAO for manipulatingGroup
-
-
Field Summary
Fields Modifier and Type Field Description protected CurrentUserProvider
_currentUserProvider
The current user provider.protected GroupDirectoryDAO
_groupDirectoryDAO
The DAO for group directoriesprotected GroupManager
_groupManager
The group managerprotected ServiceManager
_smanager
The service managerprotected UserHelper
_userHelper
The user helper
-
Constructor Summary
Constructors Constructor Description GroupDAO()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected UserIdentity
_getCurrentUser()
Provides the current user.Map<String,Object>
addGroup(String groupDirectoryId, String name)
Creates a new groupMap<String,Object>
addUsersGroup(String groupDirectoryId, String groupId, List<Map<String,String>> users)
Add users to groupvoid
deleteGroups(String groupDirectoryId, List<String> groupIds)
Deletes groupsMap<String,Object>
getGroup(String groupDirectoryId, String id)
Get group's informationList<Map<String,Object>>
getUsersGroup(Map<String,String> user)
Get the list of groups of a userprotected Map<String,Object>
group2Json(Group group)
Get the JSON representation of a groupboolean
isModifiable(String groupDirectoryId, String id)
Checks if the group is modifiableMap<String,Object>
removeUsersGroup(String groupDirectoryId, String groupId, List<Map<String,String>> users)
Remove users from groupMap<String,Object>
renameGroup(String groupDirectoryId, String groupId, String name)
Renames a groupvoid
service(ServiceManager smanager)
Map<String,Object>
setUsersGroup(String groupDirectoryId, String groupId, List<Map<String,String>> users)
Set the users' group-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
_smanager
protected ServiceManager _smanager
The service manager
-
_currentUserProvider
protected CurrentUserProvider _currentUserProvider
The current user provider.
-
_groupManager
protected GroupManager _groupManager
The group manager
-
_groupDirectoryDAO
protected GroupDirectoryDAO _groupDirectoryDAO
The DAO for group directories
-
_userHelper
protected UserHelper _userHelper
The user helper
-
-
Constructor Detail
-
GroupDAO
public GroupDAO()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
addGroup
public Map<String,Object> addGroup(String groupDirectoryId, String name) throws InvalidModificationException
Creates a new group- Parameters:
groupDirectoryId
- The id of the group directoryname
- The group's name- Returns:
- The group's information
- Throws:
InvalidModificationException
- If modification are not possible
-
setUsersGroup
public Map<String,Object> setUsersGroup(String groupDirectoryId, String groupId, List<Map<String,String>> users) throws InvalidModificationException
Set the users' group- Parameters:
groupDirectoryId
- The id of the group directorygroupId
- The group's idusers
- The group's users- Returns:
- The group's information
- Throws:
InvalidModificationException
- If modification are not possible
-
addUsersGroup
public Map<String,Object> addUsersGroup(String groupDirectoryId, String groupId, List<Map<String,String>> users) throws InvalidModificationException
Add users to group- Parameters:
groupDirectoryId
- The id of the group directorygroupId
- The group's idusers
- The users to add- Returns:
- The group's information
- Throws:
InvalidModificationException
- If modification are not possible
-
removeUsersGroup
public Map<String,Object> removeUsersGroup(String groupDirectoryId, String groupId, List<Map<String,String>> users) throws InvalidModificationException
Remove users from group- Parameters:
groupDirectoryId
- The id of the group directorygroupId
- The group's idusers
- The users to add- Returns:
- The group's information
- Throws:
InvalidModificationException
- If modification are not possible
-
getUsersGroup
public List<Map<String,Object>> getUsersGroup(Map<String,String> user)
Get the list of groups of a user- Parameters:
user
- The user (using the format ofUserHelper.json2userIdentity(Map)
- Returns:
- The list of groups information
-
renameGroup
public Map<String,Object> renameGroup(String groupDirectoryId, String groupId, String name) throws InvalidModificationException
Renames a group- Parameters:
groupDirectoryId
- The id of the group directorygroupId
- The group'sidname
- The new name- Returns:
- The group's information
- Throws:
InvalidModificationException
- If modification are not possible
-
deleteGroups
public void deleteGroups(String groupDirectoryId, List<String> groupIds) throws InvalidModificationException
Deletes groups- Parameters:
groupDirectoryId
- The id of the group directorygroupIds
- The ids of groups to delete- Throws:
InvalidModificationException
- If modification are not possible
-
getGroup
public Map<String,Object> getGroup(String groupDirectoryId, String id)
Get group's information- Parameters:
groupDirectoryId
- The id of the group directoryid
- the group id- Returns:
- group's information
-
isModifiable
public boolean isModifiable(String groupDirectoryId, String id)
Checks if the group is modifiable- Parameters:
groupDirectoryId
- The id of the group directoryid
- The group id- Returns:
- True if the group is modifiable
-
group2Json
protected Map<String,Object> group2Json(Group group)
Get the JSON representation of a group- Parameters:
group
- The group- Returns:
- The group
-
_getCurrentUser
protected UserIdentity _getCurrentUser()
Provides the current user.- Returns:
- the user which cannot be
null
.
-
-