james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r965270 [2/4] - in /james/imap/trunk: ./ api/src/main/java/org/apache/james/imap/api/ api/src/main/java/org/apache/james/imap/api/process/ deployment/src/test/java/org/apache/james/imap/functional/ jcr/src/main/java/org/apache/james/imap/jc...
Date Sun, 18 Jul 2010 18:18:10 GMT
Modified: james/imap/trunk/mailbox/src/test/java/org/apache/james/imap/mailbox/MailboxExpressionTest.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/mailbox/src/test/java/org/apache/james/imap/mailbox/MailboxExpressionTest.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/mailbox/src/test/java/org/apache/james/imap/mailbox/MailboxExpressionTest.java (original)
+++ james/imap/trunk/mailbox/src/test/java/org/apache/james/imap/mailbox/MailboxExpressionTest.java Sun Jul 18 18:18:08 2010
@@ -21,6 +21,7 @@ package org.apache.james.imap.mailbox;
 
 import static org.junit.Assert.*;
 
+import org.apache.james.imap.api.MailboxPath;
 import org.junit.Test;
 
 public class MailboxExpressionTest {
@@ -30,10 +31,11 @@ public class MailboxExpressionTest {
     private static final String SECOND_PART = "sub";
 
     private static final String BASE = "BASE";
+    private static final MailboxPath BASE_PATH = new MailboxPath(null, null, BASE);
 
 
     private MailboxQuery create(String expression) {
-        return new MailboxQuery(BASE, expression, '*', '%');
+        return new MailboxQuery(BASE_PATH, expression, '*', '%');
     }
 
     @Test
@@ -53,204 +55,178 @@ public class MailboxExpressionTest {
 
     @Test
     public void testCombinedNameEmptyPart() throws Exception {
-        MailboxQuery expression = new MailboxQuery(BASE, "", '*', '%');
-        assertEquals(BASE, expression.getCombinedName('.'));
-
+        MailboxQuery expression = new MailboxQuery(BASE_PATH, "", '*', '%');
+        assertEquals(BASE, expression.getCombinedName());
     }
 
     @Test
     public void testNullCombinedName() throws Exception {
-        MailboxQuery expression = new MailboxQuery(null, null, '*',
-                '%');
-        assertNotNull(expression.getCombinedName('.'));
-
+        MailboxQuery expression = new MailboxQuery(new MailboxPath(null, null, null), null, '*', '%');
+        assertNotNull(expression.getCombinedName());
     }
 
     @Test
     public void testSimpleCombinedName() throws Exception {
         MailboxQuery expression = create(PART);
-        assertEquals(BASE + "." + PART, expression.getCombinedName('.'));
-        assertEquals(BASE + "/" + PART, expression.getCombinedName('/'));
+        assertEquals(BASE + "." + PART, expression.getCombinedName());
     }
 
     @Test
     public void testCombinedNamePartStartsWithDelimiter() throws Exception {
         MailboxQuery expression = create("." + PART);
-        assertEquals(BASE + "." + PART, expression.getCombinedName('.'));
-        assertEquals(BASE + "/." + PART, expression.getCombinedName('/'));
+        assertEquals(BASE + "." + PART, expression.getCombinedName());
     }
 
     @Test
     public void testCombinedNameBaseEndsWithDelimiter() throws Exception {
-        MailboxQuery expression = new MailboxQuery(BASE + '.', PART,
-                '*', '%');
-        assertEquals(BASE + "." + PART, expression.getCombinedName('.'));
-        assertEquals(BASE + "./" + PART, expression.getCombinedName('/'));
+        MailboxQuery expression = new MailboxQuery(new MailboxPath(null, null, BASE + '.'), PART, '*', '%');
+        assertEquals(BASE + "." + PART, expression.getCombinedName());
     }
 
     @Test
     public void testCombinedNameBaseEndsWithDelimiterPartStarts()
             throws Exception {
-        MailboxQuery expression = new MailboxQuery(BASE + '.',
-                '.' + PART, '*', '%');
-        assertEquals(BASE + "." + PART, expression.getCombinedName('.'));
-        assertEquals(BASE + "./." + PART, expression.getCombinedName('/'));
+        MailboxQuery expression = new MailboxQuery(new MailboxPath(null, null, BASE + '.'), '.' + PART, '*', '%');
+        assertEquals(BASE + "." + PART, expression.getCombinedName());
     }
 
     @Test
     public void testSimpleExpression() throws Exception {
         MailboxQuery expression = create(PART);
-        assertTrue(expression.isExpressionMatch(PART, '.'));
-        assertTrue(expression.isExpressionMatch(PART, '/'));
-        assertFalse(expression.isExpressionMatch('.' + PART, '.'));
-        assertFalse(expression.isExpressionMatch(PART + '.', '.'));
-        assertFalse(expression.isExpressionMatch(SECOND_PART, '.'));
+        assertTrue(expression.isExpressionMatch(PART));
+        assertFalse(expression.isExpressionMatch('.' + PART));
+        assertFalse(expression.isExpressionMatch(PART + '.'));
+        assertFalse(expression.isExpressionMatch(SECOND_PART));
     }
 
     @Test
     public void testEmptyExpression() throws Exception {
         MailboxQuery expression = create("");
-        assertTrue(expression.isExpressionMatch("", '.'));
-        assertTrue(expression.isExpressionMatch("", '/'));
-        assertFalse(expression.isExpressionMatch("whatever", '.'));
-        assertFalse(expression.isExpressionMatch(BASE + '.' + "whatever", '.'));
-        assertFalse(expression.isExpressionMatch(BASE + "whatever", '.'));
+        assertTrue(expression.isExpressionMatch(""));
+        assertFalse(expression.isExpressionMatch("whatever"));
+        assertFalse(expression.isExpressionMatch(BASE + '.' + "whatever"));
+        assertFalse(expression.isExpressionMatch(BASE + "whatever"));
     }
 
     @Test
     public void testOnlyLocalWildcard() throws Exception {
         MailboxQuery expression = create("%");
-        assertTrue(expression.isExpressionMatch("", '.'));
-        assertTrue(expression.isExpressionMatch(SECOND_PART, '.'));
-        assertTrue(expression.isExpressionMatch(PART, '.'));
-        assertTrue(expression.isExpressionMatch(PART + SECOND_PART, '.'));
-        assertFalse(expression.isExpressionMatch(PART + '.' + SECOND_PART, '.'));
-        assertTrue(expression.isExpressionMatch(PART + '/' + SECOND_PART, '.'));
+        assertTrue(expression.isExpressionMatch(""));
+        assertTrue(expression.isExpressionMatch(SECOND_PART));
+        assertTrue(expression.isExpressionMatch(PART));
+        assertTrue(expression.isExpressionMatch(PART + SECOND_PART));
+        assertFalse(expression.isExpressionMatch(PART + '.' + SECOND_PART));
     }
 
     @Test
     public void testOnlyFreeWildcard() throws Exception {
         MailboxQuery expression = create("*");
-        assertTrue(expression.isExpressionMatch("", '.'));
-        assertTrue(expression.isExpressionMatch(SECOND_PART, '.'));
-        assertTrue(expression.isExpressionMatch(PART, '.'));
-        assertTrue(expression.isExpressionMatch(PART + SECOND_PART, '.'));
-        assertTrue(expression.isExpressionMatch(PART + '.' + SECOND_PART, '.'));
-        assertTrue(expression.isExpressionMatch(PART + '/' + SECOND_PART, '.'));
-        assertTrue(expression.isExpressionMatch(PART + '.' + SECOND_PART, '.'));
+        assertTrue(expression.isExpressionMatch(""));
+        assertTrue(expression.isExpressionMatch(SECOND_PART));
+        assertTrue(expression.isExpressionMatch(PART));
+        assertTrue(expression.isExpressionMatch(PART + SECOND_PART));
+        assertTrue(expression.isExpressionMatch(PART + '.' + SECOND_PART));
+        assertTrue(expression.isExpressionMatch(PART + '.' + SECOND_PART));
     }
 
     @Test
     public void testEndsWithLocalWildcard() throws Exception {
         MailboxQuery expression = create(PART + '%');
-        assertFalse(expression.isExpressionMatch("", '.'));
-        assertFalse(expression.isExpressionMatch(SECOND_PART, '.'));
-        assertTrue(expression.isExpressionMatch(PART, '.'));
-        assertTrue(expression.isExpressionMatch(PART + SECOND_PART, '.'));
-        assertFalse(expression.isExpressionMatch(PART + '.' + SECOND_PART, '.'));
-        assertTrue(expression.isExpressionMatch(PART + '/' + SECOND_PART, '.'));
-        assertFalse(expression.isExpressionMatch(PART + '.' + SECOND_PART, '.'));
+        assertFalse(expression.isExpressionMatch(""));
+        assertFalse(expression.isExpressionMatch(SECOND_PART));
+        assertTrue(expression.isExpressionMatch(PART));
+        assertTrue(expression.isExpressionMatch(PART + SECOND_PART));
+        assertFalse(expression.isExpressionMatch(PART + '.' + SECOND_PART));
+        assertFalse(expression.isExpressionMatch(PART + '.' + SECOND_PART));
     }
 
     @Test
     public void testStartsWithLocalWildcard() throws Exception {
         MailboxQuery expression = create('%' + PART);
-        assertFalse(expression.isExpressionMatch("", '.'));
-        assertFalse(expression.isExpressionMatch(SECOND_PART, '.'));
-        assertTrue(expression.isExpressionMatch(PART, '.'));
-        assertTrue(expression.isExpressionMatch(SECOND_PART + PART, '.'));
-        assertFalse(expression.isExpressionMatch(SECOND_PART + '.' + PART, '.'));
-        assertFalse(expression.isExpressionMatch(SECOND_PART + '.' + PART + '.'
-                + SECOND_PART, '.'));
-        assertFalse(expression.isExpressionMatch(SECOND_PART, '.'));
+        assertFalse(expression.isExpressionMatch(""));
+        assertFalse(expression.isExpressionMatch(SECOND_PART));
+        assertTrue(expression.isExpressionMatch(PART));
+        assertTrue(expression.isExpressionMatch(SECOND_PART + PART));
+        assertFalse(expression.isExpressionMatch(SECOND_PART + '.' + PART));
+        assertFalse(expression.isExpressionMatch(SECOND_PART + '.' + PART + '.' + SECOND_PART));
+        assertFalse(expression.isExpressionMatch(SECOND_PART));
     }
 
     @Test
     public void testContainsLocalWildcard() throws Exception {
         MailboxQuery expression = create(SECOND_PART + '%' + PART);
-        assertFalse(expression.isExpressionMatch("", '.'));
-        assertFalse(expression.isExpressionMatch(SECOND_PART, '.'));
-        assertTrue(expression.isExpressionMatch(SECOND_PART + PART, '.'));
-        assertFalse(expression.isExpressionMatch(SECOND_PART + '.' + PART, '.'));
-        assertTrue(expression.isExpressionMatch(SECOND_PART + '/' + PART, '.'));
-        assertFalse(expression.isExpressionMatch(PART, '.'));
-        assertFalse(expression.isExpressionMatch(SECOND_PART + "w.hat.eve.r"
-                + PART, '.'));
+        assertFalse(expression.isExpressionMatch(""));
+        assertFalse(expression.isExpressionMatch(SECOND_PART));
+        assertTrue(expression.isExpressionMatch(SECOND_PART + PART));
+        assertFalse(expression.isExpressionMatch(SECOND_PART + '.' + PART));
+        assertFalse(expression.isExpressionMatch(PART));
+        assertFalse(expression.isExpressionMatch(SECOND_PART + "w.hat.eve.r" + PART));
     }
 
     @Test
     public void testEndsWithFreeWildcard() throws Exception {
         MailboxQuery expression = create(PART + '*');
-        assertFalse(expression.isExpressionMatch("", '.'));
-        assertFalse(expression.isExpressionMatch(SECOND_PART, '.'));
-        assertTrue(expression.isExpressionMatch(PART, '.'));
-        assertTrue(expression.isExpressionMatch(PART + SECOND_PART, '.'));
-        assertTrue(expression.isExpressionMatch(PART + '.' + SECOND_PART, '.'));
-        assertTrue(expression.isExpressionMatch(PART + '/' + SECOND_PART, '.'));
-        assertTrue(expression.isExpressionMatch(PART + '.' + SECOND_PART, '.'));
+        assertFalse(expression.isExpressionMatch(""));
+        assertFalse(expression.isExpressionMatch(SECOND_PART));
+        assertTrue(expression.isExpressionMatch(PART));
+        assertTrue(expression.isExpressionMatch(PART + SECOND_PART));
+        assertTrue(expression.isExpressionMatch(PART + '.' + SECOND_PART));
+        assertTrue(expression.isExpressionMatch(PART + '.' + SECOND_PART));
     }
 
     @Test
     public void testStartsWithFreeWildcard() throws Exception {
         MailboxQuery expression = create('*' + PART);
-        assertFalse(expression.isExpressionMatch("", '.'));
-        assertFalse(expression.isExpressionMatch(SECOND_PART, '.'));
-        assertTrue(expression.isExpressionMatch(PART, '.'));
-        assertTrue(expression.isExpressionMatch(SECOND_PART + PART, '.'));
-        assertTrue(expression.isExpressionMatch(SECOND_PART + '.' + PART, '.'));
-        assertFalse(expression.isExpressionMatch(SECOND_PART, '.'));
+        assertFalse(expression.isExpressionMatch(""));
+        assertFalse(expression.isExpressionMatch(SECOND_PART));
+        assertTrue(expression.isExpressionMatch(PART));
+        assertTrue(expression.isExpressionMatch(SECOND_PART + PART));
+        assertTrue(expression.isExpressionMatch(SECOND_PART + '.' + PART));
+        assertFalse(expression.isExpressionMatch(SECOND_PART));
     }
 
     @Test
     public void testContainsFreeWildcard() throws Exception {
         MailboxQuery expression = create(SECOND_PART + '*' + PART);
-        assertFalse(expression.isExpressionMatch("", '.'));
-        assertFalse(expression.isExpressionMatch(SECOND_PART, '.'));
-        assertTrue(expression.isExpressionMatch(SECOND_PART + PART, '.'));
-        assertTrue(expression.isExpressionMatch(SECOND_PART + '.' + PART, '.'));
-        assertTrue(expression.isExpressionMatch(SECOND_PART + '/' + PART, '.'));
-        assertFalse(expression.isExpressionMatch(PART, '.'));
-        assertTrue(expression.isExpressionMatch(SECOND_PART + "w.hat.eve.r"
-                + PART, '.'));
+        assertFalse(expression.isExpressionMatch(""));
+        assertFalse(expression.isExpressionMatch(SECOND_PART));
+        assertTrue(expression.isExpressionMatch(SECOND_PART + PART));
+        assertTrue(expression.isExpressionMatch(SECOND_PART + '.' + PART));
+        assertFalse(expression.isExpressionMatch(PART));
+        assertTrue(expression.isExpressionMatch(SECOND_PART + "w.hat.eve.r" + PART));
     }
 
     @Test
     public void testDoubleFreeWildcard() throws Exception {
         MailboxQuery expression = create(SECOND_PART + "**" + PART);
-        assertFalse(expression.isExpressionMatch("", '.'));
-        assertFalse(expression.isExpressionMatch(SECOND_PART, '.'));
-        assertTrue(expression.isExpressionMatch(SECOND_PART + PART, '.'));
-        assertTrue(expression.isExpressionMatch(SECOND_PART + '.' + PART, '.'));
-        assertTrue(expression.isExpressionMatch(SECOND_PART + '/' + PART, '.'));
-        assertFalse(expression.isExpressionMatch(PART, '.'));
-        assertTrue(expression.isExpressionMatch(SECOND_PART + "w.hat.eve.r"
-                + PART, '.'));
+        assertFalse(expression.isExpressionMatch(""));
+        assertFalse(expression.isExpressionMatch(SECOND_PART));
+        assertTrue(expression.isExpressionMatch(SECOND_PART + PART));
+        assertTrue(expression.isExpressionMatch(SECOND_PART + '.' + PART));
+        assertFalse(expression.isExpressionMatch(PART));
+        assertTrue(expression.isExpressionMatch(SECOND_PART + "w.hat.eve.r" + PART));
     }
 
     @Test
     public void testFreeLocalWildcard() throws Exception {
         MailboxQuery expression = create(SECOND_PART + "*%" + PART);
-        assertFalse(expression.isExpressionMatch("", '.'));
-        assertFalse(expression.isExpressionMatch(SECOND_PART, '.'));
-        assertTrue(expression.isExpressionMatch(SECOND_PART + PART, '.'));
-        assertTrue(expression.isExpressionMatch(SECOND_PART + '.' + PART, '.'));
-        assertTrue(expression.isExpressionMatch(SECOND_PART + '/' + PART, '.'));
-        assertFalse(expression.isExpressionMatch(PART, '.'));
-        assertTrue(expression.isExpressionMatch(SECOND_PART + "w.hat.eve.r"
-                + PART, '.'));
+        assertFalse(expression.isExpressionMatch(""));
+        assertFalse(expression.isExpressionMatch(SECOND_PART));
+        assertTrue(expression.isExpressionMatch(SECOND_PART + PART));
+        assertTrue(expression.isExpressionMatch(SECOND_PART + '.' + PART));
+        assertFalse(expression.isExpressionMatch(PART));
+        assertTrue(expression.isExpressionMatch(SECOND_PART + "w.hat.eve.r" + PART));
     }
 
     @Test
     public void testLocalFreeWildcard() throws Exception {
         MailboxQuery expression = create(SECOND_PART + "%*" + PART);
-        assertFalse(expression.isExpressionMatch("", '.'));
-        assertFalse(expression.isExpressionMatch(SECOND_PART, '.'));
-        assertTrue(expression.isExpressionMatch(SECOND_PART + PART, '.'));
-        assertTrue(expression.isExpressionMatch(SECOND_PART + '.' + PART, '.'));
-        assertTrue(expression.isExpressionMatch(SECOND_PART + '/' + PART, '.'));
-        assertFalse(expression.isExpressionMatch(PART, '.'));
-        assertTrue(expression.isExpressionMatch(SECOND_PART + "w.hat.eve.r"
-                + PART, '.'));
+        assertFalse(expression.isExpressionMatch(""));
+        assertFalse(expression.isExpressionMatch(SECOND_PART));
+        assertTrue(expression.isExpressionMatch(SECOND_PART + PART));
+        assertTrue(expression.isExpressionMatch(SECOND_PART + '.' + PART));
+        assertFalse(expression.isExpressionMatch(PART));
+        assertTrue(expression.isExpressionMatch(SECOND_PART + "w.hat.eve.r" + PART));
     }
 
     @Test
@@ -258,26 +234,26 @@ public class MailboxExpressionTest {
         MailboxQuery expression = create(SECOND_PART + '*' + PART + '*'
                 + SECOND_PART + "**");
         assertTrue(expression.isExpressionMatch(SECOND_PART + PART
-                + SECOND_PART, '.'));
+                + SECOND_PART));
         assertTrue(expression.isExpressionMatch(SECOND_PART + '.' + PART + '.'
-                + SECOND_PART, '.'));
+                + SECOND_PART));
         assertTrue(expression.isExpressionMatch(SECOND_PART + "tosh.bosh"
-                + PART + "tosh.bosh" + SECOND_PART + "boshtosh", '.'));
+                + PART + "tosh.bosh" + SECOND_PART + "boshtosh"));
         assertFalse(expression.isExpressionMatch(SECOND_PART + '.'
-                + PART.substring(1) + '.' + SECOND_PART, '.'));
+                + PART.substring(1) + '.' + SECOND_PART));
         assertTrue(expression.isExpressionMatch(SECOND_PART + '.'
                 + PART.substring(1) + '.' + SECOND_PART + PART + '.'
-                + SECOND_PART + "toshbosh", '.'));
+                + SECOND_PART + "toshbosh"));
         assertFalse(expression.isExpressionMatch(SECOND_PART + '.'
                 + PART.substring(1) + '.' + SECOND_PART + PART + '.'
-                + SECOND_PART.substring(1), '.'));
+                + SECOND_PART.substring(1)));
         assertTrue(expression.isExpressionMatch(SECOND_PART + "tosh.bosh"
                 + PART + "tosh.bosh" + PART + SECOND_PART + "boshtosh" + PART
-                + SECOND_PART, '.'));
+                + SECOND_PART));
         assertFalse(expression.isExpressionMatch(SECOND_PART.substring(1)
                 + "tosh.bosh" + PART + "tosh.bosh" + SECOND_PART
                 + PART.substring(1) + SECOND_PART + "boshtosh" + PART
-                + SECOND_PART.substring(1), '.'));
+                + SECOND_PART.substring(1)));
     }
 
     @Test
