return createErrorJsonObject("invalid-post-id");
}
Reply reply = webInterface.getCore().createReply(currentSone, post, text);
- return new JsonObject().put("success", true).put("reply", reply.getId());
+ return createSuccessJsonObject().put("reply", reply.getId());
}
}
return createErrorJsonObject("not-authorized");
}
currentSone.removePost(post);
- return new JsonObject().put("success", true);
+ return createSuccessJsonObject();
}
}
return createErrorJsonObject("not-authorized");
}
webInterface.getCore().deleteReply(reply);
- return new JsonObject().put("success", true);
+ return createSuccessJsonObject();
}
}
}
currentSone.addFriend(soneId);
webInterface.getCore().saveSone(currentSone);
- return new JsonObject().put("success", true);
+ return createSuccessJsonObject();
}
}
if ("post".equals(type)) {
Post post = webInterface.getCore().getPost(id);
Set<Sone> sones = webInterface.getCore().getLikes(post);
- return new JsonObject().put("success", true).put("likes", sones.size()).put("sones", getSones(sones));
+ return createSuccessJsonObject().put("likes", sones.size()).put("sones", getSones(sones));
} else if ("reply".equals(type)) {
Reply reply = webInterface.getCore().getReply(id);
Set<Sone> sones = webInterface.getCore().getLikes(reply);
- return new JsonObject().put("success", true).put("likes", sones.size()).put("sones", getSones(sones));
+ return createSuccessJsonObject().put("likes", sones.size()).put("sones", getSones(sones));
}
return createErrorJsonObject("invalid-type");
}
Closer.close(templateWriter);
}
synchronized (dateFormat) {
- return new JsonObject().put("success", true).put("soneId", reply.getSone().getId()).put("soneName", SoneAccessor.getNiceName(reply.getSone())).put("time", reply.getTime()).put("displayTime", dateFormat.format(new Date(reply.getTime()))).put("text", reply.getText()).put("html", templateWriter.toString());
+ return createSuccessJsonObject().put("soneId", reply.getSone().getId()).put("soneName", SoneAccessor.getNiceName(reply.getSone())).put("time", reply.getTime()).put("displayTime", dateFormat.format(new Date(reply.getTime()))).put("text", reply.getText()).put("html", templateWriter.toString());
}
}
String soneId = request.getHttpRequest().getParam("sone");
Sone sone = webInterface.getCore().getSone(soneId);
SoneStatus soneStatus = webInterface.getCore().getSoneStatus(sone);
- return new JsonObject().put("status", soneStatus.name()).put("name", SoneAccessor.getNiceName(sone)).put("modified", webInterface.getCore().isModifiedSone(sone)).put("lastUpdated", new SimpleDateFormat("MMM d, yyyy, HH:mm:ss").format(new Date(sone.getTime()))).put("age", (System.currentTimeMillis() - sone.getTime()) / 1000);
+ return createSuccessJsonObject().put("status", soneStatus.name()).put("name", SoneAccessor.getNiceName(sone)).put("modified", webInterface.getCore().isModifiedSone(sone)).put("lastUpdated", new SimpleDateFormat("MMM d, yyyy, HH:mm:ss").format(new Date(sone.getTime()))).put("age", (System.currentTimeMillis() - sone.getTime()) / 1000);
}
/**
protected JsonObject createJsonObject(Request request) {
String key = request.getHttpRequest().getParam("key");
String translation = webInterface.getL10n().getString(key);
- return new JsonObject().put("value", translation);
+ return createSuccessJsonObject().put("value", translation);
}
/**
//
/**
+ * Creates a success reply.
+ *
+ * @return A reply signaling success
+ */
+ protected JsonObject createSuccessJsonObject() {
+ return new JsonObject().put("success", true);
+ }
+
+ /**
* Creates an error reply.
*
* @param error
} else {
return createErrorJsonObject("invalid-type");
}
- return new JsonObject().put("success", true);
+ return createSuccessJsonObject();
}
}
}
currentSone.removeFriend(soneId);
webInterface.getCore().saveSone(currentSone);
- return new JsonObject().put("success", true);
+ return createSuccessJsonObject();
}
}
} else {
return createErrorJsonObject("invalid-type");
}
- return new JsonObject().put("success", true);
+ return createSuccessJsonObject();
}
}