Package org.eurekastreams.server.support.email

Examples of org.eurekastreams.server.support.email.EmailTemplate


            // create reponse message
            MimeMessage response = emailerFactory.createMessage();
            emailerFactory.setTo(response, user.getEmail());

            EmailTemplate template = errorMessageTemplates.get(actionName);
            if (template == null)
            {
                log.warn("Missing template for error response message for action {}.  Sending generic response.",
                        actionName);

                emailerFactory.setSubject(response, "Error processing received email");
                emailerFactory.setTextBody(response,
                        "There was an error processing your email.  " + cleanException.getMessage()
                                + "  Original message is attached.");
            }
            else
            {
                // prepare for template rendering
                Context velocityContext = new VelocityContext(velocityGlobalContext);
                velocityContext.put("action", actionName);
                velocityContext.put("params", actionSelection.getParams());
                velocityContext.put("user", user);
                velocityContext.put("exception", cleanException);
                velocityContext.put("originalException", inException);
                velocityContext.put("settings", systemSettingsDao.execute(null));

                // build the subject
                StringWriter writer = new StringWriter();
                velocityEngine.evaluate(velocityContext, writer, "EmailSubject-" + actionName,
                        template.getSubjectTemplate());
                emailerFactory.setSubject(response, writer.toString());

                // build the text body
                Template vt = velocityEngine.getTemplate(template.getTextBodyTemplateResourcePath());
                writer.getBuffer().setLength(0);
                vt.merge(velocityContext, writer);
                emailerFactory.setTextBody(response, writer.toString());

                // build the HTML body
                vt = velocityEngine.getTemplate(template.getHtmlBodyTemplateResourcePath());
                // HTML-escape all content inserted
                EventCartridge ec = new EventCartridge();
                ec.addEventHandler(new EscapeHtmlReference());
                ec.attachToContext(velocityContext);
                writer.getBuffer().setLength(0);
View Full Code Here


     */
    public MessageReplierTest()
    {
        Map<String, EmailTemplate> map = new HashMap<String, EmailTemplate>(2);

        EmailTemplate template = new EmailTemplate();
        template.setHtmlBody(HTML_BODY_RESOURCE);
        template.setSubject(SUBJECT_TEMPLATE);
        template.setTextBody(TEXT_BODY_RESOURCE);
        map.put(ACTION_NAME, template);
        template = new EmailTemplate();
        template.setHtmlBody(HTML_BODY_RESOURCE + "NotUsed");
        template.setSubject(SUBJECT_TEMPLATE + "NotUsed");
        template.setTextBody(TEXT_BODY_RESOURCE + "NotUsed");
        map.put(ACTION_NAME + "NotUsed", template);

        errorMessageTemplates = Collections.unmodifiableMap(map);
    }
View Full Code Here

TOP

Related Classes of org.eurekastreams.server.support.email.EmailTemplate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.