1 package net.suberic.pooka.filter; 2 import net.suberic.pooka.gui.MessageProxy; 3 import net.suberic.pooka.Pooka; 4 5 import javax.mail.Address ; 6 import javax.mail.internet.InternetAddress ; 7 8 import java.util.List ; 9 import java.util.ArrayList ; 10 11 12 15 public class BounceFilterAction implements FilterAction { 16 17 private Address [] targetAddresses= null; 18 19 private boolean removeBounced = false; 20 21 public BounceFilterAction() { 22 } 23 24 34 public List performFilter(List filteredMessages) { 35 List removed = new ArrayList (); 36 for (int i = 0; i < filteredMessages.size(); i++) { 37 MessageProxy current = (MessageProxy) filteredMessages.get(i); 38 current.bounceMessage(getTargetAddresses(), removeBounced, false); 39 if (removeBounced) { 40 removed.add(current); 41 } 42 } 43 44 return removed; 45 } 46 47 53 54 public void initializeFilter(String sourceProperty) { 55 try { 56 String addressString = Pooka.getProperty(sourceProperty + ".targetAddresses", ""); 57 targetAddresses = InternetAddress.parse(addressString, false); 58 59 removeBounced = Pooka.getProperty(sourceProperty + ".removeBounced", "false").equalsIgnoreCase("true"); 60 } catch (javax.mail.MessagingException me) { 61 String errorMessage = Pooka.getProperty("error.bounceMessage.addresses", "Error parsing address entry"); 62 if (Pooka.getUIFactory() != null) { 63 Pooka.getUIFactory().showError(errorMessage + ": " + sourceProperty, me); 64 } else { 65 System.err.println(errorMessage + ": " + sourceProperty); 66 me.printStackTrace(); 67 } 68 } 69 } 70 71 76 public Address [] getTargetAddresses() { 77 return targetAddresses; 78 } 79 80 } 81 | Popular Tags |