Class MailActionExecuter
java.lang.Object
org.alfresco.repo.action.CommonResourceAbstractBase
org.alfresco.repo.action.ParameterizedItemAbstractBase
org.alfresco.repo.action.executer.ActionExecuterAbstractBase
org.alfresco.repo.action.executer.MailActionExecuter
- All Implemented Interfaces:
ActionExecuter,LoggingAwareExecuter,TestModeable,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.InitializingBean
public class MailActionExecuter
extends ActionExecuterAbstractBase
implements org.springframework.beans.factory.InitializingBean, TestModeable
Mail action executor implementation.
Note on executing this action as System: it is allowed to execute
mail actions as system. However there is a limitation if you do so. Because the system user is not a normal user and specifically because there is no corresponding cm:person node for system, it is not possible to use any reference to that person in the associated email template. Various email templates use a 'person' object in the FTL model to access things like first name, last name etc. In the case of mail actions sent while running as system, none of these will be available.- Author:
- Roy Wetherall
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringAction executor constantsstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class org.alfresco.repo.action.executer.ActionExecuterAbstractBase
actionAccessRestrictions, actionDefinition, applicableTypes, publicActionFields inherited from class org.alfresco.repo.action.ParameterizedItemAbstractBase
adhocPropertiesAllowed, DISPLAY_LABEL, runtimeActionServiceFields inherited from class org.alfresco.repo.action.CommonResourceAbstractBase
nameFields inherited from interface org.alfresco.repo.action.executer.ActionExecuter
PARAM_RESULT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddParameterDefinitions(List<ParameterDefinition> paramList) Add the parameter definitionsvoidInitialise beanvoidUsed when test mode is enabled.protected voidexecuteImpl(Action ruleAction, NodeRef actionedUponNodeRef) Send an email messageintintgetPersonEmail(String user) intvoidinit()Init methodbooleanstatic booleanbooleanprotected voidonFail()protected voidonSend()booleanpersonExists(String user) org.springframework.mail.javamail.MimeMessageHelperprepareEmail(Action ruleAction, NodeRef actionedUponNodeRef, Pair<String, Locale> recipient, Pair<jakarta.mail.internet.InternetAddress, Locale> sender) intjakarta.mail.internet.MimeMessageReturns the most recent message that wasn't sent because TestMode had been enabled.booleanSend a test messagevoidsetAuthenticationService(AuthenticationService authService) voidsetAuthorityService(AuthorityService authorityService) voidsetFromAddress(String fromAddress) voidsetFromEnabled(boolean fromEnabled) voidsetHeaderEncoding(String headerEncoding) voidsetImageResolver(TemplateImageResolver imageResolver) voidsetMailService(org.springframework.mail.javamail.JavaMailSender javaMailSender) voidsetNodeService(NodeService nodeService) voidsetPersonService(PersonService personService) voidsetPreferenceService(PreferenceService preferenceService) voidsetSendTestMessage(boolean sendTestMessage) voidsetServiceRegistry(ServiceRegistry serviceRegistry) voidsetSysAdminParams(SysAdminParams sysAdminParams) voidsetTemplateService(TemplateService templateService) voidsetTenantService(TenantService tenantService) voidsetTestMessageSubject(String testMessageSubject) voidsetTestMessageText(String testMessageText) voidsetTestMessageTo(String testMessageTo) voidsetTestMode(boolean testMode) voidsetTestModeRecipient(String testModeRecipient) voidsetValidateAddresses(boolean validateAddresses) Methods inherited from class org.alfresco.repo.action.executer.ActionExecuterAbstractBase
createActionDefinition, execute, getActionAccessRestrictions, getActionDefinition, getIgnoreLock, getQueueName, getTrackStatus, isApplicableType, onLogException, setActionAccessRestrictions, setApplicableTypes, setBaseNodeService, setDictionaryService, setIgnoreLock, setLockService, setMlAwareNodeService, setPublicAction, setQueueName, setTrackStatus, verifyActionAccessRestrictionsMethods inherited from class org.alfresco.repo.action.ParameterizedItemAbstractBase
checkMandatoryProperties, getAdhocPropertiesAllowed, getDescriptionKey, getLocalizedParameterDefinitions, getParamDisplayLabel, getParamDisplayLabel, getParameterDefintions, getTitleKey, setAdhocPropertiesAllowed, setLocales, setRuntimeActionService, toStringMethods inherited from class org.alfresco.repo.action.CommonResourceAbstractBase
setBeanNameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.alfresco.repo.action.executer.ActionExecuter
isExecuteAsynchronously
-
Field Details
-
NAME
Action executor constants- See Also:
-
PARAM_LOCALE
- See Also:
-
PARAM_TO
- See Also:
-
PARAM_CC
- See Also:
-
PARAM_BCC
- See Also:
-
PARAM_TO_MANY
- See Also:
-
PARAM_SUBJECT
- See Also:
-
PARAM_SUBJECT_PARAMS
- See Also:
-
PARAM_TEXT
- See Also:
-
PARAM_HTML
- See Also:
-
PARAM_FROM
- See Also:
-
PARAM_FROM_PERSONAL_NAME
- See Also:
-
PARAM_TEMPLATE
- See Also:
-
PARAM_TEMPLATE_MODEL
- See Also:
-
PARAM_IGNORE_SEND_FAILURE
- See Also:
-
PARAM_SEND_AFTER_COMMIT
- See Also:
-
-
Constructor Details
-
MailActionExecuter
public MailActionExecuter()
-
-
Method Details
-
setMailService
public void setMailService(org.springframework.mail.javamail.JavaMailSender javaMailSender) - Parameters:
javaMailSender- the java mail sender
-
setTemplateService
- Parameters:
templateService- the TemplateService
-
setPersonService
- Parameters:
personService- the PersonService
-
setPreferenceService
-
setAuthenticationService
- Parameters:
authService- the AuthenticationService
-
setServiceRegistry
- Parameters:
serviceRegistry- the ServiceRegistry
-
setAuthorityService
- Parameters:
authorityService- the AuthorityService
-
setNodeService
- Parameters:
nodeService- the NodeService to set.
-
setTenantService
- Parameters:
tenantService- the TenantService to set.
-
setHeaderEncoding
- Parameters:
headerEncoding- The mail header encoding to set.
-
setFromAddress
- Parameters:
fromAddress- The default mail address.
-
setSysAdminParams
-
setImageResolver
-
setTestMessageTo
-
getTestMessageTo
-
setTestMessageSubject
-
setTestMessageText
-
setSendTestMessage
public void setSendTestMessage(boolean sendTestMessage) -
sendTestMessage
public boolean sendTestMessage()Send a test message- Returns:
- true, message sent
- Throws:
org.alfresco.error.AlfrescoRuntimeException
-
setTestModeRecipient
-
setValidateAddresses
public void setValidateAddresses(boolean validateAddresses) -
init
public void init()Description copied from class:ActionExecuterAbstractBaseInit method- Overrides:
initin classActionExecuterAbstractBase
-
afterPropertiesSet
Initialise bean- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-
executeImpl
Send an email message- Specified by:
executeImplin classActionExecuterAbstractBase- Parameters:
ruleAction- the actionactionedUponNodeRef- the actioned upon node- Throws:
org.alfresco.error.AlfrescoRuntimeException
-
prepareEmail
-
personExists
-
getPerson
-
getPersonEmail
-
addParameterDefinitions
Add the parameter definitions- Specified by:
addParameterDefinitionsin classParameterizedItemAbstractBase- Parameters:
paramList- the parameter definitions list
-
setTestMode
public void setTestMode(boolean testMode) - Specified by:
setTestModein interfaceTestModeable
-
isTestMode
public boolean isTestMode()- Specified by:
isTestModein interfaceTestModeable
-
retrieveLastTestMessage
public jakarta.mail.internet.MimeMessage retrieveLastTestMessage()Returns the most recent message that wasn't sent because TestMode had been enabled. -
getTestSentCount
public int getTestSentCount() -
resetTestSentCount
public int resetTestSentCount() -
clearLastTestMessage
public void clearLastTestMessage()Used when test mode is enabled. Clears the record of the last message that was sent. -
setFromEnabled
public void setFromEnabled(boolean fromEnabled) -
isFromEnabled
public boolean isFromEnabled() -
isHTML
-
onSend
protected void onSend() -
onFail
protected void onFail() -
getNumberSuccessfulSends
public int getNumberSuccessfulSends() -
getNumberFailedSends
public int getNumberFailedSends()
-