Class FormSendMailFunction
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.ametys.plugins.forms.workflow.FormSendMailFunction
- All Implemented Interfaces:
com.opensymphony.workflow.FunctionProvider
,EnhancedFunction
,Component
,LogEnabled
,Serviceable
public class FormSendMailFunction
extends AbstractLogEnabled
implements Component, EnhancedFunction, Serviceable
OS workflow function to send mail after an action is triggered.
The author of a form entry is also notified if the receipt is set
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.ametys.plugins.workflow.EnhancedFunction
EnhancedFunction.FunctionType
-
Field Summary
Modifier and TypeFieldDescriptionprotected CurrentUserProvider
The current user providerprotected FormDAO
The form DAOprotected FormMailHelper
The form mail helperprotected I18nUtils
I18nUtilsprotected AmetysObjectResolver
The ametys object resolverprotected SiteManager
The site managerprotected SourceResolver
The source resolver.protected UserManager
The user managerprotected WorkflowFormMailExtensionPoint
The workflow form mail EPstatic final String
Body key argument of the emailstatic final String
Body xsl argument of the emailstatic final String
Comment argument of the emailstatic final String
Recipient argument of the emailstatic final String
Recipient role argument of the emailstatic final String
Send if comment argument of the emailstatic final String
Sender argument of the emailstatic final String
Sender role argument of the emailstatic final String
Subject key argument of the email -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected String
_getBody
(FormEntry formEntry, Map transientVars, Map args, org.ametys.plugins.forms.workflow.FormSendMailFunction.UserAndMail receiver, I18nizableText subject) Get the mail body First look at the configured xsl in mail-xsl Then look at the configured body i18n key in body-key Then take the default i18n keyprotected String
_getBodyFromI18nKey
(FormEntry formEntry, Map transientVars, Map args, I18nizableText subject) Get the mail body from i18n key First look at the configured body i18n key in body-key Then take the default i18n key_getBodyI18nParams
(FormEntry formEntry) Get the i18n parameters of mail body textprotected List<org.ametys.plugins.forms.workflow.FormSendMailFunction.UserAndMail>
_getRecipients
(FormEntry formEntry, Map transientVars, Map args) Get the list of recipients to send the mail First look at the configured recipient role in recipient-role Then look at the configured recipient in recipient Then take the entry userprotected String
_getSender
(FormEntry formEntry, Map transientVars, Map args) Get the sender of the mail First look at the configured sender role in sender-role Then look at the configured sender in sender Then take the current user Then take the sender in admin configurationprotected I18nizableText
_getSubject
(FormEntry formEntry, Map transientVars, Map args) Get the mail subject First look at the configured subject i18n key in subject-key Then take the default i18n key_getSubjectI18nParams
(FormEntry formEntry) Get the i18n parameters of mail subjectvoid
Get the list of accepted arguments for this functionReturn the type for the functiongetLabel()
Get the label for this functionvoid
service
(ServiceManager manager) Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.ametys.plugins.workflow.EnhancedFunction
getFullLabel, getVisibilities
-
Field Details
-
ARG_SENDER
Sender argument of the email- See Also:
-
ARG_SENDER_ROLE
Sender role argument of the email- See Also:
-
ARG_RECIPIENT
Recipient argument of the email- See Also:
-
ARG_RECIPIENT_ROLE
Recipient role argument of the email- See Also:
-
ARG_SUBJECT_KEY
Subject key argument of the email- See Also:
-
ARG_BODY_KEY
Body key argument of the email- See Also:
-
ARG_BODY_XSL
Body xsl argument of the email- See Also:
-
ARG_COMMENT
Comment argument of the email- See Also:
-
ARG_SEND_IF_COMMENT
Send if comment argument of the email- See Also:
-
_currentUserProvider
The current user provider -
_userManager
The user manager -
_sourceResolver
The source resolver. -
_resolver
The ametys object resolver -
_formDAO
The form DAO -
_i18nUtils
I18nUtils -
_workflowFormMailEP
The workflow form mail EP -
_siteManager
The site manager -
_formMailHelper
The form mail helper
-
-
Constructor Details
-
FormSendMailFunction
public FormSendMailFunction()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
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
-
_getSender
Get the sender of the mail First look at the configured sender role in sender-role Then look at the configured sender in sender Then take the current user Then take the sender in admin configuration- Parameters:
formEntry
- the form entrytransientVars
- the workflow transient varsargs
- the workflow args- Returns:
- the mail subject as string
-
_getRecipients
protected List<org.ametys.plugins.forms.workflow.FormSendMailFunction.UserAndMail> _getRecipients(FormEntry formEntry, Map transientVars, Map args) Get the list of recipients to send the mail First look at the configured recipient role in recipient-role Then look at the configured recipient in recipient Then take the entry user- Parameters:
formEntry
- the form entrytransientVars
- the workflow transient varsargs
- the workflow args- Returns:
- the list of user or mail
-
_getSubject
Get the mail subject First look at the configured subject i18n key in subject-key Then take the default i18n key- Parameters:
formEntry
- the form entrytransientVars
- the workflow transient varsargs
- the workflow args- Returns:
- the mail subject as string
-
_getBody
protected String _getBody(FormEntry formEntry, Map transientVars, Map args, org.ametys.plugins.forms.workflow.FormSendMailFunction.UserAndMail receiver, I18nizableText subject) throws IOException Get the mail body First look at the configured xsl in mail-xsl Then look at the configured body i18n key in body-key Then take the default i18n key- Parameters:
formEntry
- the form entrytransientVars
- the workflow transient varsargs
- the workflow argsreceiver
- the receiversubject
- the subject of the mail- Returns:
- the mail body as string
- Throws:
IOException
- if an error occurred
-
_getBodyFromI18nKey
protected String _getBodyFromI18nKey(FormEntry formEntry, Map transientVars, Map args, I18nizableText subject) throws IOException Get the mail body from i18n key First look at the configured body i18n key in body-key Then take the default i18n key- Parameters:
formEntry
- the form entrytransientVars
- the workflow transient varsargs
- the workflow argssubject
- the mail subject- Returns:
- the mail body as string
- Throws:
IOException
- if an error occurred
-
_getSubjectI18nParams
Get the i18n parameters of mail subject- Parameters:
formEntry
- the form entry- Returns:
- the i18n parameters
-
_getBodyI18nParams
Get the i18n parameters of mail body text- Parameters:
formEntry
- the form entry- Returns:
- the i18n parameters
-
getFunctionExecType
Description copied from interface:EnhancedFunction
Return the type for the function- Specified by:
getFunctionExecType
in interfaceEnhancedFunction
- Returns:
- the type 's code
-
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
-
getLabel
Description copied from interface:EnhancedFunction
Get the label for this function- Specified by:
getLabel
in interfaceEnhancedFunction
- Returns:
- the label
-