SubscribeConfirmpublic class SubscribeConfirm extends BaseCommand Subscribe handles the subscribe-confirm command.
It is configured by:
<command name="subscribe-confirm" class="SubscribeConfirm"/>
It uses the formatted text-based resources for its return mail body:
- subscribe-confirm
- admincommands
After formatting the text, the message is delivered with {@link #sendStandardReply}
This command basically sends the welcome message and adds the user to the mailing list. |
Fields Summary |
---|
protected org.apache.james.util.XMLResources[] | xmlResources | protected static final int | SUBSCRIBE_CONFIRM | protected static final int | ADMIN_COMMANDS |
Methods Summary |
---|
protected boolean | checkSubscriptionStatus(org.apache.mailet.Mail mail)Checks to see if this user is already subscribed, if so return false and send a message
MailAddress mailAddress = mail.getSender();
UsersRepository usersRepository = getUsersRepository();
if (usersRepository.contains(mailAddress.toString())) {
getCommandListservManager().onError(mail,
"Invalid request",
xmlResources[SUBSCRIBE_CONFIRM].getString("already.subscribed", getStandardProperties()));
return false;
}
return true;
| public void | init(org.apache.james.transport.mailets.ICommandListservManager commandListservManager, org.apache.avalon.framework.configuration.Configuration configuration)
super.init(commandListservManager, configuration);
xmlResources = initXMLResources(new String[]{"subscribeConfirm", "admincommands"});
| public void | onCommand(org.apache.mailet.Mail mail)After ensuring that the user isn't already subscribed, add the user to the
mailing list, and send a welcome message.
It uses the formatted text-based resources for its return mail body:
- {@link #SUBSCRIBE_CONFIRM}
- {@link #ADMIN_COMMANDS}
if (checkSubscriptionStatus(mail)) {
getUsersRepository().addUser(mail.getSender().toString(), "");
//send mail
Properties props = getStandardProperties();
props.put("SENDER_ADDR", mail.getSender().toString());
String confirmationMail = xmlResources[SUBSCRIBE_CONFIRM].getString("text", props);
String adminCommands = xmlResources[ADMIN_COMMANDS].getString("text", props);
String subject = xmlResources[SUBSCRIBE_CONFIRM].getString("welcome.subscribe.address", props);
sendStandardReply(mail, subject, confirmationMail + adminCommands, null);
}
|
|