Package com.alibaba.citrus.service.mail.builder

Examples of com.alibaba.citrus.service.mail.builder.MailBuilder


            if (mailService == null) {
                throw new MailBuilderException("Could not find mail \"" + mailRef + "\": no MailService");
            }

            MailBuilder mailBuilder;

            try {
                mailBuilder = mailService.getMailBuilder(mailRef);
            } catch (MailNotFoundException e) {
                throw new MailBuilderException("Could not find mail \"" + mailRef + "\"", e);
            }

            Message mail = mailBuilder.getMessage(getMailBuilder().getSession());

            render(mailPart, mail);
        }
View Full Code Here


    protected final <T> T getService(Class<T> serviceType, String defaultId, T defaultInstance) {
        if (defaultInstance != null) {
            return defaultInstance;
        }

        MailBuilder builder = getMailBuilder(false);

        if (builder != null) {
            MailService mailService = builder.getMailService();

            if (mailService != null) {
                return mailService.getService(serviceType, defaultId);
            }
        }
View Full Code Here

    }

    @Test
    public void build() throws Exception {
        builder = createVeryComplexMail();
        MailBuilder copy = builder.clone();

        // 检查content tree是否为类型相同,实例不同
        Object[] tree1 = getMailBuilderTree(builder);
        Object[] tree2 = getMailBuilderTree(copy);
View Full Code Here

        assertEquals(1, StringUtil.countMatches(eml, "Content-Disposition: inline; filename=java.gif"));
        assertEquals(1, StringUtil.countMatches(eml, "Content-Disposition: inline; filename=bible.jpg"));
    }

    private MailBuilder createVeryComplexMail() {
        MailBuilder builder = new MailBuilder();

        // 创建所有contents。
        MultipartContent attachable = new MixedMultipartContent();
        attachable.setId("attachable");

        MultipartContent alternative = new AlternativeMultipartContent();
        alternative.setId("alternative");

        TextContent plainText = new TextContent("我爱北京敏感词", "text/plain");
        plainText.setId("plainText");

        TextContent htmlText = new TextContent("<爱北京敏感词>", "text/html");
        htmlText.setId("htmlText");

        TextTemplateContent plainTextTemplate = new TextTemplateContent("mail/mytemplate.vm", "text/plain");
        plainTextTemplate.setId("plainTextTemplate");

        AttachmentContent textAttachment = new AttachmentContent("testfile.txt");
        textAttachment.setId("textAttachment");

        HTMLTemplateContent htmlTemplate = new HTMLTemplateContent("mail/complexhtml.vm");
        htmlTemplate.setId("htmlTemplate");

        plainTextTemplate.setTemplateService(templateService);
        plainTextTemplate.setPullService(pullService);

        htmlTemplate.setTemplateService(templateService);
        htmlTemplate.setPullService(pullService);
        htmlTemplate.setResourceLoader(factory);
        htmlTemplate.addInlineResource("image", "/");

        textAttachment.setResourceLoader(factory);

        // 加入builder
        builder.setContent(attachable);
        {
            attachable.addContent(alternative);
            {
                alternative.addContent(plainText);
                alternative.addContent(htmlText);
            }

            attachable.addContent(plainTextTemplate);
            attachable.addContent(textAttachment);
            attachable.addContent(htmlTemplate);
        }

        // 检查getId()
        assertSame(attachable, builder.getContent("attachable"));
        assertSame(alternative, builder.getContent("alternative"));
        assertSame(plainText, builder.getContent("plainText"));
        assertSame(htmlText, builder.getContent("htmlText"));
        assertSame(plainTextTemplate, builder.getContent("plainTextTemplate"));
        assertSame(textAttachment, builder.getContent("textAttachment"));
        assertSame(htmlTemplate, builder.getContent("htmlTemplate"));

        return builder;
    }
View Full Code Here

TOP

Related Classes of com.alibaba.citrus.service.mail.builder.MailBuilder

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.