- StringWriter notificationWriter = new StringWriter();
- try {
- if (notification instanceof TemplateNotification) {
- TemplateContext templateContext = webInterface.getTemplateContextFactory().createTemplateContext().mergeContext(((TemplateNotification) notification).getTemplateContext());
- templateContext.set("notification", notification);
- ((TemplateNotification) notification).render(templateContext, notificationWriter);
- } else {
- notification.render(notificationWriter);
- }
- } catch (IOException ioe1) {
- /* StringWriter never throws, ignore. */
- }
- jsonNotification.put("text", notificationWriter.toString());
- jsonNotification.put("createdTime", notification.getCreatedTime());