protected String expandTemplateFromResource(String templateName, Map<String, Object> model) throws MailCompositionTemplateException { try { // load and render a template Map<String, Object> templateContext = new HashMap<>(); templateContext.putAll(initialTemplateContext); templateContext.putAll(model); StringWriter sw = new StringWriter(); templateEngine.renderResource(templateName, templateContext, sw); return sw.toString(); } catch (Exception ex) { log.error("Failed to render body template!", ex); throw new MailCompositionTemplateException("Template engine threw an exception.", ex); } }
protected String expandTemplateFromString(String templateContent, Map<String, Object> model) throws MailCompositionTemplateException { try { // render a string template Map<String, Object> templateContext = new HashMap<>(); templateContext.putAll(initialTemplateContext); templateContext.putAll(model); StringWriter sw = new StringWriter(); templateEngine.renderString(templateContent, templateContext, sw); return sw.toString(); } catch (Exception ex) { log.error("Failed to render subject template!", ex); throw new MailCompositionTemplateException("Template engine threw an exception.", ex); } }
protected String expandTemplateFromString(String templateContent, Map<String, Object> model) throws MailCompositionTemplateException { try { // render a string template Map<String, Object> templateContext = new HashMap<>(); templateContext.putAll(initialTemplateContext); templateContext.putAll(model); StringWriter sw = new StringWriter(); templateEngine.renderString(templateContent, templateContext, sw); return sw.toString(); } catch (Exception ex) { log.error("Failed to render subject template!", ex); throw new MailCompositionTemplateException("Template engine threw an exception.", ex); } }
protected String expandTemplateFromResource(String templateName, Map<String, Object> model) throws MailCompositionTemplateException { try { // load and render a template Map<String, Object> templateContext = new HashMap<>(); templateContext.putAll(initialTemplateContext); templateContext.putAll(model); StringWriter sw = new StringWriter(); templateEngine.renderResource(templateName, templateContext, sw); return sw.toString(); } catch (Exception ex) { log.error("Failed to render body template!", ex); throw new MailCompositionTemplateException("Template engine threw an exception.", ex); } }
protected String expandTemplateFromResource( String templateResourceName, Map<String, Object> model ) throws MailCompositionTemplateException { try { StringWriter sw = new StringWriter(); Template template = velocityEngineProvider.get().getTemplate( templateResourceName, "UTF-8" ); VelocityContext context = new VelocityContext( getInitialVelocityContext(), new VelocityContext( model ) ); template.merge( context, sw ); return sw.toString(); } catch ( Exception ex ) { throw new MailCompositionTemplateException( "Velocity throw exception during template merge.", ex ); } }
protected String expandTemplateFromString( String template, Map<String, Object> model ) throws MailCompositionTemplateException { try { StringWriter sw = new StringWriter(); VelocityContext context = new VelocityContext( getInitialVelocityContext(), new VelocityContext( model ) ); velocityEngineProvider.get().evaluate( context, sw, "SUBJECT", template ); return sw.toString(); } catch ( Exception ex ) { throw new MailCompositionTemplateException( "Velocity throw exception during template merge.", ex ); } }
protected String expandTemplateFromResource( String templateResourceName, Map<String, Object> model ) throws MailCompositionTemplateException { try { StringWriter sw = new StringWriter(); Template template = velocityComponent.getEngine().getTemplate( templateResourceName, "UTF-8" ); VelocityContext context = new VelocityContext( getInitialVelocityContext(), new VelocityContext( model ) ); template.merge( context, sw ); return sw.toString(); } catch ( Exception ex ) { throw new MailCompositionTemplateException( "Velocity throw exception during template merge.", ex ); } }
protected String expandTemplateFromString( String template, Map<String, Object> model ) throws MailCompositionTemplateException { try { StringWriter sw = new StringWriter(); VelocityContext context = new VelocityContext( getInitialVelocityContext(), new VelocityContext( model ) ); velocityComponent.getEngine().evaluate( context, sw, "SUBJECT", template ); return sw.toString(); } catch ( Exception ex ) { throw new MailCompositionTemplateException( "Velocity throw exception during template merge.", ex ); } }
status.setErrorCause( new MailCompositionTemplateException( "Unknown mailType with ID='" + request.getMailTypeId() + "'" ) );
status.setErrorCause( new MailCompositionTemplateException( "Unknown mailType with ID='" + request.getMailTypeId() + "'" ) );