- * Creates a JSON object from the given post. The JSON object will only
- * contain the ID of the post, its time, and its rendered HTML code.
- *
- * @param post
- * The post to create a JSON object from
- * @return The JSON representation of the post
- */
- private JsonObject createJsonPost(Post post) {
- JsonObject jsonPost = new JsonObject();
- jsonPost.put("id", post.getId());
- jsonPost.put("time", post.getTime());
- StringWriter stringWriter = new StringWriter();
- postTemplate.set("post", post);
- try {
- postTemplate.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 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());
- }
-
- /**