Class DefaultSubscriptionManager

java.lang.Object
org.apache.wiki.notification.DefaultSubscriptionManager
All Implemented Interfaces:
EventListener, org.apache.wiki.api.engine.Initializable, org.apache.wiki.event.WikiEventListener, SubscriptionManager

public class DefaultSubscriptionManager extends Object implements SubscriptionManager, org.apache.wiki.api.engine.Initializable, org.apache.wiki.event.WikiEventListener
Default implementation of SubscriptionManager. It listens to the end of the post-save filtering and sends an e-mail to every user that is subscribed to the saved page and has an e-mail address in the profile.

The mails are sent from a single background thread, so saving a page never waits for the mail server. The mail does not contain the text of the page. The links in the mails are made absolute with the property "jspwiki.subscription.baseURL", since no request is available here. Pages with an ACL on the view permission are not notified, since the view permission of an offline user cannot be evaluated here.

Since:
3.0.1
  • Field Details

    • PROP_BASEURL

      public static final String PROP_BASEURL
      Scheme and host of the links in the mails, like https://wiki.example.org. Value is "jspwiki.subscription.baseURL".
      See Also:
  • Constructor Details

  • Method Details

    • initialize

      public void initialize(org.apache.wiki.api.core.Engine engine, Properties props) throws org.apache.wiki.api.exceptions.WikiException
      Specified by:
      initialize in interface org.apache.wiki.api.engine.Initializable
      Throws:
      org.apache.wiki.api.exceptions.WikiException
    • subscribe

      public void subscribe(String loginName, String pageName) throws org.apache.wiki.api.exceptions.WikiException
      Subscribes a user to the changes of a page. Subscribing twice has no effect.
      Specified by:
      subscribe in interface SubscriptionManager
      Parameters:
      loginName - login name of the user.
      pageName - name of the page.
      Throws:
      org.apache.wiki.api.exceptions.WikiException - if the user does not exist or the profile cannot be saved.
    • unsubscribe

      public void unsubscribe(String loginName, String pageName) throws org.apache.wiki.api.exceptions.WikiException
      Removes the subscription of a user to a page. Removing a subscription that does not exist has no effect.
      Specified by:
      unsubscribe in interface SubscriptionManager
      Parameters:
      loginName - login name of the user.
      pageName - name of the page.
      Throws:
      org.apache.wiki.api.exceptions.WikiException - if the user does not exist or the profile cannot be saved.
    • isSubscribed

      public boolean isSubscribed(String loginName, String pageName)
      Tells whether a user is subscribed to a page.
      Specified by:
      isSubscribed in interface SubscriptionManager
      Parameters:
      loginName - login name of the user.
      pageName - name of the page.
      Returns:
      true if the user is subscribed to the page, false otherwise, also for an unknown user.
    • getSubscriptions

      public Set<String> getSubscriptions(String loginName)
      Returns the names of the pages a user is subscribed to.
      Specified by:
      getSubscriptions in interface SubscriptionManager
      Parameters:
      loginName - login name of the user.
      Returns:
      an unmodifiable set of page names, empty for an unknown user.
    • actionPerformed

      public void actionPerformed(org.apache.wiki.event.WikiEvent event)
      Specified by:
      actionPerformed in interface org.apache.wiki.event.WikiEventListener