package net.pterodactylus.sone.web.ajax;
import net.pterodactylus.sone.core.Core;
+import net.pterodactylus.sone.data.LocalSone;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.web.WebInterface;
import net.pterodactylus.sone.web.page.FreenetRequest;
+import com.google.common.base.Optional;
+
/**
* Lets the user {@link Core#unlockSone(Sone) unlock} a {@link Sone}.
*
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
String soneId = request.getHttpRequest().getParam("sone");
- Sone sone = webInterface.getCore().getLocalSone(soneId, false);
- if (sone == null) {
+ Optional<LocalSone> localSone = webInterface.getCore().getLocalSone(soneId);
+ if (!localSone.isPresent()) {
return createErrorJsonObject("invalid-sone-id");
}
- webInterface.getCore().unlockSone(sone);
+ webInterface.getCore().unlockSone(localSone.get());
return createSuccessJsonObject();
}