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
  • Field Details

  • Constructor Details

    • MailActionExecuter

      public MailActionExecuter()
  • Method Details

    • 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(NodeService nodeService)
      Parameters:
      nodeService - the NodeService to set.
    • setTenantService

      public void setTenantService(TenantService tenantService)
      Parameters:
      tenantService - the TenantService to set.
    • setHeaderEncoding

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

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

      public void setSysAdminParams(SysAdminParams sysAdminParams)
    • setImageResolver

      public void setImageResolver(TemplateImageResolver imageResolver)
    • setTestMessageTo

      public void setTestMessageTo(String testMessageTo)
    • getTestMessageTo

      public String getTestMessageTo()
    • setTestMessageSubject

      public void setTestMessageSubject(String testMessageSubject)
    • setTestMessageText

      public void setTestMessageText(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(String testModeRecipient)
    • setValidateAddresses

      public void setValidateAddresses(boolean validateAddresses)
    • init

      public void init()
      Description copied from class: ActionExecuterAbstractBase
      Init method
      Overrides:
      init in class ActionExecuterAbstractBase
    • afterPropertiesSet

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

      protected void executeImpl(Action ruleAction, 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, NodeRef actionedUponNodeRef, Pair<String,Locale> recipient, Pair<jakarta.mail.internet.InternetAddress,Locale> sender)
    • personExists

      public boolean personExists(String user)
    • getPerson

      public NodeRef getPerson(String user)
    • getPersonEmail

      public String getPersonEmail(String user)
    • addParameterDefinitions

      protected void addParameterDefinitions(List<ParameterDefinition> paramList)
      Add the parameter definitions
      Specified by:
      addParameterDefinitions in class ParameterizedItemAbstractBase
      Parameters:
      paramList - the parameter definitions list
    • setTestMode

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

      public boolean isTestMode()
      Specified by:
      isTestMode in interface TestModeable
    • 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

      public static boolean isHTML(String value)
    • onSend

      protected void onSend()
    • onFail

      protected void onFail()
    • getNumberSuccessfulSends

      public int getNumberSuccessfulSends()
    • getNumberFailedSends

      public int getNumberFailedSends()