james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r965271 - in /james/server/trunk: mailets/src/main/java/org/apache/james/transport/matchers/ pop3server/src/main/java/org/apache/james/pop3server/core/ pop3server/src/test/java/org/apache/james/pop3server/ spoolmanager/src/main/java/org/apa...
Date Sun, 18 Jul 2010 18:19:54 GMT
Author: norman
Date: Sun Jul 18 18:19:54 2010
New Revision: 965271

URL: http://svn.apache.org/viewvc?rev=965271&view=rev
Log:
Introduce a MailboxPath to better handle the identification of a mailbox. This will allow
us to have different namespaces later. The code is based on a patch of Tim Christian Mundt
(thx). See IMAP-168

Modified:
    james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/AbstractStorageQuota.java
    james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/core/PassCmdHandler.java
    james/server/trunk/pop3server/src/test/java/org/apache/james/pop3server/AbstractAsyncPOP3ServerTest.java
    james/server/trunk/spoolmanager/src/main/java/org/apache/james/MailboxManagerPoster.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=965271&r1=965270&r2=965271&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
Sun Jul 18 18:19:54 2010
@@ -29,6 +29,7 @@ import javax.mail.MessagingException;
 import org.apache.commons.logging.Log;
 import org.apache.james.api.user.JamesUser;
 import org.apache.james.api.user.UsersRepository;
+import org.apache.james.imap.api.MailboxPath;
 import org.apache.james.imap.mailbox.Mailbox;
 import org.apache.james.imap.mailbox.MailboxConstants;
 import org.apache.james.imap.mailbox.MailboxManager;
@@ -170,7 +171,9 @@ abstract public class AbstractStorageQuo
         	
         });
         manager.startProcessingRequest(session);
