Rename SoneImpl to DefaultSone, implement SoneProvider in MemoryDatabase.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / LoginPage.java
index 6f43b6f..d1bb0ed 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - LoginPage.java - Copyright © 2010 David Roden
+ * Sone - LoginPage.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
@@ -29,8 +29,11 @@ import net.pterodactylus.util.logging.Logging;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
 import net.pterodactylus.util.web.Method;
+
 import freenet.clients.http.ToadletContext;
 
+import com.google.common.base.Optional;
+
 /**
  * The login page manages logging the user in.
  *
@@ -70,9 +73,9 @@ public class LoginPage extends SoneTemplatePage {
                templateContext.set("sones", localSones);
                if (request.getMethod() == Method.POST) {
                        String soneId = request.getHttpRequest().getPartAsStringFailsafe("sone-id", 100);
-                       Sone selectedSone = webInterface.getCore().getLocalSone(soneId, false);
-                       if (selectedSone != null) {
-                               setCurrentSone(request.getToadletContext(), selectedSone);
+                       Optional<Sone> selectedSone = webInterface.getCore().getLocalSone(soneId);
+                       if (selectedSone.isPresent()) {
+                               setCurrentSone(request.getToadletContext(), selectedSone.get());
                                String target = request.getHttpRequest().getParam("target");
                                if ((target == null) || (target.length() == 0)) {
                                        target = "index.html";