Class 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
    • Constructor Detail

      • MailActionExecuter

        public MailActionExecuter()
    • Method Detail

      • setMailService

        public void setMailService​(org.springframework.mail.javamail.JavaMailSender javaMailSender)
        Parameters:
        javaMailSender - the java mail sender
      • setTemplateService

        public void setTemplateService​(TemplateService templateService)
        Parameters:
        templateService - the TemplateService
      • setPersonService

        public void setPersonService​(PersonService personService)
        Parameters:
        personService - the PersonService
      • setPreferenceService

        public void setPreferenceService​(PreferenceService preferenceService)
      • setAuthenticationService

        public void setAuthenticationService​(AuthenticationService authService)
        Parameters:
        authService - the AuthenticationService
      • setServiceRegistry

        public void setServiceRegistry​(ServiceRegistry serviceRegistry)
        Parameters:
        serviceRegistry - the ServiceRegistry
      • setAuthorityService

        public void setAuthorityService​(AuthorityService authorityService)
        Parameters:
        authorityService - the AuthorityService
      • setNodeService

        public void setNodeService​(org.alfresco.service.cmr.repository.NodeService nodeService)
        Parameters:
        nodeService - the NodeService to set.
      • setTenantService

        public void setTenantService​(org.alfresco.repo.tenant.TenantService tenantService)
        Parameters:
        tenantService - the TenantService to set.
      • setHeaderEncoding

        public void setHeaderEncoding​(java.lang.String headerEncoding)
        Parameters:
        headerEncoding - The mail header encoding to set.
      • setFromAddress

        public void setFromAddress​(java.lang.String fromAddress)
        Parameters:
        fromAddress - The default mail address.
      • setSysAdminParams

        public void setSysAdminParams​(SysAdminParams sysAdminParams)
      • setTestMessageTo

        public void setTestMessageTo​(java.lang.String testMessageTo)
      • getTestMessageTo

        public java.lang.String getTestMessageTo()
      • setTestMessageSubject

        public void setTestMessageSubject​(java.lang.String testMessageSubject)
      • setTestMessageText

        public void setTestMessageText​(java.lang.String testMessageText)
      • setSendTestMessage

        public void setSendTestMessage​(boolean sendTestMessage)
      • sendTestMessage

        public boolean sendTestMessage()
        Send a test message
        Returns:
        true, message sent
        Throws:
        org.alfresco.error.AlfrescoRuntimeException
      • setTestModeRecipient

        public void setTestModeRecipient​(java.lang.String testModeRecipient)
      • setValidateAddresses

        public void setValidateAddresses​(boolean validateAddresses)
      • afterPropertiesSet

        public void afterPropertiesSet()
                                throws java.lang.Exception
        Initialise bean
        Specified by:
        afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
        Throws:
        java.lang.Exception
      • executeImpl

        protected void executeImpl​(Action ruleAction,
                                   org.alfresco.service.cmr.repository.NodeRef actionedUponNodeRef)
        Send an email message
        Specified by:
        executeImpl in class ActionExecuterAbstractBase
        Parameters:
        ruleAction - the action
        actionedUponNodeRef - the actioned upon node
        Throws:
        org.alfresco.error.AlfrescoRuntimeException
      • prepareEmail

        public org.springframework.mail.javamail.MimeMessageHelper prepareEmail​(Action ruleAction,
                                                                                org.alfresco.service.cmr.repository.NodeRef actionedUponNodeRef,
                                                                                org.alfresco.util.Pair<java.lang.String,​java.util.Locale> recipient,
                                                                                org.alfresco.util.Pair<javax.mail.internet.InternetAddress,​java.util.Locale> sender)
      • personExists

        public boolean personExists​(java.lang.String user)
      • getPerson

        public org.alfresco.service.cmr.repository.NodeRef getPerson​(java.lang.String user)
      • getPersonEmail

        public java.lang.String getPersonEmail​(java.lang.String user)
      • setTestMode

        public void setTestMode​(boolean testMode)
        Specified by:
        setTestMode in interface TestModeable
      • retrieveLastTestMessage

        public javax.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

        public static boolean isHTML​(java.lang.String value)
      • onSend

        protected void onSend()
      • onFail

        protected void onFail()
      • getNumberSuccessfulSends

        public int getNumberSuccessfulSends()
      • getNumberFailedSends

        public int getNumberFailedSends()