Merge branch 'release-0.9.6'
[Sone.git] / src / main / java / net / pterodactylus / sone / web / DismissNotificationPage.java
index 9d79195..c14a012 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - DismissNotificationPage.java - Copyright © 2010 David Roden
+ * Sone - DismissNotificationPage.java - Copyright © 2010–2016 David Roden
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -22,6 +22,8 @@ import net.pterodactylus.util.notify.Notification;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
 
+import com.google.common.base.Optional;
+
 /**
  * Page that lets the user dismiss a notification.
  *
@@ -49,12 +51,11 @@ public class DismissNotificationPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
-               super.processTemplate(request, templateContext);
+       protected void handleRequest(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                String notificationId = request.getHttpRequest().getPartAsStringFailsafe("notification", 36);
-               Notification notification = webInterface.getNotifications().getNotification(notificationId);
-               if ((notification != null) && notification.isDismissable()) {
-                       notification.dismiss();
+               Optional<Notification> notification = webInterface.getNotification(notificationId);
+               if (notification.isPresent() && notification.get().isDismissable()) {
+                       notification.get().dismiss();
                }
                String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
                throw new RedirectException(returnPage);