+ //
+ // PRIVATE METHODS
+ //
+
+ /**
+ * Creates a JSON representation of the given reply.
+ *
+ * @param request
+ * The request being processed
+ * @param reply
+ * The reply to convert
+ * @param currentSone
+ * The currently logged in Sone (to store in the template)
+ * @return The JSON representation of the reply
+ */
+ private JsonObject createJsonReply(FreenetRequest request, PostReply reply, Sone currentSone) {
+ JsonObject jsonReply = new JsonObject();
+ jsonReply.put("id", reply.getId());
+ jsonReply.put("postId", reply.getPost().getId());
+ jsonReply.put("soneId", reply.getSone().getId());
+ jsonReply.put("time", reply.getTime());
+ StringWriter stringWriter = new StringWriter();
+ TemplateContext templateContext = webInterface.getTemplateContextFactory().createTemplateContext();
+ templateContext.set("core", webInterface.getCore());
+ templateContext.set("request", request);
+ templateContext.set("reply", reply);
+ templateContext.set("currentSone", currentSone);
+ try {
+ replyTemplate.render(templateContext, stringWriter);
+ } catch (TemplateException te1) {
+ /* TODO - shouldn’t happen. */
+ } finally {
+ Closer.close(stringWriter);
+ }
+ return jsonReply.put("html", stringWriter.toString());
+ }
+