private void writeFile(File file, String template, VelocityContext context) { String templatePath; if(config.getTemplateFolder() == null) { templatePath = template; } else { templatePath = config.getTemplateFolder()+ System.getProperty("file.separator") + template; } Writer writer = null; try { log.info("Writing " + file); Template velocityTemplate = engine.getTemplate(templatePath); writer = new FileWriter(file); velocityTemplate.merge(context, writer); } catch (IOException e) { log.error(e.getMessage(), e); } catch (ResourceNotFoundException e) { log.error(e.getMessage(), e); } catch (ParseErrorException e) { log.error(e.getMessage(), e); } catch (Exception e) { log.error(e.getMessage(), e); } finally { FileUtils.close(writer); } }
+ " template: " + e.getMessage(), e );
+ " template: " + e.getMessage(), e );
+ " template: " + e.getMessage(), e );
public String evaluate(Map<String, Object> context, TemplatePack templatePack, Template template) throws IOException { StringWriter sw = new StringWriter(); try { engine.evaluate(new VelocityContext(context), sw, template.getName(), template.getTemplate()); return sw.toString(); } catch (ParseErrorException parseException) { handleStopFileGeneration(parseException); log.error("In " + templatePack.getName() + ":" + template.getName() + " template, parse exception " + parseException.getMessage(), parseException.getCause()); displayLinesInError(parseException, templatePack, template); throw new IllegalStateException(); } catch (MethodInvocationException mie) { handleStopFileGeneration(mie); log.error("In " + templatePack.getName() + ":" + mie.getTemplateName() + " method [" + mie.getMethodName() + "] has not been set", mie.getCause()); displayLinesInError(mie, templatePack, template); throw mie; } finally { closeQuietly(sw); } }
public String generateMail( String templateName, AuthenticationKey authkey, String baseUrl ) { VelocityContext context = createVelocityContext( authkey, baseUrl ); String packageName = getClass().getPackage().getName().replace( '.', '/' ); String templateFile = packageName + "/template/" + templateName + ".vm"; StringWriter writer = new StringWriter(); try { velocity.getEngine().mergeTemplate( templateFile, context, writer ); } catch ( ResourceNotFoundException e ) { getLogger().error( "No such template: '" + templateFile + "'." ); } catch ( ParseErrorException e ) { getLogger().error( "Unable to generate email for template '" + templateFile + "': " + e.getMessage(), e ); } catch ( MethodInvocationException e ) { getLogger().error( "Unable to generate email for template '" + templateFile + "': " + e.getMessage(), e ); } catch ( Exception e ) { getLogger().error( "Unable to generate email for template '" + templateFile + "': " + e.getMessage(), e ); } return writer.getBuffer().toString(); }
public String evaluate(Map<String, Object> context, TemplatePack templatePack, Template template) throws IOException { StringWriter sw = new StringWriter(); try { engine.evaluate(new VelocityContext(context), sw, template.getName(), template.getTemplate()); return sw.toString(); } catch (ParseErrorException parseException) { handleStopFileGeneration(parseException); log.error("In " + templatePack.getName() + ":" + template.getName() + " template, parse exception " + parseException.getMessage(), parseException.getCause()); displayLinesInError(parseException, templatePack, template); throw new IllegalStateException(); } catch (MethodInvocationException mie) { handleStopFileGeneration(mie); log.error("In " + templatePack.getName() + ":" + mie.getTemplateName() + " method [" + mie.getMethodName() + "] has not been set", mie.getCause()); displayLinesInError(mie, templatePack, template); throw mie; } finally { closeQuietly(sw); } }
rnfe.printStackTrace(); } catch (ParseErrorException pee) { System.err.println(pee.getMessage()); pee.printStackTrace(); } catch (Exception e) {
parseErrorException.getMessage());
parseErrorException.getMessage());
logsevere("Velocity Parsing error in " + templateName + ": " + pe.getMessage() + "\n" + pe.getInvalidSyntax()); throw new ActivityException(-1, pe.getMessage(), pe);
log.error("ResourceManager: parse exception: {}", pee.getMessage()); throw pee;
macroLibrary, pe.getMessage(), pe); throw pe;
throw new ParseErrorException( pex.getMessage(), info );
throw new ParseErrorException( pex.getMessage(), info );
throw new ParseErrorException( pex.getMessage(), info );