Convert “update found” into EventBus-based event.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / WebInterface.java
index 1c58bd3..dc4c4f0 100644 (file)
@@ -45,11 +45,13 @@ import net.pterodactylus.sone.core.event.NewPostReplyFoundEvent;
 import net.pterodactylus.sone.core.event.NewSoneFoundEvent;
 import net.pterodactylus.sone.core.event.PostRemovedEvent;
 import net.pterodactylus.sone.core.event.PostReplyRemovedEvent;
+import net.pterodactylus.sone.core.event.SoneInsertAbortedEvent;
 import net.pterodactylus.sone.core.event.SoneInsertedEvent;
 import net.pterodactylus.sone.core.event.SoneInsertingEvent;
 import net.pterodactylus.sone.core.event.SoneLockedEvent;
 import net.pterodactylus.sone.core.event.SoneRemovedEvent;
 import net.pterodactylus.sone.core.event.SoneUnlockedEvent;
+import net.pterodactylus.sone.core.event.UpdateFoundEvent;
 import net.pterodactylus.sone.data.Album;
 import net.pterodactylus.sone.data.Image;
 import net.pterodactylus.sone.data.Post;
@@ -138,7 +140,6 @@ import net.pterodactylus.util.template.TemplateParser;
 import net.pterodactylus.util.template.TemplateProvider;
 import net.pterodactylus.util.template.XmlFilter;
 import net.pterodactylus.util.thread.Ticker;
-import net.pterodactylus.util.version.Version;
 import net.pterodactylus.util.web.RedirectPage;
 import net.pterodactylus.util.web.StaticPage;
 import net.pterodactylus.util.web.TemplatePage;
@@ -1005,34 +1006,40 @@ public class WebInterface implements CoreListener {
                }
        }
 
-       //
-       // CORELISTENER METHODS
-       //
-
        /**
-        * {@inheritDoc}
+        * Notifies the web interface that a {@link Sone} insert was aborted.
+        *
+        * @param soneInsertAbortedEvent
+        *            The event
         */
-       @Override
-       public void soneInsertAborted(Sone sone, Throwable cause) {
-               TemplateNotification soneInsertNotification = getSoneInsertNotification(sone);
+       @Subscribe
+       public void soneInsertAborted(SoneInsertAbortedEvent soneInsertAbortedEvent) {
+               TemplateNotification soneInsertNotification = getSoneInsertNotification(soneInsertAbortedEvent.sone());
                soneInsertNotification.set("soneStatus", "insert-aborted");
-               soneInsertNotification.set("insert-error", cause);
-               if (sone.getOptions().getBooleanOption("EnableSoneInsertNotifications").get()) {
+               soneInsertNotification.set("insert-error", soneInsertAbortedEvent.cause());
+               if (soneInsertAbortedEvent.sone().getOptions().getBooleanOption("EnableSoneInsertNotifications").get()) {
                        notificationManager.addNotification(soneInsertNotification);
                }
        }
 
        /**
-        * {@inheritDoc}
+        * Notifies the web interface that a new Sone version was found.
+        *
+        * @param updateFoundEvent
+        *            The event
         */
-       @Override
-       public void updateFound(Version version, long releaseTime, long latestEdition) {
-               newVersionNotification.getTemplateContext().set("latestVersion", version);
-               newVersionNotification.getTemplateContext().set("latestEdition", latestEdition);
-               newVersionNotification.getTemplateContext().set("releaseTime", releaseTime);
+       @Subscribe
+       public void updateFound(UpdateFoundEvent updateFoundEvent) {
+               newVersionNotification.getTemplateContext().set("latestVersion", updateFoundEvent.version());
+               newVersionNotification.getTemplateContext().set("latestEdition", updateFoundEvent.latestEdition());
+               newVersionNotification.getTemplateContext().set("releaseTime", updateFoundEvent.releaseTime());
                notificationManager.addNotification(newVersionNotification);
        }
 
+       //
+       // CORELISTENER METHODS
+       //
+
        /**
         * {@inheritDoc}
         */