projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Replace get post ajax page with Kotlin version
[Sone.git]
/
src
/
main
/
java
/
net
/
pterodactylus
/
sone
/
web
/
ajax
/
UntrustAjaxPage.java
diff --git
a/src/main/java/net/pterodactylus/sone/web/ajax/UntrustAjaxPage.java
b/src/main/java/net/pterodactylus/sone/web/ajax/UntrustAjaxPage.java
index
227b580
..
5ba6693
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/web/ajax/UntrustAjaxPage.java
+++ b/
src/main/java/net/pterodactylus/sone/web/ajax/UntrustAjaxPage.java
@@
-1,5
+1,5
@@
/*
/*
- * Sone - UntrustAjaxPage.java - Copyright © 2011–201
3
David Roden
+ * Sone - UntrustAjaxPage.java - Copyright © 2011–201
6
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
*
* 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
@@
-17,11
+17,14
@@
package net.pterodactylus.sone.web.ajax;
package net.pterodactylus.sone.web.ajax;
+import javax.annotation.Nonnull;
+
+import com.google.common.base.Optional;
+
import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.web.WebInterface;
import net.pterodactylus.sone.web.page.FreenetRequest;
import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.web.WebInterface;
import net.pterodactylus.sone.web.page.FreenetRequest;
-import net.pterodactylus.util.json.JsonObject;
/**
* AJAX page that lets the user untrust a Sone.
/**
* AJAX page that lets the user untrust a Sone.
@@
-29,7
+32,7
@@
import net.pterodactylus.util.json.JsonObject;
* @see Core#untrustSone(Sone, Sone)
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
* @see Core#untrustSone(Sone, Sone)
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
-public class UntrustAjaxPage extends JsonPage {
+public class UntrustAjaxPage extends
LoggedIn
JsonPage {
/**
* Creates a new “untrust Sone” AJAX handler.
/**
* Creates a new “untrust Sone” AJAX handler.
@@
-44,18
+47,15
@@
public class UntrustAjaxPage extends JsonPage {
/**
* {@inheritDoc}
*/
/**
* {@inheritDoc}
*/
+ @Nonnull
@Override
@Override
- protected JsonObject createJsonObject(FreenetRequest request) {
- Sone currentSone = getCurrentSone(request.getToadletContext(), false);
- if (currentSone == null) {
- return createErrorJsonObject("auth-required");
- }
+ protected JsonReturnObject createJsonObject(@Nonnull Sone currentSone, @Nonnull FreenetRequest request) {
String soneId = request.getHttpRequest().getParam("sone");
String soneId = request.getHttpRequest().getParam("sone");
-
Sone sone = webInterface.getCore().getSone(soneId, false
);
- if (
sone == null
) {
+
Optional<Sone> sone = webInterface.getCore().getSone(soneId
);
+ if (
!sone.isPresent()
) {
return createErrorJsonObject("invalid-sone-id");
}
return createErrorJsonObject("invalid-sone-id");
}
- webInterface.getCore().untrustSone(currentSone, sone);
+ webInterface.getCore().untrustSone(currentSone, sone
.get()
);
return createSuccessJsonObject().put("trustValue", (String) null);
}
return createSuccessJsonObject().put("trustValue", (String) null);
}