当前位置: 首页>>代码示例>>Java>>正文


Java EmailContent类代码示例

本文整理汇总了Java中org.kuali.rice.core.api.mail.EmailContent的典型用法代码示例。如果您正苦于以下问题:Java EmailContent类的具体用法?Java EmailContent怎么用?Java EmailContent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


EmailContent类属于org.kuali.rice.core.api.mail包,在下文中一共展示了EmailContent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: process

import org.kuali.rice.core.api.mail.EmailContent; //导入依赖的package包/类
public SimpleResult process(RouteContext context, RouteHelper helper) throws Exception {
   	if (context.isSimulation()) {
           if (!context.getActivationContext().isActivateRequests()) {
           	return new SimpleResult(true);
           }
       } 
loadConfiguration(context);
Document document = generateXmlInput(context);
if (LOG.isDebugEnabled()) {
    LOG.debug("XML input for email tranformation:\n" + XmlJotter.jotNode(document));
}
Templates style = loadStyleSheet(styleName);
EmailContent emailContent = emailStyleHelper.generateEmailContent(style, document);
if (!StringUtils.isBlank(to)) {
	CoreApiServiceLocator.getMailer().sendEmail(new EmailFrom(from), new EmailTo(to), new EmailSubject(emailContent.getSubject()), new EmailBody(emailContent.getBody()), emailContent.isHtml());
}
return new SimpleResult(true);
   }
 
开发者ID:kuali,项目名称:kc-rice,代码行数:19,代码来源:EmailNode.java

示例2: sendPeriodicReminder

