From 2e50c68bc1f7c92efccbb212bc62fc3c1e07402f Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 4 Jan 2011 07:08:25 +0100 Subject: [PATCH] =?utf8?q?Don=E2=80=99t=20fail=20when=20the=20trust=20can?= =?utf8?q?=20not=20be=20retrieved.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../java/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.java | 7 ++++++- src/main/java/net/pterodactylus/sone/web/ajax/TrustAjaxPage.java | 7 ++++++- src/main/java/net/pterodactylus/sone/web/ajax/UntrustAjaxPage.java | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.java index 7bc9aa9..1a6d28f 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.java @@ -19,6 +19,7 @@ package net.pterodactylus.sone.web.ajax; import net.pterodactylus.sone.core.Core; import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.sone.freenet.wot.Trust; import net.pterodactylus.sone.web.WebInterface; import net.pterodactylus.util.json.JsonObject; @@ -55,7 +56,11 @@ public class DistrustAjaxPage extends JsonPage { return createErrorJsonObject("invalid-sone-id"); } webInterface.getCore().distrustSone(currentSone, sone); - return createSuccessJsonObject().put("trustValue", webInterface.getCore().getTrust(currentSone, sone).getExplicit()); + Trust trust = webInterface.getCore().getTrust(currentSone, sone); + if (trust == null) { + return createErrorJsonObject("wot-plugin"); + } + return createSuccessJsonObject().put("trustValue", trust.getExplicit()); } } diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/TrustAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/TrustAjaxPage.java index e298a50..d6e2750 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/TrustAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/TrustAjaxPage.java @@ -19,6 +19,7 @@ package net.pterodactylus.sone.web.ajax; import net.pterodactylus.sone.core.Core; import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.sone.freenet.wot.Trust; import net.pterodactylus.sone.web.WebInterface; import net.pterodactylus.util.json.JsonObject; @@ -55,7 +56,11 @@ public class TrustAjaxPage extends JsonPage { return createErrorJsonObject("invalid-sone-id"); } webInterface.getCore().trustSone(currentSone, sone); - return createSuccessJsonObject().put("trustValue", webInterface.getCore().getTrust(currentSone, sone).getExplicit()); + Trust trust = webInterface.getCore().getTrust(currentSone, sone); + if (trust == null) { + return createErrorJsonObject("wot-plugin"); + } + return createSuccessJsonObject().put("trustValue", trust.getExplicit()); } } 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 3fe8599..32c6229 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/UntrustAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/UntrustAjaxPage.java @@ -19,6 +19,7 @@ package net.pterodactylus.sone.web.ajax; import net.pterodactylus.sone.core.Core; import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.sone.freenet.wot.Trust; import net.pterodactylus.sone.web.WebInterface; import net.pterodactylus.util.json.JsonObject; @@ -55,7 +56,11 @@ public class UntrustAjaxPage extends JsonPage { return createErrorJsonObject("invalid-sone-id"); } webInterface.getCore().untrustSone(currentSone, sone); - return createSuccessJsonObject().put("trustValue", (String) null); + Trust trust = webInterface.getCore().getTrust(currentSone, sone); + if (trust == null) { + return createErrorJsonObject("wot-plugin"); + } + return createSuccessJsonObject().put("trustValue", trust.getExplicit()); } } -- 2.7.4