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

UnSubscribe

public class UnSubscribe extends BaseCommand
UnSubscribe handles the unsubscribe command. It is configured by:
<command name="unsubscribe" class="UnSubscribe"/>


It uses the formatted text-based resources for its return mail body:
  • unsubscribe


After formatting the text, the message is delivered with {@link #sendStandardReply} Note, prior to formatting and sending any text, the user is checked to see that they are currently subscribed to this list. If so, they will be sent a confirmation mail to be processed by {@link UnSubscribeConfirm}
version
CVS $Revision: 494012 $ $Date: 2007-01-08 11:23:58 +0100 (Mo, 08 Jan 2007) $
since
2.2.0
see
UnSubscribeConfirm

Fields Summary
protected org.apache.james.util.XMLResources
xmlResources
Constructors Summary
Methods Summary
protected booleancheckSubscriptionStatus(org.apache.mailet.Mail mail)
Checks to see that this user is already subscribed, if not return false and send a message

param
mail
return
false if the user isn't subscribed, true otherwise
throws
MessagingException

        MailAddress mailAddress = mail.getSender();
        UsersRepository usersRepository = getUsersRepository();
        if (!usersRepository.contains(mailAddress.toString())) {
            getCommandListservManager().onError(mail,
                    "Invalid request",
                    xmlResources.getString("not.subscribed", getStandardProperties()));
            return false;
        }
        return true;
    
public voidinit(org.apache.james.transport.mailets.ICommandListservManager commandListservManager, org.apache.avalon.framework.configuration.Configuration configuration)

        super.init(commandListservManager, configuration);
        xmlResources = initXMLResources(new String[]{"unsubscribe"})[0];
    
public voidonCommand(org.apache.mailet.Mail mail)
After ensuring that the user is currently subscribed, confirmation mail will be sent to be processed by {@link UnSubscribeConfirm}.

param
mail
throws
MessagingException

        if (checkSubscriptionStatus(mail)) {
            //send confirmation mail
            Properties props = getStandardProperties();
            props.put("SENDER_ADDR", mail.getSender().toString());

            String confirmationMail = xmlResources.getString("text", props);
            String subject = xmlResources.getString("confirm.unsubscribe.subject", props);
            String replyAddress = xmlResources.getString("confirm.unsubscribe.address", props);

            sendStandardReply(mail, subject, confirmationMail, replyAddress);
        }