Class NotificationManager

java.lang.Object
com.jalios.jcms.NotificationManager
All Implemented Interfaces:
JcmsConstants, JaliosConstants

public class NotificationManager extends Object implements JcmsConstants
This class is instantiated by a Channel in method initAfterLoad() only if property 'notification.enabled' is set to true. The NotificationManager handles 4 alarms, one per hour, one per day, one per week, one per month. A single AlarmManager listens to these alarms and launches notifications threads (@see NotificationThread) each time an alarm is fired. CAUTION: NotificationThread checks the server is not 127.0.0.1 nor localhost, to avoid emails being sent by mistake while staging.
  • Field Details

  • Constructor Details

    • NotificationManager

      public NotificationManager()
  • Method Details

    • init

      public void init()
    • processNotification

      public void processNotification(int period)
      Launches a thread that notifies all members who have requested to be alerted of specific changes at each period.
      Parameters:
      period - The period type
    • getAvailablePeriods

      public static int[] getAvailablePeriods()
    • getAvailableMutationTypes

      public static int[] getAvailableMutationTypes()
    • getPeriodLabels

      public static String[] getPeriodLabels()
    • getPeriodLabel

      public static String getPeriodLabel(int period)
      Retrieve the property used to retrieve label of the specified period.
      Parameters:
      period - a period constant from : MINUTED, HOURLY, DAILY, WEEKLY or MONTHLY
      Returns:
      a property e.g "ui.work.notification.sch.hour"
    • getMutationTypeLabel

      public static String getMutationTypeLabel(int mutationType)
    • getNotificationCriteria

      public static NotificationCriteria[] getNotificationCriteria(Member member)
    • getGroupsCriteriaSet

      public static Set<NotificationCriteria> getGroupsCriteriaSet(Member member)
    • isDefault

      public static boolean isDefault(Notification notification)
      Tell if the given notification is equivalent to no notification at all.
      Parameters:
      notification - the notification
      Returns:
      true is notification is equivalent to no notification at all.
      Since:
      JCMS-5.7.5
    • isDefault

      public static boolean isDefault(NotificationCriteria[] criterias, int selectionCriteriaMode)
    • isSameCriteria

      public static boolean isSameCriteria(NotificationCriteria[] criterias1, NotificationCriteria[] criterias2)
      Compares two arrays of NotificationCriteria
      Parameters:
      criterias1 - the first array of NotificationCriteria
      criterias2 - the second array of NotificationCriteria
      Returns:
      true if they can be considered as equivalent
      Since:
      JCMS-5.7.5
    • isSameCriteria

      public static boolean isSameCriteria(NotificationCriteria criteria1, NotificationCriteria criteria2)
      Compares two NotificationCriteria
      Parameters:
      criteria1 - the first NotificationCriteria
      criteria2 - the second NotificationCriteria
      Returns:
      true if they can be considered as equivalent
      Since:
      JCMS-5.7.5
    • getNotificationMailSubject

      public static String getNotificationMailSubject(Member mbr)
      Parameters:
      mbr - the recipient Member
      Returns:
      the subject for given Member
      Since:
      jcms-8.0.0
    • getFollowedTypeList

      public static List getFollowedTypeList(String userLang)
      Returns the list of types that can be selected for NotificationCriteria
      Parameters:
      userLang - the userLang (to sort types)
      Returns:
      the list of types that can be selected for NotificationCriteria
      Since:
      jcms-8.0.0
    • getFollowedTypesOn

      protected static Collection<Class<?>> getFollowedTypesOn()
      Returns the whitelist of exact types that can be selected for NotificationCriteria
      Returns:
      the whitelist of exact types that can be selected for NotificationCriteria
      Since:
      jcms-10.0.1
    • getFollowedTypesOff

      protected static Collection<Class<?>> getFollowedTypesOff()
      Returns the list of types that cannot be selected for NotificationCriteria
      Returns:
      the list of types that cannot be selected for NotificationCriteria
      Since:
      jcms-10.0.1
    • getInternalQueryHandlerDefaultFollowedTypes

      protected static Collection<Class<? extends Publication>> getInternalQueryHandlerDefaultFollowedTypes()
      Returns the list of default root types to use for QueryHandler when user did not select any type to follow.
      By default: Content and UserContent classes.
      Does NOT check white and blacklist.

      Internal method to prevent a stackOverflow.

      Returns:
      the list of default types to use for QueryHandler when user did not select any type to follow.
      Since:
      jcms-10.0.1
    • canBeFollowed

      protected static boolean canBeFollowed(Class<?> clazz)
      Return true if given class can be followed.
      It can be followed:
      • if it is a Content, or a UserContent.
      • And:
        • if either followed whitelist is empty
        • else, if given clazz is in white list, or if a super clazz of given clazz is in white list
      • and given exact clazz is not blacklisted.
      Parameters:
      clazz - the clazz to test
      Returns:
      true if given clazz matches followable types rules.
      Since:
      jcms-10.0.1
    • getNotificationOriginMap

      public static Map<String,String> getNotificationOriginMap(Member member)
      Compute origin of each NotificationCriteria of given Member.

      NotificationCriteria's origin can be either the member itself, or a group the member belongs to.

      Parameters:
      member - the member to compute origin of its notification
      Returns:
      a map with notificationCriteria's id as key, and member's id or group's id as value.
      Since:
      jcms-9.0.3