@@ -285,15 +261,15 @@ public class MailboxExpressionTest {
         MailboxQuery expression = create(SECOND_PART + '%' + PART + '*'
                 + SECOND_PART);
         assertTrue(expression.isExpressionMatch(SECOND_PART + PART
-                + SECOND_PART, '.'));
+                + SECOND_PART));
         assertFalse(expression.isExpressionMatch(SECOND_PART + '.' + PART
-                + SECOND_PART, '.'));
+                + SECOND_PART));
         assertTrue(expression.isExpressionMatch(SECOND_PART + PART + '.'
-                + SECOND_PART, '.'));
+                + SECOND_PART));
         assertTrue(expression.isExpressionMatch(SECOND_PART + PART
-                + SECOND_PART + "Whatever", '.'));
+                + SECOND_PART + "Whatever"));
         assertTrue(expression.isExpressionMatch(SECOND_PART + PART
-                + SECOND_PART + ".Whatever.", '.'));
+                + SECOND_PART + ".Whatever."));
     }
 
     @Test
@@ -301,28 +277,28 @@ public class MailboxExpressionTest {
         MailboxQuery expression = create(SECOND_PART + '*' + PART + '%'
                 + SECOND_PART);
         assertTrue(expression.isExpressionMatch(SECOND_PART + PART
-                + SECOND_PART, '.'));
+                + SECOND_PART));
         assertTrue(expression.isExpressionMatch(SECOND_PART + '.' + PART
-                + SECOND_PART, '.'));
+                + SECOND_PART));
         assertFalse(expression.isExpressionMatch(SECOND_PART + PART + '.'
-                + SECOND_PART, '.'));
+                + SECOND_PART));
         assertTrue(expression.isExpressionMatch(SECOND_PART + PART + "Whatever"
-                + SECOND_PART, '.'));
+                + SECOND_PART));
         assertFalse(expression.isExpressionMatch(SECOND_PART + PART
-                + SECOND_PART + ".Whatever.", '.'));
+                + SECOND_PART + ".Whatever."));
         assertTrue(expression.isExpressionMatch(SECOND_PART + '.' + PART
-                + SECOND_PART, '.'));
+                + SECOND_PART));
         assertFalse(expression.isExpressionMatch(SECOND_PART + '.' + PART
-                + SECOND_PART + '.' + SECOND_PART, '.'));
+                + SECOND_PART + '.' + SECOND_PART));
         assertTrue(expression.isExpressionMatch(SECOND_PART + '.' + PART + '.'
-                + SECOND_PART + PART + SECOND_PART, '.'));
+                + SECOND_PART + PART + SECOND_PART));
     }
     
     @Test
     public void testTwoLocalWildcardsShouldMatchMailboxs() throws Exception {
         MailboxQuery expression = create("%.%");
-        assertFalse(expression.isExpressionMatch(PART, '.'));
-        assertFalse(expression.isExpressionMatch(PART + '.' + SECOND_PART + '.' + SECOND_PART, '.'));
-        assertTrue(expression.isExpressionMatch(PART + '.' + SECOND_PART, '.'));
+        assertFalse(expression.isExpressionMatch(PART));
+        assertFalse(expression.isExpressionMatch(PART + '.' + SECOND_PART + '.' + SECOND_PART));
+        assertTrue(expression.isExpressionMatch(PART + '.' + SECOND_PART));
     }
 }

