Class NotificationManager

  • All Implemented Interfaces:
    JcmsConstants, JaliosConstants

    public class NotificationManager
    extends java.lang.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.
    Version:
    $Revision: 136308 $
    • Constructor Detail

      • NotificationManager

        public NotificationManager()
    • Method Detail

      • 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 java.lang.String[] getPeriodLabels()
      • getPeriodLabel

        public static java.lang.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 java.lang.String getMutationTypeLabel​(int mutationType)
      • 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 java.lang.String getNotificationMailSubject​(Member mbr)
        Parameters:
        mbr - the recipient Member
        Returns:
        the subject for given Member
        Since:
        jcms-8.0.0
      • getFollowedTypeList

        public static java.util.List getFollowedTypeList​(java.lang.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 java.util.Collection<java.lang.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 java.util.Collection<java.lang.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 java.util.Collection<java.lang.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​(java.lang.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 java.util.Map<java.lang.String,​java.lang.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