FileDocCategorySizeDatePackage
ErrorCommand.javaAPI DocApache James 2.3.13944Fri Jan 12 12:56:30 GMT 2007org.apache.james.transport.mailets.listservcommands

ErrorCommand

public class ErrorCommand extends BaseCommand
Error handles the error command. It is configured by:
<command name="error" class="ErrorCommand"/>


It uses the formatted text-based resources for its return mail body:
  • header
  • error
  • admincommands


After formatting the text, the message is delivered with {@link #sendStandardReply}
version
CVS $Revision: 494012 $ $Date: 2007-01-08 11:23:58 +0100 (Mo, 08 Jan 2007) $
since
2.2.0

Fields Summary
protected org.apache.james.util.XMLResources[]
xmlResources
protected static final int
HEADER
protected static final int
ERROR
protected static final int
ADMIN_COMMANDS
Constructors Summary
Methods Summary
public voidinit(org.apache.james.transport.mailets.ICommandListservManager commandListservManager, org.apache.avalon.framework.configuration.Configuration configuration)


            
        super.init(commandListservManager, configuration);
        xmlResources = initXMLResources(new String[]{"header", "error", "admincommands"});
    
public voidonCommand(org.apache.mailet.Mail mail)
Delegate to {@link #onError}

param
mail
throws
MessagingException

        onError(mail, "an unknown error occurred", "an unknown error occurred");
    
public voidonError(org.apache.mailet.Mail mail, java.lang.String subject, java.lang.String errorMessage)
An error occurred, send a message with the following text resources:
  • {@link #HEADER}
  • {@link #ERROR}
  • {@link #ADMIN_COMMANDS}

param
subject the subject of the message to send
param
mail
param
errorMessage


        Properties props = getStandardProperties();
        props.put("ERROR_MESSAGE", errorMessage);

        StringBuffer plainTextMessage = new StringBuffer();
        String header = xmlResources[HEADER].getString("text", props);
        plainTextMessage.append(header);

        String errorText = xmlResources[ERROR].getString("text", props);
        plainTextMessage.append(errorText);

        String adminCommands = xmlResources[ADMIN_COMMANDS].getString("text", props);
        plainTextMessage.append(adminCommands);

        sendStandardReply(mail, subject, plainTextMessage.toString(), null);