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
,Contextualizable
,LogEnabled
,Serviceable
public class GroupDAO
extends AbstractLogEnabled
implements Serviceable, Component, Contextualizable
DAO for manipulating
Group
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AmetysContextHelper
The ametys context helperprotected Context
The Avalon contextprotected CurrentUserProvider
The current user provider.protected GroupDirectoryContextHelper
The directory context helperprotected GroupDirectoryDAO
The DAO for group directoriesprotected GroupHelper
The group helperprotected GroupManager
The group managerprotected PopulationContextHelper
The population context helperprotected RightManager
The right managerprotected ServiceManager
The service managerprotected UserHelper
The user helper -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected UserIdentity
Provides the current user._getSearchParameters
(String searchCriteria) Get the search parametersCreates a new groupAdd users to groupvoid
contextualize
(Context context) void
deleteGroups
(String groupDirectoryId, List<String> groupIds) Deletes groupsGet group's informationgetGroupsByContextAndGroupDirectory
(List<String> groupsAndDirectories, List<String> contexts) Get the requested groups in the requested group directory from the contextsgetGroupsByGroupDirectory
(List<String> groupIds, String groupDirectoryId) Get the requested groups in the requested group directorygetUsersGroup
(Map<String, String> user) Get the list of groups of a usergroup2Json
(Group group) Get the JSON representation of a groupboolean
isModifiable
(String groupDirectoryId, String id) Checks if the group is modifiableRemove users from grouprenameGroup
(String groupDirectoryId, String groupId, String name) Renames a groupGet the requested groups from the contextssearchGroupsByDirectory
(String groupDirectoryId, String searchCriteria, Integer limit, Integer offset) Get the requested groups in the requested group directoryvoid
service
(ServiceManager smanager) Set the users' groupMethods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
_smanager
The service manager -
_currentUserProvider
The current user provider. -
_groupManager
The group manager -
_groupDirectoryDAO
The DAO for group directories -
_userHelper
The user helper -
_directoryContextHelper
The directory context helper -
_groupHelper
The group helper -
_context
The Avalon context -
_rightManager
The right manager -
_populationContextHelper
The population context helper -
_ametysContextHelper
The ametys context helper
-
-
Constructor Details
-
GroupDAO
public GroupDAO()
-
-
Method Details
-
contextualize
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
service
- 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 InvalidModificationExceptionSet 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 InvalidModificationExceptionAdd 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 InvalidModificationExceptionRemove 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
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
-
getGroupsByContextAndGroupDirectory
public List<Map<String,Object>> getGroupsByContextAndGroupDirectory(List<String> groupsAndDirectories, List<String> contexts) throws AccessDeniedException Get the requested groups in the requested group directory from the contexts- Parameters:
groupsAndDirectories
- The group Id and the group directory Id separated by '#'contexts
- The contexts- Returns:
- a non-null list of groups
- Throws:
AccessDeniedException
- If the user tried to retrieve groups from unauthorized contexts
-
getGroupsByGroupDirectory
public List<Map<String,Object>> getGroupsByGroupDirectory(List<String> groupIds, String groupDirectoryId) throws AccessDeniedException Get the requested groups in the requested group directory- Parameters:
groupIds
- The ids of the groupsgroupDirectoryId
- The id of the group directory- Returns:
- a non-null list of groups
- Throws:
AccessDeniedException
- If the user tried to retrieve groups from unauthorized contexts
-
searchGroupsByContexts
public List<Map<String,Object>> searchGroupsByContexts(List<String> contexts, Integer limit, Integer offset, String searchCriteria) throws AccessDeniedException Get the requested groups from the contexts- Parameters:
contexts
- The contextslimit
- The limit of results. Can be null, default value_DEFAULT_SEARCH_COUNT_VALUE
.offset
- The offset, where to start returning results (offset). Can be null, default value_DEFAULT_SEARCH_OFFSET_VALUE
searchCriteria
- The criteria (pattern) for the search. Can be null.- Returns:
- a non-null list of groups
- Throws:
AccessDeniedException
- If the user tried to retrieve groups from unauthorized contexts
-
searchGroupsByDirectory
public List<Map<String,Object>> searchGroupsByDirectory(String groupDirectoryId, String searchCriteria, Integer limit, Integer offset) Get the requested groups in the requested group directory- Parameters:
groupDirectoryId
- The id of the group directorysearchCriteria
- The criteria (pattern) for the search. Can be null.limit
- The limit of results. Can be null, default value_DEFAULT_SEARCH_COUNT_VALUE
.offset
- The offset, where to start returning results (offset). Can be null, default value_DEFAULT_SEARCH_OFFSET_VALUE
- Returns:
- a non-null list of groups
- Throws:
AccessDeniedException
- If the user tried to retrieve groups from unauthorized contexts
-
_getSearchParameters
Get the search parameters- Parameters:
searchCriteria
- The search pattern- Returns:
- the search parameters
-
getGroup
Get group's information- Parameters:
groupDirectoryId
- The id of the group directoryid
- the group id- Returns:
- group's information
-
isModifiable
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
Get the JSON representation of a group- Parameters:
group
- The group- Returns:
- The group
-
_getCurrentUser
Provides the current user.- Returns:
- the user which cannot be
null
.
-