-        Mailbox mailbox = manager.getMailbox(MailboxConstants.USER_NAMESPACE + manager.getDelimiter()
+ "INBOX", session);
+        Mailbox mailbox = manager.getMailbox(new MailboxPath(MailboxConstants.USER_NAMESPACE,
+                                            session.getUser().getUserName(), "INBOX"),
+                                            session);
         Iterator<MessageResult> results = mailbox.getMessages(MessageRange.all(), new
FetchGroupImpl(FetchGroup.MINIMAL), session);
         
         while (results.hasNext()) {

Modified: james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/core/PassCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/core/PassCmdHandler.java?rev=965271&r1=965270&r2=965271&view=diff
==============================================================================
--- james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/core/PassCmdHandler.java
(original)
+++ james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/core/PassCmdHandler.java
Sun Jul 18 18:19:54 2010
@@ -25,6 +25,7 @@ import java.util.List;
 
 import javax.annotation.Resource;
 
+import org.apache.james.imap.api.MailboxPath;
 import org.apache.james.imap.mailbox.BadCredentialsException;
 import org.apache.james.imap.mailbox.Mailbox;
 import org.apache.james.imap.mailbox.MailboxConstants;
@@ -62,20 +63,13 @@ public class PassCmdHandler extends Rset
             String passArg = parameters;
             try {
                 MailboxSession mSession = mailboxManager.login(session.getUser(), passArg,
session.getLogger());
-                StringBuffer sb = new StringBuffer();
-                sb.append(MailboxConstants.USER_NAMESPACE);
-                sb.append(mailboxManager.getDelimiter());
-                sb.append(session.getUser());
-                sb.append(mailboxManager.getDelimiter());
-                sb.append("INBOX");
-                ;
-                String mailboxName = sb.toString();
-
+                MailboxPath mailboxPath = new MailboxPath(MailboxConstants.USER_NAMESPACE,
session.getUser(), "INBOX");
+                
                 // check if mailbox exists.. if not just create it
-                if (mailboxManager.mailboxExists(mailboxName, mSession) == false) {
-                    mailboxManager.createMailbox(mailboxName, mSession);
+                if (mailboxManager.mailboxExists(mailboxPath, mSession) == false) {
+                    mailboxManager.createMailbox(mailboxPath, mSession);
                 }
-                Mailbox mailbox = mailboxManager.getMailbox(mailboxName, mSession);
+                Mailbox mailbox = mailboxManager.getMailbox(mailboxPath, mSession);
 
                 session.getState().put(POP3Session.MAILBOX_SESSION, mSession);
                 session.setUserMailbox(mailbox);

Modified: james/server/trunk/pop3server/src/test/java/org/apache/james/pop3server/AbstractAsyncPOP3ServerTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/pop3server/src/test/java/org/apache/james/pop3server/AbstractAsyncPOP3ServerTest.java?rev=965271&r1=965270&r2=965271&view=diff
==============================================================================
--- james/server/trunk/pop3server/src/test/java/org/apache/james/pop3server/AbstractAsyncPOP3ServerTest.java
(original)
+++ james/server/trunk/pop3server/src/test/java/org/apache/james/pop3server/AbstractAsyncPOP3ServerTest.java
Sun Jul 18 18:19:54 2010
@@ -40,10 +40,12 @@ import org.apache.james.api.dnsservice.A
 import org.apache.james.api.dnsservice.DNSService;
 import org.apache.james.services.FakeLoader;
 import org.apache.james.api.user.UsersRepository;
+import org.apache.james.imap.api.MailboxPath;
 import org.apache.james.imap.inmemory.InMemoryMailboxManager;
 import org.apache.james.imap.inmemory.InMemoryMailboxSessionMapperFactory;
 import org.apache.james.imap.inmemory.InMemorySubscriptionManager;
 import org.apache.james.imap.mailbox.Mailbox;
+import org.apache.james.imap.mailbox.MailboxConstants;
 import org.apache.james.imap.mailbox.MailboxSession;
 import org.apache.james.imap.store.Authenticator;
 import org.apache.james.lifecycle.LifecycleUtil;
@@ -251,12 +253,12 @@ public abstract class AbstractAsyncPOP3S
         assertEquals("Found unexpected messages", 0, list.length);
 
         m_pop3Protocol.disconnect();
-        String mailboxName = "#private.foo.INBOX";
+        MailboxPath mailboxPath = new MailboxPath(MailboxConstants.USER_NAMESPACE, "foo",
"INBOX");
         MailboxSession session = manager.login("foo", "bar", new SimpleLog("Test"));
-        if (manager.mailboxExists(mailboxName, session) == false) {
-            manager.createMailbox(mailboxName, session);
+        if (manager.mailboxExists(mailboxPath, session) == false) {
+            manager.createMailbox(mailboxPath, session);
         }
-        setupTestMails(session,manager.getMailbox(mailboxName, session));
+        setupTestMails(session,manager.getMailbox(mailboxPath, session));
         
         m_pop3Protocol.connect("127.0.0.1",m_pop3ListenerPort);
         m_pop3Protocol.login("foo", "bar");
@@ -267,7 +269,7 @@ public abstract class AbstractAsyncPOP3S
         POP3MessageInfo p3i = m_pop3Protocol.listUniqueIdentifier(1);
         assertNotNull(p3i);
         
-        manager.deleteMailbox("#private.foo.INBOX", session);
+        manager.deleteMailbox(mailboxPath, session);
 
 
     }
@@ -332,15 +334,15 @@ public abstract class AbstractAsyncPOP3S
         m_pop3Protocol.connect("127.0.0.1",m_pop3ListenerPort);
 
         m_usersRepository.addUser("foo2", "bar2");
-        
-        String mailboxName = "#private.foo2.INBOX";
+
+        MailboxPath mailboxPath = new MailboxPath(MailboxConstants.USER_NAMESPACE, "foo2",
"INBOX");
         MailboxSession session = manager.login("foo2", "bar2", new SimpleLog("Test"));
         
-        if (manager.mailboxExists(mailboxName, session) == false) {
-            manager.createMailbox(mailboxName, session);
+        if (manager.mailboxExists(mailboxPath, session) == false) {
+            manager.createMailbox(mailboxPath, session);
         }
         
-        setupTestMails(session,manager.getMailbox(mailboxName, session));
+        setupTestMails(session,manager.getMailbox(mailboxPath, session));
         
         m_pop3Protocol.sendCommand("retr","1");
         assertEquals(0, m_pop3Protocol.getState());
@@ -406,7 +408,7 @@ public abstract class AbstractAsyncPOP3S
         Reader r3 = m_pop3Protocol.retrieveMessageTop(entries[0].number, 0);
         assertNotNull(r3);
         r3.close();
-        manager.deleteMailbox(mailboxName, session);
+        manager.deleteMailbox(mailboxPath, session);
     }
 
     private void setupTestMails(MailboxSession session, Mailbox mailbox) throws MessagingException
{

Modified: james/server/trunk/spoolmanager/src/main/java/org/apache/james/MailboxManagerPoster.java
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager/src/main/java/org/apache/james/MailboxManagerPoster.java?rev=965271&r1=965270&r2=965271&view=diff
==============================================================================
--- james/server/trunk/spoolmanager/src/main/java/org/apache/james/MailboxManagerPoster.java
(original)
+++ james/server/trunk/spoolmanager/src/main/java/org/apache/james/MailboxManagerPoster.java
Sun Jul 18 18:19:54 2010
@@ -31,6 +31,7 @@ import javax.mail.MessagingException;
 import javax.mail.internet.MimeMessage;
 
 import org.apache.commons.logging.Log;
+import org.apache.james.imap.api.MailboxPath;
 import org.apache.james.imap.mailbox.Mailbox;
 import org.apache.james.imap.mailbox.MailboxConstants;
 import org.apache.james.imap.mailbox.MailboxManager;
@@ -64,7 +65,7 @@ public class MailboxManagerPoster implem
     /**
      * @see org.apache.jsieve.mailet.Poster#post(java.lang.String, javax.mail.internet.MimeMessage)
      */
-    public void post(String url, MimeMessage mail)throws MessagingException {
+    public void post(String url, MimeMessage mail) throws MessagingException {
         final int endOfScheme = url.indexOf(':');
         if (endOfScheme < 0) {
             throw new MessagingException("Malformed URI");
@@ -110,13 +111,15 @@ public class MailboxManagerPoster implem
                         if (destination == null || "".equals(destination)) {
                             destination = "INBOX";
                         }
-                        final String name = mailboxManager.resolve(user, destination);
+                        if (destination.startsWith(MailboxConstants.DEFAULT_DELIMITER_STRING))
+                            destination = destination.substring(1);
+                        final MailboxPath path = new MailboxPath(MailboxConstants.USER_NAMESPACE,
user, destination);
                         try
                         {
-                            if ("INBOX".equalsIgnoreCase(destination) && !(mailboxManager.mailboxExists(name,
session))) {
-                                mailboxManager.createMailbox(name, session);
+                            if ("INBOX".equalsIgnoreCase(destination) && !(mailboxManager.mailboxExists(path,
session))) {
+                                mailboxManager.createMailbox(path, session);
                             }
-                            final Mailbox mailbox = mailboxManager.getMailbox(name, session);
+                            final Mailbox mailbox = mailboxManager.getMailbox(path, session);
                             
                             if (mailbox == null) {
                                 final String error = "Mailbox for user " + user



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message