Class DefaultEmailService

java.lang.Object
de.hybris.platform.acceleratorservices.email.impl.DefaultEmailService
All Implemented Interfaces:
EmailService

public class DefaultEmailService extends Object implements EmailService
Service to create and send emails.
  • Field Details

  • Constructor Details

    • DefaultEmailService

      public DefaultEmailService()
  • Method Details

    • getOrCreateEmailAddressForEmail

      public EmailAddressModel getOrCreateEmailAddressForEmail(String emailAddress, String displayName)
      Description copied from interface: EmailService
      Returns a EmailAddressModel. Instance is found for the given email address and display name criteria. If there is no instance for this condition the new EmailAddressModel instance is returned based on the given criteria.
      Specified by:
      getOrCreateEmailAddressForEmail in interface EmailService
      Parameters:
      emailAddress - Email id
      displayName - Display name
      Returns:
      EmailAddress object
    • createEmailAttachment

      public EmailAttachmentModel createEmailAttachment(DataInputStream masterDataStream, String filename, String mimeType)
      Description copied from interface: EmailService
      Creates an email attachment from an input stream.
      Specified by:
      createEmailAttachment in interface EmailService
      Parameters:
      masterDataStream - Input data stream
      filename - File name
      mimeType - Mime type
      Returns:
      EmailAttachment object
    • getEmailAttachmentsMediaFolder

      protected MediaFolderModel getEmailAttachmentsMediaFolder()
    • getEmailBodyMediaFolder

      protected MediaFolderModel getEmailBodyMediaFolder()
    • createEmailMessage

      public EmailMessageModel createEmailMessage(List<EmailAddressModel> toAddresses, List<EmailAddressModel> ccAddresses, List<EmailAddressModel> bccAddresses, EmailAddressModel fromAddress, String replyToAddress, String subject, String body, List<EmailAttachmentModel> attachments)
      Description copied from interface: EmailService
      Creates and EmailMessage object.
      Specified by:
      createEmailMessage in interface EmailService
      Parameters:
      toAddresses - List of To email addresses
      ccAddresses - List of CC email addresses
      bccAddresses - List of BCC email addresses
      fromAddress - From email address
      replyToAddress - Reply To email address
      subject - Subject of the email
      body - Contents of the email
      attachments - List of email attachments
      Returns:
      EmailMessage object
    • validateAddresses

      protected void validateAddresses(List<EmailAddressModel> toAddresses, EmailAddressModel fromAddress)
    • validateContent

      protected void validateContent(String subject, String body)
    • createBodyMedia

      protected MediaModel createBodyMedia(String bodyMediaName, String body)
      Method creates MediaModel object for storing email body
      Parameters:
      bodyMediaName - - name for created object
      body - - content of email body
      Returns:
      created MediaModel object
    • getCatalogVersion

      protected CatalogVersionModel getCatalogVersion()
    • validateEmailAddress

      protected void validateEmailAddress(String address, String type)
    • send

      public boolean send(EmailMessageModel message)
      Description copied from interface: EmailService
      Sends an email
      Specified by:
      send in interface EmailService
      Parameters:
      message - EmailMessage
      Returns:
      true if successful
    • addReplyTo

      protected void addReplyTo(EmailMessageModel message, org.apache.commons.mail.HtmlEmail email) throws org.apache.commons.mail.EmailException
      Throws:
      org.apache.commons.mail.EmailException
    • logInfo

      protected void logInfo(EmailMessageModel message, org.apache.commons.mail.EmailException e)
    • processAttachmentsSuccessful

      protected boolean processAttachmentsSuccessful(org.apache.commons.mail.HtmlEmail email, List<EmailAttachmentModel> attachments)
    • setAddresses

      protected void setAddresses(EmailMessageModel message, org.apache.commons.mail.HtmlEmail email, List<EmailAddressModel> toAddresses) throws org.apache.commons.mail.EmailException
      Throws:
      org.apache.commons.mail.EmailException
    • getPerConfiguredEmail

      protected org.apache.commons.mail.HtmlEmail getPerConfiguredEmail() throws org.apache.commons.mail.EmailException
      Throws:
      org.apache.commons.mail.EmailException
    • getBody

      protected String getBody(EmailMessageModel message)
      Method checks which attribute is storing email body (bodyMedia or body) and return its content as string
      Parameters:
      message - - email message object
      Returns:
      email body
    • nullifyEmpty

      protected String nullifyEmpty(String str)
    • getAddresses

      protected Collection<javax.mail.internet.InternetAddress> getAddresses(List<EmailAddressModel> emailAddresses)
    • createInternetAddress

      protected javax.mail.internet.InternetAddress createInternetAddress(String emailAddress, String displayName) throws org.apache.commons.mail.EmailException
      Throws:
      org.apache.commons.mail.EmailException
    • convertToStrings

      protected List<String> convertToStrings(List<EmailAddressModel> addresses)
    • logDebugException

      protected void logDebugException(Exception e)
    • getEmailAddressFetchStrategy

      protected EmailAddressFetchStrategy getEmailAddressFetchStrategy()
    • setEmailAddressFetchStrategy

      public void setEmailAddressFetchStrategy(EmailAddressFetchStrategy emailAddressFetchStrategy)
    • getEmailAttachmentsMediaFolderName

      protected String getEmailAttachmentsMediaFolderName()
    • setEmailAttachmentsMediaFolderName

      public void setEmailAttachmentsMediaFolderName(String emailAttachmentsMediaFolderName)
    • getEmailBodyMediaFolderName

      protected String getEmailBodyMediaFolderName()
    • setEmailBodyMediaFolderName

      public void setEmailBodyMediaFolderName(String emailBodyMediaFolderName)
    • getModelService

      protected ModelService getModelService()
    • setModelService

      public void setModelService(ModelService modelService)
    • getMediaService

      protected MediaService getMediaService()
    • setMediaService

      public void setMediaService(MediaService mediaService)
    • getConfigurationService

      protected ConfigurationService getConfigurationService()
    • setConfigurationService

      public void setConfigurationService(ConfigurationService configurationService)
    • getCatalogVersionService

      protected CatalogVersionService getCatalogVersionService()
    • setCatalogVersionService

      public void setCatalogVersionService(CatalogVersionService catalogVersionService)
    • getCatalogService

      protected CatalogService getCatalogService()
    • setCatalogService

      public void setCatalogService(CatalogService catalogService)