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
Modifier and TypeClassDescriptionstatic class
This class represents a member of a project. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The id of the members serviceprotected AbstractCacheManager
The cache managerprotected Context
Avalon contextprotected CurrentUserProvider
Current user providerprotected GroupDirectoryContextHelper
The group directory context helperprotected GroupManager
The groups managerprotected LanguagesManager
The language managerprotected WorkspaceModuleExtensionPoint
Module managers EPprotected ObservationManager
The observation managerprotected PopulationContextHelper
The population context helperprotected ProfileAssignmentStorageExtensionPoint
Profile assignment storageprotected ProjectInvitationHelper
The project invitation helperprotected ProjectManager
Project managerprotected ProjectRightHelper
Project rights helperprotected AmetysObjectResolver
Ametys object resolverprotected RightManager
Rights managerprotected RightProfilesDAO
Profiles right managerprotected URIResolverExtensionPoint
The page URI resolver.protected UserDirectoryHelper
The user directory helperprotected UserDirectoryPageResolver
The resolver for user directory pagesprotected UserHelper
The user helperprotected UserManager
Users managerprotected UserSignupManager
The user signup managerstatic final String
Avalon Role -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGet a map of each available module, with the default profileprotected 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 necessary_setProjectMemberData
(String projectName, String identity, String type, Map<String, String> newProfiles, String role, boolean isNewUser) Set the user data in the projectAdd a new memberAdd new members and invitation by emailaddOrUpdateProjectMember
(Project project, GroupIdentity group, Map<String, String> allowedProfiles) Add a group to a project, using the provided profile valuesaddOrUpdateProjectMember
(Project project, UserIdentity user, Map<String, String> allowedProfiles) Add a user to a project, using the provided profile valuesaddOrUpdateProjectMember
(Project project, UserIdentity user, Map<String, String> allowedProfiles, UserIdentity issuer) Add a user to a project, using the provided profile valuesaddProjectMember
(Project project, UserIdentity user) Add a user to a project with open inscriptions, using the default valuesvoid
contextualize
(Context context) Get the current user informationgetGroupUsersFromProject
(Group group, Project project, BiPredicate<Project, UserIdentity> filteringPredicate) Get the users from a group that are part of the project.getJCRProjectMembers
(Project project) Get the list of users of the projectgetMemberModuleRights
(String projectName) Retrieves the rights for the current user in the projectgetMembersCount
(Project project) Count the total of unique users in the project and in the project's groupgetProjectMember
(Project project, UserIdentity userIdentity) Retrieve the member of a project corresponding to the user identitygetProjectMember
(Project project, UserIdentity userIdentity, Set<GroupIdentity> userGroups) Retrieve the member of a project corresponding to the user identitygetProjectMemberData
(String projectName, String identity, String type) Retrieve the data of a member of a project, or the default data if no user is providedGet the members of current project or all the members of all projects in where is no current projectgetProjectMembers
(String projectName, String lang) Get the members of a project, sorted by managers, non empty role and namegetProjectMembers
(String projectName, String lang, boolean expandGroup) Get the members of a project, sorted by managers, non empty role and namegetProjectMembers
(Project project, boolean expandGroup) Get the members of a project, sorted by managers, non empty role and namegetProjectMembers
(Project project, boolean expandGroup, Set<ProjectMemberManager.ProjectMember> defaultSet) Get the members of a project, sorted by managers, non empty role and namegetUserContent
(String lang, User user) Get user contentgroup2Json
(Group group) Get the JSON representation of a groupvoid
boolean
isProjectMember
(Project project, UserIdentity userIdentity) Test if an user is a member of a project (directly or by a group)removeMember
(String projectName, String identity, String type) Remove a user from a projectvoid
service
(ServiceManager manager) void
setProfileOnModule
(JCRProjectMember member, Project project, WorkspaceModule module, Set<String> allowedProfiles) Affect profiles for a member on a given modulevoid
setProjectManager
(String projectName, String profileId, List<UserIdentity> managers) Set the manager of a projectsetProjectMemberData
(String projectName, String identity, String type, Map<String, String> newProfiles, String role) Set the user data in the projectMethods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
Avalon Role -
__WORKSPACES_SERVICE_MEMBERS
The id of the members service- See Also:
-
_context
Avalon context -
_projectManager
Project manager -
_projectRightHelper
Project rights helper -
_rightProfilesDAO
Profiles right manager -
_profileAssignmentStorageExtensionPoint
Profile assignment storage -
_resolver
Ametys object resolver -
_rightManager
Rights manager -
_currentUserProvider
Current user provider -
_userManager
Users manager -
_observationManager
The observation manager -
_moduleManagerEP
Module managers EP -
_userHelper
The user helper -
_groupManager
The groups manager -
_populationContextHelper
The population context helper -
_userDirectoryHelper
The user directory helper -
_projectInvitationHelper
The project invitation helper -
_languagesManager
The language manager -
_userDirectoryPageResolver
The resolver for user directory pages -
_uriResolver
The page URI resolver. -
_groupDirectoryContextHelper
The group directory context helper -
_abstractCacheManager
The cache manager -
_userSignupManager
The user signup manager
-
-
Constructor Details
-
ProjectMemberManager
public ProjectMemberManager()
-
-
Method Details
-
contextualize
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
initialize
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
getProjectMemberData
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
-
addMembers
public Map<String,Object> addMembers(String projectName, List<Map<String, String>> newMembers, List<String> invitEmails) 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
-
addMember
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
-
_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) 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
-
_setProjectMemberData
protected Map<String,Object> _setProjectMemberData(String projectName, String identity, String type, Map<String, String> newProfiles, String role, boolean isNewUser) 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 projectisNewUser
-true
if the user is just added- Returns:
- The result
-
addProjectMember
Add a user to a project with open inscriptions, using the default values- Parameters:
project
- The projectuser
- The user- Returns:
- the added member in case of success, null otherwise
-
addOrUpdateProjectMember
public JCRProjectMember 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:
- the added member in case of success, null otherwise
-
addOrUpdateProjectMember
public JCRProjectMember addOrUpdateProjectMember(Project project, UserIdentity user, Map<String, String> allowedProfiles, UserIdentity issuer) Add a user to a project, using the provided profile values- Parameters:
project
- The projectuser
- The userallowedProfiles
- the profile valuesissuer
- identity of the user that approved the member- Returns:
- the added member in case of success, null otherwise
-
addOrUpdateProjectMember
public JCRProjectMember 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:
- the added member in case of success, null otherwise
-
setProfileOnModule
public void setProfileOnModule(JCRProjectMember member, Project project, WorkspaceModule module, Set<String> allowedProfiles) Affect profiles for a member on a given module- Parameters:
member
- The memberproject
- The projectmodule
- The moduleallowedProfiles
- The allowed profiles for the module
-
getCurrentUser
Get the current user information- Returns:
- The user
-
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 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:
AmetysRepositoryException
- if an error occurred
-
getUserContent
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
-
getProjectMembers
public Set<ProjectMemberManager.ProjectMember> getProjectMembers(Project project, boolean expandGroup, Set<ProjectMemberManager.ProjectMember> defaultSet) 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 groupdefaultSet
- default set to return when project has no site- Returns:
- the members of project
- Throws:
AmetysRepositoryException
- if an error occurred
-
getMemberModuleRights
Retrieves the rights for the current user in the project- Parameters:
projectName
- The project Name- Returns:
- The project
-
getJCRProjectMembers
Get the list of users of the project- Parameters:
project
- The project- Returns:
- The list of users
-
isProjectMember
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
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
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
-
_getProjectMembersNode
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
Get the JSON representation of a group- Parameters:
group
- The group- Returns:
- The group
-
getMembersCount
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
-