Class ProjectInvitationHelper
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.workspaces.members.ProjectInvitationHelper
-
- All Implemented Interfaces:
LogEnabled
,PluginAware
,Component
,Configurable
,Contextualizable
,Serviceable
public class ProjectInvitationHelper extends AbstractLogEnabled implements Serviceable, Component, Configurable, PluginAware, Contextualizable
Helper for invitations by email
-
-
Field Summary
Fields Modifier and Type Field Description private static String
__MAIL_PROJECT_EMAIL_PATTERN
private static String
__MAIL_PROJECT_TOKEN_PATTERN
private Context
_context
private CurrentUserProvider
_currentUserProvider
private String
_htmlBodyKeyForInvitation
private String
_htmlBodyKeyForInvitationAccepted
private I18nUtils
_i18nUtils
private WorkspaceModuleExtensionPoint
_moduleEP
private String
_pluginName
private PopulationContextHelper
_populationContextHelper
private ProjectManager
_projectManager
private ProjectMemberManager
_projectMemberManager
private ProjectRightHelper
_projectRightsHelper
private UserSignUpConfiguration
_signupConfig
private UserSignupManager
_signupManager
private SiteManager
_siteManager
private String
_subjectKeyForInvitation
private String
_subjectKeyForInvitationAccepted
private String
_textBodyKeyForInvitation
private String
_textBodyKeyForInvitationAccepted
private UserHelper
_userHelper
private UserManager
_userManager
static String
ROLE
The role
-
Constructor Summary
Constructors Constructor Description ProjectInvitationHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
_addOrUpdateInvitation(Project project, String catalogSiteName, MembersWorkspaceModule module, String email, Map<String,String> allowedProfileByModules, String populationId, String userDirectoryId, String mailSubject, String mailBody)
protected I18nizableText
_getI18nizableText(String fullI18nKey, Map<String,I18nizableText> i18nParams)
Get theI18nizableText
from the configured key and i18n parametersprivate Map<String,Object>
_getInvitationEmailConfiguration(Project project, String lang)
private User
_getUser(String siteName, String email)
private String
_getUserDirectoryForSignup(Map<String,Object> result, String catalogSiteName, String lang)
private String
_getUserDirectoryForSignup(Page signupPage)
private void
_sendInvitationMail(String catalogSiteName, String email, String populationId, String userDirectoryId, String mailSubject, String mailBodyTpl)
void
configure(Configuration configuration)
void
contextualize(Context context)
void
createMemberFromInvitations(User user)
Add user as member of all project where it has been invitedString
getHtmlBodyForInvitationAcceptedEmail(Map<String,I18nizableText> defaultI18nParams, String language)
The email html body for invitation by emailString
getHtmlBodyForInvitationEmail(Map<String,I18nizableText> defaultI18nParams, String language)
The email html body for invitation by emailMap<String,Object>
getInvitationConfiguration(String projectName, String lang)
Get the configuration to invite users by emailsString
getSubjectForInvitationAcceptedEmail(Map<String,I18nizableText> defaultI18nParams, String language)
The email subject for invitation by emailString
getSubjectForInvitationEmail(Map<String,I18nizableText> defaultI18nParams, String language)
The email subject for invitation by emailString
getTextBodyForInvitationAcceptedEmail(Map<String,I18nizableText> defaultI18nParams, String language)
The email text body for invitation by emailString
getTextBodyForInvitationEmail(Map<String,I18nizableText> defaultI18nParams, String language)
The email text body for invitation by emailMap<String,Object>
inviteEmails(String projectName, String siteName, String lang, List<String> emails, Map<String,String> allowedProfileByModule, String mailSubject, String mailBody)
Invite emails to be member of a projectprotected void
sendInvitationAcceptedMail(Project project, User invitAuthor, User newMember)
Send email to the user who initiated the invitationvoid
service(ServiceManager serviceManager)
void
setPluginInfo(String pluginName, String featureName, String id)
Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
__MAIL_PROJECT_EMAIL_PATTERN
private static final String __MAIL_PROJECT_EMAIL_PATTERN
- See Also:
- Constant Field Values
-
__MAIL_PROJECT_TOKEN_PATTERN
private static final String __MAIL_PROJECT_TOKEN_PATTERN
- See Also:
- Constant Field Values
-
_projectManager
private ProjectManager _projectManager
-
_signupConfig
private UserSignUpConfiguration _signupConfig
-
_signupManager
private UserSignupManager _signupManager
-
_siteManager
private SiteManager _siteManager
-
_moduleEP
private WorkspaceModuleExtensionPoint _moduleEP
-
_currentUserProvider
private CurrentUserProvider _currentUserProvider
-
_userManager
private UserManager _userManager
-
_userHelper
private UserHelper _userHelper
-
_projectRightsHelper
private ProjectRightHelper _projectRightsHelper
-
_projectMemberManager
private ProjectMemberManager _projectMemberManager
-
_populationContextHelper
private PopulationContextHelper _populationContextHelper
-
_subjectKeyForInvitation
private String _subjectKeyForInvitation
-
_textBodyKeyForInvitation
private String _textBodyKeyForInvitation
-
_htmlBodyKeyForInvitation
private String _htmlBodyKeyForInvitation
-
_subjectKeyForInvitationAccepted
private String _subjectKeyForInvitationAccepted
-
_textBodyKeyForInvitationAccepted
private String _textBodyKeyForInvitationAccepted
-
_htmlBodyKeyForInvitationAccepted
private String _htmlBodyKeyForInvitationAccepted
-
_i18nUtils
private I18nUtils _i18nUtils
-
_pluginName
private String _pluginName
-
-
Constructor Detail
-
ProjectInvitationHelper
public ProjectInvitationHelper()
-
-
Method Detail
-
setPluginInfo
public void setPluginInfo(String pluginName, String featureName, String id)
Description copied from interface:PluginAware
Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.- Specified by:
setPluginInfo
in interfacePluginAware
- Parameters:
pluginName
- Unique identifier for the plugin hosting the extensionfeatureName
- Unique feature identifier (unique for a given pluginName)id
- Unique identifier of this component
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
configure
public void configure(Configuration configuration) throws ConfigurationException
- Specified by:
configure
in interfaceConfigurable
- Throws:
ConfigurationException
-
inviteEmails
public Map<String,Object> inviteEmails(String projectName, String siteName, String lang, List<String> emails, Map<String,String> allowedProfileByModule, String mailSubject, String mailBody) throws UserManagementException, IllegalAccessException, NotUniqueUserException
Invite emails to be member of a project- Parameters:
projectName
- The project namesiteName
- The site namelang
- the current languageemails
- The emailsallowedProfileByModule
- the allowed profiles by modulemailSubject
- The subject of mailmailBody
- The body of mail- Returns:
- The result
- Throws:
UserManagementException
- if failed to invit userNotUniqueUserException
- if many users match the given emailIllegalAccessException
- If the user cannot execute this operation
-
_getUser
private User _getUser(String siteName, String email) throws NotUniqueUserException
- Throws:
NotUniqueUserException
-
getInvitationConfiguration
public Map<String,Object> getInvitationConfiguration(String projectName, String lang)
Get the configuration to invite users by emails- Parameters:
projectName
- The current projectlang
- the current language- Returns:
- the configuration for email invitations
-
_getInvitationEmailConfiguration
private Map<String,Object> _getInvitationEmailConfiguration(Project project, String lang)
-
_sendInvitationMail
private void _sendInvitationMail(String catalogSiteName, String email, String populationId, String userDirectoryId, String mailSubject, String mailBodyTpl) throws UserManagementException
- Throws:
UserManagementException
-
_addOrUpdateInvitation
private boolean _addOrUpdateInvitation(Project project, String catalogSiteName, MembersWorkspaceModule module, String email, Map<String,String> allowedProfileByModules, String populationId, String userDirectoryId, String mailSubject, String mailBody) throws UserManagementException
- Throws:
UserManagementException
-
_getUserDirectoryForSignup
private String _getUserDirectoryForSignup(Map<String,Object> result, String catalogSiteName, String lang)
-
_getUserDirectoryForSignup
private String _getUserDirectoryForSignup(Page signupPage)
-
createMemberFromInvitations
public void createMemberFromInvitations(User user)
Add user as member of all project where it has been invited- Parameters:
user
- the new user
-
sendInvitationAcceptedMail
protected void sendInvitationAcceptedMail(Project project, User invitAuthor, User newMember)
Send email to the user who initiated the invitation- Parameters:
project
- The projectinvitAuthor
- The author of invitationnewMember
- The new member
-
getSubjectForInvitationEmail
public String getSubjectForInvitationEmail(Map<String,I18nizableText> defaultI18nParams, String language)
The email subject for invitation by email- Parameters:
defaultI18nParams
- The default i18n parameterslanguage
- the language- Returns:
- the email subject for invitation by email
-
getTextBodyForInvitationEmail
public String getTextBodyForInvitationEmail(Map<String,I18nizableText> defaultI18nParams, String language)
The email text body for invitation by email- Parameters:
defaultI18nParams
- The default i18n parameters with : siteName the site name email the mail token the token confirmUri the confirmation uri siteTitle the site title siteUrl the site urllanguage
- the language- Returns:
- the email text for invitation by email
-
getHtmlBodyForInvitationEmail
public String getHtmlBodyForInvitationEmail(Map<String,I18nizableText> defaultI18nParams, String language)
The email html body for invitation by email- Parameters:
defaultI18nParams
- The default i18n parameters with : siteName the site name email the mail token the token confirmUri the confirmation uri siteTitle the site title siteUrl the site urllanguage
- the language- Returns:
- the email html for invitation by email
-
getSubjectForInvitationAcceptedEmail
public String getSubjectForInvitationAcceptedEmail(Map<String,I18nizableText> defaultI18nParams, String language)
The email subject for invitation by email- Parameters:
defaultI18nParams
- The default i18n parameterslanguage
- the language- Returns:
- the email subject for invitation by email
-
getTextBodyForInvitationAcceptedEmail
public String getTextBodyForInvitationAcceptedEmail(Map<String,I18nizableText> defaultI18nParams, String language)
The email text body for invitation by email- Parameters:
defaultI18nParams
- The default i18n parameters with :language
- the language- Returns:
- the email text for invitation by email
-
getHtmlBodyForInvitationAcceptedEmail
public String getHtmlBodyForInvitationAcceptedEmail(Map<String,I18nizableText> defaultI18nParams, String language)
The email html body for invitation by email- Parameters:
defaultI18nParams
- The default i18n parameters with :language
- the language- Returns:
- the email html for invitation by email
-
_getI18nizableText
protected I18nizableText _getI18nizableText(String fullI18nKey, Map<String,I18nizableText> i18nParams)
Get theI18nizableText
from the configured key and i18n parameters- Parameters:
fullI18nKey
- the configured i18n keyi18nParams
- the i18n parameters- Returns:
- the i18nizable text
-
-