Subscribepublic class Subscribe extends BaseCommand Subscribe handles the subscribe command.
It is configured by:
<command name="subscribe" class="Subscribe"/>
It uses the formatted text-based resources for its return mail body:
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 if they
are already subscribed to this list. If not, they will be sent a confirmation mail to
be processed by {@link SubscribeConfirm} |
Fields Summary |
---|
protected org.apache.james.util.XMLResources | xmlResources |
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.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[]{"subscribe"})[0];
| public void | onCommand(org.apache.mailet.Mail mail)After ensuring that the user isn't already subscribed, confirmation mail
will be sent to be processed by {@link SubscribeConfirm}.
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.subscribe.subject", props);
String replyAddress = xmlResources.getString("confirm.subscribe.address", props);
sendStandardReply(mail, subject, confirmationMail, replyAddress);
}
|
|