Class AbstractUserNotificationBuilder

    • Constructor Detail

      • AbstractUserNotificationBuilder

        protected AbstractUserNotificationBuilder()
        Default constructor
      • AbstractUserNotificationBuilder

        protected AbstractUserNotificationBuilder​(String title,
                                                  String content)
        Constructs the notification builder and prepares the notification to build with the specified title and content.
        Parameters:
        title - the title of the notification.
        content - the content of the notification.
    • Method Detail

      • getAction

        protected abstract NotifAction getAction()
        Gets the type of action on the resource concerned by the notification if any.
        Returns:
        a value of the NotifAction enumeration.
      • getComponentInstanceId

        protected abstract String getComponentInstanceId()
        Gets the component instance identifier.
        Returns:
        the unique identifier of the component instance concerned by the notification to build.
      • getSender

        protected abstract String getSender()
        Gets the sender (the user identifier usually)
        Returns:
        the unique identifier of the sender.
      • isUserCanBeNotified

        protected abstract boolean isUserCanBeNotified​(String userId)
        Is the specified user can be notified? The reason depends on the nature of the notification and as such it is delegated to the implementor. For example, for notifications about a resource, only users that can access the resource can be notified, not the others even if they are part of the recipients.
        Returns:
        true of the specified user satisfies all the requirements to be notified.
      • isGroupCanBeNotified

        protected abstract boolean isGroupCanBeNotified​(String groupId)
        Is the specified group of users can be notified? The reason depends on the nature of the notification and as such it is delegated to the implementor. For example, for notifications about a resource, only groups of users that can access the resource can be notified, not the others even if they are part of the recipients.
        Returns:
        true of the specified group satisfies all the requirements to be notified.
      • getNotificationMetaData

        protected final NotificationMetaData getNotificationMetaData()
        Gets the notification metadata.
        Returns:
        the metadata about the notification to build.
      • isSendImmediately

        protected boolean isSendImmediately()
        Is the notification to build has to be sent immediately? If no, then its sending will be delayed according to the preferences of the users.
        Returns:
        true if the notification to build has to be sent immediately.
      • getUserIdsToNotify

        protected abstract Collection<String> getUserIdsToNotify()
        A collection of user identifiers. All the users in this collection will be notified. This method requires to be implemented.
        Returns:
      • getUserIdsToExcludeFromNotifying

        protected Collection<String> getUserIdsToExcludeFromNotifying()
        Collection of identifiers of users that don't have to be notified. By default, an empty collection is returned.
        Returns:
        a collection of identifiers of the users to exclude from the notification.
      • getGroupIdsToNotify

        protected Collection<String> getGroupIdsToNotify()
        Gets a collection of user group's identifiers. All the users in this collection will be notified. By default, an empty collection is returned.
        Returns:
        a collection of user group's identifiers.
      • getExternalAddressesToNotify

        protected Collection<String> getExternalAddressesToNotify()
        Gets a collection of email addresses, each of them corresponding to a person external of Silverpeas. By default, an empty collection is returned.
        Returns:
        a collection of email addresses.
      • stopWhenNoUserToNotify

        protected boolean stopWhenNoUserToNotify()
        Should the notification treatment be stopped if there is no user to notify? By default true. This method can be overridden to specify a different or a contextualized answer. In that case, the recipients setting should be then performed out of the builder.
        Returns:
        true if no notification has to be done when no recipient is defined.
      • performBuild

        protected abstract void performBuild()
        Builds the notification data container
      • getLocalizationBundlePath

        protected String getLocalizationBundlePath()
        Gets the path of the localization bundle to load. By default, returns the general translations. For more specific localized text to use in the notification, override this method.
        Returns:
        the path of the localization bundle.
      • getBundle

        protected final LocalizationBundle getBundle()
        Gets the localization bundle from which the localized text to use in the notification can be get.
        Returns:
        the localization bundle whose the path is provided by the getLocalizationBundlePath() method.
      • getBundle

        protected final LocalizationBundle getBundle​(String language)
        Gets the localization bundle for the specified locale to use in the building the notification.
        Parameters:
        language - the ISO-631 code of a language.
        Returns:
        the localization bundle whose path is provided by the getLocalizationBundlePath() method.
      • getTitle

        protected String getTitle()
        Gets the title of the notification. By overriding this method, the title can be customized. By default, the title is the one set explicitly in the constructor of this builder.
        Returns:
        the title of the notification.
      • getContent

        protected String getContent()
        Gets the content of the notification. By overriding this method, the content can be customized. By default, the content is the one set explicitly in the constructor of this builder.
        Returns:
        the content of the notification (aka the message itself).
      • stop

        protected void stop()
        Stops the treatment