protected final Response fillTemplate(Closure<StringTemplate> populator) { StringWriter output = new StringWriter(); try { templateHelper.writeTemplate(output, populator); } catch (TemplateException e) { throw new WebApplicationException(e); } return Response.ok(output.toString()).build(); }
private String fillTemplate(final Iterable<DisplayMetric> metrics) { StringWriter output = new StringWriter(); try { templateHelper.writeTemplate( output, new Closure<StringTemplate>() { @Override public void execute(StringTemplate template) { template.setAttribute("cluster_name", clusterName); template.setAttribute("metrics", metrics); } }); } catch (TemplateException e) { throw new WebApplicationException(e); } return output.toString(); }