Coverage Report - org.kuali.rice.kns.service.impl.MailServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
MailServiceImpl
0%
0/26
0%
0/2
1.429
 
 1  
 /*
 2  
  * Copyright 2006-2008 The Kuali Foundation
 3  
  * 
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  * 
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  * 
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 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  
         // Send email
 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  
      * Sets the batchMailingList attribute value.
 73  
      * @param batchMailingList The batchMailingList to set.
 74  
      */
 75  
     public void setBatchMailingList(String batchMailingList) {
 76  0
         this.batchMailingList = batchMailingList;
 77  0
     }
 78  
 
 79  
     /**
 80  
      * @see org.kuali.rice.kns.service.MailService#getBatchMailingList()
 81  
      */
 82  
     public String getBatchMailingList() {
 83  0
         return batchMailingList;
 84  
     }
 85  
     
 86  
         /**
 87  
          * @return the incidentMailingList
 88  
          */
 89  
         public String getIncidentMailingList() {
 90  0
                 return this.incidentMailingList;
 91  
         }
 92  
 
 93  
         /**
 94  
          * @param incidentMailingList the incidentMailingList to set
 95  
          */
 96  
         public void setIncidentMailingList(String incidentMailingList) {
 97  0
                 this.incidentMailingList = incidentMailingList;
 98  0
         }
 99  
 
 100  
 }