Class AlertBuilder

java.lang.Object
com.jalios.jcms.alert.AlertBuilder
All Implemented Interfaces:
AlertConstants, JcmsConstants, JaliosConstants
Direct Known Subclasses:
SecurityAlertBuilder

public class AlertBuilder extends Object implements AlertConstants, JcmsConstants
  • Field Details

    • level

      protected Alert.Level level
    • domain

      protected String domain
    • name

      protected String name
    • author

      protected Member author
    • data

      protected Data data
    • isAuthorRecipient

      protected boolean isAuthorRecipient
    • expiration

      protected Date expiration
    • propPrefix

      protected String propPrefix
    • lastThread

      protected static Thread lastThread
  • Constructor Details

    • AlertBuilder

      public AlertBuilder(Alert.Level level, String domain, String name)
    • AlertBuilder

      public AlertBuilder(Alert.Level level, String domain, String name, Data data)
    • AlertBuilder

      public AlertBuilder(Alert.Level level, String domain, String name, Data data, Member author)
    • AlertBuilder

      public AlertBuilder(Alert.Level level, String domain, String name, Data data, Member author, boolean isAuthorRecipient)
      Parameters:
      level - the alert's level
      domain - the alert's domain
      name - the alert's name
      data - the alert's data
      author - the alert's author
      isAuthorRecipient - if false the alert won't be sent to the alert's author
      Since:
      jcms-8.0.0
    • AlertBuilder

      public AlertBuilder(Alert.Level level, String domain, String name, Data data, Member author, boolean isAuthorRecipient, Date expiration)
      Parameters:
      level - the alert's level
      domain - the alert's domain
      name - the alert's name
      data - the alert's data
      author - the alert's author
      isAuthorRecipient - if false the alert won't be sent to the alert's author
      expiration - the alert's expiration date
      Since:
      jcms-9.0.0
  • Method Details

    • isRecipient

      public boolean isRecipient(Member mbr)
    • getTitle

      public String getTitle(Member recipient)
    • getShortDescription

      public String getShortDescription(Member recipient)
    • getDescription

      public String getDescription(Member recipient)
    • getSummary

      public String getSummary(Member recipient)
    • getMessage

      public String getMessage(Member mbr)
    • getMessageMarkup

      public String getMessageMarkup()
    • canBeSaved

      public boolean canBeSaved()
    • getContext

      public Map<String,Object> getContext()
    • getTitlePropName

      protected String getTitlePropName()
    • getShortDescriptionPropName

      protected String getShortDescriptionPropName()
    • getDescriptionPropName

      protected String getDescriptionPropName()
    • getSummaryPropName

      protected String getSummaryPropName()
    • glp

      protected String glp(Member recipient, String prop, Map<String,String> paramMap)
    • addParams

      protected void addParams(Member recipient, Map<String,String> paramMap, String markup)
      This method is called to add parameters to the map used to format the properties.
      Parameters:
      recipient - the recipient
      paramMap - the paramMap
      markup - the markup used (i.e. TEXT_MARKUP or HTML_MARKUP)
      Since:
      jcms-8.0.0
    • getDataRepresentation

      protected String getDataRepresentation(Data data, String markup, Member recipient)
      Returns a representation of the given data suitable for the given markup.
      Parameters:
      data - the data
      markup - the markup
      recipient - the recipient (for localisation)
      Returns:
      a representation of the given data suitable for the given markup.
      Since:
      jcms-8.0.0
    • getDataLink

      protected String getDataLink(Data data, Member recipient)
      Returns the HTML link for the given data (with an absolute URL).
      Parameters:
      data - the data
      recipient - the recipient (for localisation)
      Returns:
      the HTML link for the given data (with an absolute URL).
      Since:
      jcms-8.0.0
    • getDataText

      protected String getDataText(Data data, Member recipient)
      Returns the textual representation for the given data.
      Parameters:
      data - the data
      recipient - the recipient (for localisation)
      Returns:
      the textual representation for the given data.
      Since:
      jcms-8.0.0
    • getHtmlAbstract

      protected String getHtmlAbstract(Member recipient)
      Returns an HTML representation of the abstract of the data (only if data instanceof Publication).
      Parameters:
      recipient - the recipient (for localisation)
      Returns:
      an HTML representation of the abstract of the data (only if data instanceof Publication).
      Since:
      jcms-8.0.0
    • getTextPropParamMap

      protected Map<String,String> getTextPropParamMap(Member recipient)
    • getHtmlPropParamMap

      protected Map<String,String> getHtmlPropParamMap(Member recipient)
    • sendAlert

      public void sendAlert(Collection<Member> recipientCollection)
    • sendAlertInCurrentThread

      public void sendAlertInCurrentThread(Collection<Member> recipientCollection)
    • waitForSending

      public static void waitForSending()
      A convenient method for unit test to wait for the ending of the sending thread. This method is not thread safe (it only wait for the last sending thread).
      Since:
      jcms-8.0.0
    • sendAlert

      public void sendAlert(Member recipient)
      Sends the alert to the given recipient.
      Parameters:
      recipient - the recipient
      Since:
      jcms-8.0.0
    • buildAlert

      public Alert buildAlert(Member recipient)
    • sendToDisabledAccount

      public AlertBuilder sendToDisabledAccount()
      Force the Alert to be sent to recipient even if recipient Member is disabled. Default behavior is to NOT send Alert to disabled account.
      Returns:
      this AlertBuilder, for method chaining
      Since:
      10.0.7 / JCMS-9426
    • sendToContact

      public AlertBuilder sendToContact()
      Force the Alert to be sent to recipient even if recipient Member is a contact.

      Default behavior is to NOT send Alert to contact.

      Returns:
      this AlertBuilder, for method chaining
      Since:
      10.0.7 / JCMS-9426