- return jsonPost.put("html", stringWriter.toString());
- }
-
- /**
- * Creates a JSON object from the given reply. The JSON object will only
- * contain the ID of the reply, the ID of its post, its time, and its
- * rendered HTML code.
- *
- * @param reply
- * The reply to create a JSON object from
- * @return The JSON representation of the reply
- */
- private JsonObject createJsonReply(Reply reply) {
- JsonObject jsonPost = new JsonObject();
- jsonPost.put("postId", reply.getPost().getId());
- jsonPost.put("id", reply.getId());
- jsonPost.put("time", reply.getTime());
- StringWriter stringWriter = new StringWriter();
- replyTemplate.set("reply", reply);
- try {
- replyTemplate.render(stringWriter);
- } catch (TemplateException te1) {
- /* TODO - shouldn’t happen. */
- } finally {
- Closer.close(stringWriter);
- }
- return jsonPost.put("html", stringWriter.toString());
- }
-
- /**
- * Creates a JSON object from the given notification.
- *
- * @param notification
- * The notification to create a JSON object
- * @return The JSON object
- */
- private static JsonObject createJsonNotification(Notification notification) {
- JsonObject jsonNotification = new JsonObject();
- jsonNotification.put("id", notification.getId());
- jsonNotification.put("text", notification.toString());
- jsonNotification.put("createdTime", notification.getCreatedTime());
- jsonNotification.put("lastUpdatedTime", notification.getLastUpdatedTime());
- jsonNotification.put("dismissable", notification.isDismissable());
- return jsonNotification;