Search in sources :

Example 11 with EmailInfo

use of org.broadleafcommerce.common.email.service.info.EmailInfo in project BroadleafCommerce by BroadleafCommerce.

the class AdminSpringBootTestConfiguration method blFulfillmentOrderTrackingEmailInfo.

@Bean
public EmailInfo blFulfillmentOrderTrackingEmailInfo() {
    EmailInfo info = blEmailInfo();
    info.setSubject("Your order with The Heat Clinic Has Shipped");
    info.setEmailTemplate("fulfillmentOrderTracking-email");
    return info;
}
Also used : EmailInfo(org.broadleafcommerce.common.email.service.info.EmailInfo) MapFactoryBean(org.springframework.beans.factory.config.MapFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 12 with EmailInfo

use of org.broadleafcommerce.common.email.service.info.EmailInfo in project BroadleafCommerce by BroadleafCommerce.

the class EmailStatusHandler method handleStatus.

public void handleStatus(String serviceName, ServiceStatusType status) {
    String message = serviceName + " is reporting a status of " + status.getType();
    EmailInfo copy = emailInfo.clone();
    copy.setMessageBody(message);
    copy.setSubject(message);
    emailService.sendBasicEmail(copy, emailTarget, null);
}
Also used : EmailInfo(org.broadleafcommerce.common.email.service.info.EmailInfo)

Example 13 with EmailInfo

use of org.broadleafcommerce.common.email.service.info.EmailInfo in project BroadleafCommerce by BroadleafCommerce.

the class JMSEmailServiceProducerImpl method send.

public void send(final Map props) {
    if (props instanceof Serializable) {
        final Serializable sProps = (Serializable) props;
        emailServiceTemplate.send(emailServiceDestination, new MessageCreator() {

            public Message createMessage(Session session) throws JMSException {
                ObjectMessage message = session.createObjectMessage(sProps);
                EmailInfo info = (EmailInfo) props.get(EmailPropertyType.INFO.getType());
                message.setJMSPriority(Integer.parseInt(info.getSendAsyncPriority()));
                return message;
            }
        });
    } else {
        throw new IllegalArgumentException("The properties map must be Serializable");
    }
}
Also used : Serializable(java.io.Serializable) ObjectMessage(javax.jms.ObjectMessage) Message(javax.jms.Message) ObjectMessage(javax.jms.ObjectMessage) JMSException(javax.jms.JMSException) EmailInfo(org.broadleafcommerce.common.email.service.info.EmailInfo) MessageCreator(org.springframework.jms.core.MessageCreator) Session(javax.jms.Session)

Example 14 with EmailInfo

use of org.broadleafcommerce.common.email.service.info.EmailInfo 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)

Example 15 with EmailInfo

use of org.broadleafcommerce.common.email.service.info.EmailInfo in project BroadleafCommerce by BroadleafCommerce.

the class EmailServiceImpl method sendTemplateEmail.

public boolean sendTemplateEmail(EmailTarget emailTarget, EmailInfo emailInfo, 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);
    Long emailId = emailTrackingManager.createTrackedEmail(emailTarget.getEmailAddress(), emailInfo.getEmailType(), null);
    props.put("emailTrackingId", emailId);
    return sendBasicEmail(emailInfo, emailTarget, props);
}
Also used : NullEmailInfo(org.broadleafcommerce.common.email.service.info.NullEmailInfo) EmailInfo(org.broadleafcommerce.common.email.service.info.EmailInfo)

Aggregations

EmailInfo (org.broadleafcommerce.common.email.service.info.EmailInfo)15 Bean (org.springframework.context.annotation.Bean)8 MapFactoryBean (org.springframework.beans.factory.config.MapFactoryBean)7 NullEmailInfo (org.broadleafcommerce.common.email.service.info.NullEmailInfo)2 Serializable (java.io.Serializable)1 HashMap (java.util.HashMap)1 Locale (java.util.Locale)1 JMSException (javax.jms.JMSException)1 Message (javax.jms.Message)1 ObjectMessage (javax.jms.ObjectMessage)1 Session (javax.jms.Session)1 MimeMessage (javax.mail.internet.MimeMessage)1 ByteArrayDataSource (javax.mail.util.ByteArrayDataSource)1 EmailTarget (org.broadleafcommerce.common.email.domain.EmailTarget)1 EmailException (org.broadleafcommerce.common.email.service.exception.EmailException)1 MessageCreator (org.springframework.jms.core.MessageCreator)1 MimeMessageHelper (org.springframework.mail.javamail.MimeMessageHelper)1 MimeMessagePreparator (org.springframework.mail.javamail.MimeMessagePreparator)1 Test (org.testng.annotations.Test)1