Move notification manager to web interface.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / WebInterface.java
index 9dce6a7..1c429e7 100644 (file)
@@ -40,7 +40,6 @@ import net.pterodactylus.sone.template.CollectionAccessor;
 import net.pterodactylus.sone.template.CssClassNameFilter;
 import net.pterodactylus.sone.template.GetPagePlugin;
 import net.pterodactylus.sone.template.IdentityAccessor;
-import net.pterodactylus.sone.template.NotificationAccessor;
 import net.pterodactylus.sone.template.NotificationManagerAccessor;
 import net.pterodactylus.sone.template.PostAccessor;
 import net.pterodactylus.sone.template.ReplyAccessor;
@@ -63,7 +62,6 @@ import net.pterodactylus.sone.web.page.PageToadlet;
 import net.pterodactylus.sone.web.page.PageToadletFactory;
 import net.pterodactylus.sone.web.page.StaticPage;
 import net.pterodactylus.util.logging.Logging;
-import net.pterodactylus.util.notify.Notification;
 import net.pterodactylus.util.notify.NotificationManager;
 import net.pterodactylus.util.notify.TemplateNotification;
 import net.pterodactylus.util.template.DateFilter;
@@ -92,6 +90,9 @@ public class WebInterface {
        /** The logger. */
        private static final Logger logger = Logging.getLogger(WebInterface.class);
 
+       /** The notification manager. */
+       private final NotificationManager notificationManager = new NotificationManager();
+
        /** The Sone plugin. */
        private final SonePlugin sonePlugin;
 
@@ -121,7 +122,6 @@ public class WebInterface {
                templateFactory.addAccessor(Post.class, new PostAccessor(getCore()));
                templateFactory.addAccessor(Reply.class, new ReplyAccessor(getCore()));
                templateFactory.addAccessor(Identity.class, new IdentityAccessor(getCore()));
-               templateFactory.addAccessor(Notification.class, new NotificationAccessor());
                templateFactory.addAccessor(NotificationManager.class, new NotificationManagerAccessor());
                templateFactory.addFilter("date", new DateFilter());
                templateFactory.addFilter("l10n", new L10nFilter(getL10n()));
@@ -150,6 +150,15 @@ public class WebInterface {
        }
 
        /**
+        * Returns the notification manager.
+        *
+        * @return The notification manager
+        */
+       public NotificationManager getNotifications() {
+               return notificationManager;
+       }
+
+       /**
         * Returns the l10n helper of the node.
         *
         * @return The node’s l10n helper
@@ -195,13 +204,13 @@ public class WebInterface {
                Template startupNotificationTemplate = templateFactory.createTemplate(createReader("/templates/notify/startupNotification.html"));
 
                final TemplateNotification startupNotification = new TemplateNotification(startupNotificationTemplate);
-               getCore().getNotifications().addNotification(startupNotification);
+               notificationManager.addNotification(startupNotification);
 
                Ticker.getInstance().registerEvent(System.currentTimeMillis() + (120 * 1000), new Runnable() {
 
                        @Override
                        public void run() {
-                               getCore().getNotifications().removeNotification(startupNotification);
+                               startupNotification.dismiss();
                        }
                }, "Sone Startup Notification Remover");
        }