Author: norman
Date: Thu Feb 17 06:14:43 2011
New Revision: 1071508
URL: http://svn.apache.org/viewvc?rev=1071508&view=rev
Log:
Use the right username to lookup Mailbox depending on useVirtualHosting
setting. See JAMES-1197
Modified:
james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/AbstractStorageQuota.java
Modified:
james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/AbstractStorageQuota.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/AbstractStorageQuota.java?rev=1071508&r1=1071507&r2=1071508&view=diff
==============================================================================
---
james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/AbstractStorageQuota.java
(original)
+++
james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/AbstractStorageQuota.java
Thu Feb 17 06:14:43 2011
@@ -22,6 +22,7 @@
package org.apache.james.transport.matchers;
import java.util.Iterator;
+import java.util.Locale;
import javax.annotation.Resource;
import javax.mail.MessagingException;
@@ -38,7 +39,7 @@ import org.apache.james.mailbox.MessageR
import org.apache.james.mailbox.MessageResult.FetchGroup;
import org.apache.james.mailbox.util.FetchGroupImpl;
import org.apache.james.user.api.UsersRepository;
-import org.apache.james.user.api.model.JamesUser;
+import org.apache.james.user.api.UsersRepositoryException;
import org.apache.james.transport.util.MailetContextLog;
import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;
@@ -107,7 +108,19 @@ abstract public class AbstractStorageQuo
long size = 0;
MailboxSession session;
try {
- session =
manager.createSystemSession(getPrimaryName(recipient.getLocalPart()),log);
+ String username;
+ try {
+ // see if we need use the full email address as username or
not.
+ // See JAMES-1197
+ if (localusers.supportVirtualHosting()) {
+ username = recipient.toString().toLowerCase(Locale.US);
+ } else {
+ username = recipient.getLocalPart().toLowerCase(Locale.US);
+ }
+ } catch (UsersRepositoryException e) {
+ throw new MessagingException("Unable to access
UsersRepository", e);
+ }
+ session = manager.createSystemSession(username,log);
manager.startProcessingRequest(session);
MessageManager mailbox = manager.getMailbox(new
MailboxPath(MailboxConstants.USER_NAMESPACE,
session.getUser().getUserName(), "INBOX"),
@@ -129,25 +142,5 @@ abstract public class AbstractStorageQuo
}
- /**
- * Gets the main name of a local customer, handling aliases.
- *
- * @param originalUsername the user name to look for; it can be already
the primary name or an alias
- * @return the primary name, or originalUsername unchanged if not found
- */
- protected String getPrimaryName(String originalUsername) {
- String username;
- try {
- username = originalUsername;
- JamesUser user = (JamesUser) localusers.getUserByName(username);
- if (user.getAliasing()) {
- username = user.getAlias();
- }
- }
- catch (Exception e) {
- username = originalUsername;
- }
- return username;
- }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]