X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FWebInterface.java;h=e245b6a945fb238eb621c087835bb7cc4b945019;hb=fd88107b013522d7620f5297386472206f320e10;hp=02a5dd50ef81c48d92ce178ed35086e82a41aa77;hpb=1a2c9eb50e89d9ba5f9ea9b72721ebfeb68650cd;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/WebInterface.java b/src/main/java/net/pterodactylus/sone/web/WebInterface.java index 02a5dd5..e245b6a 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -64,6 +64,7 @@ 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.LocalSone; import net.pterodactylus.sone.data.Post; import net.pterodactylus.sone.data.PostReply; import net.pterodactylus.sone.data.Profile; @@ -381,7 +382,7 @@ public class WebInterface { * @return The currently logged in Sone, or {@code null} if no Sone is * currently logged in */ - public Sone getCurrentSone(ToadletContext toadletContext) { + public Optional getCurrentSone(ToadletContext toadletContext) { return getCurrentSone(toadletContext, true); } @@ -396,10 +397,10 @@ public class WebInterface { * @return The currently logged in Sone, or {@code null} if no Sone is * currently logged in */ - public Sone getCurrentSone(ToadletContext toadletContext, boolean createSession) { - Collection localSones = getCore().getLocalSones(); + public Optional getCurrentSone(ToadletContext toadletContext, boolean createSession) { + Collection localSones = getCore().getLocalSones(); if (localSones.size() == 1) { - return localSones.iterator().next(); + return Optional.of(localSones.iterator().next()); } return getCurrentSone(getCurrentSession(toadletContext, createSession)); } @@ -412,13 +413,13 @@ public class WebInterface { * @return The currently logged in Sone, or {@code null} if no Sone is * currently logged in */ - public Sone getCurrentSone(Optional session) { + public Optional getCurrentSone(Optional session) { if (!session.isPresent()) { - return null; + return Optional.absent(); } String soneId = (String) session.get().getAttribute("Sone.CurrentSone"); if (soneId == null) { - return null; + return Optional.absent(); } return getCore().getLocalSone(soneId); }