private Template getTemplate(String path) { Template template = (Template) templateMap.get(path); if (template == null) { try { template = engine.getTemplate(path, ENCODING); } catch (ResourceNotFoundException e) { e.printStackTrace(); } catch (ParseErrorException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } return template; } }
public String CcdaToHtml(ArrayList<CCDAValidationReportItem> ccdaItem) { String res = ""; // first, get and initialize an engine try { VelocityEngine ve = VelocitySingleton.getVelocityEngine(); Template t2 = ve.getTemplate("CCDAValidationReport.vm"); VelocityContext context = new VelocityContext(); context.put("validationReport", ccdaItem); StringWriter writer = new StringWriter(); t2.merge( context, writer ); res = writer.toString(); } catch (ResourceNotFoundException e) { e.printStackTrace(); } catch (ParseErrorException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return res; }
public String XdmToHtml(ArrayList<XDMValidationReportItem> xdmItem) { String res = ""; // first, get and initialize an engine try { VelocityEngine ve = VelocitySingleton.getVelocityEngine(); Template t2 = ve.getTemplate("XDMValidationReport.vm"); VelocityContext context = new VelocityContext(); context.put("validationReport", xdmItem); StringWriter writer = new StringWriter(); t2.merge( context, writer ); res = writer.toString(); } catch (ResourceNotFoundException e) { e.printStackTrace(); } catch (ParseErrorException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return res; }
protected String merge(Template template, VelocityContext context) { if (template == null) { return ""; } StringWriter writer = new StringWriter(); try { template.merge(context, writer); } catch (ResourceNotFoundException e) { e.printStackTrace(); } catch (ParseErrorException e) { e.printStackTrace(); } catch (MethodInvocationException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } String ret = writer.toString(); writer.flush(); return ret; }
private static String createLog4jXml(VelocityContext velocityContext) { StringWriter sw = new StringWriter(); try { InputStream is = LoggingService.class.getClassLoader().getResourceAsStream("log4j.xml.vm"); StringBuilder sb = new StringBuilder(); if (is != null) { List<String> lines = IOUtils.readLines(is); for (String line : lines) { sb.append(line).append("\n"); } } Velocity.evaluate(velocityContext, sw, null, sb.toString()); } catch (ParseErrorException e) { e.printStackTrace(); } catch (MethodInvocationException e) { e.printStackTrace(); } catch (ResourceNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return sw.toString(); }
/** * Get the velocity template. * * @param ve * * @return the velocity template. * * @throws MojoExecutionException */ private Template getVelocityTemplate(VelocityEngine ve) throws MojoExecutionException { Template template = null; try { template = ve.getTemplate(getRelativeFilePath(project.getBasedir(), templateFile)); } catch (ResourceNotFoundException e) { e.printStackTrace(); throw new MojoExecutionException("Unable to locate template " + templateFile, e); } catch (ParseErrorException e) { e.printStackTrace(); throw new MojoExecutionException("Problem parsing the template", e); } catch (MethodInvocationException e) { e.printStackTrace(); throw new MojoExecutionException("Something invoked in the template threw an exception", e); } catch (Exception e) { e.printStackTrace(); throw new MojoExecutionException("Some random template parsing error occurred", e); } return template; }
} catch (ParseErrorException e1) { e1.printStackTrace(); } catch (Exception e1) {
e.printStackTrace(); } catch (ParseErrorException e) { e.printStackTrace(); } catch (MethodInvocationException e) { e.printStackTrace();
e.printStackTrace(); } catch (ParseErrorException e) { e.printStackTrace(); } catch (MethodInvocationException e) { e.printStackTrace();
} catch (ParseErrorException pee) { System.err.println(pee.getMessage()); pee.printStackTrace(); } catch (Exception e) { System.err.println(e.getMessage());
public String getHtml() throws EmailException { if (engine == null || context == null) { // If either the engine, or the context are null, just skip return super.getHtml(); } StringWriter writer = new StringWriter(); try { engine.evaluate(context, writer, "HtmlTemplate", super.getHtml()); } catch (ParseErrorException e) { // TODO Auto-generated catch block e.printStackTrace(); throw new EmailException("Error Processing HtmlTemplate", e); } catch (MethodInvocationException e) { // TODO Auto-generated catch block e.printStackTrace(); throw new EmailException("Error Processing HtmlTemplate", e); } catch (ResourceNotFoundException e) { throw new EmailException("Error Processing HtmlTemplate", e); } catch (IOException e) { throw new EmailException("Error Processing HtmlTemplate", e); } return writer.toString(); }
public String getText() throws EmailException { if (engine == null || context == null) { // If either the engine, or the context are null, just skip return super.getText(); } StringWriter writer = new StringWriter(); try { engine.evaluate(context, writer, "TextTemplate", super.getText()); } catch (ParseErrorException e) { // TODO Auto-generated catch block e.printStackTrace(); throw new EmailException("Error Processing TextTemplate", e); } catch (MethodInvocationException e) { // TODO Auto-generated catch block e.printStackTrace(); throw new EmailException("Error Processing TextTemplate", e); } catch (ResourceNotFoundException e) { throw new EmailException("Error Processing TextTemplate", e); } catch (IOException e) { throw new EmailException("Error Processing TextTemplate", e); } return writer.toString(); }