import org.kuali.rice.core.api.mail.EmailContent; //导入依赖的package包/类
@Override
protected void sendPeriodicReminder(String principalId, Collection<ActionItem> actionItems, String emailSetting) {
    actionItems = filterActionItemsToNotify(principalId, actionItems, emailSetting);
    Collection<org.kuali.rice.kew.api.action.ActionItem> apiActionItems = new ArrayList<org.kuali.rice.kew.api.action.ActionItem>();
    for(ActionItem actionItem : actionItems) {
        apiActionItems.add(ActionItem.to(actionItem));
    }
    // if there are no action items after being filtered, there's no
    // reason to send the email
    if (actionItems.isEmpty()) {
        return;
    }
    EmailContent content;
    Person person = KimApiServiceLocator.getPersonService().getPerson(principalId);
    if (KewApiConstants.EMAIL_RMNDR_DAY_VAL.equals(emailSetting)) {
        content = getEmailContentGenerator().generateDailyReminder(person, apiActionItems);
    } else if (KewApiConstants.EMAIL_RMNDR_WEEK_VAL.equals(emailSetting)) {
        content = getEmailContentGenerator().generateWeeklyReminder(person, apiActionItems);
    } else {
        // else...refactor this...
        throw new RuntimeException("invalid email setting. this code needs refactoring");
    }
    sendEmail(person, new EmailSubject(content.getSubject()), new EmailBody(content.getBody()));
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:25,代码来源:CustomizableActionListEmailServiceImpl.java

示例3: testGroup

import org.kuali.rice.core.api.mail.EmailContent; //导入依赖的package包/类
/**
 * This method specifically exercises a group responsibility to assure that the 
 * {@link StyleableEmailContentServiceImpl} can handle that case.
 * See KULRICE-3659.
 */
@Test
public void testGroup() throws Exception {
	String ewestfalPrincipalId = getPrincipalIdForName("ewestfal");
	
	// this document type has a group responsibility
	WorkflowDocument doc = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("rkirkend"), "EmailTestWorkgroupDocType");
	doc.route("");
	
	ActionListFilter actionListFilter = new ActionListFilter();
	actionListFilter.setDocumentType(doc.getDocumentTypeName());
	Collection<ActionItem> actionItems = KEWServiceLocator.getActionListService().getActionList(ewestfalPrincipalId, actionListFilter);

	EmailContentService emailContentService = KEWServiceLocator.getEmailContentService();
	
	Person person = KimApiServiceLocator.getPersonService().getPerson(ewestfalPrincipalId);
	// this would blow up before the fix
	EmailContent emailContent = emailContentService.generateDailyReminder(person, ActionItem.to(new ArrayList<ActionItem>(actionItems)));
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:24,代码来源:EmailContentServiceTest.java

示例4: testUserDelegator

import org.kuali.rice.core.api.mail.EmailContent; //导入依赖的package包/类
/**
 * This method tests that delegation doesn't break the email
 * 
 * @throws Exception
 */
@Test
public void testUserDelegator() throws Exception {
	
	RuleTestUtils.createDelegationToUser("EmailTestUserDocType", "WorkflowDocumentTemplate", "user1");
	
	String user1PrincipalId = getPrincipalIdForName("user1");
	
	// this document type has a group responsibility
	WorkflowDocument doc = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("rkirkend"), "EmailTestUserDocType");
	doc.route("");
	
	ActionListFilter actionListFilter = new ActionListFilter();
	actionListFilter.setDocumentType(doc.getDocumentTypeName());
	Collection<ActionItem> actionItems = KEWServiceLocator.getActionListService().getActionList(user1PrincipalId, actionListFilter);

	EmailContentService emailContentService = KEWServiceLocator.getEmailContentService();
	
	Person person = KimApiServiceLocator.getPersonService().getPerson(user1PrincipalId);
	EmailContent emailContent = emailContentService.generateDailyReminder(person, ActionItem.to(new ArrayList<ActionItem>(actionItems)));
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:26,代码来源:EmailContentServiceTest.java

示例5: testGroupDelegator

import org.kuali.rice.core.api.mail.EmailContent; //导入依赖的package包/类
/**
 * This method tests that 
 * 
 * @throws Exception
 */
@Test
public void testGroupDelegator() throws Exception {
	
	RuleTestUtils.createDelegationToGroup("EmailTestWorkgroupDocType", "WorkflowDocumentTemplate", "EmailTestDelegateWorkgroup");
	
	String user1PrincipalId = getPrincipalIdForName("user1");
	
	// this document type has a group responsibility
	WorkflowDocument doc = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("rkirkend"), "EmailTestWorkgroupDocType");
	doc.route("");
	
	ActionListFilter actionListFilter = new ActionListFilter();
	actionListFilter.setDocumentType(doc.getDocumentTypeName());
	Collection<ActionItem> actionItems = KEWServiceLocator.getActionListService().getActionList(user1PrincipalId, actionListFilter);

	EmailContentService emailContentService = KEWServiceLocator.getEmailContentService();
	
	Person person = KimApiServiceLocator.getPersonService().getPerson(user1PrincipalId);
	EmailContent emailContent = emailContentService.generateDailyReminder(person, ActionItem.to(new ArrayList<ActionItem>(actionItems)));
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:26,代码来源:EmailContentServiceTest.java

示例6: testGenerateRemindersCustomStyleSheet

import org.kuali.rice.core.api.mail.EmailContent; //导入依赖的package包/类
/**
 * tests custom stylesheet
 * @throws Exception
 */
@Test
public void testGenerateRemindersCustomStyleSheet() throws Exception {
    loadXmlFile("customEmailStyleData.xml");
    assertNotNull(CoreServiceApiServiceLocator.getStyleService().getStyle("kew.email.style"));

    Person user = KimApiServiceLocator.getPersonService().getPersonByPrincipalName("arh14");
    int count = generateDocs(new String[] { "PingDocument", "PingDocumentWithEmailAttrib" }, user);

    Collection<ActionItem> actionItems = org.kuali.rice.kew.actionitem.ActionItem.to(new ArrayList<org.kuali.rice.kew.actionitem.ActionItem>(KEWServiceLocator.getActionListService().getActionList(user.getPrincipalId(), null)));
    assertEquals("user should have " + count + " items in his action list.", count, actionItems.size());

    EmailContent content = styleableContentService.generateImmediateReminder(user, actionItems.iterator().next(), KEWServiceLocator.getDocumentTypeService().findByName(actionItems.iterator().next().getDocName()));
    assertTrue("Unexpected subject", content.getSubject().startsWith("CUSTOM:"));
    assertTrue("Unexpected body", content.getBody().startsWith("CUSTOM:"));

    content = styleableContentService.generateDailyReminder(user, actionItems);
    assertTrue("Unexpected subject", content.getSubject().startsWith("CUSTOM:"));
    assertTrue("Unexpected body", content.getBody().startsWith("CUSTOM:"));

    content = styleableContentService.generateWeeklyReminder(user, actionItems);
    assertTrue("Unexpected subject", content.getSubject().startsWith("CUSTOM:"));
    assertTrue("Unexpected body", content.getBody().startsWith("CUSTOM:"));
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:28,代码来源:EmailMessageTest.java

示例7: sendPeriodicReminder

import org.kuali.rice.core.api.mail.EmailContent; //导入依赖的package包/类
@Override
protected void sendPeriodicReminder(String principalId, Collection<ActionItemActionListExtension> actionItems, String emailSetting) {
    actionItems = filterActionItemsToNotify(principalId, actionItems, emailSetting);
    Collection<org.kuali.rice.kew.api.action.ActionItem> apiActionItems = new ArrayList<org.kuali.rice.kew.api.action.ActionItem>();
    for(ActionItem actionItem : actionItems) {
        apiActionItems.add(ActionItem.to(actionItem));
    }
    // if there are no action items after being filtered, there's no
    // reason to send the email
    if (actionItems.isEmpty()) {
        return;
    }
    EmailContent content;
    Person person = KimApiServiceLocator.getPersonService().getPerson(principalId);
    if (KewApiConstants.EMAIL_RMNDR_DAY_VAL.equals(emailSetting)) {
        content = getEmailContentGenerator().generateDailyReminder(person, apiActionItems);
    } else if (KewApiConstants.EMAIL_RMNDR_WEEK_VAL.equals(emailSetting)) {
        content = getEmailContentGenerator().generateWeeklyReminder(person, apiActionItems);
    } else {
        // else...refactor this...
        throw new RuntimeException("invalid email setting. this code needs refactoring");
    }
    sendEmail(person, new EmailSubject(content.getSubject()), new EmailBody(content.getBody()));
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:25,代码来源:CustomizableActionListEmailServiceImpl.java

示例8: testGroup

import org.kuali.rice.core.api.mail.EmailContent; //导入依赖的package包/类
/**
 * This method specifically exercises a group responsibility to assure that the 
 * {@link StyleableEmailContentServiceImpl} can handle that case.
 * See KULRICE-3659.
 */
@Test
public void testGroup() throws Exception {
	String ewestfalPrincipalId = getPrincipalIdForName("ewestfal");
	
	// this document type has a group responsibility
	WorkflowDocument doc = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("rkirkend"), "EmailTestWorkgroupDocType");
	doc.route("");
	
	ActionListFilter actionListFilter = new ActionListFilter();
	actionListFilter.setDocumentType(doc.getDocumentTypeName());
	Collection<ActionItemActionListExtension> actionItems = KEWServiceLocator.getActionListService().getActionList(ewestfalPrincipalId, actionListFilter);

	EmailContentService emailContentService = KEWServiceLocator.getEmailContentService();
	
	Person person = KimApiServiceLocator.getPersonService().getPerson(ewestfalPrincipalId);
	// this would blow up before the fix
	EmailContent emailContent = emailContentService.generateDailyReminder(person, ActionItem.to(new ArrayList<ActionItem>(actionItems)));
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:24,代码来源:EmailContentServiceTest.java

示例9: testUserDelegator

import org.kuali.rice.core.api.mail.EmailContent; //导入依赖的package包/类
/**
 * This method tests that delegation doesn't break the email
 * 
 * @throws Exception
 */
@Test
public void testUserDelegator() throws Exception {
	
	RuleTestUtils.createDelegationToUser("EmailTestUserDocType", "WorkflowDocumentTemplate", "user1");
	
	String user1PrincipalId = getPrincipalIdForName("user1");
	
	// this document type has a group responsibility
	WorkflowDocument doc = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("rkirkend"), "EmailTestUserDocType");
	doc.route("");
	
	ActionListFilter actionListFilter = new ActionListFilter();
	actionListFilter.setDocumentType(doc.getDocumentTypeName());
	Collection<ActionItemActionListExtension> actionItems = KEWServiceLocator.getActionListService().getActionList(user1PrincipalId, actionListFilter);

	EmailContentService emailContentService = KEWServiceLocator.getEmailContentService();
	
	Person person = KimApiServiceLocator.getPersonService().getPerson(user1PrincipalId);
	EmailContent emailContent = emailContentService.generateDailyReminder(person, ActionItem.to(new ArrayList<ActionItem>(actionItems)));
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:26,代码来源:EmailContentServiceTest.java

示例10: testGroupDelegator

import org.kuali.rice.core.api.mail.EmailContent; //导入依赖的package包/类
/**
 * This method tests that 
 * 
 * @throws Exception
 */
@Test
public void testGroupDelegator() throws Exception {
	
	RuleTestUtils.createDelegationToGroup("EmailTestWorkgroupDocType", "WorkflowDocumentTemplate", "EmailTestDelegateWorkgroup");
	
	String user1PrincipalId = getPrincipalIdForName("user1");
	
	// this document type has a group responsibility
	WorkflowDocument doc = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("rkirkend"), "EmailTestWorkgroupDocType");
	doc.route("");
	
	ActionListFilter actionListFilter = new ActionListFilter();
	actionListFilter.setDocumentType(doc.getDocumentTypeName());
	Collection<ActionItemActionListExtension> actionItems = KEWServiceLocator.getActionListService().getActionList(user1PrincipalId, actionListFilter);

	EmailContentService emailContentService = KEWServiceLocator.getEmailContentService();
	
	Person person = KimApiServiceLocator.getPersonService().getPerson(user1PrincipalId);
	EmailContent emailContent = emailContentService.generateDailyReminder(person, ActionItem.to(new ArrayList<ActionItem>(actionItems)));
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:26,代码来源:EmailContentServiceTest.java

示例11: sendFeedback

import org.kuali.rice.core.api.mail.EmailContent; //导入依赖的package包/类
public ActionForward sendFeedback(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
	FeedbackForm feedbackForm = (FeedbackForm)form;    	
    EmailContentService emailContentService = KEWServiceLocator.getEmailContentService();
    String fromAddress = determineFromAddress(emailContentService, feedbackForm);
	String toAddress = emailContentService.getApplicationEmailAddress();
    EmailContent content = emailContentService.generateFeedback(feedbackForm);
    CoreApiServiceLocator.getMailer().sendEmail(new EmailFrom(fromAddress), new EmailTo(toAddress), new EmailSubject(content.getSubject()), new EmailBody(content.getBody()), content.isHtml());
	return mapping.findForward("sent");
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:10,代码来源:FeedbackAction.java

示例12: generateEmailContent

import org.kuali.rice.core.api.mail.EmailContent; //导入依赖的package包/类
public EmailContent generateEmailContent(Templates style, Document document) {
DOMResult result = new DOMResult();
       if (LOG.isDebugEnabled()) {
           LOG.debug("Input document: " + XmlJotter.jotNode(document.getDocumentElement(), true));
       }
       try {
           style.newTransformer().transform(new DOMSource(document), result);
       } catch (TransformerException te) {
           String message = "Error transforming immediate reminder DOM";
           LOG.error(message, te);
           throw new WorkflowRuntimeException(message, te);
       }

       Node node = result.getNode();

       if (LOG.isDebugEnabled()) {
           LOG.debug("Email to be sent: " + XmlJotter.jotNode(node));
       }
       XPathFactory xpf = XPathFactory.newInstance();
       XPath xpath = xpf.newXPath();
       try {
           String subject = (String) xpath.evaluate("/email/subject", node, XPathConstants.STRING);
           String body = (String) xpath.evaluate("/email/body", node, XPathConstants.STRING);
           // simple heuristic to determine whether content is HTML
           return new EmailContent(subject, body, body.matches("(?msi).*<(\\w+:)?html.*"));
       } catch (XPathExpressionException xpee) {
           throw new WorkflowRuntimeException("Error evaluating generated email content", xpee);
       }
   }
 
开发者ID:kuali,项目名称:kc-rice,代码行数:30,代码来源:EmailStyleHelper.java

示例13: sendImmediateReminder

import org.kuali.rice.core.api.mail.EmailContent; //导入依赖的package包/类
@Override
public void sendImmediateReminder(org.kuali.rice.kew.api.action.ActionItem actionItem, Boolean skipOnApprovals) {
    if (actionItem == null) {
        LOG.warn("Request to send immediate reminder to recipient of a null action item... aborting.");
        return;
    }

    if (actionItem.getPrincipalId() == null) {
        LOG.warn("Request to send immediate reminder to null recipient of an action item... aborting.");
        return;
    }

    if (skipOnApprovals != null && skipOnApprovals.booleanValue()
            && actionItem.getActionRequestCd().equals(KewApiConstants.ACTION_REQUEST_APPROVE_REQ)) {
        LOG.debug("As requested, skipping immediate reminder notification on action item approval for " + actionItem.getPrincipalId());
        return;
    }

    Preferences preferences = KewApiServiceLocator.getPreferencesService().getPreferences(actionItem.getPrincipalId());
    if(!checkEmailNotificationPreferences(actionItem, preferences, KewApiConstants.EMAIL_RMNDR_IMMEDIATE)) {
        LOG.debug("Email suppressed due to the user's preferences");
        return;
    }

    if (!sendActionListEmailNotification()) {
        LOG.debug("not sending immediate reminder");
        return;
    }

    // since this is a message for a single document, we can customize the from
    // line based on DocumentType
    DocumentRouteHeaderValue document = KEWServiceLocator.getRouteHeaderService().getRouteHeader(actionItem.getDocumentId());
    Person person = KimApiServiceLocator.getPersonService().getPerson(actionItem.getPrincipalId());
    if (person != null) {
        EmailContent content = getEmailContentGenerator().generateImmediateReminder(person, actionItem, document.getDocumentType());
        sendEmail(person, new EmailSubject(content.getSubject()),
                    new EmailBody(content.getBody()), document.getDocumentType());
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:40,代码来源:CustomizableActionListEmailServiceImpl.java

示例14: generateFeedback

import org.kuali.rice.core.api.mail.EmailContent; //导入依赖的package包/类
@Override
public EmailContent generateFeedback(FeedbackForm form) {
       DocumentBuilder db = getDocumentBuilder(true);
       Document doc = db.newDocument();
       String styleSheet = globalEmailStyleSheet;

       // if the doc type is specified, see if that doc has a custom email stylesheet and use it
       // NOTE: do we need to do this for feedback? presumably feedback will be going back to admins
       /*String docTypeName = form.getDocumentType();
       if (!StringUtils.isBlank(docTypeName)) {
           DocumentType docType = KEWServiceLocator.getDocumentTypeService().findByName(docTypeName);
           if (docType == null) {
               LOG.error("User specified document type '" + docTypeName + "' in feedback form, but the document type was not found in the system");
           } else {
               if (docType.getCustomEmailStylesheet() != null) {
                   styleSheet = docType.getCustomEmailStylesheet();
               }
           }
       }*/
       LOG.info("form: " + form.getDocumentId());
       try {
           addObjectXML(doc, form, null, "feedback");
       } catch (Exception e) {
           String message = "Error generating XML for feedback form: " + form;
           LOG.error(message, e);
           throw new WorkflowRuntimeException(message, e);
       }
       setStandardAttributes(doc.getDocumentElement());

       return generateEmailContent(styleSheet, doc);
   }
 
开发者ID:kuali,项目名称:kc-rice,代码行数:32,代码来源:StyleableEmailContentServiceImpl.java

示例15: testGenerateRemindersDocCustomStyleSheet

import org.kuali.rice.core.api.mail.EmailContent; //导入依赖的package包/类
/**
 * tests custom stylesheet
 * @throws Exception
 */
@Test
public void testGenerateRemindersDocCustomStyleSheet() throws Exception {
    // we need to make sure that the immediate email message is customized on a per-doc basis
    // so we need to easily distinguish from the global style and the custom style
    // an easy way to do that is use two styles that have introduced obvious and blatent
    // distinguishing marker...so we just reuse the global custom email style here
    loadXmlFile("customEmailStyleData.xml");
    loadXmlFile("docCustomEmailStyleData.xml");
    assertNotNull(CoreServiceApiServiceLocator.getStyleService().getStyle("kew.email.style"));
    assertNotNull(CoreServiceApiServiceLocator.getStyleService().getStyle("doc.custom.email.style"));

    Person user = KimApiServiceLocator.getPersonService().getPersonByPrincipalName("arh14");
    int count = generateDocs(new String[] { "PingDocumentCustomStyle" }, user);

    Collection<ActionItem> actionItems = org.kuali.rice.kew.actionitem.ActionItem.to(new ArrayList<org.kuali.rice.kew.actionitem.ActionItem>(KEWServiceLocator.getActionListService().getActionList(user.getPrincipalId(), null)));
    assertEquals("user should have " + count + " items in his action list.", count, actionItems.size());

    EmailContent content = styleableContentService.generateImmediateReminder(user, actionItems.iterator().next(), KEWServiceLocator.getDocumentTypeService().findByName(actionItems.iterator().next().getDocName()));
    // immediate email reminder should have used the doc type email style and NOT the global style
    assertFalse("Unexpected subject", content.getSubject().startsWith("CUSTOM:"));
    assertFalse("Unexpected body", content.getBody().startsWith("CUSTOM:"));
    assertTrue("Unexpected subject", content.getSubject().startsWith("DOCTYPE CUSTOM:"));
    assertTrue("Unexpected body", content.getBody().startsWith("DOCTYPE CUSTOM:"));


    // daily and weekly are unchanged since they are not document type specific
    content = styleableContentService.generateDailyReminder(user, actionItems);
    assertTrue("Unexpected subject", content.getSubject().startsWith("CUSTOM:"));
    assertTrue("Unexpected body", content.getBody().startsWith("CUSTOM:"));

    content = styleableContentService.generateWeeklyReminder(user, actionItems);
    assertTrue("Unexpected subject", content.getSubject().startsWith("CUSTOM:"));
    assertTrue("Unexpected body", content.getBody().startsWith("CUSTOM:"));
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:39,代码来源:EmailMessageTest.java


注:本文中的org.kuali.rice.core.api.mail.EmailContent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。