Package org.ametys.cms.workflow
Class SendMailFunction
java.lang.Object
org.ametys.plugins.workflow.AbstractWorkflowComponent
org.ametys.cms.workflow.AbstractContentWorkflowComponent
org.ametys.cms.workflow.SendMailFunction
- All Implemented Interfaces:
com.opensymphony.workflow.FunctionProvider
,EnhancedFunction
,PluginAware
,Initializable
,Contextualizable
,LogEnabled
,Serviceable
- Direct Known Subclasses:
SendMailFunction
,SendMailToUserFunction
public class SendMailFunction
extends AbstractContentWorkflowComponent
implements EnhancedFunction, Initializable, PluginAware, Contextualizable
OS workflow function to send mail after an action is triggered.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.ametys.plugins.workflow.EnhancedFunction
EnhancedFunction.FunctionArgument
-
Field Summary
Modifier and TypeFieldDescriptionprotected Context
The Avalon context.protected I18nUtils
I18nUtilsprotected String
The plugin name.protected RightManager
The rights manager.protected RightsExtensionPoint
The rights extension pointprotected SourceResolver
The source resolver.protected UserManager
The users manager.protected WorkflowProvider
The workflow.protected static final String
The mail body key.protected static final String
The rights key.static final String
Provide "false" to prevent the function sending the mail.protected static final String
The mail subject key.Fields inherited from class org.ametys.cms.workflow.AbstractContentWorkflowComponent
_contentHelper, CONTENT_KEY, HAS_CHANGED_KEY
Fields inherited from class org.ametys.plugins.workflow.AbstractWorkflowComponent
_logger, _manager, CONTEXT_PARAMETERS_KEY, FAIL_CONDITIONS_KEY, RESULT_MAP_KEY, WORKFLOW_ERRORS_KEY, WORKFLOW_WARNS_KEY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected String
_getContentUri
(WorkflowAwareContent content) Get the content uriRetrieve the request from which this component is called.protected String
Get the request URI.protected Set<UserIdentity>
_getUsers
(WorkflowAwareContent content, Set<String> rights) Get the user logins.protected void
Send the notification emails.void
contextualize
(Context context) void
Get the list of accepted arguments for this functiongetBodyI18nParams
(User user, WorkflowAwareContent content) Get the i18n parameters of mail body textgetCaller
(Map transientVars, WorkflowAwareContent content) Get the caller of the workflow actiongetDescription
(Map<String, String> argumentsValues) Get the function descriptions depending on arguments valuesprotected String
getMailBody
(String bodyI18nKey, User user, WorkflowAwareContent content, Map transientVars) Get the text body of mailprotected String
getMailSubject
(String subjectI18nKey, User user, WorkflowAwareContent content, Map transientVars) Get the subject of mailgetRecipients
(Map transientVars, WorkflowAwareContent content, Set<String> rights) Get the recipientsprotected String
getSender
(Map transientVars, WorkflowAwareContent content) Get the sender for mailgetSubjectI18nParams
(User user, WorkflowAwareContent content) Get the i18n parameters of mail subjectvoid
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.cms.workflow.AbstractContentWorkflowComponent
getContent, service
Methods inherited from class org.ametys.plugins.workflow.AbstractWorkflowComponent
addWorkflowError, addWorkflowWarning, enableLogging, getConditionFailures, getContextParameters, getResultsMap, getUser
-
Field Details
-
SEND_MAIL
Provide "false" to prevent the function sending the mail. Useful when making large automatic workflow operations (for instance, when bulk importing and proposing in one action).- See Also:
-
RIGHTS_KEY
The rights key.- See Also:
-
SUBJECT_KEY
The mail subject key.- See Also:
-
BODY_KEY
The mail body key.- See Also:
-
_rightManager
The rights manager. -
_userManager
The users manager. -
_sourceResolver
The source resolver. -
_workflowProvider
The workflow. -
_context
The Avalon context. -
_pluginName
The plugin name. -
_i18nUtils
I18nUtils -
_rightsExtensionPoint
The rights extension point
-
-
Constructor Details
-
SendMailFunction
public SendMailFunction()
-
-
Method Details
-
initialize
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
contextualize
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
setPluginInfo
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
-
execute
public void execute(Map transientVars, Map args, com.opensymphony.module.propertyset.PropertySet ps) throws com.opensymphony.workflow.WorkflowException - Specified by:
execute
in interfacecom.opensymphony.workflow.FunctionProvider
- Throws:
com.opensymphony.workflow.WorkflowException
-
getMailSubject
protected String getMailSubject(String subjectI18nKey, User user, WorkflowAwareContent content, Map transientVars) Get the subject of mail- Parameters:
subjectI18nKey
- the i18n key to use for subjectuser
- the callercontent
- the contenttransientVars
- the transient variables- Returns:
- the subject
-
getMailBody
protected String getMailBody(String bodyI18nKey, User user, WorkflowAwareContent content, Map transientVars) Get the text body of mail- Parameters:
bodyI18nKey
- the i18n key to use for bodyuser
- the callercontent
- the contenttransientVars
- the transient variables- Returns:
- the text body
-
_sendMails
Send the notification emails.- Parameters:
subject
- the e-mail subject.body
- the e-mail body.recipients
- the recipients emails address.from
- the address sending the e-mail.
-
getSubjectI18nParams
Get the i18n parameters of mail subject- Parameters:
user
- the callercontent
- the content- Returns:
- the i18n parameters
-
getBodyI18nParams
Get the i18n parameters of mail body text- Parameters:
user
- the callercontent
- the content- Returns:
- the i18n parameters
-
_getContentUri
Get the content uri- Parameters:
content
- the content- Returns:
- the content uri
-
_getRequestUri
Get the request URI.- Returns:
- the full request URI.
-
_getRequest
Retrieve the request from which this component is called.- Returns:
- the request or
null
.
-
getCaller
public User getCaller(Map transientVars, WorkflowAwareContent content) throws com.opensymphony.workflow.WorkflowException Get the caller of the workflow action- Parameters:
transientVars
- the transient variablescontent
- content the content- Returns:
- caller the caller if the workflow function
- Throws:
com.opensymphony.workflow.WorkflowException
- if failed to get caller
-
getSender
protected String getSender(Map transientVars, WorkflowAwareContent content) throws com.opensymphony.workflow.WorkflowException Get the sender for mail- Parameters:
transientVars
- the transient variablescontent
- the content- Returns:
- the sender email address
- Throws:
com.opensymphony.workflow.WorkflowException
- if failed to get email for sender
-
getRecipients
protected Set<String> getRecipients(Map transientVars, WorkflowAwareContent content, Set<String> rights) throws com.opensymphony.workflow.WorkflowException Get the recipients- Parameters:
transientVars
- the transient variablescontent
- the content.rights
- the set of rights to check.- Returns:
- the recipients.
- Throws:
com.opensymphony.workflow.WorkflowException
- If failed to get recipients
-
_getUsers
protected Set<UserIdentity> _getUsers(WorkflowAwareContent content, Set<String> rights) throws com.opensymphony.workflow.WorkflowException Get the user logins.- Parameters:
content
- the content.rights
- the set of rights to check.- Returns:
- the users.
- Throws:
com.opensymphony.workflow.WorkflowException
- If an error occurred
-
getArguments
Description copied from interface:EnhancedFunction
Get the list of accepted arguments for this function- Specified by:
getArguments
in interfaceEnhancedFunction
- Returns:
- a List of argument names and associated description
-
getDescription
Description copied from interface:EnhancedFunction
Get the function descriptions depending on arguments values- Specified by:
getDescription
in interfaceEnhancedFunction
- Parameters:
argumentsValues
- a map of the arguments with their values in current workflow- Returns:
- a description to display in workflow editor vue
-