X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FEditProfilePage.java;h=df5a35220070673f60246834e6e1e1b3b7cdb409;hb=9d9b901b7173a9b8221a8b830ece31bc5ee36578;hp=0d1f7d3442251b952a562f0d7cc004842c2067d8;hpb=e42eee396d1646bf97316696f1cd7b836aabd8c6;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/EditProfilePage.java b/src/main/java/net/pterodactylus/sone/web/EditProfilePage.java index 0d1f7d3..df5a352 100644 --- a/src/main/java/net/pterodactylus/sone/web/EditProfilePage.java +++ b/src/main/java/net/pterodactylus/sone/web/EditProfilePage.java @@ -29,8 +29,11 @@ import net.pterodactylus.util.number.Numbers; 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; + /** * This page lets the user edit her profile. * @@ -82,7 +85,7 @@ public class EditProfilePage extends SoneTemplatePage { profile.setAvatar(webInterface.getCore().getImage(avatarId).transform(GET_ID)); for (Field field : fields) { String value = request.getHttpRequest().getPartAsStringFailsafe("field-" + field.getId(), 400); - field.setValue(value); + profile.setField(field, value); } currentSone.setProfile(profile); webInterface.getCore().touchConfiguration(); @@ -106,21 +109,21 @@ public class EditProfilePage extends SoneTemplatePage { } id = getFieldId(request, "move-up-field-"); if (id != null) { - Field field = profile.getFieldById(id); - if (field == null) { + Optional field = profile.getFieldById(id); + if (!field.isPresent()) { throw new RedirectException("invalid.html"); } - profile.moveFieldUp(field); + profile.moveFieldUp(field.get()); currentSone.setProfile(profile); throw new RedirectException("editProfile.html#profile-fields"); } id = getFieldId(request, "move-down-field-"); if (id != null) { - Field field = profile.getFieldById(id); - if (field == null) { + Optional field = profile.getFieldById(id); + if (!field.isPresent()) { throw new RedirectException("invalid.html"); } - profile.moveFieldDown(field); + profile.moveFieldDown(field.get()); currentSone.setProfile(profile); throw new RedirectException("editProfile.html#profile-fields"); }