1 17 18 package org.apache.james.transport.mailets.listservcommands; 19 20 import org.apache.james.transport.mailets.ICommandListservManager; 21 import org.apache.james.util.XMLResources; 22 import org.apache.mailet.Mail; 23 import org.apache.avalon.framework.configuration.Configuration; 24 import org.apache.avalon.framework.configuration.ConfigurationException; 25 26 import javax.mail.MessagingException ; 27 import java.util.Properties ; 28 29 51 public class ErrorCommand extends BaseCommand { 52 53 protected XMLResources[] xmlResources; 55 56 protected static final int HEADER = 0; 57 protected static final int ERROR = 1; 58 protected static final int ADMIN_COMMANDS = 2; 59 60 public void init(ICommandListservManager commandListservManager, Configuration configuration) throws ConfigurationException { 61 super.init(commandListservManager, configuration); 62 xmlResources = initXMLResources(new String []{"header", "error", "admincommands"}); 63 } 64 65 70 public void onCommand(Mail mail) throws MessagingException { 71 onError(mail, "an unkown error occurred", "an unkown error occurred"); 72 } 73 74 86 public void onError(Mail mail, String subject, String errorMessage) throws MessagingException { 87 88 Properties props = getStandardProperties(); 89 props.put("ERROR_MESSAGE", errorMessage); 90 91 StringBuffer plainTextMessage = new StringBuffer (); 92 String header = xmlResources[HEADER].getString("text", props); 93 plainTextMessage.append(header); 94 95 String errorText = xmlResources[ERROR].getString("text", props); 96 plainTextMessage.append(errorText); 97 98 String adminCommands = xmlResources[ADMIN_COMMANDS].getString("text", props); 99 plainTextMessage.append(adminCommands); 100 101 sendStandardReply(mail, subject, plainTextMessage.toString(), null); 102 } 103 } 104 | Popular Tags |