* session
*/
protected Session getCurrentSession(ToadletContext toadletContenxt, boolean create) {
- try {
- Session session = webInterface.getSessionManager().useSession(toadletContenxt);
- if (create && (session == null)) {
- session = webInterface.getSessionManager().createSession(UUID.randomUUID().toString(), toadletContenxt);
- }
- return session;
- } catch (freenet.clients.http.RedirectException re1) {
- return null;
+ Session session = webInterface.getSessionManager().useSession(toadletContenxt);
+ if (create && (session == null)) {
+ session = webInterface.getSessionManager().createSession(UUID.randomUUID().toString(), toadletContenxt);
}
+ return session;
}
/**
if (soneId == null) {
return null;
}
- for (Sone sone : webInterface.core().getSones()) {
- if (sone.getId().equals(soneId)) {
- return sone;
- }
- }
- return null;
+ return webInterface.getCore().getLocalSone(soneId, false);
}
//
}
//
+ // PROTECTED METHODS
+ //
+
+ /**
+ * Creates a success reply.
+ *
+ * @return A reply signaling success
+ */
+ protected JsonObject createSuccessJsonObject() {
+ return new JsonObject().put("success", true);
+ }
+
+ /**
+ * Creates an error reply.
+ *
+ * @param error
+ * The error that has occured
+ * @return The JSON object, signalling failure and the error code
+ */
+ protected JsonObject createErrorJsonObject(String error) {
+ return new JsonObject().put("success", false).put("error", error);
+ }
+
+ //
// PAGE METHODS
//