Refactor notification filtering
[Sone.git] / src / main / java / net / pterodactylus / sone / web / DismissNotificationPage.java
index d5bb6ea..24b6aaa 100644 (file)
@@ -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.
  *
@@ -52,9 +54,9 @@ public class DismissNotificationPage extends SoneTemplatePage {
        protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                super.processTemplate(request, templateContext);
                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);