/*
- * Sone - LockSonePage.java - Copyright © 2010 David Roden
+ * Sone - UnlockSonePage.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
package net.pterodactylus.sone.web;
import net.pterodactylus.sone.data.Sone;
-import net.pterodactylus.util.template.DataProvider;
+import net.pterodactylus.sone.web.page.FreenetRequest;
import net.pterodactylus.util.template.Template;
+import net.pterodactylus.util.template.TemplateContext;
+
+import com.google.common.base.Optional;
/**
* This page lets the user unlock a {@link Sone} to allow its insertion.
// TEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
- protected void processTemplate(Request request, DataProvider dataProvider) throws RedirectException {
- super.processTemplate(request, dataProvider);
+ protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
+ super.processTemplate(request, templateContext);
String soneId = request.getHttpRequest().getPartAsStringFailsafe("sone", 44);
- Sone sone = webInterface.getCore().getLocalSone(soneId, false);
- if (sone != null) {
- webInterface.getCore().unlockSone(sone);
+ Optional<Sone> sone = webInterface.getCore().getLocalSone(soneId);
+ if (sone.isPresent()) {
+ webInterface.getCore().unlockSone(sone.get());
}
String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
throw new RedirectException(returnPage);