Modified: james/imap/trunk/mailbox/src/test/java/org/apache/james/imap/mailbox/util/MailboxEventDispatcherFlagsTest.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/mailbox/src/test/java/org/apache/james/imap/mailbox/util/MailboxEventDispatcherFlagsTest.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/mailbox/src/test/java/org/apache/james/imap/mailbox/util/MailboxEventDispatcherFlagsTest.java (original)
+++ james/imap/trunk/mailbox/src/test/java/org/apache/james/imap/mailbox/util/MailboxEventDispatcherFlagsTest.java Sun Jul 18 18:18:08 2010
@@ -25,6 +25,7 @@ import java.util.Iterator;
 
 import javax.mail.Flags;
 
+import org.apache.james.imap.api.MailboxPath;
 import org.apache.james.imap.mailbox.MailboxListener;
 import org.apache.james.imap.mailbox.MessageResult;
 import org.jmock.Expectations;
@@ -48,7 +49,7 @@ public class MailboxEventDispatcherFlags
 
     private Mockery mockery = new JUnit4Mockery();
 
-    private String name = "test";
+    private MailboxPath path = new MailboxPath(null, null, "test");
     @Before
     public void setUp() throws Exception {
         dispatcher = new MailboxEventDispatcher();
@@ -63,7 +64,7 @@ public class MailboxEventDispatcherFlags
    
     @Test
     public void testShouldReturnNoChangesWhenOriginalNull() throws Exception {
-        dispatcher.flagsUpdated(result.getUid(), sessionId, name, null, new Flags(
+        dispatcher.flagsUpdated(result.getUid(), sessionId, path, null, new Flags(
                 Flags.Flag.DELETED));
         assertEquals(1, collector.events.size());
         assertTrue(collector.events.get(0) instanceof MailboxListener.FlagsUpdated);
@@ -76,7 +77,7 @@ public class MailboxEventDispatcherFlags
 
     @Test
     public void testShouldReturnNoChangesWhenSystemFlagsUnchanged() {
-        dispatcher.flagsUpdated(result.getUid(), sessionId,name, new Flags(
+        dispatcher.flagsUpdated(result.getUid(), sessionId, path, new Flags(
                 Flags.Flag.DELETED), new Flags(Flags.Flag.DELETED));
         assertEquals(1, collector.events.size());
         assertTrue(collector.events.get(0) instanceof MailboxListener.FlagsUpdated);
@@ -89,7 +90,7 @@ public class MailboxEventDispatcherFlags
 
     @Test
     public void testShouldShowAnsweredAdded() {
-        dispatcher.flagsUpdated(result.getUid(), sessionId, name, new Flags(),
+        dispatcher.flagsUpdated(result.getUid(), sessionId, path, new Flags(),
                 new Flags(Flags.Flag.ANSWERED));
         assertEquals(1, collector.events.size());
         assertTrue(collector.events.get(0) instanceof MailboxListener.FlagsUpdated);
@@ -104,7 +105,7 @@ public class MailboxEventDispatcherFlags
 
     @Test
     public void testShouldShowAnsweredRemoved() {
-        dispatcher.flagsUpdated(result.getUid(), sessionId, name, new Flags(
+        dispatcher.flagsUpdated(result.getUid(), sessionId, path, new Flags(
                 Flags.Flag.ANSWERED), new Flags());
         assertEquals(1, collector.events.size());
         assertTrue(collector.events.get(0) instanceof MailboxListener.FlagsUpdated);
@@ -119,7 +120,7 @@ public class MailboxEventDispatcherFlags
 
     @Test
     public void testShouldShowDeletedAdded() {
-        dispatcher.flagsUpdated(result.getUid(), sessionId, name, new Flags(),
+        dispatcher.flagsUpdated(result.getUid(), sessionId, path, new Flags(),
                 new Flags(Flags.Flag.DELETED));
         assertEquals(1, collector.events.size());
         assertTrue(collector.events.get(0) instanceof MailboxListener.FlagsUpdated);
@@ -134,7 +135,7 @@ public class MailboxEventDispatcherFlags
 
     @Test
     public void testShouldShowDeletedRemoved() {
-        dispatcher.flagsUpdated(result.getUid(), sessionId, name, new Flags(
+        dispatcher.flagsUpdated(result.getUid(), sessionId, path, new Flags(
                 Flags.Flag.DELETED), new Flags());
         assertEquals(1, collector.events.size());
         assertTrue(collector.events.get(0) instanceof MailboxListener.FlagsUpdated);
@@ -149,7 +150,7 @@ public class MailboxEventDispatcherFlags
 
     @Test
     public void testShouldShowDraftAdded() {
-        dispatcher.flagsUpdated(result.getUid(), sessionId, name, new Flags(),
+        dispatcher.flagsUpdated(result.getUid(), sessionId, path, new Flags(),
                 new Flags(Flags.Flag.DRAFT));
         assertEquals(1, collector.events.size());
         assertTrue(collector.events.get(0) instanceof MailboxListener.FlagsUpdated);
@@ -164,7 +165,7 @@ public class MailboxEventDispatcherFlags
 
     @Test
     public void testShouldShowDraftRemoved() {
-        dispatcher.flagsUpdated(result.getUid(), sessionId, name, new Flags(
+        dispatcher.flagsUpdated(result.getUid(), sessionId, path, new Flags(
                 Flags.Flag.DRAFT), new Flags());
         assertEquals(1, collector.events.size());
         assertTrue(collector.events.get(0) instanceof MailboxListener.FlagsUpdated);
@@ -179,7 +180,7 @@ public class MailboxEventDispatcherFlags
 
     @Test
     public void testShouldShowFlaggedAdded() {
-        dispatcher.flagsUpdated(result.getUid(), sessionId, name, new Flags(),
+        dispatcher.flagsUpdated(result.getUid(), sessionId, path, new Flags(),
                 new Flags(Flags.Flag.FLAGGED));
         assertEquals(1, collector.events.size());
         assertTrue(collector.events.get(0) instanceof MailboxListener.FlagsUpdated);
@@ -194,7 +195,7 @@ public class MailboxEventDispatcherFlags
 
     @Test
     public void testShouldShowFlaggedRemoved() {
-        dispatcher.flagsUpdated(result.getUid(), sessionId, name, new Flags(
+        dispatcher.flagsUpdated(result.getUid(), sessionId, path, new Flags(
                 Flags.Flag.FLAGGED), new Flags());
         assertEquals(1, collector.events.size());
         assertTrue(collector.events.get(0) instanceof MailboxListener.FlagsUpdated);
@@ -209,7 +210,7 @@ public class MailboxEventDispatcherFlags
 
     @Test
     public void testShouldShowRecentAdded() {
-        dispatcher.flagsUpdated(result.getUid(), sessionId, name, new Flags(),
+        dispatcher.flagsUpdated(result.getUid(), sessionId, path, new Flags(),
                 new Flags(Flags.Flag.RECENT));
         assertEquals(1, collector.events.size());
         assertTrue(collector.events.get(0) instanceof MailboxListener.FlagsUpdated);
@@ -224,7 +225,7 @@ public class MailboxEventDispatcherFlags
 
     @Test
     public void testShouldShowRecentRemoved() {
-        dispatcher.flagsUpdated(result.getUid(), sessionId, name, new Flags(
+        dispatcher.flagsUpdated(result.getUid(), sessionId, path, new Flags(
                 Flags.Flag.RECENT), new Flags());
         assertEquals(1, collector.events.size());
         assertTrue(collector.events.get(0) instanceof MailboxListener.FlagsUpdated);
@@ -239,7 +240,7 @@ public class MailboxEventDispatcherFlags
 
     @Test
     public void testShouldShowSeenAdded() {
-        dispatcher.flagsUpdated(result.getUid(), sessionId, name, new Flags(),
+        dispatcher.flagsUpdated(result.getUid(), sessionId, path, new Flags(),
                 new Flags(Flags.Flag.SEEN));
         assertEquals(1, collector.events.size());
         assertTrue(collector.events.get(0) instanceof MailboxListener.FlagsUpdated);
@@ -254,7 +255,7 @@ public class MailboxEventDispatcherFlags
 
     @Test
     public void testShouldShowSeenRemoved() {
-        dispatcher.flagsUpdated(result.getUid(), sessionId, name, new Flags(
+        dispatcher.flagsUpdated(result.getUid(), sessionId, path, new Flags(
                 Flags.Flag.SEEN), new Flags());
         assertEquals(1, collector.events.size());
         assertTrue(collector.events.get(0) instanceof MailboxListener.FlagsUpdated);
@@ -277,7 +278,7 @@ public class MailboxEventDispatcherFlags
         updated.add(Flags.Flag.DRAFT);
         updated.add(Flags.Flag.SEEN);
 
-        dispatcher.flagsUpdated(result.getUid(), sessionId, name, originals, updated);
+        dispatcher.flagsUpdated(result.getUid(), sessionId, path, originals, updated);
         assertEquals(1, collector.events.size());
         assertTrue(collector.events.get(0) instanceof MailboxListener.FlagsUpdated);
         MailboxListener.FlagsUpdated event = (MailboxListener.FlagsUpdated) collector.events

Modified: james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/InMemoryMailboxManager.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/InMemoryMailboxManager.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/InMemoryMailboxManager.java (original)
+++ james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/InMemoryMailboxManager.java Sun Jul 18 18:18:08 2010
@@ -19,6 +19,7 @@
 
 package org.apache.james.imap.inmemory;
 
+import org.apache.james.imap.api.MailboxPath;
 import org.apache.james.imap.inmemory.mail.model.InMemoryMailbox;
 import org.apache.james.imap.mailbox.MailboxException;
 import org.apache.james.imap.mailbox.MailboxSession;
@@ -50,8 +51,8 @@ public class InMemoryMailboxManager exte
     }
 
     @Override
-    protected void doCreateMailbox(String namespaceName, MailboxSession session) throws StorageException {
-        InMemoryMailbox mailbox = new InMemoryMailbox(randomId(), namespaceName, randomUidValidity());
+    protected void doCreateMailbox(MailboxPath mailboxPath, MailboxSession session) throws StorageException {
+        InMemoryMailbox mailbox = new InMemoryMailbox(randomId(), mailboxPath, randomUidValidity());
         try {
             mailboxSessionMapperFactory.getMailboxMapper(session).save(mailbox);
         } catch (MailboxException e) {

Modified: james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/mail/InMemoryMailboxMapper.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/mail/InMemoryMailboxMapper.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/mail/InMemoryMailboxMapper.java (original)
+++ james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/mail/InMemoryMailboxMapper.java Sun Jul 18 18:18:08 2010
@@ -23,6 +23,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
+import org.apache.james.imap.api.MailboxPath;
 import org.apache.james.imap.inmemory.mail.model.InMemoryMailbox;
 import org.apache.james.imap.mailbox.MailboxException;
 import org.apache.james.imap.mailbox.MailboxNotFoundException;
@@ -75,16 +76,17 @@ public class InMemoryMailboxMapper imple
      * (non-Javadoc)
      * @see org.apache.james.imap.store.mail.MailboxMapper#findMailboxByName(java.lang.String)
      */
-    public synchronized Mailbox<Long> findMailboxByName(String name) throws StorageException, MailboxNotFoundException {
+    public synchronized Mailbox<Long> findMailboxByPath(MailboxPath path) throws StorageException, MailboxNotFoundException {
         Mailbox<Long> result = null;
         for (final InMemoryMailbox mailbox:mailboxesById.values()) {
-            if (mailbox.getName().equals(name)) {
+            MailboxPath mp = new MailboxPath(mailbox.getNamespace(), mailbox.getUser(), mailbox.getName());
+            if (mp.equals(path)) {
                 result = mailbox;
                 break;
             }
         }
         if (result == null) {
-            throw new MailboxNotFoundException(name);
+            throw new MailboxNotFoundException(path);
         } else {
             return result;
         }
@@ -94,8 +96,8 @@ public class InMemoryMailboxMapper imple
      * (non-Javadoc)
      * @see org.apache.james.imap.store.mail.MailboxMapper#findMailboxWithNameLike(java.lang.String)
      */
-    public List<Mailbox<Long>> findMailboxWithNameLike(String name) throws StorageException {
-        final String regex = name.replace("%", ".*");
+    public List<Mailbox<Long>> findMailboxWithPathLike(MailboxPath path) throws StorageException {
+        final String regex = path.getName().replace("%", ".*");
         List<Mailbox<Long>> results = new ArrayList<Mailbox<Long>>();
         for (final InMemoryMailbox mailbox:mailboxesById.values()) {
             if (mailbox.getName().matches(regex)) {

Modified: james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/mail/model/InMemoryMailbox.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/mail/model/InMemoryMailbox.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/mail/model/InMemoryMailbox.java (original)
+++ james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/mail/model/InMemoryMailbox.java Sun Jul 18 18:18:08 2010
@@ -21,6 +21,7 @@ package org.apache.james.imap.inmemory.m
 
 import java.util.concurrent.atomic.AtomicLong;
 
+import org.apache.james.imap.api.MailboxPath;
 import org.apache.james.imap.store.mail.model.Mailbox;
 
 /**
@@ -28,16 +29,20 @@ import org.apache.james.imap.store.mail.
  */
 public class InMemoryMailbox implements Mailbox<Long> {
 
-    private final long id;    
+    private final long id;
     private final long uidValidity;
     private final AtomicLong nextUid;
+    private String namespace;
+    private String user;
     private String name;
     
-    public InMemoryMailbox(final long id, final String name, final long uidValidity) {
+    public InMemoryMailbox(final long id, final MailboxPath path, final long uidValidity) {
         super();
         this.nextUid = new AtomicLong(0);
         this.id = id;
-        this.name = name;
+        this.namespace = path.getNamespace();
+        this.user = path.getUser();
+        this.name = path.getName();
         this.uidValidity = uidValidity;
     }
 
@@ -53,16 +58,31 @@ public class InMemoryMailbox implements 
         return id;
     }
 
-    public String getName() {
-        return name;
+    public String getNamespace() {
+        return namespace;
+    }
+
+    public void setNamespace(String namespace) {
+        this.namespace = namespace;
     }
 
+    public String getUser() {
+        return user;
+    }
 
-    public long getUidValidity() {
-        return uidValidity;
+    public void setuser(String user) {
+        this.user = user;
+    }
+
+    public String getName() {
+        return name;
     }
 
     public void setName(String name) {
         this.name = name;
     }
+
+    public long getUidValidity() {
+        return uidValidity;
+    }
 }

Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ListingEncodingUtils.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ListingEncodingUtils.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ListingEncodingUtils.java (original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ListingEncodingUtils.java Sun Jul 18 18:18:08 2010
@@ -37,10 +37,8 @@ public class ListingEncodingUtils {
         final List<String> attributes = getNameAttributes(response);
 
         final String name = response.getName();
-        final String hierarchyDelimiter = response.getHierarchyDelimiter();
 
-        composer.listResponse(responseTypeName, attributes, hierarchyDelimiter,
-                name);
+        composer.listResponse(responseTypeName, attributes, ImapConstants.HIERARCHY_DELIMITER, name);
     }
 
     private static List<String> getNameAttributes(final AbstractListingResponse response) {

Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/AbstractListingResponse.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/AbstractListingResponse.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/AbstractListingResponse.java (original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/AbstractListingResponse.java Sun Jul 18 18:18:08 2010
@@ -19,6 +19,8 @@
 
 package org.apache.james.imap.message.response;
 
+import org.apache.james.imap.api.ImapConstants;
+
 /**
  * <code>LIST</code> and <code>LSUB</code> return identical data.
  */
@@ -36,14 +38,14 @@ public abstract class AbstractListingRes
 
     private final boolean unmarked;
 
-    private final String hierarchyDelimiter;
+    private final String hierarchyDelimiter = ImapConstants.HIERARCHY_DELIMITER;
 
     private final String name;
 
     public AbstractListingResponse(final boolean noInferiors,
             final boolean noSelect, final boolean marked,
             final boolean unmarked, boolean hasChildren,
-            boolean hasNoChildren, final String hierarchyDelimiter, final String name) {
+            boolean hasNoChildren, final String name) {
         super();
         this.noInferiors = noInferiors;
         this.noSelect = noSelect;
@@ -51,7 +53,6 @@ public abstract class AbstractListingRes
         this.unmarked = unmarked;
         this.children = hasChildren;
         this.noChildren = hasNoChildren;
-        this.hierarchyDelimiter = hierarchyDelimiter;
         this.name = name;
     }
 

Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/LSubResponse.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/LSubResponse.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/LSubResponse.java (original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/LSubResponse.java Sun Jul 18 18:18:08 2010
@@ -25,8 +25,7 @@ import org.apache.james.imap.api.message
  */
 public final class LSubResponse extends AbstractListingResponse implements
         ImapResponseMessage {
-    public LSubResponse(final String name, final String hierarchyDelimiter,
-            final boolean noSelect) {
-        super(false, noSelect, false, false, false, false, hierarchyDelimiter, name);
+    public LSubResponse(final String name, final boolean noSelect) {
+        super(false, noSelect, false, false, false, false, name);
     }
 }

Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/ListResponse.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/ListResponse.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/ListResponse.java (original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/ListResponse.java Sun Jul 18 18:18:08 2010
@@ -28,7 +28,7 @@ public final class ListResponse extends 
     
     public ListResponse(final boolean noInferiors, final boolean noSelect,
             final boolean marked, final boolean unmarked,
-            boolean hasChildren, boolean hasNoChildren, final String hierarchyDelimiter, final String name) {
-        super(noInferiors, noSelect, marked, unmarked, hasChildren, hasNoChildren, hierarchyDelimiter, name);
+            boolean hasChildren, boolean hasNoChildren, final String name) {
+        super(noInferiors, noSelect, marked, unmarked, hasChildren, hasNoChildren, name);
     }
 }

Modified: james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/LSubResponseEncoderTest.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/LSubResponseEncoderTest.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/LSubResponseEncoderTest.java (original)
+++ james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/LSubResponseEncoderTest.java Sun Jul 18 18:18:08 2010
@@ -60,8 +60,8 @@ public class LSubResponseEncoderTest  {
     @Test
     public void testIsAcceptable() {
         assertFalse(encoder.isAcceptable(new ListResponse(true, true, true,
-                true, false, false, ".", "name")));
-        assertTrue(encoder.isAcceptable(new LSubResponse("name", ".", true)));
+                true, false, false, "name")));
+        assertTrue(encoder.isAcceptable(new LSubResponse("name", true)));
         assertFalse(encoder.isAcceptable(context.mock(ImapMessage.class)));
         assertFalse(encoder.isAcceptable(null));
     }
@@ -70,35 +70,26 @@ public class LSubResponseEncoderTest  {
     @SuppressWarnings("unchecked")
 	public void testName() throws Exception {
         context.checking(new Expectations() {{
-            oneOf(composer).listResponse(with(same("LSUB")),with(aNull(List.class)), with(same(".")), with(same("INBOX.name")));
+            oneOf(composer).listResponse(with(equal("LSUB")),with(aNull(List.class)), with(equal(".")), with(equal("INBOX.name")));
         }});
-        encoder.encode(new LSubResponse("INBOX.name", ".", false), composer, new FakeImapSession());
+        encoder.encode(new LSubResponse("INBOX.name", false), composer, new FakeImapSession());
     }
 
     @Test
     @SuppressWarnings("unchecked")
 	public void testDelimiter() throws Exception {
         context.checking(new Expectations() {{
-            oneOf(composer).listResponse(with(same("LSUB")),with(aNull(List.class)), with(same("@")), with(same("INBOX.name")));
+            oneOf(composer).listResponse(with(equal("LSUB")),with(aNull(List.class)), with(equal(".")), with(equal("INBOX.name")));
         }});
-        encoder.encode(new LSubResponse("INBOX.name", "@", false), composer, new FakeImapSession());
-    }
-
-    @Test
-    @SuppressWarnings("unchecked")
-	public void testNoDelimiter() throws Exception {
-        context.checking(new Expectations() {{
-            oneOf(composer).listResponse(with(same("LSUB")),with(aNull(List.class)), with(aNull(String.class)), with(same("INBOX.name")));
-        }});
-        encoder.encode(new LSubResponse("INBOX.name", null, false), composer, new FakeImapSession());
+        encoder.encode(new LSubResponse("INBOX.name", false), composer, new FakeImapSession());
     }
 
     @Test
     public void testNoSelect() throws Exception {
         final String[] values = { ImapConstants.NAME_ATTRIBUTE_NOSELECT };
         context.checking(new Expectations() {{
-            oneOf(composer).listResponse(with(same("LSUB")),with(equal(Arrays.asList(values))), with(equal(".")), with(same("INBOX.name")));
+            oneOf(composer).listResponse(with(equal("LSUB")),with(equal(Arrays.asList(values))), with(equal(".")), with(equal("INBOX.name")));
         }});
-        encoder.encode(new LSubResponse("INBOX.name", ".", true), composer, new FakeImapSession());
+        encoder.encode(new LSubResponse("INBOX.name", true), composer, new FakeImapSession());
     }
 }

Modified: james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/ListingEncodingUtilsTest.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/ListingEncodingUtilsTest.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/ListingEncodingUtilsTest.java (original)
+++ james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/ListingEncodingUtilsTest.java Sun Jul 18 18:18:08 2010
@@ -33,7 +33,6 @@ import org.junit.runner.RunWith;
 @RunWith(JMock.class)
 public class ListingEncodingUtilsTest  {
 
-    final String deliminatorParameter = ".";
     final String nameParameter = "LIST";
     final String typeNameParameters = "A Type Name";
     
@@ -50,7 +49,7 @@ public class ListingEncodingUtilsTest  {
         
         context.checking (new Expectations() {{
             oneOf(mock).listResponse(with(equal(typeNameParameters)), with(equal(attributesOutput)), 
-                    with(equal(deliminatorParameter)), with(equal(nameParameter)));
+                    with(equal(".")), with(equal(nameParameter)));
         }});
     }
 
@@ -58,7 +57,7 @@ public class ListingEncodingUtilsTest  {
     public void testShouldAddHasChildrenToAttributes() throws Exception {
         // Setup 
         attributesOutput.add("\\HasChildren");
-        ListResponse input = new ListResponse(false, false, false, false, true, false, deliminatorParameter, nameParameter);
+        ListResponse input = new ListResponse(false, false, false, false, true, false, nameParameter);
             
         // Exercise
         ListingEncodingUtils.encodeListingResponse(typeNameParameters, mock, input);
@@ -68,7 +67,7 @@ public class ListingEncodingUtilsTest  {
     public void testShouldAddHasNoChildrenToAttributes() throws Exception {
         // Setup 
         attributesOutput.add("\\HasNoChildren");
-        ListResponse input = new ListResponse(false, false, false, false, false, true, deliminatorParameter, nameParameter);
+        ListResponse input = new ListResponse(false, false, false, false, false, true, nameParameter);
             
         // Exercise
         ListingEncodingUtils.encodeListingResponse(typeNameParameters, mock, input);

Modified: james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/SearchResponseEncoderTest.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/SearchResponseEncoderTest.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/SearchResponseEncoderTest.java (original)
+++ james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/SearchResponseEncoderTest.java Sun Jul 18 18:18:08 2010
@@ -60,8 +60,8 @@ public class SearchResponseEncoderTest {
     @Test
     public void testIsAcceptable() {
         assertTrue(encoder.isAcceptable(new ListResponse(true, true, true,
-                true, false, false, ".", "name")));
-        assertFalse(encoder.isAcceptable(new LSubResponse("name", ".", true)));
+                true, false, false, "name")));
+        assertFalse(encoder.isAcceptable(new LSubResponse("name", true)));
         assertFalse(encoder.isAcceptable(context.mock(ImapMessage.class)));
         assertFalse(encoder.isAcceptable(null));
     }
@@ -71,12 +71,12 @@ public class SearchResponseEncoderTest {
 	public void testName() throws Exception {
         context.checking(new Expectations() {{
             oneOf(composer).listResponse(
-                            with(same("LIST")), 
+                            with(equal("LIST")), 
                             with(aNull(List.class)), 
-                            with(same(".")), 
-                            with(same("INBOX.name")));
+                            with(equal(".")), 
+                            with(equal("INBOX.name")));
         }});
-        encoder.encode(new ListResponse(false, false, false, false, false, false, ".", "INBOX.name"), composer, new FakeImapSession());
+        encoder.encode(new ListResponse(false, false, false, false, false, false, "INBOX.name"), composer, new FakeImapSession());
     }
 
     @Test
@@ -84,26 +84,14 @@ public class SearchResponseEncoderTest {
 	public void testDelimiter() throws Exception {
         context.checking(new Expectations() {{
             oneOf(composer).listResponse(
-                            with(same("LIST")), 
+                            with(equal("LIST")), 
                             with(aNull(List.class)), 
-                            with(same("@")), 
-                            with(same("INBOX.name")));
+                            with(equal(".")), 
+                            with(equal("INBOX.name")));
         }});
-        encoder.encode(new ListResponse(false, false, false, false, false, false, "@", "INBOX.name"), composer, new FakeImapSession());
+        encoder.encode(new ListResponse(false, false, false, false, false, false, "INBOX.name"), composer, new FakeImapSession());
     }
 
-    @Test
-    @SuppressWarnings("unchecked")
-	public void testNoDelimiter() throws Exception {
-        context.checking(new Expectations() {{
-            oneOf(composer).listResponse(
-                            with(same("LIST")), 
-                            with(aNull(List.class)), 
-                            with(aNull(String.class)), 
-                            with(same("INBOX.name")));
-        }});
-        encoder.encode(new ListResponse(false, false, false, false, false, false, null, "INBOX.name"), composer, new FakeImapSession());
-    }
 
     @Test
     public void testAllAttributes() throws Exception {
@@ -113,12 +101,12 @@ public class SearchResponseEncoderTest {
                 ImapConstants.NAME_ATTRIBUTE_UNMARKED };
         context.checking(new Expectations() {{
             oneOf(composer).listResponse(
-                            with(same("LIST")), 
+                            with(equal("LIST")), 
                             with(equal(Arrays.asList(all))), 
-                            with(same(".")), 
-                            with(same("INBOX.name")));
+                            with(equal(".")), 
+                            with(equal("INBOX.name")));
         }});
-        encoder.encode(new ListResponse(true, true, true, true, false, false, ".", "INBOX.name"), composer, new FakeImapSession());
+        encoder.encode(new ListResponse(true, true, true, true, false, false, "INBOX.name"), composer, new FakeImapSession());
     }
 
     @Test
@@ -126,12 +114,12 @@ public class SearchResponseEncoderTest {
         final String[] values = { ImapConstants.NAME_ATTRIBUTE_NOINFERIORS };
         context.checking(new Expectations() {{
             oneOf(composer).listResponse(
-                            with(same("LIST")), 
+                            with(equal("LIST")), 
                             with(equal(Arrays.asList(values))), 
-                            with(same(".")), 
-                            with(same("INBOX.name")));
+                            with(equal(".")), 
+                            with(equal("INBOX.name")));
         }});
-        encoder.encode(new ListResponse(true, false, false, false, false, false, ".", "INBOX.name"), composer, new FakeImapSession());
+        encoder.encode(new ListResponse(true, false, false, false, false, false, "INBOX.name"), composer, new FakeImapSession());
     }
 
     @Test
@@ -139,12 +127,12 @@ public class SearchResponseEncoderTest {
         final String[] values = { ImapConstants.NAME_ATTRIBUTE_NOSELECT };
         context.checking(new Expectations() {{
             oneOf(composer).listResponse(
-                            with(same("LIST")), 
+                            with(equal("LIST")), 
                             with(equal(Arrays.asList(values))), 
-                            with(same(".")), 
-                            with(same("INBOX.name")));
+                            with(equal(".")), 
+                            with(equal("INBOX.name")));
         }});
-        encoder.encode(new ListResponse(false, true, false, false, false, false, ".", "INBOX.name"), composer, new FakeImapSession());
+        encoder.encode(new ListResponse(false, true, false, false, false, false, "INBOX.name"), composer, new FakeImapSession());
     }
 
     @Test
@@ -152,12 +140,12 @@ public class SearchResponseEncoderTest {
         final String[] values = { ImapConstants.NAME_ATTRIBUTE_MARKED };
         context.checking(new Expectations() {{
             oneOf(composer).listResponse(
-                            with(same("LIST")), 
+                            with(equal("LIST")), 
                             with(equal(Arrays.asList(values))), 
-                            with(same(".")), 
-                            with(same("INBOX.name")));
+                            with(equal(".")), 
+                            with(equal("INBOX.name")));
         }});
-        encoder.encode(new ListResponse(false, false, true, false, false, false, ".", "INBOX.name"), composer, new FakeImapSession());
+        encoder.encode(new ListResponse(false, false, true, false, false, false, "INBOX.name"), composer, new FakeImapSession());
     }
 
     @Test
@@ -165,11 +153,11 @@ public class SearchResponseEncoderTest {
         final String[] values = { ImapConstants.NAME_ATTRIBUTE_UNMARKED };
         context.checking(new Expectations() {{
             oneOf(composer).listResponse(
-                            with(same("LIST")), 
+                            with(equal("LIST")), 
                             with(equal(Arrays.asList(values))), 
-                            with(same(".")), 
-                            with(same("INBOX.name")));
+                            with(equal(".")), 
+                            with(equal("INBOX.name")));
         }});
-        encoder.encode(new ListResponse(false, false, false, true, false, false, ".", "INBOX.name"), composer, new FakeImapSession());
+        encoder.encode(new ListResponse(false, false, false, true, false, false, "INBOX.name"), composer, new FakeImapSession());
     }
 }

Modified: james/imap/trunk/pom.xml
URL: http://svn.apache.org/viewvc/james/imap/trunk/pom.xml?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/pom.xml (original)
+++ james/imap/trunk/pom.xml Sun Jul 18 18:18:08 2010
@@ -41,13 +41,13 @@
     <module>mailbox</module>
     <module>store</module>
     <module>processor</module>
-    <module>torque</module>
     <module>jpa</module>
     <module>jcr</module>
     <module>memory</module>
     <module>seda</module>
     <module>deployment</module>
     <module>parent</module>
+    <module>torque</module>
     <!--  
     <module>maildir</module>
     -->

Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractMailboxProcessor.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractMailboxProcessor.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractMailboxProcessor.java (original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractMailboxProcessor.java Sun Jul 18 18:18:08 2010
@@ -18,8 +18,6 @@
  ****************************************************************/
 package org.apache.james.imap.processor;
 
-import static org.apache.james.imap.api.ImapConstants.NAMESPACE_PREFIX;
-
 import java.util.Collection;
 import java.util.Iterator;
 
@@ -28,7 +26,9 @@ import javax.mail.MessagingException;
 
 import org.apache.commons.logging.Log;
 import org.apache.james.imap.api.ImapCommand;
+import org.apache.james.imap.api.ImapConstants;
 import org.apache.james.imap.api.ImapMessage;
+import org.apache.james.imap.api.MailboxPath;
 import org.apache.james.imap.api.display.HumanReadableText;
 import org.apache.james.imap.api.message.request.ImapRequest;
 import org.apache.james.imap.api.message.response.ImapResponseMessage;
@@ -38,6 +38,7 @@ import org.apache.james.imap.api.process
 import org.apache.james.imap.api.process.ImapSession;
 import org.apache.james.imap.api.process.SelectedMailbox;
 import org.apache.james.imap.mailbox.Mailbox;
+import org.apache.james.imap.mailbox.MailboxConstants;
 import org.apache.james.imap.mailbox.MailboxException;
 import org.apache.james.imap.mailbox.MailboxExistsException;
 import org.apache.james.imap.mailbox.MailboxManager;
@@ -229,9 +230,8 @@ abstract public class AbstractMailboxPro
     }
 
     private Mailbox getMailbox(final ImapSession session, final SelectedMailbox selected) throws MailboxException {
-        final String fullMailboxName = buildFullName(session, selected.getName());
         final MailboxManager mailboxManager = getMailboxManager();
-        final Mailbox mailbox = mailboxManager.getMailbox(fullMailboxName, ImapSessionUtils.getMailboxSession(session));
+        final Mailbox mailbox = mailboxManager.getMailbox(selected.getPath(), ImapSessionUtils.getMailboxSession(session));
         return mailbox;
     }
 
@@ -311,13 +311,57 @@ abstract public class AbstractMailboxPro
             ImapSession session, String tag, ImapCommand command,
             Responder responder);
 
-    public String buildFullName(final ImapSession session, String mailboxName)
-            throws MailboxException {
+    public MailboxPath buildFullPath(final ImapSession session, String mailboxName) {
+        String namespace = null;
+        String name = null;
+        if (mailboxName.charAt(0) == ImapConstants.NAMESPACE_PREFIX_CHAR) {
+            int namespaceLength = mailboxName.indexOf(MailboxConstants.DEFAULT_DELIMITER);
+            if (namespaceLength > -1) {
+                namespace = mailboxName.substring(0, namespaceLength);
+                if (mailboxName.length() > namespaceLength)
+                    name = mailboxName.substring(++namespaceLength);
+            }
+            else {
+                namespace = mailboxName;
+            }
+        }
+        else {
+            namespace = MailboxConstants.USER_NAMESPACE;
+            name = mailboxName;
+        }
         final String user = ImapSessionUtils.getUserName(session);
-        if (!mailboxName.startsWith(NAMESPACE_PREFIX)) {
-            mailboxName = getMailboxManager().resolve(user, mailboxName);
+        return new MailboxPath(namespace, user, name);
+    }
+    
+    /**
+     * Joins the elements of a mailboxPath together and returns them as a string
+     * @param mailboxPath
+     * @return
+     */
+    public String joinMailboxPath(MailboxPath mailboxPath) {
+        StringBuffer sb = new StringBuffer("");
+        if (mailboxPath.getNamespace() != null && !mailboxPath.getNamespace().equals("")) {
+            sb.append(mailboxPath.getNamespace());
+        }
+        if (mailboxPath.getUser() != null && !mailboxPath.getUser().equals("")) {
+            if (sb.length() > 0)
+                sb.append(MailboxConstants.DEFAULT_DELIMITER);
+            sb.append(mailboxPath.getUser());
+        }
+        if (mailboxPath.getName() != null && !mailboxPath.getName().equals("")) {
+            if (sb.length() > 0)
+                sb.append(MailboxConstants.DEFAULT_DELIMITER);
+            sb.append(mailboxPath.getName());
+        }
+        return sb.toString();
+    }
+
+    public String mailboxName(final boolean relative, final MailboxPath path) {
+        if (relative) {
+            return path.getName();
+        } else {
+            return joinMailboxPath(path);
         }
-        return mailboxName;
     }
     
     public MailboxManager getMailboxManager() {
@@ -330,9 +374,8 @@ abstract public class AbstractMailboxPro
         if (selectedMailbox == null) {
             result = null;
         } else {
-            final String mailboxName = selectedMailbox.getName();
             final MailboxManager mailboxManager = getMailboxManager();
-            result = mailboxManager.getMailbox(mailboxName, ImapSessionUtils.getMailboxSession(session));
+            result = mailboxManager.getMailbox(selectedMailbox.getPath(), ImapSessionUtils.getMailboxSession(session));
         }
         return result;
     }

Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractSelectionProcessor.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractSelectionProcessor.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractSelectionProcessor.java (original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractSelectionProcessor.java Sun Jul 18 18:18:08 2010
@@ -26,6 +26,7 @@ import java.util.List;
 import javax.mail.Flags;
 
 import org.apache.james.imap.api.ImapCommand;
+import org.apache.james.imap.api.MailboxPath;
 import org.apache.james.imap.api.display.HumanReadableText;
 import org.apache.james.imap.api.message.request.ImapRequest;
 import org.apache.james.imap.api.message.response.StatusResponse;
@@ -79,8 +80,8 @@ abstract class AbstractSelectionProcesso
         final AbstractMailboxSelectionRequest request = (AbstractMailboxSelectionRequest) message;
         final String mailboxName = request.getMailboxName();
         try {
-            final String fullMailboxName = buildFullName(session, mailboxName);
-            final Mailbox.MetaData metaData = selectMailbox(fullMailboxName, session);
+            final MailboxPath fullMailboxPath = buildFullPath(session, mailboxName);
+            final Mailbox.MetaData metaData = selectMailbox(fullMailboxPath, session);
             respond(tag, command, session, metaData, responder);
         } catch (MailboxNotFoundException e) {
             responder.respond(statusResponseFactory.taggedNo(tag, command,
@@ -172,18 +173,17 @@ abstract class AbstractSelectionProcesso
         responder.respond(existsResponse);
     }
 
-    private Mailbox.MetaData  selectMailbox(String mailboxName, ImapSession session)
+    private Mailbox.MetaData  selectMailbox(MailboxPath mailboxPath, ImapSession session)
             throws MailboxException {
         final MailboxManager mailboxManager = getMailboxManager();
         final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session);
-        final Mailbox mailbox = mailboxManager.getMailbox(mailboxName, mailboxSession);
+        final Mailbox mailbox = mailboxManager.getMailbox(mailboxPath, mailboxSession);
 
         final SelectedMailbox sessionMailbox;
         final SelectedMailbox currentMailbox = session.getSelected();
         if (currentMailbox == null
-                || !currentMailbox.getName().equals(mailboxName)) {
-            sessionMailbox = createNewSelectedMailbox(mailbox, mailboxSession,
-                    session, mailboxName);
+                || !currentMailbox.getPath().equals(mailboxPath)) {
+            sessionMailbox = createNewSelectedMailbox(mailbox, mailboxSession, session, mailboxPath);
         } else {
             sessionMailbox = currentMailbox;
         }
@@ -193,9 +193,8 @@ abstract class AbstractSelectionProcesso
     }
 
     private SelectedMailbox createNewSelectedMailbox(final Mailbox mailbox,
-            final MailboxSession mailboxSession, ImapSession session, String name)
+            final MailboxSession mailboxSession, ImapSession session, MailboxPath path)
             throws MailboxException {
-        final SelectedMailbox sessionMailbox;
         final Iterator<MessageResult> it = mailbox.getMessages(MessageRange.all(),
                 FetchGroupImpl.MINIMAL, mailboxSession);
 
@@ -205,8 +204,8 @@ abstract class AbstractSelectionProcesso
             uids.add(result.getUid());
         }
         
-        sessionMailbox = new SelectedMailboxImpl(getMailboxManager(), uids,
-                mailboxSession, name);
+        final SelectedMailbox sessionMailbox = new SelectedMailboxImpl(getMailboxManager(), uids,
+                                                                        mailboxSession, path);
         session.selected(sessionMailbox);
         return sessionMailbox;
     }

Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AppendProcessor.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AppendProcessor.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AppendProcessor.java (original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AppendProcessor.java Sun Jul 18 18:18:08 2010
@@ -28,6 +28,7 @@ import javax.mail.Flags;
 import org.apache.commons.logging.Log;
 import org.apache.james.imap.api.ImapCommand;
 import org.apache.james.imap.api.ImapMessage;
+import org.apache.james.imap.api.MailboxPath;
 import org.apache.james.imap.api.display.HumanReadableText;
 import org.apache.james.imap.api.message.request.ImapRequest;
 import org.apache.james.imap.api.message.response.StatusResponse;
@@ -68,11 +69,11 @@ public class AppendProcessor extends Abs
         final Flags flags = request.getFlags();
         try {
 
-            final String fullMailboxName = buildFullName(session, mailboxName);
+            final MailboxPath mailboxPath = buildFullPath(session, mailboxName);
             final MailboxManager mailboxManager = getMailboxManager();
-            final Mailbox mailbox = mailboxManager.getMailbox(fullMailboxName, ImapSessionUtils.getMailboxSession(session));
+            final Mailbox mailbox = mailboxManager.getMailbox(mailboxPath, ImapSessionUtils.getMailboxSession(session));
             appendToMailbox(messageIn, datetime, flags, session, tag,
-                    command, mailbox, responder, fullMailboxName);
+                    command, mailbox, responder, mailboxPath);
         } catch (MailboxNotFoundException e) {
             // consume message on exception
             cosume(messageIn);
@@ -122,18 +123,16 @@ public class AppendProcessor extends Abs
         no(command, tag, responder,
                 HumanReadableText.FAILURE_NO_SUCH_MAILBOX,
                 StatusResponse.ResponseCode.tryCreate());
-       
     }
 
     private void appendToMailbox(final InputStream message, final Date datetime,
             final Flags flagsToBeSet, final ImapSession session, final String tag,
-            final ImapCommand command, final Mailbox mailbox, Responder responder, final String fullMailboxName) {
+            final ImapCommand command, final Mailbox mailbox, Responder responder, final MailboxPath mailboxPath) {
         try {
-            final MailboxSession mailboxSession = ImapSessionUtils
-                    .getMailboxSession(session);
+            final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session);
             final SelectedMailbox selectedMailbox = session.getSelected();
             final boolean isSelectedMailbox = selectedMailbox != null
-                    && fullMailboxName.equals(selectedMailbox.getName());
+                    && selectedMailbox.getPath().equals(mailboxPath);
             final long uid  = mailbox.appendMessage(message, datetime, mailboxSession, 
                     !isSelectedMailbox, flagsToBeSet);
             if (isSelectedMailbox) {
@@ -152,4 +151,6 @@ public class AppendProcessor extends Abs
             no(command, tag, responder, e, session);
         }
     }
+    
+    
 }

Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/CopyProcessor.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/CopyProcessor.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/CopyProcessor.java (original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/CopyProcessor.java Sun Jul 18 18:18:08 2010
@@ -21,6 +21,7 @@ package org.apache.james.imap.processor;
 
 import org.apache.james.imap.api.ImapCommand;
 import org.apache.james.imap.api.ImapMessage;
+import org.apache.james.imap.api.MailboxPath;
 import org.apache.james.imap.api.display.HumanReadableText;
 import org.apache.james.imap.api.message.IdRange;
 import org.apache.james.imap.api.message.request.ImapRequest;
@@ -51,19 +52,16 @@ public class CopyProcessor extends Abstr
     protected void doProcess(ImapRequest message, ImapSession session,
             String tag, ImapCommand command, Responder responder) {
         final CopyRequest request = (CopyRequest) message;
-        final String mailboxName = request.getMailboxName();
+        final MailboxPath targetMailbox = buildFullPath(session, request.getMailboxName());
         final IdRange[] idSet = request.getIdSet();
         final boolean useUids = request.isUseUids();
         final SelectedMailbox currentMailbox = session.getSelected();
         try {
             final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session);
-            final String fullMailboxName = buildFullName(session, mailboxName);
             final MailboxManager mailboxManager = getMailboxManager();
-            final boolean mailboxExists = mailboxManager
-                    .mailboxExists(fullMailboxName, mailboxSession);
+            final boolean mailboxExists = mailboxManager.mailboxExists(targetMailbox, mailboxSession);
             if (!mailboxExists) {
-                no(command, tag, responder,
-                        HumanReadableText.FAILURE_NO_SUCH_MAILBOX,
+                no(command, tag, responder, HumanReadableText.FAILURE_NO_SUCH_MAILBOX,
                         ResponseCode.tryCreate());
             } else {
                 for (int i = 0; i < idSet.length; i++) {
@@ -79,8 +77,9 @@ public class CopyProcessor extends Abstr
                                 (int) idSet[i].getLowVal());
                     }
                     MessageRange messageSet = MessageRange.range(lowVal, highVal);
-                    mailboxManager.copyMessages(messageSet, currentMailbox
-                            .getName(), fullMailboxName, mailboxSession);
+
+                    mailboxManager.copyMessages(messageSet, currentMailbox.getPath(),
+                                                targetMailbox, mailboxSession);
                 }
                 unsolicitedResponses(session, responder, useUids);
                 okComplete(command, tag, responder);

Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/CreateProcessor.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/CreateProcessor.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/CreateProcessor.java (original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/CreateProcessor.java Sun Jul 18 18:18:08 2010
@@ -21,6 +21,7 @@ package org.apache.james.imap.processor;
 
 import org.apache.james.imap.api.ImapCommand;
 import org.apache.james.imap.api.ImapMessage;
+import org.apache.james.imap.api.MailboxPath;
 import org.apache.james.imap.api.message.request.ImapRequest;
 import org.apache.james.imap.api.message.response.StatusResponseFactory;
 import org.apache.james.imap.api.process.ImapProcessor;
@@ -45,12 +46,10 @@ public class CreateProcessor extends Abs
     protected void doProcess(ImapRequest message, ImapSession session,
             String tag, ImapCommand command, Responder responder) {
         final CreateRequest request = (CreateRequest) message;
-        final String mailboxName = request.getMailboxName();
+        final MailboxPath mailboxPath = buildFullPath(session, request.getMailboxName());
         try {
-
-            final String fullMailboxName = buildFullName(session, mailboxName);
             final MailboxManager mailboxManager = getMailboxManager();
-            mailboxManager.createMailbox(fullMailboxName, ImapSessionUtils.getMailboxSession(session));
+            mailboxManager.createMailbox(mailboxPath, ImapSessionUtils.getMailboxSession(session));
             unsolicitedResponses(session, responder, false);
             okComplete(command, tag, responder);
         } catch (MailboxException e) {

Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/DeleteProcessor.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/DeleteProcessor.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/DeleteProcessor.java (original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/DeleteProcessor.java Sun Jul 18 18:18:08 2010
@@ -21,6 +21,7 @@ package org.apache.james.imap.processor;
 
 import org.apache.james.imap.api.ImapCommand;
 import org.apache.james.imap.api.ImapMessage;
+import org.apache.james.imap.api.MailboxPath;
 import org.apache.james.imap.api.message.request.ImapRequest;
 import org.apache.james.imap.api.message.response.StatusResponseFactory;
 import org.apache.james.imap.api.process.ImapProcessor;
@@ -46,19 +47,16 @@ public class DeleteProcessor extends Abs
     protected void doProcess(ImapRequest message, ImapSession session,
             String tag, ImapCommand command, Responder responder) {
         final DeleteRequest request = (DeleteRequest) message;
-        final String mailboxName = request.getMailboxName();
+        final MailboxPath mailboxPath = buildFullPath(session, request.getMailboxName());
         try {
-            final String fullMailboxName = buildFullName(session, mailboxName);
             final SelectedMailbox selected = session.getSelected();
-            if (selected != null && selected.getName().equals(fullMailboxName)) {
+            if (selected != null && selected.getPath().equals(mailboxPath)) {
                 session.deselect();
             }
             final MailboxManager mailboxManager = getMailboxManager();
-            mailboxManager.deleteMailbox(fullMailboxName, ImapSessionUtils
-                    .getMailboxSession(session));
+            mailboxManager.deleteMailbox(mailboxPath, ImapSessionUtils.getMailboxSession(session));
             unsolicitedResponses(session, responder, false);
             okComplete(command, tag, responder);
-
         } catch (MailboxException e) {
             no(command, tag, responder, e, session);
         }

Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/LSubProcessor.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/LSubProcessor.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/LSubProcessor.java (original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/LSubProcessor.java Sun Jul 18 18:18:08 2010
@@ -25,11 +25,13 @@ import java.util.Collection;
 import org.apache.james.imap.api.ImapCommand;
 import org.apache.james.imap.api.ImapConstants;
 import org.apache.james.imap.api.ImapMessage;
+import org.apache.james.imap.api.MailboxPath;
 import org.apache.james.imap.api.display.HumanReadableText;
 import org.apache.james.imap.api.message.request.ImapRequest;
 import org.apache.james.imap.api.message.response.StatusResponseFactory;
 import org.apache.james.imap.api.process.ImapProcessor;
 import org.apache.james.imap.api.process.ImapSession;
+import org.apache.james.imap.mailbox.MailboxConstants;
 import org.apache.james.imap.mailbox.MailboxException;
 import org.apache.james.imap.mailbox.MailboxManager;
 import org.apache.james.imap.mailbox.MailboxQuery;
@@ -60,10 +62,8 @@ public class LSubProcessor extends Abstr
         try {
             if (mailboxPattern.length() == 0) {
                 respondWithHierarchyDelimiter(responder);
-
             } else {
-                listSubscriptions(session, responder, referenceName,
-                        mailboxPattern);
+                listSubscriptions(session, responder, referenceName, mailboxPattern);
             }
 
             okComplete(command, tag, responder);
@@ -86,42 +86,50 @@ public class LSubProcessor extends Abstr
     }
 
     private void listSubscriptions(ImapSession session, Responder responder,
-            final String referenceName, final String mailboxPattern)
+            final String referenceName, final String mailboxName)
             throws SubscriptionException, MailboxException {
         final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session);
         final MailboxManager manager = getMailboxManager();
         final Collection<String> mailboxes = manager.subscriptions(mailboxSession);
-        final MailboxQuery expression = new MailboxQuery(
-                referenceName, mailboxPattern, '*', '%');
+        // If the mailboxName is fully qualified, ignore the reference name.
+        String finalReferencename = referenceName;
+        if (mailboxName.charAt(0) == ImapConstants.NAMESPACE_PREFIX_CHAR) {
+            finalReferencename = "";
+        }
+        // Is the interpreted (combined) pattern relative?
+        boolean isRelative = ((finalReferencename + mailboxName).charAt(0) != ImapConstants.NAMESPACE_PREFIX_CHAR);
+        MailboxPath basePath = null;
+        if (isRelative) {
+            basePath = new MailboxPath(MailboxConstants.USER_NAMESPACE,
+                    mailboxSession.getUser().getUserName(), finalReferencename);
+        }
+        else {
+            basePath = buildFullPath(session, finalReferencename);
+        }
+        
+        final MailboxQuery expression = new MailboxQuery(basePath, mailboxName, '*', '%');
         final Collection<String> mailboxResponses = new ArrayList<String>();
-        for (final String mailboxName: mailboxes) {
-            respond(responder, expression, mailboxName, true, mailboxes,
-                    mailboxResponses);
+        for (final String mailbox: mailboxes) {
+            respond(responder, expression, mailbox, true, mailboxes, mailboxResponses);
         }
     }
 
-    private void respond(Responder responder,
-            final MailboxQuery expression, final String mailboxName,
-            final boolean originalSubscription, final Collection<String> mailboxes,
-            final Collection<String> mailboxResponses) {
-        if (expression.isExpressionMatch(mailboxName,
-                ImapConstants.HIERARCHY_DELIMITER_CHAR)) {
+    private void respond(Responder responder, final MailboxQuery expression,
+            final String mailboxName, final boolean originalSubscription,
+            final Collection<String> mailboxes, final Collection<String> mailboxResponses) {
+        if (expression.isExpressionMatch(mailboxName)) {
             if (!mailboxResponses.contains(mailboxName)) {
-                final LSubResponse response = new LSubResponse(mailboxName,
-                        ImapConstants.HIERARCHY_DELIMITER,
-                        !originalSubscription);
+                final LSubResponse response = new LSubResponse(mailboxName, !originalSubscription);
                 responder.respond(response);
                 mailboxResponses.add(mailboxName);
             }
-        } else {
-            final int lastDelimiter = mailboxName
-                    .lastIndexOf(ImapConstants.HIERARCHY_DELIMITER_CHAR);
+        }
+        else {
+            final int lastDelimiter = mailboxName.lastIndexOf(ImapConstants.HIERARCHY_DELIMITER_CHAR);
             if (lastDelimiter > 0) {
-                final String parentMailbox = mailboxName.substring(0,
-                        lastDelimiter);
+                final String parentMailbox = mailboxName.substring(0, lastDelimiter);
                 if (!mailboxes.contains(parentMailbox)) {
-                    respond(responder, expression, parentMailbox, false,
-                            mailboxes, mailboxResponses);
+                    respond(responder, expression, parentMailbox, false, mailboxes, mailboxResponses);
                 }
             }
         }
@@ -135,8 +143,7 @@ public class LSubProcessor extends Abstr
      *            IMAP reference name, possibly null
      */
     private void respondWithHierarchyDelimiter(final Responder responder) {
-        final LSubResponse response = new LSubResponse("",
-                ImapConstants.HIERARCHY_DELIMITER, true);
+        final LSubResponse response = new LSubResponse("", true);
         responder.respond(response);
     }
 }



---------------------------------------------------------------------
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