Example usage for javax.mail AuthenticationFailedException getClass

List of usage examples for javax.mail AuthenticationFailedException getClass

Introduction

In this page you can find the example usage for javax.mail AuthenticationFailedException getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.clustercontrol.jobmanagement.util.SendApprovalMail.java

/**
 * ?????/*from w  w  w  .j  a  v a2  s  .  c  om*/
 * 
 * @param jobInfo
 *            
 * @param subject
 *            ??
 * @param content
 *            
 */
private void sendMail(JobInfoEntity jobInfo, String subject, String content, String approvalRequestUser)
        throws HinemosUnknown {
    m_log.debug("sendMail()");

    m_log.debug("sendMail() subject:" + subject);
    m_log.debug("sendMail() content:" + content);

    try {
        ArrayList<String> toAddressList = new ArrayList<String>();

        String userId = null;
        List<String> userIdList = null;
        String addr;

        userId = jobInfo.getApprovalReqUserId();
        if (userId != null && !userId.equals("*")) {
            addr = getUserMailAdress(userId);
            if (addr != null) {
                toAddressList.add(addr);
            }
        } else {
            userIdList = UserRoleCache.getUserIdList(jobInfo.getApprovalReqRoleId());
            if (userIdList != null && !userIdList.isEmpty()) {
                for (String user : userIdList) {
                    addr = null;
                    addr = getUserMailAdress(user);
                    if (addr != null) {
                        toAddressList.add(addr);
                    }
                }
            }
        }

        if (approvalRequestUser != null && !approvalRequestUser.equals("")) {
            addr = null;
            addr = getUserMailAdress(approvalRequestUser);
            if (addr != null) {
                toAddressList.add(addr);
            }
        }
        // ????????
        if (toAddressList.size() == 0) {
            m_log.debug("sendMail() : mail address is empty");
            internalEventNotify(PriorityConstant.TYPE_INFO, jobInfo.getId().getSessionId(),
                    jobInfo.getId().getJobId(), MessageConstant.MESSAGE_SYS_019_JOB, null);
            return;
        }
        String[] toAddress = toAddressList.toArray(new String[0]);

        try {
            this.sendMail(toAddress, null, subject, content);
        } catch (AuthenticationFailedException e) {
            String detailMsg = "cannot connect to the mail server due to an Authentication Failure";
            m_log.warn("sendMail() " + e.getMessage() + " : " + detailMsg + " : " + e.getClass().getSimpleName()
                    + ", " + e.getMessage());
            internalEventNotify(PriorityConstant.TYPE_CRITICAL, jobInfo.getId().getSessionId(),
                    jobInfo.getId().getJobId(), MessageConstant.MESSAGE_SYS_020_JOB, null);
        } catch (SMTPAddressFailedException e) {
            String detailMsg = e.getMessage() + "(SMTPAddressFailedException)";
            m_log.warn("sendMail() " + e.getMessage() + " : " + detailMsg + " : " + e.getClass().getSimpleName()
                    + ", " + e.getMessage());
            internalEventNotify(PriorityConstant.TYPE_CRITICAL, jobInfo.getId().getSessionId(),
                    jobInfo.getId().getJobId(), MessageConstant.MESSAGE_SYS_020_JOB, null);
        } catch (MessagingException e) {
            String detailMsg = e.getCause() != null ? e.getMessage() + " Cause : " + e.getCause().getMessage()
                    : e.getMessage();
            m_log.warn("sendMail() " + e.getMessage() + " : " + detailMsg + " : " + e.getClass().getSimpleName()
                    + ", " + e.getMessage());
            internalEventNotify(PriorityConstant.TYPE_CRITICAL, jobInfo.getId().getSessionId(),
                    jobInfo.getId().getJobId(), MessageConstant.MESSAGE_SYS_020_JOB, null);
        } catch (UnsupportedEncodingException e) {
            String detailMsg = e.getCause() != null ? e.getMessage() + " Cause : " + e.getCause().getMessage()
                    : e.getMessage();
            m_log.warn("sendMail() " + e.getMessage() + " : " + detailMsg + detailMsg + " : "
                    + e.getClass().getSimpleName() + ", " + e.getMessage(), e);
            internalEventNotify(PriorityConstant.TYPE_CRITICAL, jobInfo.getId().getSessionId(),
                    jobInfo.getId().getJobId(), MessageConstant.MESSAGE_SYS_020_JOB, null);
        }
    } catch (RuntimeException e1) {
        String detailMsg = e1.getCause() != null ? e1.getMessage() + " Cause : " + e1.getCause().getMessage()
                : e1.getMessage();
        m_log.warn("sendMail() " + e1.getMessage() + " : " + detailMsg + detailMsg + " : "
                + e1.getClass().getSimpleName() + ", " + e1.getMessage(), e1);
        internalEventNotify(PriorityConstant.TYPE_CRITICAL, jobInfo.getId().getSessionId(),
                jobInfo.getId().getJobId(), MessageConstant.MESSAGE_SYS_020_JOB, null);
    }
}