* The Sone web interface
*/
public GetLikesAjaxPage(WebInterface webInterface) {
- super("ajax/getLikes.ajax", webInterface);
+ super("getLikes.ajax", webInterface);
}
//
String type = request.getHttpRequest().getParam("type", null);
String id = request.getHttpRequest().getParam(type, null);
if ((id == null) || (id.length() == 0)) {
- return new JsonObject().put("success", false).put("error", "invalid-" + type + "-id");
+ return createErrorJsonObject("invalid-" + type + "-id");
}
if ("post".equals(type)) {
- Post post = webInterface.core().getPost(id);
- Set<Sone> sones = webInterface.core().getLikes(post);
- return new JsonObject().put("success", true).put("likes", sones.size()).put("sones", getSones(sones));
+ Post post = webInterface.getCore().getPost(id);
+ Set<Sone> sones = webInterface.getCore().getLikes(post);
+ return createSuccessJsonObject().put("likes", sones.size()).put("sones", getSones(sones));
} else if ("reply".equals(type)) {
- Reply reply = webInterface.core().getReply(id);
- Set<Sone> sones = webInterface.core().getLikes(reply);
- return new JsonObject().put("success", true).put("likes", sones.size()).put("sones", getSones(sones));
+ Reply reply = webInterface.getCore().getReply(id);
+ Set<Sone> sones = webInterface.getCore().getLikes(reply);
+ return createSuccessJsonObject().put("likes", sones.size()).put("sones", getSones(sones));
}
- return new JsonObject().put("success", false).put("error", "invalid-type");
+ return createErrorJsonObject("invalid-type");
}
/**