X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FMarkAsKnownAjaxPage.java;h=4727686b9f6a717870736ae94c1d6f9b1cafa5ca;hp=18450b126cf8322b2c59a115ea3d6adf2410e449;hb=419098bcd6215125408b29e60bd888e60979d37b;hpb=14b1aa4bf4b88e80f9cce4ec14d0950727df4a5f diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/MarkAsKnownAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/MarkAsKnownAjaxPage.java index 18450b1..4727686 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/MarkAsKnownAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/MarkAsKnownAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - MarkAsKnownAjaxPage.java - Copyright © 2011–2013 David Roden + * Sone - MarkAsKnownAjaxPage.java - Copyright © 2011–2015 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 @@ -24,7 +24,8 @@ import net.pterodactylus.sone.data.Reply; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.web.WebInterface; import net.pterodactylus.sone.web.page.FreenetRequest; -import net.pterodactylus.util.json.JsonObject; + +import com.google.common.base.Optional; /** * AJAX page that lets the user mark a number of {@link Sone}s, {@link Post}s, @@ -48,7 +49,7 @@ public class MarkAsKnownAjaxPage extends JsonPage { * {@inheritDoc} */ @Override - protected JsonObject createJsonObject(FreenetRequest request) { + protected JsonReturnObject createJsonObject(FreenetRequest request) { String type = request.getHttpRequest().getParam("type"); if (!type.equals("sone") && !type.equals("post") && !type.equals("reply")) { return createErrorJsonObject("invalid-type"); @@ -57,23 +58,23 @@ public class MarkAsKnownAjaxPage extends JsonPage { Core core = webInterface.getCore(); for (String id : ids) { if (type.equals("post")) { - Post post = core.getPost(id); - if (post == null) { + Optional post = core.getPost(id); + if (!post.isPresent()) { continue; } - core.markPostKnown(post); + core.markPostKnown(post.get()); } else if (type.equals("reply")) { - PostReply reply = core.getPostReply(id, false); - if (reply == null) { + Optional reply = core.getPostReply(id); + if (!reply.isPresent()) { continue; } - core.markReplyKnown(reply); + core.markReplyKnown(reply.get()); } else if (type.equals("sone")) { - Sone sone = core.getSone(id, false); - if (sone == null) { + Optional sone = core.getSone(id); + if (!sone.isPresent()) { continue; } - core.markSoneKnown(sone); + core.markSoneKnown(sone.get()); } } return createSuccessJsonObject();