Class ProjectMemberManager
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.workspaces.members.ProjectMemberManager
-
- All Implemented Interfaces:
LogEnabled,Initializable,Component,Contextualizable,Serviceable
public class ProjectMemberManager extends AbstractLogEnabled implements Serviceable, Component, Contextualizable, Initializable
Helper component for managing project's users
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classProjectMemberManager.ProjectMemberThis class represents a member of a project.
-
Field Summary
Fields Modifier and Type Field Description static String__WORKSPACES_SERVICE_MEMBERSThe id of the members serviceprotected AbstractCacheManager_abstractCacheManagerThe cache managerprotected Context_contextAvalon contextprotected CurrentUserProvider_currentUserProviderCurrent user providerprotected GroupDirectoryContextHelper_groupDirectoryContextHelperThe group directory context helperprotected GroupManager_groupManagerThe groups managerprotected LanguagesManager_languagesManagerThe language managerprotected WorkspaceModuleExtensionPoint_moduleManagerEPModule managers EPprotected ObservationManager_observationManagerThe observation managerprotected PopulationContextHelper_populationContextHelperThe population context helperprotected ProfileAssignmentStorageExtensionPoint_profileAssignmentStorageExtensionPointProfile assignment storageprotected ProjectInvitationHelper_projectInvitationHelperThe project invitation helperprotected ProjectManager_projectManagerProject managerprotected ProjectRightHelper_projectRightHelperProject rights helperprotected AmetysObjectResolver_resolverAmetys object resolverprotected RightManager_rightManagerRights managerprotected RightProfilesDAO_rightProfilesDAOProfiles right managerprotected URIResolverExtensionPoint_uriResolverThe page URI resolver.protected UserDirectoryHelper_userDirectoryHelperThe user directory helperprotected UserDirectoryPageResolver_userDirectoryPageResolverThe resolver for user directory pagesprotected UserHelper_userHelperThe user helperprotected UserManager_userManagerUsers managerstatic StringROLEAvalon Role
-
Constructor Summary
Constructors Constructor Description ProjectMemberManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Map<String,String>_getDefaultProfilesByModule()Get a map of each available module, with the default profileprotected Map<JCRProjectMember,Object>_getJCRProjectMembers(Project project)Get the list of users of the projectprotected JCRProjectMember_getOrCreateJCRProjectMember(Project project, Predicate<? super AmetysObject> findMemberPredicate)Retrieve or create a member in a projectprotected ModifiableTraversableAmetysObject_getProjectMembersNode(Project project)Retrieves the users node of the project The users node will be created if necessaryMap<String,Object>addMember(String projectName, String identity, String type)Add a new memberMap<String,Object>addMembers(String projectName, List<Map<String,String>> newMembers, List<String> invitEmails)Add new members and invitation by emailbooleanaddOrUpdateProjectMember(Project project, GroupIdentity group, Map<String,String> allowedProfiles)Add a group to a project, using the provided profile valuesbooleanaddOrUpdateProjectMember(Project project, UserIdentity user, Map<String,String> allowedProfiles)Add a user to a project, using the provided profile valuesbooleanaddProjectMember(Project project, UserIdentity user)Add a user to a project with open inscriptions, using the default valuesvoidcontextualize(Context context)Map<String,Object>getCurrentUser()Get the current user informationList<User>getGroupUsersFromProject(Group group, Project project, BiPredicate<Project,UserIdentity> filteringPredicate)Get the users from a group that are part of the project.Map<String,Object>getMemberModuleRights(String projectName)Retrieves the rights for the current user in the projectLonggetMembersCount(Project project)Count the total of unique users in the project and in the project's groupProjectMemberManager.ProjectMembergetProjectMember(Project project, UserIdentity userIdentity)Retrieve the member of a project corresponding to the user identityProjectMemberManager.ProjectMembergetProjectMember(Project project, UserIdentity userIdentity, Set<GroupIdentity> userGroups)Retrieve the member of a project corresponding to the user identityMap<String,Object>getProjectMemberData(String projectName, String identity, String type)Retrieve the data of a member of a project, or the default data if no user is providedMap<String,Object>getProjectMembers()Get the members of current project or all the members of all projects in where is no current projectMap<String,Object>getProjectMembers(String projectName, String lang)Get the members of a project, sorted by managers, non empty role and nameMap<String,Object>getProjectMembers(String projectName, String lang, boolean expandGroup)Get the members of a project, sorted by managers, non empty role and nameSet<ProjectMemberManager.ProjectMember>getProjectMembers(Project project, boolean expandGroup)Get the members of a project, sorted by managers, non empty role and nameContentgetUserContent(String lang, User user)Get user contentprotected Map<String,Object>group2Json(Group group)Get the JSON representation of a groupvoidinitialize()booleanisProjectMember(Project project, UserIdentity userIdentity)Test if an user is a member of a project (directly or by a group)Map<String,Object>removeMember(String projectName, String identity, String type)Remove a user from a projectvoidservice(ServiceManager manager)voidsetProjectManager(String projectName, String profileId, List<UserIdentity> managers)Set the manager of a projectMap<String,Object>setProjectMemberData(String projectName, String identity, String type, Map<String,String> newProfiles, String role)Set the user data in the project-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
__WORKSPACES_SERVICE_MEMBERS
public static final String __WORKSPACES_SERVICE_MEMBERS
The id of the members service- See Also:
- Constant Field Values
-
_projectManager
protected ProjectManager _projectManager
Project manager
-
_projectRightHelper
protected ProjectRightHelper _projectRightHelper
Project rights helper
-
_rightProfilesDAO
protected RightProfilesDAO _rightProfilesDAO
Profiles right manager
-
_profileAssignmentStorageExtensionPoint
protected ProfileAssignmentStorageExtensionPoint _profileAssignmentStorageExtensionPoint
Profile assignment storage
-
_resolver
protected AmetysObjectResolver _resolver
Ametys object resolver
-
_rightManager
protected RightManager _rightManager
Rights manager
-
_currentUserProvider
protected CurrentUserProvider _currentUserProvider
Current user provider
-
_userManager
protected UserManager _userManager
Users manager
-
_observationManager
protected ObservationManager _observationManager
The observation manager
-
_moduleManagerEP
protected WorkspaceModuleExtensionPoint _moduleManagerEP
Module managers EP
-
_userHelper
protected UserHelper _userHelper
The user helper
-
_groupManager
protected GroupManager _groupManager
The groups manager
-
_populationContextHelper
protected PopulationContextHelper _populationContextHelper
The population context helper
-
_userDirectoryHelper
protected UserDirectoryHelper _userDirectoryHelper
The user directory helper
-
_projectInvitationHelper
protected ProjectInvitationHelper _projectInvitationHelper
The project invitation helper
-
_languagesManager
protected LanguagesManager _languagesManager
The language manager
-
_userDirectoryPageResolver
protected UserDirectoryPageResolver _userDirectoryPageResolver
The resolver for user directory pages
-
_uriResolver
protected URIResolverExtensionPoint _uriResolver
The page URI resolver.
-
_groupDirectoryContextHelper
protected GroupDirectoryContextHelper _groupDirectoryContextHelper
The group directory context helper
-
_abstractCacheManager
protected AbstractCacheManager _abstractCacheManager
The cache manager
-
-
Constructor Detail
-
ProjectMemberManager
public ProjectMemberManager()
-
-
Method Detail
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualizein interfaceContextualizable- Throws:
ContextException
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
initialize
public void initialize() throws Exception
- Specified by:
initializein interfaceInitializable- Throws:
Exception
-
getProjectMemberData
public Map<String,Object> getProjectMemberData(String projectName, String identity, String type) throws IllegalAccessException
Retrieve the data of a member of a project, or the default data if no user is provided- Parameters:
projectName- The name of the projectidentity- The user or group identity. If null, return the default profiles for a new usertype- The type of the identity. Can be "user" or "group"- Returns:
- The map of profiles per module for the user
- Throws:
IllegalAccessException- If the user cannot execute this operation
-
addMembers
public Map<String,Object> addMembers(String projectName, List<Map<String,String>> newMembers, List<String> invitEmails) throws IllegalAccessException
Add new members and invitation by email- Parameters:
projectName- The project namenewMembers- The members to add (users or groups)invitEmails- The invitation emails- Returns:
- the result with errors
- Throws:
IllegalAccessException- If the user cannot execute this operation
-
addMember
public Map<String,Object> addMember(String projectName, String identity, String type) throws IllegalAccessException
Add a new member- Parameters:
projectName- The project nameidentity- The user or group identity.type- The type of the identity. Can be "user" or "group"- Returns:
- the result
- Throws:
IllegalAccessException- If the user cannot execute this operation
-
_getDefaultProfilesByModule
protected Map<String,String> _getDefaultProfilesByModule()
Get a map of each available module, with the default profile- Returns:
- A map with moduleId : profileId
-
setProjectMemberData
public Map<String,Object> setProjectMemberData(String projectName, String identity, String type, Map<String,String> newProfiles, String role) throws IllegalAccessException
Set the user data in the project- Parameters:
projectName- The project nameidentity- The user or group identity.type- The type of the identity. Can be "user" or "group"newProfiles- The profiles to affect, mapped by modulerole- The user role inside the project- Returns:
- The result
- Throws:
IllegalAccessException- If the user cannot execute this operation
-
addProjectMember
public boolean addProjectMember(Project project, UserIdentity user)
Add a user to a project with open inscriptions, using the default values- Parameters:
project- The projectuser- The user- Returns:
- True if the user was successfully added
-
addOrUpdateProjectMember
public boolean addOrUpdateProjectMember(Project project, UserIdentity user, Map<String,String> allowedProfiles)
Add a user to a project, using the provided profile values- Parameters:
project- The projectuser- The userallowedProfiles- the profile values- Returns:
- True if the user was successfully added
-
addOrUpdateProjectMember
public boolean addOrUpdateProjectMember(Project project, GroupIdentity group, Map<String,String> allowedProfiles)
Add a group to a project, using the provided profile values- Parameters:
project- The projectgroup- The groupallowedProfiles- the profile values- Returns:
- True if the user was successfully added
-
getCurrentUser
public Map<String,Object> getCurrentUser()
Get the current user information- Returns:
- The user
-
getProjectMembers
public Map<String,Object> getProjectMembers()
Get the members of current project or all the members of all projects in where is no current project- Returns:
- The members
-
getProjectMembers
public Map<String,Object> getProjectMembers(String projectName, String lang) throws IllegalAccessException, AmetysRepositoryException
Get the members of a project, sorted by managers, non empty role and name- Parameters:
projectName- the project's namelang- the language to get user content- Returns:
- the members of project
- Throws:
IllegalAccessException- if an error occurredAmetysRepositoryException- if an error occurred
-
getProjectMembers
public Map<String,Object> getProjectMembers(String projectName, String lang, boolean expandGroup) throws IllegalAccessException, AmetysRepositoryException
Get the members of a project, sorted by managers, non empty role and name- Parameters:
projectName- the project's namelang- the language to get user contentexpandGroup- true if groups are expanded- Returns:
- the members of project
- Throws:
IllegalAccessException- if an error occurredAmetysRepositoryException- if an error occurred
-
getUserContent
public Content getUserContent(String lang, User user)
Get user content- Parameters:
lang- the languser- the user- Returns:
- the user content or null if no exist
-
getProjectMembers
public Set<ProjectMemberManager.ProjectMember> getProjectMembers(Project project, boolean expandGroup) throws AmetysRepositoryException
Get the members of a project, sorted by managers, non empty role and name- Parameters:
project- the projectexpandGroup- true to expand the user of a group- Returns:
- the members of project
- Throws:
AmetysRepositoryException- if an error occurred
-
getMemberModuleRights
public Map<String,Object> getMemberModuleRights(String projectName)
Retrieves the rights for the current user in the project- Parameters:
projectName- The project Name- Returns:
- The project
-
_getJCRProjectMembers
protected Map<JCRProjectMember,Object> _getJCRProjectMembers(Project project)
Get the list of users of the project- Parameters:
project- The project- Returns:
- The list of users
-
isProjectMember
public boolean isProjectMember(Project project, UserIdentity userIdentity)
Test if an user is a member of a project (directly or by a group)- Parameters:
project- The projectuserIdentity- The user identity- Returns:
- True if this user is a member of this project
-
getProjectMember
public ProjectMemberManager.ProjectMember getProjectMember(Project project, UserIdentity userIdentity)
Retrieve the member of a project corresponding to the user identity- Parameters:
project- The projectuserIdentity- The user identity- Returns:
- The member of this project, which can be of type "user" or "group", or null if the user is not in the project
-
getProjectMember
public ProjectMemberManager.ProjectMember getProjectMember(Project project, UserIdentity userIdentity, Set<GroupIdentity> userGroups)
Retrieve the member of a project corresponding to the user identity- Parameters:
project- The projectuserIdentity- The user identityuserGroups- The user groups. If null the user's groups will be expanded.- Returns:
- The member of this project, which can be of type "user" or "group", or null if the user is not in the project
-
setProjectManager
public void setProjectManager(String projectName, String profileId, List<UserIdentity> managers)
Set the manager of a project- Parameters:
projectName- The project nameprofileId- The profile id to affectmanagers- The managers' user identity
-
_getOrCreateJCRProjectMember
protected JCRProjectMember _getOrCreateJCRProjectMember(Project project, Predicate<? super AmetysObject> findMemberPredicate)
Retrieve or create a member in a project- Parameters:
project- The projectfindMemberPredicate- The predicate to find the member node- Returns:
- The member node. A new node is created if the member node was not found
-
removeMember
public Map<String,Object> removeMember(String projectName, String identity, String type) throws IllegalAccessException
Remove a user from a project- Parameters:
projectName- The project nameidentity- The identity of the user or group, who must be a member of the projecttype- The type of the member, user or group- Returns:
- The error code, if an error occurred
- Throws:
IllegalAccessException- If the user cannot execute this operation
-
_getProjectMembersNode
protected ModifiableTraversableAmetysObject _getProjectMembersNode(Project project)
Retrieves the users node of the project The users node will be created if necessary- Parameters:
project- The project- Returns:
- The users node of the project
-
group2Json
protected Map<String,Object> group2Json(Group group)
Get the JSON representation of a group- Parameters:
group- The group- Returns:
- The group
-
getMembersCount
public Long getMembersCount(Project project)
Count the total of unique users in the project and in the project's group- Parameters:
project- The project- Returns:
- The total of members
-
getGroupUsersFromProject
public List<User> getGroupUsersFromProject(Group group, Project project, BiPredicate<Project,UserIdentity> filteringPredicate)
Get the users from a group that are part of the project. They can be filtered with a predicate- Parameters:
group- The groupproject- The projectfilteringPredicate- The predicate to filter- Returns:
- The list of users
-
-