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
FieldsModifier and TypeFieldDescriptionprotected CurrentUserProviderThe current user providerprotected FormDAOThe form DAOprotected FormMailHelperThe form mail helperprotected I18nUtilsI18nUtilsprotected AmetysObjectResolverThe ametys object resolverprotected SiteManagerThe site managerprotected SourceResolverThe source resolver.protected UserLanguagesManagerThe user languages managerprotected UserManagerThe user managerprotected WorkflowFormMailExtensionPointThe workflow form mail EPstatic final StringBody key argument of the emailstatic final StringBody xsl argument of the emailstatic final StringComment argument of the emailstatic final StringRecipient argument of the emailstatic final StringRecipient role argument of the emailstatic final StringSend if comment argument of the emailstatic final StringSender argument of the emailstatic final StringSender role argument of the emailstatic final StringSubject key argument of the email -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleantrueto add attachments to emailprotected String_getBody(FormEntry formEntry, Map transientVars, Map args, org.ametys.plugins.forms.workflow.FormSendMailFunction.UserAndMail receiver, I18nizableText subject, String language) 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, String language) 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 subjectprotected booleantrueto add only readable file question in attachmentprotected booleantrueto add only writable file question in attachmentvoidGet the list of accepted arguments for this functionReturn the type for the functiongetLabel()Get the label for this functionvoidservice(ServiceManager manager) Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLoggerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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 -
_userLanguagesManager
The user languages manager
-
-
Constructor Details
-
FormSendMailFunction
public FormSendMailFunction()
-
-
Method Details
-
service
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
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
-
_addAttachment
trueto add attachments to email- Returns:
trueto add attachments to email
-
_onlyWritableQuestionForAttachment
trueto add only writable file question in attachment- Returns:
trueto add only writable file question in attachment
-
_onlyReadableQuestionForAttachment
trueto add only readable file question in attachment- Returns:
trueto add only readable file question in attachment
-
_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, String language) 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 maillanguage- The language to use- Returns:
- the mail body as string
- Throws:
IOException- if an error occurred
-
_getBodyFromI18nKey
protected String _getBodyFromI18nKey(FormEntry formEntry, Map transientVars, Map args, I18nizableText subject, String language) 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 subjectlanguage- The language to use- 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:EnhancedFunctionReturn the type for the function- Specified by:
getFunctionExecTypein interfaceEnhancedFunction- Returns:
- the type 's code
-
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
-
getLabel
Description copied from interface:EnhancedFunctionGet the label for this function- Specified by:
getLabelin interfaceEnhancedFunction- Returns:
- the label
-