/*
- * Sone - DeleteProfileFieldPage.java - Copyright © 2011–2012 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
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.
*
// SONETEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
/* get parameters from request. */
String fieldId = request.getHttpRequest().getParam("field");
- Field field = profile.getFieldById(fieldId);
- if (field == null) {
+ Optional<Field> field = profile.getFieldById(fieldId);
+ if (!field.isPresent()) {
throw new RedirectException("invalid.html");
}
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());
}
}