Search in sources :

Example 1 with EmailException

use of org.broadleafcommerce.common.email.service.exception.EmailException in project BroadleafCommerce by BroadleafCommerce.

the class EmailServiceMDP method onMessage.

/*
     * (non-Javadoc)
     * @see javax.jms.MessageListener#onMessage(javax.jms.Message)
     */
@SuppressWarnings("unchecked")
public void onMessage(Message message) {
    try {
        HashMap props = (HashMap) ((ObjectMessage) message).getObject();
        messageCreator.sendMessage(props);
    } catch (MailAuthenticationException e) {
        throw new EmailException(e);
    } catch (MailPreparationException e) {
        throw new EmailException(e);
    } catch (MailParseException e) {
        throw new EmailException(e);
    } catch (MailSendException e) {
        /*
             * TODO find the specific exception that results from the smtp
             * server being down, and throw this as an EmailException.
             * Otherwise, log and then swallow this exception, as it may have
             * been possible that this email was actually sent.
             */
        throw new EmailException(e);
    } catch (JMSException e) {
        throw new EmailException(e);
    }
}
Also used : MailPreparationException(org.springframework.mail.MailPreparationException) MailAuthenticationException(org.springframework.mail.MailAuthenticationException) MailSendException(org.springframework.mail.MailSendException) HashMap(java.util.HashMap) EmailException(org.broadleafcommerce.common.email.service.exception.EmailException) MailParseException(org.springframework.mail.MailParseException) JMSException(javax.jms.JMSException)

Example 2 with EmailException

use of org.broadleafcommerce.common.email.service.exception.EmailException in project BroadleafCommerce by BroadleafCommerce.

the class EmailServiceImpl method sendBasicEmail.

public boolean sendBasicEmail(EmailInfo emailInfo, EmailTarget emailTarget, Map<String, Object> props) {
    if (props == null) {
        props = new HashMap<String, Object>();
    }
    if (emailInfo == null) {
        emailInfo = new EmailInfo();
    }
    props.put(EmailPropertyType.INFO.getType(), emailInfo);
    props.put(EmailPropertyType.USER.getType(), emailTarget);
    if (Boolean.parseBoolean(emailInfo.getSendEmailReliableAsync())) {
        if (emailServiceProducer == null) {
            throw new EmailException("The property sendEmailReliableAsync on EmailInfo is true, but the EmailService does not have an instance of JMSEmailServiceProducer set.");
        }
        emailServiceProducer.send(props);
    } else {
        messageCreator.sendMessage(props);
    }
    return true;
}
Also used : EmailException(org.broadleafcommerce.common.email.service.exception.EmailException) NullEmailInfo(org.broadleafcommerce.common.email.service.info.NullEmailInfo) EmailInfo(org.broadleafcommerce.common.email.service.info.EmailInfo)

Aggregations

EmailException (org.broadleafcommerce.common.email.service.exception.EmailException)2 HashMap (java.util.HashMap)1 JMSException (javax.jms.JMSException)1 EmailInfo (org.broadleafcommerce.common.email.service.info.EmailInfo)1 NullEmailInfo (org.broadleafcommerce.common.email.service.info.NullEmailInfo)1 MailAuthenticationException (org.springframework.mail.MailAuthenticationException)1 MailParseException (org.springframework.mail.MailParseException)1 MailPreparationException (org.springframework.mail.MailPreparationException)1 MailSendException (org.springframework.mail.MailSendException)1