1 17 18 package org.apache.james.transport.mailets; 19 20 import org.apache.mailet.GenericMailet; 21 import org.apache.mailet.Mail; 22 import org.apache.mailet.MailetException; 23 import java.util.Iterator ; 24 import java.util.ArrayList ; 25 import java.util.StringTokenizer ; 26 import javax.mail.MessagingException ; 27 28 40 public class RemoveMailAttribute extends GenericMailet { 41 42 private ArrayList attributesToRemove = new ArrayList (); 43 44 49 public String getMailetInfo() { 50 return "Remove Mail Attribute Mailet"; 51 } 52 53 58 public void init() throws MailetException 59 { 60 String name = getInitParameter("name"); 61 62 if (name != null) { 63 StringTokenizer st = new StringTokenizer (name, ",") ; 64 while (st.hasMoreTokens()) { 65 String attribute_name = st.nextToken().trim() ; 66 attributesToRemove.add(attribute_name); 67 } 68 } 69 } 70 71 78 public void service(Mail mail) throws MessagingException { 79 Iterator iter = attributesToRemove.iterator(); 80 while (iter.hasNext()) { 81 String attribute_name = iter.next().toString(); 82 mail.removeAttribute (attribute_name); 83 } 84 } 85 86 87 } 88 | Popular Tags |