Make Sone returned by a Sone provider optional.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / ImageBrowserPage.java
index a6d3daf..53c22f2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - ImageBrowserPage.java - Copyright © 2011–2012 David Roden
+ * Sone - ImageBrowserPage.java - Copyright © 2011–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
@@ -22,6 +22,8 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
+import com.google.common.base.Optional;
+
 import net.pterodactylus.sone.data.Album;
 import net.pterodactylus.sone.data.Image;
 import net.pterodactylus.sone.data.Sone;
@@ -65,6 +67,7 @@ public class ImageBrowserPage extends SoneTemplatePage {
                        Album album = webInterface.getCore().getAlbum(albumId, false);
                        templateContext.set("albumRequested", true);
                        templateContext.set("album", album);
+                       templateContext.set("page", request.getHttpRequest().getParam("page"));
                        return;
                }
                String imageId = request.getHttpRequest().getParam("image", null);
@@ -76,9 +79,9 @@ public class ImageBrowserPage extends SoneTemplatePage {
                }
                String soneId = request.getHttpRequest().getParam("sone", null);
                if (soneId != null) {
-                       Sone sone = webInterface.getCore().getSone(soneId, false);
+                       Optional<Sone> sone = webInterface.getCore().getSone(soneId);
                        templateContext.set("soneRequested", true);
-                       templateContext.set("sone", sone);
+                       templateContext.set("sone", sone.orNull());
                        return;
                }
                String mode = request.getHttpRequest().getParam("mode", null);