⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mailaction.java

📁 J2EE & Tomcat books published by hope
💻 JAVA
字号:
/* */package org.impact.stars.control.ejb;import java.util.Locale;import java.rmi.RemoteException;import javax.ejb.EJBException;import javax.ejb.FinderException;import javax.ejb.CreateException;import javax.naming.NamingException;import javax.ejb.SessionBean;import javax.ejb.SessionContext;import org.impact.stars.mail.ejb.EMailMessage;import org.impact.stars.mail.exceptions.MailerAppException;//import org.impact.stars.Stakeholder.account.model.AccountModel;import org.impact.stars.conflictmd.conflict.model.ConflictModel;import org.impact.stars.organizationmd.stakeholder.ejb.StakeholderLocal;import org.impact.stars.organizationmd.stakeholder.ejb.StakeholderLocalHome;import org.impact.stars.conflictmd.conflict.ejb.ConflictLocal;import org.impact.stars.conflictmd.conflict.ejb.ConflictLocalHome;import org.impact.stars.util.Debug;import org.impact.stars.util.EJBUtil;import org.impact.stars.mail.ejb.Mailer;import org.impact.stars.util.JSPUtil;/** * This class encapsulates all the logic to build an EMail Message. * It uses the Conflict EJB and Account EJB to get the info to build * and send a message. * */public class MailAction implements java.io.Serializable {    public MailAction( ) {    }     /**     * This method creates an email confirmation message     * for an conflict and sends an email to the Stakeholder.     * The Conflict EJB and Account EJB are accessed to     * create the email message content.     *     * @param  conflict    is the conflictEJB used to generate content     *                  for the email message for a particular     *                  Stakeholder conflict     * @return          an EMailMessage object containing all info     *                  to send the email.     */    public void sendConfirmationMessage(String userName,                                        int conflictId,                                        Locale locale) throws                                                       CreateException,                                                       FinderException,                                                       RemoteException{        EMailMessage eMess = null;        StakeholderLocalHome shome = null;        StakeholderLocal shdr = null;        ConflictLocalHome chome = null;        ConflictLocal cfli = null;        ConflictModel conflictDetails = null;        try {                chome = EJBUtil.getConflictLocalHome();                cfli = chome.findByPrimaryKey(String.valueOf(conflictId));        } catch (javax.naming.NamingException ne) {            throw new RemoteException("Irrecoverable error while getting conflict instance for sending mail : " + ne);        } catch (javax.ejb.FinderException ce) {            throw new FinderException("Unable to get a reference to the conflict to send the mail");        }/*        try {                        conflictDetails = shdr.getConflictDetails(conflictId);            accountDetails = shdr.getAccountDetails(userName);            if (accountDetails == null) {                Debug.print("Can't find user corresponding to the conflict " +                            conflictDetails.getConflictId()+ "!");            }            //params:mail subjectLine, message contents, emailAddress            eMess = new EMailMessage(createSubjectLine(conflictDetails),                           createMessage(conflictDetails, accountDetails, locale),                           accountDetails.getContactInformation().getEMail(), locale);            Mailer mailer = EJBUtil.createMailerEJB();            mailer.sendMail(eMess);        }      catch (CreateException ce) {           throw new CreateException("Unable to get a reference to the conflict to send the mail");        } catch (FinderException fe) {            throw new FinderException("Unable to get a reference to the conflict to send the mail");        } catch (MailerAppException mx) {        }*/    }    /**     *  Builds the email message contents     */    private String createMessage(ConflictModel conflictDetails) {      StringBuffer msg = new StringBuffer();       msg.append("Conflict Detected in the Design Process\n");       msg.append("This mail is a confirmation for the conflict# " +                                conflictDetails.getConflictID() + "\n");      msg.append("The Conflict\n" + conflictDetails.getName() + "\n");      msg.append("is detected by \n" + conflictDetails.getPStakeholder());      return msg.toString();    }    /**     *  Builds the subject line for the  email message     */    private String createSubjectLine(ConflictModel conflictDetails) {      StringBuffer msg = new StringBuffer();      msg.append("New conflict#" + conflictDetails.getConflictID());      return msg.toString();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -