| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.kns.service.impl; |
| 17 | |
|
| 18 | |
import java.util.Arrays; |
| 19 | |
import java.util.Collections; |
| 20 | |
import java.util.Iterator; |
| 21 | |
import java.util.Set; |
| 22 | |
|
| 23 | |
import org.kuali.rice.kns.mail.InvalidAddressException; |
| 24 | |
import org.kuali.rice.kns.mail.MailMessage; |
| 25 | |
import org.kuali.rice.kns.service.MailService; |
| 26 | |
import org.springframework.mail.MailException; |
| 27 | |
import org.springframework.mail.MailSender; |
| 28 | |
import org.springframework.mail.SimpleMailMessage; |
| 29 | |
|
| 30 | |
public class MailServiceImpl implements MailService { |
| 31 | 0 | private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(MailServiceImpl.class); |
| 32 | |
|
| 33 | |
private MailSender mailSender; |
| 34 | |
private String batchMailingList; |
| 35 | |
private String incidentMailingList; |
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
public MailServiceImpl() { |
| 41 | 0 | super(); |
| 42 | 0 | } |
| 43 | |
|
| 44 | |
public void sendMessage(MailMessage message) throws InvalidAddressException { |
| 45 | 0 | LOG.debug("sendMessage() started"); |
| 46 | |
|
| 47 | |
|
| 48 | 0 | SimpleMailMessage smm = new SimpleMailMessage(); |
| 49 | 0 | smm.setTo( (String[])message.getToAddresses().toArray(new String[message.getToAddresses().size()]) ); |
| 50 | 0 | smm.setBcc( (String[])message.getBccAddresses().toArray(new String[message.getBccAddresses().size()]) ); |
| 51 | 0 | smm.setCc( (String[])message.getCcAddresses().toArray(new String[message.getCcAddresses().size()]) ); |
| 52 | 0 | smm.setSubject(message.getSubject()); |
| 53 | 0 | smm.setText(message.getMessage()); |
| 54 | 0 | smm.setFrom(message.getFromAddress()); |
| 55 | |
|
| 56 | |
try { |
| 57 | 0 | if ( LOG.isDebugEnabled() ) { |
| 58 | 0 | LOG.debug( "About to send message: " + smm.toString() ); |
| 59 | |
} |
| 60 | 0 | mailSender.send(smm); |
| 61 | |
} |
| 62 | 0 | catch (MailException e) { |
| 63 | 0 | throw new InvalidAddressException(e); |
| 64 | 0 | } |
| 65 | 0 | } |
| 66 | |
|
| 67 | |
public void setMailSender(MailSender ms) { |
| 68 | 0 | mailSender = ms; |
| 69 | 0 | } |
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
public void setBatchMailingList(String batchMailingList) { |
| 76 | 0 | this.batchMailingList = batchMailingList; |
| 77 | 0 | } |
| 78 | |
|
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
public String getBatchMailingList() { |
| 83 | 0 | return batchMailingList; |
| 84 | |
} |
| 85 | |
|
| 86 | |
|
| 87 | |
|
| 88 | |
|
| 89 | |
public String getIncidentMailingList() { |
| 90 | 0 | return this.incidentMailingList; |
| 91 | |
} |
| 92 | |
|
| 93 | |
|
| 94 | |
|
| 95 | |
|
| 96 | |
public void setIncidentMailingList(String incidentMailingList) { |
| 97 | 0 | this.incidentMailingList = incidentMailingList; |
| 98 | 0 | } |
| 99 | |
|
| 100 | |
} |