You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ba...@apache.org on 2005/12/29 18:48:45 UTC
svn commit: r359857 - in
/james/server/trunk/src/java/org/apache/james/transport/mailets:
LocalDelivery.java ToMultiRepository.java
UsersRepositoryAliasingForwarding.java
Author: bago
Date: Thu Dec 29 09:48:39 2005
New Revision: 359857
URL: http://svn.apache.org/viewcvs?rev=359857&view=rev
Log:
Completed comments and modularity for LocalDelivery new components (ToMultiRepository and LocalDelivery) (Fixes #4 and #5 of JAMES-414)
Modified:
james/server/trunk/src/java/org/apache/james/transport/mailets/LocalDelivery.java
james/server/trunk/src/java/org/apache/james/transport/mailets/ToMultiRepository.java
james/server/trunk/src/java/org/apache/james/transport/mailets/UsersRepositoryAliasingForwarding.java
Modified: james/server/trunk/src/java/org/apache/james/transport/mailets/LocalDelivery.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/transport/mailets/LocalDelivery.java?rev=359857&r1=359856&r2=359857&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/transport/mailets/LocalDelivery.java (original)
+++ james/server/trunk/src/java/org/apache/james/transport/mailets/LocalDelivery.java Thu Dec 29 09:48:39 2005
@@ -17,15 +17,25 @@
package org.apache.james.transport.mailets;
+import org.apache.commons.collections.iterators.IteratorChain;
import org.apache.mailet.GenericMailet;
import org.apache.mailet.Mail;
+import org.apache.mailet.MailetConfig;
+import org.apache.mailet.MailetContext;
import javax.mail.MessagingException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
/**
- * Receives a Mail from JamesSpoolManager and takes care of delivery
- * of the message to local inboxes.
- *
+ * Receives a Mail from JamesSpoolManager and takes care of delivery of the
+ * message to local inboxes.
+ *
+ * Since James 2.3.0 this mailet is a composition of
+ * UserRepositoryAliasingForwarding and ToMultiRepository
+ * configurated to mimic the old "LocalDelivery" behaviour.
*/
public class LocalDelivery extends GenericMailet {
@@ -33,7 +43,7 @@
* Mailet that apply aliasing and forwarding
*/
private UsersRepositoryAliasingForwarding aliasingMailet;
-
+
/**
* Mailet that actually store the message
*/
@@ -41,10 +51,12 @@
/**
* Delivers a mail to a local mailbox.
- *
- * @param mail the mail being processed
- *
- * @throws MessagingException if an error occurs while storing the mail
+ *
+ * @param mail
+ * the mail being processed
+ *
+ * @throws MessagingException
+ * if an error occurs while storing the mail
*/
public void service(Mail mail) throws MessagingException {
aliasingMailet.service(mail);
@@ -55,7 +67,7 @@
/**
* Return a string describing this mailet.
- *
+ *
* @return a string describing this mailet
*/
public String getMailetInfo() {
@@ -70,7 +82,50 @@
aliasingMailet = new UsersRepositoryAliasingForwarding();
aliasingMailet.init(getMailetConfig());
deliveryMailet = new ToMultiRepository();
- deliveryMailet.init(getMailetConfig());
+ MailetConfig m = new MailetConfig() {
+
+ /**
+ * @see org.apache.mailet.MailetConfig#getInitParameter(java.lang.String)
+ */
+ public String getInitParameter(String name) {
+ if (name == "addDeliveryHeader") {
+ return "Delivered-To";
+ } else if (name == "resetReturnPath") {
+ return "true";
+ } else {
+ return getMailetConfig().getInitParameter(name);
+ }
+ }
+
+ /**
+ * @see org.apache.mailet.MailetConfig#getInitParameterNames()
+ */
+ public Iterator getInitParameterNames() {
+ IteratorChain c = new IteratorChain();
+ Collection h = new ArrayList();
+ h.add("addDeliveryHeader");
+ h.add("resetReturnPath");
+ c.addIterator(getMailetConfig().getInitParameterNames());
+ c.addIterator(h.iterator());
+ return c;
+ }
+
+ /**
+ * @see org.apache.mailet.MailetConfig#getMailetContext()
+ */
+ public MailetContext getMailetContext() {
+ return getMailetConfig().getMailetContext();
+ }
+
+ /**
+ * @see org.apache.mailet.MailetConfig#getMailetName()
+ */
+ public String getMailetName() {
+ return getMailetConfig().getMailetName();
+ }
+
+ };
+ deliveryMailet.init(m);
}
}
Modified: james/server/trunk/src/java/org/apache/james/transport/mailets/ToMultiRepository.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/transport/mailets/ToMultiRepository.java?rev=359857&r1=359856&r2=359857&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/transport/mailets/ToMultiRepository.java (original)
+++ james/server/trunk/src/java/org/apache/james/transport/mailets/ToMultiRepository.java Thu Dec 29 09:48:39 2005
@@ -17,6 +17,8 @@
package org.apache.james.transport.mailets;
+import org.apache.avalon.cornerstone.services.store.Store;
+import org.apache.avalon.framework.configuration.DefaultConfiguration;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.james.Constants;
@@ -42,66 +44,123 @@
import java.util.Vector;
/**
- * Receives a Mail from JamesSpoolManager and takes care of delivery
- * of the message to local inboxes.
+ * Receives a Mail from JamesSpoolManager and takes care of delivery of the
+ * message to local inboxes or a specific repository.
+ *
+ * Differently from LocalDelivery this does not lookup the UserRepository This
+ * simply store the message in a repository named like the local part of the
+ * recipient address.
+ *
+ * If no repository is specified then this fallback to MailServer.getUserInbox.
+ * Otherwise you can add your own configuration for the repository
+ *
+ * e.g: <repositoryUrl>file://var/spool/userspools/</repositoryUrl>
+ * <repositoryType>SPOOL</repositoryType>
+ *
+ * <repositoryUrl>file://var/mail/inboxes/</repositoryUrl> <repositoryType>MAIL</repositoryType>
+ *
+ * Header "Delivered-To" can be added to every message adding the
+ * <addDeliveryHeader>Delivered-To</addDeliveryHeader>
*
- * Differently from LocalDelivery this does not lookup the UserRepository
- * This simply store the message in a repository named like the local part
- * of the recipient address.
*/
public class ToMultiRepository extends GenericMailet {
/**
- * The number of mails generated. Access needs to be synchronized for
- * thread safety and to ensure that all threads see the latest value.
+ * The number of mails generated. Access needs to be synchronized for thread
+ * safety and to ensure that all threads see the latest value.
*/
private static long count;
-
+
/**
* The mailserver reference
*/
private MailServer mailServer;
/**
+ * The mailstore
+ */
+ private Store store;
+
+ /**
+ * The optional repositoryUrl
+ */
+ private String repositoryUrl;
+
+ /**
+ * The optional repositoryType
+ */
+ private String repositoryType;
+
+ /**
+ * The delivery header
+ */
+ private String deliveryHeader;
+
+ /**
+ * resetReturnPath
+ */
+ private boolean resetReturnPath;
+
+ /**
* Delivers a mail to a local mailbox.
- *
- * @param mail the mail being processed
- *
- * @throws MessagingException if an error occurs while storing the mail
+ *
+ * @param mail
+ * the mail being processed
+ *
+ * @throws MessagingException
+ * if an error occurs while storing the mail
*/
public void service(Mail mail) throws MessagingException {
Collection recipients = mail.getRecipients();
Collection errors = new Vector();
- MimeMessage message = mail.getMessage();
+ MimeMessage message = null;
+ if (deliveryHeader != null || resetReturnPath) {
+ message = mail.getMessage();
+ }
- // Set Return-Path and remove all other Return-Path headers from the message
- // This only works because there is a placeholder inserted by MimeMessageWrapper
- message.setHeader(RFC2822Headers.RETURN_PATH, (mail.getSender() == null ? "<>" : "<" + mail.getSender() + ">"));
+ if (resetReturnPath) {
+ // Set Return-Path and remove all other Return-Path headers from the
+ // message
+ // This only works because there is a placeholder inserted by
+ // MimeMessageWrapper
+ message.setHeader(RFC2822Headers.RETURN_PATH,
+ (mail.getSender() == null ? "<>" : "<" + mail.getSender()
+ + ">"));
+ }
- // Copy any Delivered-To headers from the message
+ Enumeration headers;
InternetHeaders deliveredTo = new InternetHeaders();
- Enumeration headers = message.getMatchingHeaders(new String[] {"Delivered-To"});
- while (headers.hasMoreElements()) {
- Header header = (Header) headers.nextElement();
- deliveredTo.addHeader(header.getName(), header.getValue());
+ if (deliveryHeader != null) {
+ // Copy any Delivered-To headers from the message
+ headers = message
+ .getMatchingHeaders(new String[] { deliveryHeader });
+ while (headers.hasMoreElements()) {
+ Header header = (Header) headers.nextElement();
+ deliveredTo.addHeader(header.getName(), header.getValue());
+ }
}
- for (Iterator i = recipients.iterator(); i.hasNext(); ) {
+ for (Iterator i = recipients.iterator(); i.hasNext();) {
MailAddress recipient = (MailAddress) i.next();
try {
- // Add qmail's de facto standard Delivered-To header
- message.addHeader("Delivered-To", recipient.toString());
+ if (deliveryHeader != null) {
+ // Add qmail's de facto standard Delivered-To header
+ message.addHeader(deliveryHeader, recipient.toString());
+ }
storeMail(mail.getSender(), recipient, message);
- if (i.hasNext()) {
- // Remove headers but leave all placeholders
- message.removeHeader("Delivered-To");
- headers = deliveredTo.getAllHeaders();
- // And restore any original Delivered-To headers
- while (headers.hasMoreElements()) {
- Header header = (Header) headers.nextElement();
- message.addHeader(header.getName(), header.getValue());
+ if (deliveryHeader != null) {
+ if (i.hasNext()) {
+ // Remove headers but leave all placeholders
+ message.removeHeader(deliveryHeader);
+ headers = deliveredTo.getAllHeaders();
+ // And restore any original Delivered-To headers
+ while (headers.hasMoreElements()) {
+ Header header = (Header) headers.nextElement();
+ message.addHeader(header.getName(), header
+ .getValue());
+ }
}
}
} catch (Exception ex) {
@@ -111,28 +170,29 @@
}
if (!errors.isEmpty()) {
- // If there were errors, we redirect the email to the ERROR processor.
- // In order for this server to meet the requirements of the SMTP specification,
- // mails on the ERROR processor must be returned to the sender. Note that this
- // email doesn't include any details regarding the details of the failure(s).
+ // If there were errors, we redirect the email to the ERROR
+ // processor.
+ // In order for this server to meet the requirements of the SMTP
+ // specification, mails on the ERROR processor must be returned to
+ // the sender. Note that this email doesn't include any details
+ // regarding the details of the failure(s).
// In the future we may wish to address this.
- getMailetContext().sendMail(mail.getSender(),
- errors, message, Mail.ERROR);
+ getMailetContext().sendMail(mail.getSender(), errors, message,
+ Mail.ERROR);
}
- //We always consume this message
+ // We always consume this message
mail.setState(Mail.GHOST);
}
/**
* Return a string describing this mailet.
- *
+ *
* @return a string describing this mailet
*/
public String getMailetInfo() {
- return "Local Delivery Mailet";
+ return "ToMultiRepository Mailet";
}
-
/**
*
* @param sender
@@ -140,36 +200,35 @@
* @param message
* @throws MessagingException
*/
- public void storeMail(MailAddress sender, MailAddress recipient, MimeMessage message)
- throws MessagingException {
+ public void storeMail(MailAddress sender, MailAddress recipient,
+ MimeMessage message) throws MessagingException {
String username;
if (recipient == null) {
- throw new IllegalArgumentException("Recipient for mail to be spooled cannot be null.");
+ throw new IllegalArgumentException(
+ "Recipient for mail to be spooled cannot be null.");
}
if (message == null) {
- throw new IllegalArgumentException("Mail message to be spooled cannot be null.");
+ throw new IllegalArgumentException(
+ "Mail message to be spooled cannot be null.");
}
username = recipient.getUser();
Collection recipients = new HashSet();
recipients.add(recipient);
MailImpl mailImpl = new MailImpl(getId(), sender, recipients, message);
- MailRepository userInbox = mailServer.getUserInbox(username);
+ MailRepository userInbox = getRepository(username);
if (userInbox == null) {
- StringBuffer errorBuffer =
- new StringBuffer(128)
- .append("The inbox for user ")
- .append(username)
- .append(" was not found on this server.");
+ StringBuffer errorBuffer = new StringBuffer(128).append(
+ "The repository for user ").append(username).append(
+ " was not found on this server.");
throw new MessagingException(errorBuffer.toString());
}
userInbox.store(mailImpl);
}
-
/**
* Return a new mail id.
- *
+ *
* @return a new mail id
*/
public String getId() {
@@ -177,12 +236,8 @@
synchronized (James.class) {
localCount = count++;
}
- StringBuffer idBuffer =
- new StringBuffer(64)
- .append("Mail")
- .append(System.currentTimeMillis())
- .append("-")
- .append(localCount);
+ StringBuffer idBuffer = new StringBuffer(64).append("Mail").append(
+ System.currentTimeMillis()).append("-").append(localCount);
return idBuffer.toString();
}
@@ -190,18 +245,68 @@
* @see org.apache.mailet.GenericMailet#init()
*/
public void init() throws MessagingException {
- super.init();
- ServiceManager compMgr = (ServiceManager)getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER);
+ super.init();
+ ServiceManager compMgr = (ServiceManager) getMailetContext()
+ .getAttribute(Constants.AVALON_COMPONENT_MANAGER);
try {
// Instantiate the a MailRepository for outgoing mails
mailServer = (MailServer) compMgr.lookup(MailServer.ROLE);
} catch (ServiceException cnfe) {
+ log("Failed to retrieve MailServer component:" + cnfe.getMessage());
+ } catch (Exception e) {
+ log("Failed to retrieve MailServer component:" + e.getMessage());
+ }
+
+ try {
+ // Instantiate the a MailRepository for outgoing mails
+ store = (Store) compMgr.lookup(Store.ROLE);
+ } catch (ServiceException cnfe) {
log("Failed to retrieve Store component:" + cnfe.getMessage());
} catch (Exception e) {
log("Failed to retrieve Store component:" + e.getMessage());
}
-
+
+ repositoryUrl = getInitParameter("repositoryUrl");
+ if (repositoryUrl != null) {
+ repositoryType = getInitParameter("repositoryType");
+ if (repositoryType == null)
+ repositoryType = "MAIL";
+ }
+
+ deliveryHeader = getInitParameter("addDeliveryHeader");
+ String resetReturnPathString = getInitParameter("resetReturnPath");
+ resetReturnPath = "true".equalsIgnoreCase(resetReturnPathString);
+ }
+
+ /**
+ * Get the user inbox: if the repositoryUrl is null then get the userinbox
+ * from the mailserver, otherwise lookup the store with the given
+ * repositoryurl/type
+ *
+ * @param userName
+ * @return
+ */
+ private MailRepository getRepository(String userName) {
+ MailRepository userInbox;
+ if (repositoryUrl == null) {
+ userInbox = mailServer.getUserInbox(userName);
+ } else {
+ StringBuffer destinationBuffer = new StringBuffer(192).append(
+ repositoryUrl).append(userName).append("/");
+ String destination = destinationBuffer.toString();
+ DefaultConfiguration mboxConf = new DefaultConfiguration(
+ "repository", "generated:ToMultiRepository.getUserInbox()");
+ mboxConf.setAttribute("destinationURL", destination);
+ mboxConf.setAttribute("type", repositoryType);
+ try {
+ userInbox = (MailRepository) store.select(mboxConf);
+ } catch (Exception e) {
+ log("Cannot open repository " + e);
+ userInbox = null;
+ }
+ }
+ return userInbox;
}
}
Modified: james/server/trunk/src/java/org/apache/james/transport/mailets/UsersRepositoryAliasingForwarding.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/transport/mailets/UsersRepositoryAliasingForwarding.java?rev=359857&r1=359856&r2=359857&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/transport/mailets/UsersRepositoryAliasingForwarding.java (original)
+++ james/server/trunk/src/java/org/apache/james/transport/mailets/UsersRepositoryAliasingForwarding.java Thu Dec 29 09:48:39 2005
@@ -39,18 +39,28 @@
import java.util.Vector;
/**
- * Receives a Mail from JamesSpoolManager and takes care of delivery
- * of the message to local inboxes.
- *
+ * Receives a Mail from JamesSpoolManager and takes care of delivery of the
+ * message to local inboxes.
+ *
+ * Available configurations are:
+ *
+ * <enableAliases>true</enableAliases>: specify wether the user aliases should
+ * be looked up or not. Default is false.
+ *
+ * <enableForwarding>true</enableForwarding>: enable the forwarding. Default to
+ * false.
+ *
+ * <usersRepository>LocalAdmins</usersRepository>: specific users repository
+ * name. Default to empty. If empty does lookup the default userRepository.
*/
public class UsersRepositoryAliasingForwarding extends GenericMailet {
-
+
/**
- * The user repository for this mail server. Contains all the users with inboxes
- * on this server.
+ * The user repository for this mail server. Contains all the users with
+ * inboxes on this server.
*/
private UsersRepository usersRepository;
-
+
/**
* Whether to enable aliasing for users on this server
*/
@@ -66,17 +76,14 @@
*/
private boolean ignoreCase;
- /**
- * The name of the repository.
- */
- private String repositoryName;
-
/**
* Delivers a mail to a local mailbox.
- *
- * @param mail the mail being processed
- *
- * @throws MessagingException if an error occurs while storing the mail
+ *
+ * @param mail
+ * the mail being processed
+ *
+ * @throws MessagingException
+ * if an error occurs while storing the mail
*/
public void service(Mail mail) throws MessagingException {
Collection recipients = mail.getRecipients();
@@ -84,23 +91,32 @@
MimeMessage message = mail.getMessage();
- // Set Return-Path and remove all other Return-Path headers from the message
- // This only works because there is a placeholder inserted by MimeMessageWrapper
- message.setHeader(RFC2822Headers.RETURN_PATH, (mail.getSender() == null ? "<>" : "<" + mail.getSender() + ">"));
+ // Set Return-Path and remove all other Return-Path headers from the
+ // message
+ // This only works because there is a placeholder inserted by
+ // MimeMessageWrapper
+ message
+ .setHeader(RFC2822Headers.RETURN_PATH,
+ (mail.getSender() == null ? "<>" : "<"
+ + mail.getSender() + ">"));
Collection newRecipients = new LinkedList();
- for (Iterator i = recipients.iterator(); i.hasNext(); ) {
+ for (Iterator i = recipients.iterator(); i.hasNext();) {
MailAddress recipient = (MailAddress) i.next();
try {
- String username = processMail(mail.getSender(), recipient, message);
-
- // if the username is null or changed we remove it from the remaining recipients
+ String username = processMail(mail.getSender(), recipient,
+ message);
+
+ // if the username is null or changed we remove it from the
+ // remaining recipients
if (username == null) {
i.remove();
} else if (username.equals(recipient.getUser())) {
i.remove();
- // if the username has been changed we add a new recipient with the new name.
- newRecipients.add(new MailAddress(username,recipient.getHost()));
+ // if the username has been changed we add a new recipient
+ // with the new name.
+ newRecipients.add(new MailAddress(username, recipient
+ .getHost()));
}
} catch (Exception ex) {
@@ -108,64 +124,65 @@
errors.add(recipient);
}
}
-
- if (newRecipients.size()>0) {
+
+ if (newRecipients.size() > 0) {
recipients.addAll(newRecipients);
}
if (!errors.isEmpty()) {
- // If there were errors, we redirect the email to the ERROR processor.
- // In order for this server to meet the requirements of the SMTP specification,
- // mails on the ERROR processor must be returned to the sender. Note that this
- // email doesn't include any details regarding the details of the failure(s).
+ // If there were errors, we redirect the email to the ERROR
+ // processor.
+ // In order for this server to meet the requirements of the SMTP
+ // specification, mails on the ERROR processor must be returned to
+ // the sender. Note that this email doesn't include any details
+ // regarding the details of the failure(s).
// In the future we may wish to address this.
- getMailetContext().sendMail(mail.getSender(),
- errors, message, Mail.ERROR);
+ getMailetContext().sendMail(mail.getSender(), errors, message,
+ Mail.ERROR);
}
-
- if (recipients.size()==0) {
- //We always consume this message
+
+ if (recipients.size() == 0) {
+ // We always consume this message
mail.setState(Mail.GHOST);
}
}
/**
* Return a string describing this mailet.
- *
+ *
* @return a string describing this mailet
*/
public String getMailetInfo() {
return "Local User Aliasing and Forwarding Mailet";
}
-
/**
- * Return null when the mail should be GHOSTed, the username string when it should be
- * changed due to the ignoreUser configuration.
+ * Return null when the mail should be GHOSTed, the username string when it
+ * should be changed due to the ignoreUser configuration.
*
* @param sender
* @param recipient
* @param message
* @throws MessagingException
*/
- public String processMail(MailAddress sender, MailAddress recipient, MimeMessage message)
- throws MessagingException {
+ public String processMail(MailAddress sender, MailAddress recipient,
+ MimeMessage message) throws MessagingException {
String username;
if (recipient == null) {
- throw new IllegalArgumentException("Recipient for mail to be spooled cannot be null.");
+ throw new IllegalArgumentException(
+ "Recipient for mail to be spooled cannot be null.");
}
if (message == null) {
- throw new IllegalArgumentException("Mail message to be spooled cannot be null.");
+ throw new IllegalArgumentException(
+ "Mail message to be spooled cannot be null.");
}
if (ignoreCase) {
String originalUsername = recipient.getUser();
username = usersRepository.getRealName(originalUsername);
if (username == null) {
- StringBuffer errorBuffer =
- new StringBuffer(128)
- .append("The inbox for user ")
- .append(originalUsername)
- .append(" was not found on this server.");
+ StringBuffer errorBuffer = new StringBuffer(128).append(
+ "The inbox for user ").append(originalUsername).append(
+ " was not found on this server.");
throw new MessagingException(errorBuffer.toString());
}
} else {
@@ -181,31 +198,27 @@
if (enableForwarding && user.getForwarding()) {
MailAddress forwardTo = user.getForwardingDestination();
if (forwardTo == null) {
- StringBuffer errorBuffer =
- new StringBuffer(128)
+ StringBuffer errorBuffer = new StringBuffer(128)
.append("Forwarding was enabled for ")
.append(username)
- .append(" but no forwarding address was set for this account.");
+ .append(
+ " but no forwarding address was set for this account.");
throw new MessagingException(errorBuffer.toString());
}
Collection recipients = new HashSet();
recipients.add(forwardTo);
try {
getMailetContext().sendMail(sender, recipients, message);
- StringBuffer logBuffer =
- new StringBuffer(128)
- .append("Mail for ")
- .append(username)
- .append(" forwarded to ")
- .append(forwardTo.toString());
+ StringBuffer logBuffer = new StringBuffer(128).append(
+ "Mail for ").append(username).append(
+ " forwarded to ").append(forwardTo.toString());
getMailetContext().log(logBuffer.toString());
return null;
} catch (MessagingException me) {
- StringBuffer logBuffer =
- new StringBuffer(128)
- .append("Error forwarding mail to ")
- .append(forwardTo.toString())
- .append("attempting local delivery");
+ StringBuffer logBuffer = new StringBuffer(128).append(
+ "Error forwarding mail to ").append(
+ forwardTo.toString()).append(
+ "attempting local delivery");
getMailetContext().log(logBuffer.toString());
throw me;
}
@@ -213,48 +226,51 @@
}
return username;
}
-
/**
* @see org.apache.mailet.GenericMailet#init()
*/
public void init() throws MessagingException {
- super.init();
- ServiceManager compMgr = (ServiceManager)getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER);
+ super.init();
+ ServiceManager compMgr = (ServiceManager) getMailetContext()
+ .getAttribute(Constants.AVALON_COMPONENT_MANAGER);
UsersStore usersStore;
try {
usersStore = (UsersStore) compMgr.lookup(UsersStore.ROLE);
- usersRepository = usersStore.getRepository(repositoryName);
String enAliases = getInitParameter("enableAliases");
String enForward = getInitParameter("enableForwarding");
String userRep = getInitParameter("usersRepository");
-
- if (enAliases == null || enAliases.length()==0) {
+
+ if (enAliases == null || enAliases.length() == 0) {
enableAliases = false;
- } else enableAliases = new Boolean(enAliases).booleanValue();
-
- if (enForward == null || enForward.length()==0) {
+ } else
+ enableAliases = new Boolean(enAliases).booleanValue();
+
+ if (enForward == null || enForward.length() == 0) {
enableForwarding = false;
- } else enableForwarding = new Boolean(enForward).booleanValue();
-
- if (userRep == null || userRep.length()==0) {
+ } else
+ enableForwarding = new Boolean(enForward).booleanValue();
+
+ if (userRep == null || userRep.length() == 0) {
try {
- usersRepository = (UsersRepository) compMgr.lookup(UsersRepository.ROLE);
- } catch (ServiceException e) {
- log("Failed to retrieve UsersRepository component:" + e.getMessage());
- }
+ usersRepository = (UsersRepository) compMgr
+ .lookup(UsersRepository.ROLE);
+ } catch (ServiceException e) {
+ log("Failed to retrieve UsersRepository component:"
+ + e.getMessage());
+ }
} else {
usersRepository = usersStore.getRepository(userRep);
}
-
- ignoreCase = ((Boolean) getMailetContext().getAttribute(Constants.DEFAULT_IGNORE_USERNAME_CASE)).booleanValue();
+
+ ignoreCase = ((Boolean) getMailetContext().getAttribute(
+ Constants.DEFAULT_IGNORE_USERNAME_CASE)).booleanValue();
} catch (ServiceException cnfe) {
- log("Failed to retrieve UsersStore component:" + cnfe.getMessage());
- }
+ log("Failed to retrieve UsersStore component:" + cnfe.getMessage());
+ }
-
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org