X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FDeleteProfileFieldPage.java;h=93b90d153184d1cf36045c9a023cc0f58ec78d20;hb=2e03e9dddbea4b81aacaf1aa316f5c3ccffd4bf9;hp=030279ba8da1aa67b023984a97efe79515e7474a;hpb=0df5e91852f737d760c5a9f54c5667309fbadcc2;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/DeleteProfileFieldPage.java b/src/main/java/net/pterodactylus/sone/web/DeleteProfileFieldPage.java index 030279b..93b90d1 100644 --- a/src/main/java/net/pterodactylus/sone/web/DeleteProfileFieldPage.java +++ b/src/main/java/net/pterodactylus/sone/web/DeleteProfileFieldPage.java @@ -1,5 +1,5 @@ /* - * Sone - DeleteProfileFieldPage.java - Copyright © 2011 David Roden + * Sone - DeleteProfileFieldPage.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 @@ -25,6 +25,8 @@ import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; import net.pterodactylus.util.web.Method; +import com.google.common.base.Optional; + /** * Page that lets the user confirm the deletion of a profile field. * @@ -48,9 +50,6 @@ public class DeleteProfileFieldPage extends SoneTemplatePage { // SONETEMPLATEPAGE METHODS // - /** - * {@inheritDoc} - */ @Override protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException { super.processTemplate(request, templateContext); @@ -59,8 +58,8 @@ public class DeleteProfileFieldPage extends SoneTemplatePage { /* get parameters from request. */ String fieldId = request.getHttpRequest().getParam("field"); - Field field = profile.getFieldById(fieldId); - if (field == null) { + Optional field = profile.getFieldById(fieldId); + if (!field.isPresent()) { throw new RedirectException("invalid.html"); } @@ -69,17 +68,17 @@ public class DeleteProfileFieldPage extends SoneTemplatePage { if (request.getHttpRequest().getPartAsStringFailsafe("confirm", 4).equals("true")) { fieldId = request.getHttpRequest().getParam("field"); field = profile.getFieldById(fieldId); - if (field == null) { + if (!field.isPresent()) { throw new RedirectException("invalid.html"); } - profile.removeField(field); + profile.removeField(field.get()); currentSone.setProfile(profile); } throw new RedirectException("editProfile.html#profile-fields"); } /* set current values in template. */ - templateContext.set("field", field); + templateContext.set("field", field.get()); } }