X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FFollowSonePage.java;h=ca29fc94f05a692c9703a1eeb75249dc5da72ee1;hb=53a71d1d6b91e4d56af49a06f2e06bc4d11bf3eb;hp=4083b9985eb34e414109c722c806697f88648c97;hpb=b3d8b88791743298e897d7f5400304a54f6e2ba4;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/FollowSonePage.java b/src/main/java/net/pterodactylus/sone/web/FollowSonePage.java index 4083b99..ca29fc9 100644 --- a/src/main/java/net/pterodactylus/sone/web/FollowSonePage.java +++ b/src/main/java/net/pterodactylus/sone/web/FollowSonePage.java @@ -1,5 +1,5 @@ /* - * Sone - FollowSonePage.java - Copyright © 2010 David Roden + * Sone - FollowSonePage.java - Copyright © 2010–2013 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 @@ -17,6 +17,8 @@ package net.pterodactylus.sone.web; +import com.google.common.base.Optional; + import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.template.Template; @@ -52,12 +54,13 @@ public class FollowSonePage extends SoneTemplatePage { super.processTemplate(request, templateContext); if (request.getMethod() == Method.POST) { String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256); - Sone currentSone = getCurrentSone(request.getToadletContext()); + Sone currentSone = getCurrentSone(request.getToadletContext()).get(); String soneIds = request.getHttpRequest().getPartAsStringFailsafe("sone", 1200); for (String soneId : soneIds.split("[ ,]+")) { - if (webInterface.getCore().hasSone(soneId)) { + Optional sone = webInterface.getCore().getSone(soneId); + if (sone.isPresent()) { webInterface.getCore().followSone(currentSone, soneId); - webInterface.getCore().markSoneKnown(webInterface.getCore().getSone(soneId)); + webInterface.getCore().markSoneKnown(sone.get()); } } throw new RedirectException(returnPage);