Class DelegatingMail

java.lang.Object
ch.tocco.nice2.messaging.mail.spi.DelegatingMail
All Implemented Interfaces:
BaseMail, Mail, Cloneable
Direct Known Subclasses:
IncaIncomeMail

public class DelegatingMail extends Object implements Mail
  • Constructor Details

    • DelegatingMail

      public DelegatingMail(Mail delegate)
  • Method Details

    • getSubject

      public String getSubject()
      Specified by:
      getSubject in interface BaseMail
    • setSubject

      public void setSubject(@Nullable @Nullable String subject)
      Specified by:
      setSubject in interface BaseMail
    • getFrom

      public jakarta.mail.internet.InternetAddress getFrom()
      Specified by:
      getFrom in interface BaseMail
    • setFrom

      public void setFrom(jakarta.mail.internet.InternetAddress from)
      Specified by:
      setFrom in interface BaseMail
    • getTo

      public List<jakarta.mail.internet.InternetAddress> getTo()
      Specified by:
      getTo in interface BaseMail
    • addTo

      public void addTo(jakarta.mail.internet.InternetAddress address)
      Specified by:
      addTo in interface BaseMail
    • addTo

      public void addTo(List<String> addresses)
      Description copied from interface: BaseMail
      Add addresses from a List<String> to "to".
      Can be either only email or email and name in format: "firstname lastname <email>.
      example: "Hans Meier <hmeier@tocco.ch>" This is only necessary if no recipient entity is set or if you want to add further addresses
      Specified by:
      addTo in interface BaseMail
      Parameters:
      addresses - List
    • addTo

      public void addTo(String addresses)
      Description copied from interface: BaseMail
      Add addresses from a String to "to".
      Can be either only email or email and name in format: "firstname lastname <email>.
      example: "Hans Meier <hmeier@tocco.ch>" This is only necessary if no recipient entity is set or if you want to add further addresses
      Specified by:
      addTo in interface BaseMail
      Parameters:
      addresses - String separated with "," or "\n"
    • clearTo

      public void clearTo()
      Specified by:
      clearTo in interface BaseMail
    • getCc

      public List<jakarta.mail.internet.InternetAddress> getCc()
      Specified by:
      getCc in interface BaseMail
    • addCc

      public void addCc(jakarta.mail.internet.InternetAddress address)
      Specified by:
      addCc in interface BaseMail
    • addCc

      public void addCc(List<String> addresses)
      Description copied from interface: BaseMail
      Add addresses from a List to "cc".
      Can be either only email or email and name in format: "firstname lastname <email>.
      example: "Hans Meier <hmeier@tocco.ch>"
      Specified by:
      addCc in interface BaseMail
      Parameters:
      addresses - List
    • addCc

      public void addCc(String addresses)
      Description copied from interface: BaseMail
      Add addresses from a String to "cc".
      Can be either only email or email and name in format: "firstname lastname <email>.
      example: "Hans Meier <hmeier@tocco.ch>"
      Specified by:
      addCc in interface BaseMail
      Parameters:
      addresses - String separated with "," or "\n"
    • clearCc

      public void clearCc()
      Specified by:
      clearCc in interface BaseMail
    • getBcc

      public List<jakarta.mail.internet.InternetAddress> getBcc()
      Specified by:
      getBcc in interface BaseMail
    • addBcc

      public void addBcc(jakarta.mail.internet.InternetAddress address)
      Specified by:
      addBcc in interface BaseMail
    • addBcc

      public void addBcc(List<String> addresses)
      Description copied from interface: BaseMail
      Add addresses from a List<String> to "bcc".
      Can be either only email or email and name in format: "firstname lastname <email>.
      example: "Hans Meier <hmeier@tocco.ch>"
      Specified by:
      addBcc in interface BaseMail
      Parameters:
      addresses - List
    • addBcc

      public void addBcc(String addresses)
      Description copied from interface: BaseMail
      Add addresses from a String to "bcc".
      Can be either only email or email and name in format: "firstname lastname <email>.
      example: "Hans Meier <hmeier@tocco.ch>"
      Specified by:
      addBcc in interface BaseMail
      Parameters:
      addresses - String separated with "," or "\n"
    • clearBcc

      public void clearBcc()
      Specified by:
      clearBcc in interface BaseMail
    • getReplyTo

      public List<jakarta.mail.internet.InternetAddress> getReplyTo()
      Specified by:
      getReplyTo in interface BaseMail
    • addReplyTo

      public void addReplyTo(jakarta.mail.internet.InternetAddress address)
      Specified by:
      addReplyTo in interface BaseMail
    • addReplyTo

      public void addReplyTo(String addresses)
      Description copied from interface: BaseMail
      Add addresses from a String to "replyTo".
      Can be either only email or email and name in format: "firstname lastname <email>.
      example: "Hans Meier <hmeier@tocco.ch>"
      Specified by:
      addReplyTo in interface BaseMail
      Parameters:
      addresses - String separated with "," or "\n"
    • addReplyTo

      public void addReplyTo(List<String> addresses)
      Description copied from interface: BaseMail
      Add addresses from a List<String> to "replyTo".
      Can be either only email or email and name in format: "firstname lastname <email>.
      example: "Hans Meier <hmeier@tocco.ch>"
      Specified by:
      addReplyTo in interface BaseMail
      Parameters:
      addresses - List
    • clearReplyTo

      public void clearReplyTo()
      Specified by:
      clearReplyTo in interface BaseMail
    • getText

      @Nullable public @Nullable String getText()
      Specified by:
      getText in interface BaseMail
    • setText

      public void setText(@Nullable @Nullable String body)
      Specified by:
      setText in interface BaseMail
    • getHtml

      @Nullable public @Nullable String getHtml()
      Specified by:
      getHtml in interface BaseMail
    • setHtml

      public void setHtml(@Nullable @Nullable String html)
      Specified by:
      setHtml in interface BaseMail
    • getAttachments

      public List<Attachment> getAttachments()
      Specified by:
      getAttachments in interface BaseMail
    • clearAttachments

      public void clearAttachments()
      Specified by:
      clearAttachments in interface BaseMail
    • createAttachment

      public Attachment createAttachment(@Nullable @Nullable String id, @Nullable @Nullable String fileName, Binary binary)
      Description copied from interface: BaseMail
      Adds the given attachment to this mail. The content is taken from the given binary. The returned attachment is restricted in that it is not allowed to load new content using methods Attachment.setContent(byte[]),Attachment.loadContent(java.io.InputStream) or Attachment.setMimeType(MimeType) for setting the mime type
      Specified by:
      createAttachment in interface BaseMail
      Parameters:
      id - optional id for this attachment
      fileName - optional name for this attachment
      binary - the content
    • createAttachment

      public Attachment createAttachment(jakarta.activation.MimeType mimeType)
      Specified by:
      createAttachment in interface BaseMail
    • createAttachment

      public Attachment createAttachment(@Nullable @Nullable String id, jakarta.activation.MimeType mimeType)
      Specified by:
      createAttachment in interface BaseMail
    • addAttachment

      public void addAttachment(Attachment attachment)
      Specified by:
      addAttachment in interface BaseMail
    • getSourceEntity

      @Nullable public @Nullable Entity getSourceEntity()
      Specified by:
      getSourceEntity in interface Mail
    • setSourceEntity

      public Mail setSourceEntity(@Nullable @Nullable Entity sourceEntity)
      Specified by:
      setSourceEntity in interface Mail
    • addSourceEntity

      public Mail addSourceEntity(@Nullable @Nullable Entity sourceEntity)
      Specified by:
      addSourceEntity in interface Mail
    • getRelatedEntity

      @Nullable public @Nullable Entity getRelatedEntity()
      Specified by:
      getRelatedEntity in interface Mail
    • setRelatedEntity

      public Mail setRelatedEntity(@Nullable @Nullable Entity relatedEntity)
      Specified by:
      setRelatedEntity in interface Mail
    • getRecipientEntity

      @Nullable public @Nullable Entity getRecipientEntity()
      Specified by:
      getRecipientEntity in interface Mail
    • setRecipientEntity

      public Mail setRecipientEntity(@Nullable @Nullable Entity recipientEntity)
      Specified by:
      setRecipientEntity in interface Mail
    • addTo

      public Mail addTo(MailReceiver receiver) throws jakarta.mail.MessagingException
      Description copied from interface: Mail
      Add a receiver to "to", evaluating the right value according to the MailReceiver^s configuration.
      Specified by:
      addTo in interface Mail
      Parameters:
      receiver - the receiver
      Throws:
      jakarta.mail.MessagingException
    • addTo

      public Mail addTo(Entity userEntity) throws jakarta.mail.MessagingException
      Description copied from interface: Mail
      Add the address from a User entity to "to".
      Specified by:
      addTo in interface Mail
      Parameters:
      userEntity - Entity of type User
      Throws:
      jakarta.mail.MessagingException
    • addTo

      public Mail addTo(EntityList userEntities) throws jakarta.mail.MessagingException
      Description copied from interface: Mail
      Add addresses from User entities to "to".
      Specified by:
      addTo in interface Mail
      Parameters:
      userEntities - EntityList with entities of type User
      Throws:
      jakarta.mail.MessagingException
    • addCc

      public Mail addCc(Entity userEntity) throws jakarta.mail.MessagingException
      Description copied from interface: Mail
      Add the address from a User entity to "cc".
      Specified by:
      addCc in interface Mail
      Parameters:
      userEntity - Entity of type User
      Throws:
      jakarta.mail.MessagingException
    • addCc

      public Mail addCc(EntityList userEntities) throws jakarta.mail.MessagingException
      Description copied from interface: Mail
      Add addresses from User entities to "cc".
      Specified by:
      addCc in interface Mail
      Parameters:
      userEntities - EntityList with entities of type User
      Throws:
      jakarta.mail.MessagingException
    • addBcc

      public Mail addBcc(Entity userEntity) throws jakarta.mail.MessagingException
      Description copied from interface: Mail
      Add the address from a User entity to "bcc".
      Specified by:
      addBcc in interface Mail
      Parameters:
      userEntity - Entity of type User
      Throws:
      jakarta.mail.MessagingException
    • addBcc

      public Mail addBcc(EntityList userEntities) throws jakarta.mail.MessagingException
      Description copied from interface: Mail
      Add addresses from User entities to "bcc".
      Specified by:
      addBcc in interface Mail
      Parameters:
      userEntities - EntityList with entities of type User
      Throws:
      jakarta.mail.MessagingException
    • getContactCategory

      @Nullable public @Nullable Entity getContactCategory()
      Specified by:
      getContactCategory in interface Mail
    • setContactCategory

      public Mail setContactCategory(@Nullable @Nullable Entity contactCategory)
      Specified by:
      setContactCategory in interface Mail
    • getTemplateEntity

      @Nullable public @Nullable Entity getTemplateEntity()
      Specified by:
      getTemplateEntity in interface Mail
    • setTemplateEntity

      public Mail setTemplateEntity(@Nullable @Nullable Entity templateEntity)
      Specified by:
      setTemplateEntity in interface Mail
    • preventFromArchive

      public Mail preventFromArchive(boolean preventFromArchive)
      Specified by:
      preventFromArchive in interface Mail
    • setTemplateAttribute

      public Mail setTemplateAttribute(String name, Object value)
      Description copied from interface: Mail
      Set a template attribute. If an attribute with the same name already exists it will be overriden. To set entity data into a variable use Mail.setTemplateEntityData(String, ch.tocco.nice2.persist.entity.Entity) and Mail.setTemplateEntityListData(String, ch.tocco.nice2.persist.entity.EntityList).
      Specified by:
      setTemplateAttribute in interface Mail
      Parameters:
      name - The name for the attribute.
      value - The value.
    • setTemplateEntityData

      public Mail setTemplateEntityData(String name, Entity entity)
      Description copied from interface: Mail
      Set an entity template attribute
      Specified by:
      setTemplateEntityData in interface Mail
      Parameters:
      name - the name for the attribute
      entity - the entity
    • setTemplateEntityListData

      public Mail setTemplateEntityListData(String name, EntityList entityList)
      Description copied from interface: Mail
      Set an entity list template attribute
      Specified by:
      setTemplateEntityListData in interface Mail
      Parameters:
      name - the name for the attribute
      entityList - the entity list
    • getTemplateAttribute

      public Optional<Object> getTemplateAttribute(String name)
      Description copied from interface: Mail
      Get the value of a template attribute.
      Specified by:
      getTemplateAttribute in interface Mail
      Parameters:
      name - The name of the attribute to get.
      Returns:
      the value or Optional.empty() if it's not set.
    • getTemplateAttributes

      public Map<String,Object> getTemplateAttributes()
      Description copied from interface: Mail
      Get an unmodifiable map of all template attributes.
      Specified by:
      getTemplateAttributes in interface Mail
      Returns:
      an unmodifiable map of all attributes.
    • removeAttachment

      public boolean removeAttachment(Attachment attachment)
      Specified by:
      removeAttachment in interface BaseMail
      Specified by:
      removeAttachment in interface Mail
    • containsAttachment

      public boolean containsAttachment(Attachment attachment)
      Specified by:
      containsAttachment in interface BaseMail
      Specified by:
      containsAttachment in interface Mail
    • getAttributes

      public Map<String,Object> getAttributes()
      Specified by:
      getAttributes in interface Mail
    • send

      public void send() throws MailException
      Description copied from interface: Mail
      Send the message.
      Specified by:
      send in interface Mail
      Throws:
      MailException
    • clone

      public Mail clone() throws CloneNotSupportedException
      Specified by:
      clone in interface Mail
      Overrides:
      clone in class Object
      Throws:
      CloneNotSupportedException
    • setFrom

      public Mail setFrom(Entity from) throws jakarta.mail.MessagingException
      Specified by:
      setFrom in interface Mail
      Throws:
      jakarta.mail.MessagingException
    • getSender

      public Entity getSender()
      Specified by:
      getSender in interface Mail
    • setSender

      public Mail setSender(Entity sender)
      Specified by:
      setSender in interface Mail
    • setSingleCopyMail

      public Mail setSingleCopyMail(boolean singleCopyMail)
      Description copied from interface: Mail
      only relevant for the GUI MailAction (defaults to false), won't link the resulting MailArchive entity to the recipient but the User(s) with the email address in BaseMail.getCc().
      Specified by:
      setSingleCopyMail in interface Mail
      Parameters:
      singleCopyMail - true / false
    • isSingleCopyMail

      public boolean isSingleCopyMail()
      Specified by:
      isSingleCopyMail in interface Mail
    • getExpiryDate

      public org.joda.time.LocalDate getExpiryDate()
      Specified by:
      getExpiryDate in interface Mail
    • setExpiryDate

      public Mail setExpiryDate(org.joda.time.LocalDate expiryDate)
      Specified by:
      setExpiryDate in interface Mail
    • getTaskUuid

      public UUID getTaskUuid()
      Specified by:
      getTaskUuid in interface Mail
    • setTaskUuid

      public Mail setTaskUuid(UUID taskUuid)
      Description copied from interface: Mail
      Set the UUID which is needed to group the mails sent from the same task
      Specified by:
      setTaskUuid in interface Mail
      Parameters:
      taskUuid - a random uuid given from the task which sends the mail
    • getBody

      public String getBody() throws MailException
      Specified by:
      getBody in interface Mail
      Throws:
      MailException
    • getMimeMessageHeaders

      public Map<String,Iterable<String>> getMimeMessageHeaders() throws MailException, jakarta.mail.MessagingException
      Specified by:
      getMimeMessageHeaders in interface Mail
      Throws:
      MailException
      jakarta.mail.MessagingException
    • getMimeMessageFrom

      public String getMimeMessageFrom() throws jakarta.mail.MessagingException, MailException
      Specified by:
      getMimeMessageFrom in interface Mail
      Throws:
      jakarta.mail.MessagingException
      MailException
    • addMailListener

      public void addMailListener(Mail.MailListener listener)
      Specified by:
      addMailListener in interface Mail
    • removeMailListener

      public void removeMailListener(Mail.MailListener listener)
      Specified by:
      removeMailListener in interface Mail