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
FieldsModifier and TypeFieldDescriptionprotected ContextThe Avalon context.protected I18nUtilsI18nUtilsprotected StringThe plugin name.protected RightManagerThe rights manager.protected RightsExtensionPointThe rights extension pointprotected SourceResolverThe source resolver.protected UserManagerThe users manager.protected WorkflowProviderThe workflow.protected static final StringThe mail body key.protected static final StringThe rights key.static final StringProvide "false" to prevent the function sending the mail.protected static final StringThe mail subject key.Fields inherited from class org.ametys.cms.workflow.AbstractContentWorkflowComponent
_contentHelper, CONTENT_KEY, HAS_CHANGED_KEYFields 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected String_getContentUri(WorkflowAwareContent content) Get the content uriRetrieve the request from which this component is called.protected StringGet the request URI.protected Set<UserIdentity>_getUsers(WorkflowAwareContent content, Set<String> rights) Get the user logins.protected voidSend the notification emails.voidcontextualize(Context context) voidGet 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 StringgetMailBody(String bodyI18nKey, User user, WorkflowAwareContent content, Map transientVars) Get the text body of mailprotected StringgetMailSubject(String subjectI18nKey, User user, WorkflowAwareContent content, Map transientVars) Get the subject of mailgetRecipients(Map transientVars, WorkflowAwareContent content, Set<String> rights) Get the recipientsprotected StringgetSender(Map transientVars, WorkflowAwareContent content) Get the sender for mailgetSubjectI18nParams(User user, WorkflowAwareContent content) Get the i18n parameters of mail subjectvoidvoidsetPluginInfo(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, serviceMethods 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:
initializein interfaceInitializable- Throws:
Exception
-
contextualize
- Specified by:
contextualizein interfaceContextualizable- Throws:
ContextException
-
setPluginInfo
Description copied from interface:PluginAwareSets 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:
setPluginInfoin 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:
executein 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:EnhancedFunctionGet the list of accepted arguments for this function- Specified by:
getArgumentsin interfaceEnhancedFunction- Returns:
- a List of argument names and associated description
-
getDescription
Description copied from interface:EnhancedFunctionGet the function descriptions depending on arguments values- Specified by:
getDescriptionin interfaceEnhancedFunction- Parameters:
argumentsValues- a map of the arguments with their values in current workflow- Returns:
- a description to display in workflow editor vue
-