james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r1103358 - in /james/imap/trunk: api/src/main/java/org/apache/james/imap/api/process/ message/src/test/java/org/apache/james/imap/encode/ processor/src/main/java/org/apache/james/imap/processor/ processor/src/test/java/org/apache/james/imap...
Date Sun, 15 May 2011 12:57:43 GMT
Author: norman
Date: Sun May 15 12:57:43 2011
New Revision: 1103358

URL: http://svn.apache.org/viewvc?rev=1103358&view=rev
Log:
make it more clear howto support many namespaces. Related to MAILBOX-11

Modified:
    james/imap/trunk/api/src/main/java/org/apache/james/imap/api/process/ImapSession.java
    james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/FakeImapSession.java
    james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/NamespaceProcessor.java
    james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/ListProcessorTest.java
    james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/NamespaceProcessorTest.java
    james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerAdded.java
    james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java

Modified: james/imap/trunk/api/src/main/java/org/apache/james/imap/api/process/ImapSession.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/api/src/main/java/org/apache/james/imap/api/process/ImapSession.java?rev=1103358&r1=1103357&r2=1103358&view=diff
==============================================================================
--- james/imap/trunk/api/src/main/java/org/apache/james/imap/api/process/ImapSession.java
(original)
+++ james/imap/trunk/api/src/main/java/org/apache/james/imap/api/process/ImapSession.java
Sun May 15 12:57:43 2011
@@ -138,6 +138,13 @@ public interface ImapSession {
     public void popLineHandler();
     
     /**
+     * Return true if multiple namespaces are supported
+     * 
+     * @return multipleNamespaces
+     */
+    public boolean supportMultipleNamespaces();
+    
+    /**
      * Return true if the login / authentication via plain username / password is
      * disallowed
      * 

Modified: james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/FakeImapSession.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/FakeImapSession.java?rev=1103358&r1=1103357&r2=1103358&view=diff
==============================================================================
--- james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/FakeImapSession.java
(original)
+++ james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/FakeImapSession.java
Sun May 15 12:57:43 2011
@@ -111,13 +111,10 @@ public class FakeImapSession implements 
         return false;
     }
 
-    public void pushLineHandler(ImapLineHandler lineHandler) {
-        // TODO Auto-generated method stub
-        
+    public void pushLineHandler(ImapLineHandler lineHandler) {        
     }
 
     public void popLineHandler() {
-        // TODO Auto-generated method stub
         
     }
 
@@ -129,4 +126,8 @@ public class FakeImapSession implements 
         return false;
     }
 
+    public boolean supportMultipleNamespaces() {
+        return false;
+    }
+
 }

Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/NamespaceProcessor.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/NamespaceProcessor.java?rev=1103358&r1=1103357&r2=1103358&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/NamespaceProcessor.java
(original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/NamespaceProcessor.java
Sun May 15 12:57:43 2011
@@ -47,9 +47,9 @@ public class NamespaceProcessor extends 
     @Override
     protected void doProcess(NamespaceRequest request, ImapSession session, String tag, ImapCommand
command, Responder responder) {
         final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session);
-        final List<NamespaceResponse.Namespace> personalNamespaces = buildPersonalNamespaces(mailboxSession);
-        final List<NamespaceResponse.Namespace> otherUsersNamespaces = buildOtherUsersSpaces(mailboxSession);
-        final List<NamespaceResponse.Namespace> sharedNamespaces = buildSharedNamespaces(mailboxSession);
+        final List<NamespaceResponse.Namespace> personalNamespaces = buildPersonalNamespaces(mailboxSession,
session);
+        final List<NamespaceResponse.Namespace> otherUsersNamespaces = buildOtherUsersSpaces(mailboxSession,
session);
+        final List<NamespaceResponse.Namespace> sharedNamespaces = buildSharedNamespaces(mailboxSession,
session);
         final NamespaceResponse response = new NamespaceResponse(personalNamespaces, otherUsersNamespaces,
sharedNamespaces);
         responder.respond(response);
         unsolicitedResponses(session, responder, false);
@@ -63,16 +63,20 @@ public class NamespaceProcessor extends 
      *            not null
      * @return personal namespaces, not null
      */
-    private List<NamespaceResponse.Namespace> buildPersonalNamespaces(final MailboxSession
mailboxSession) {
+    private List<NamespaceResponse.Namespace> buildPersonalNamespaces(final MailboxSession
mailboxSession, ImapSession session) {
         final List<NamespaceResponse.Namespace> personalSpaces = new ArrayList<NamespaceResponse.Namespace>();
-        personalSpaces.add(new NamespaceResponse.Namespace(mailboxSession.getPersonalSpace(),
mailboxSession.getPathDelimiter()));
+        String personal = "";
+        if (session.supportMultipleNamespaces()) {
+            personal = mailboxSession.getPersonalSpace();
+        }
+        personalSpaces.add(new NamespaceResponse.Namespace(personal, mailboxSession.getPathDelimiter()));
         return personalSpaces;
     }
 
-    private List<NamespaceResponse.Namespace> buildOtherUsersSpaces(final MailboxSession
mailboxSession) {
+    private List<NamespaceResponse.Namespace> buildOtherUsersSpaces(final MailboxSession
mailboxSession,  ImapSession session) {
         final String otherUsersSpace = mailboxSession.getOtherUsersSpace();
         final List<NamespaceResponse.Namespace> otherUsersSpaces;
-        if (otherUsersSpace == null) {
+        if (session.supportMultipleNamespaces() == false || otherUsersSpace == null) {
             otherUsersSpaces = null;
         } else {
             otherUsersSpaces = new ArrayList<NamespaceResponse.Namespace>(1);
@@ -81,10 +85,10 @@ public class NamespaceProcessor extends 
         return otherUsersSpaces;
     }
 
-    private List<NamespaceResponse.Namespace> buildSharedNamespaces(final MailboxSession
mailboxSession) {
+    private List<NamespaceResponse.Namespace> buildSharedNamespaces(final MailboxSession
mailboxSession,  ImapSession session) {
         List<NamespaceResponse.Namespace> sharedNamespaces = null;
         final Collection<String> sharedSpaces = mailboxSession.getSharedSpaces();
-        if (!sharedSpaces.isEmpty()) {
+        if (session.supportMultipleNamespaces() && !sharedSpaces.isEmpty()) {
             sharedNamespaces = new ArrayList<NamespaceResponse.Namespace>(sharedSpaces.size());
             for (String space : sharedSpaces) {
                 sharedNamespaces.add(new NamespaceResponse.Namespace(space, mailboxSession.getPathDelimiter()));

Modified: james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/ListProcessorTest.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/ListProcessorTest.java?rev=1103358&r1=1103357&r2=1103358&view=diff
==============================================================================
--- james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/ListProcessorTest.java
(original)
+++ james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/ListProcessorTest.java
Sun May 15 12:57:43 2011
@@ -25,6 +25,7 @@ import org.apache.james.imap.api.process
 import org.apache.james.imap.api.process.ImapSession;
 import org.apache.james.imap.api.process.MailboxType;
 import org.apache.james.imap.message.response.ListResponse;
+import org.apache.james.mailbox.MailboxConstants;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxMetaData;
 import org.apache.james.mailbox.MailboxPath;
@@ -80,7 +81,7 @@ public class ListProcessorTest  {
             boolean marked, boolean unmarked, boolean hasChildren,
             boolean hasNoChildren, char hierarchyDelimiter, String mailboxName) {
         return new ListResponse(noinferior, noselect, marked, unmarked,
-                hasChildren, hasNoChildren, mailboxName, hierarchyDelimiter);
+                hasChildren, hasNoChildren, MailboxConstants.USER_NAMESPACE + MailboxConstants.DEFAULT_DELIMITER
+ mailboxName, hierarchyDelimiter);
     }
 
     void setUpResult(final MailboxMetaData.Children children, final MailboxMetaData.Selectability
selectability,

Modified: james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/NamespaceProcessorTest.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/NamespaceProcessorTest.java?rev=1103358&r1=1103357&r2=1103358&view=diff
==============================================================================
--- james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/NamespaceProcessorTest.java
(original)
+++ james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/NamespaceProcessorTest.java
Sun May 15 12:57:43 2011
@@ -84,6 +84,7 @@ public class NamespaceProcessorTest {
     @Test
     public void testNamespaceResponseShouldContainPersonalAndUserSpaces() throws Exception
{
         mockery.checking (new Expectations() {{
+            allowing(imapSessionStub).supportMultipleNamespaces(); will(returnValue(true));
             allowing(imapSessionStub).getAttribute(ImapSessionUtils.MAILBOX_SESSION_ATTRIBUTE_SESSION_KEY);
will(returnValue(mailboxSessionStub));
             allowing(mailboxSessionStub).getPersonalSpace(); will(returnValue(PERSONAL_PREFIX));
             allowing(mailboxSessionStub).getOtherUsersSpace(); will(returnValue(USERS_PREFIX));
@@ -109,6 +110,7 @@ public class NamespaceProcessorTest {
     @Test
     public void testNamespaceResponseShouldContainSharedSpaces() throws Exception {
         mockery.checking (new Expectations() {{
+            allowing(imapSessionStub).supportMultipleNamespaces(); will(returnValue(true));
             allowing(imapSessionStub).getAttribute(ImapSessionUtils.MAILBOX_SESSION_ATTRIBUTE_SESSION_KEY);
will(returnValue(mailboxSessionStub));
             allowing(mailboxSessionStub).getPersonalSpace(); will(returnValue(PERSONAL_PREFIX));
             allowing(mailboxSessionStub).getOtherUsersSpace(); will(returnValue(USERS_PREFIX));

Modified: james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerAdded.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerAdded.java?rev=1103358&r1=1103357&r2=1103358&view=diff
==============================================================================
--- james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerAdded.java
(original)
+++ james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerAdded.java
Sun May 15 12:57:43 2011
@@ -19,9 +19,8 @@
 
 package org.apache.james.imap.processor.base;
 
-import java.util.HashMap;
+import java.util.Date;
 import java.util.List;
-import java.util.Map;
 
 import javax.mail.Flags;
 
@@ -46,9 +45,34 @@ public class FakeMailboxListenerAdded ex
         return uids;
     }
 
-    @Override
-    public Map<Long, Flags> getFlags() {
-        return new HashMap<Long, Flags>();
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.mailbox.MailboxListener.Added#getMetaData(long)
+     */
+    public MessageMetaData getMetaData(long uid) {
+        return new MessageMetaData() {
+            
+            public long getUid() {
+                // TODO Auto-generated method stub
+                return 0;
+            }
+            
+            public long getSize() {
+                // TODO Auto-generated method stub
+                return 0;
+            }
+            
+            public Date getInternalDate() {
+                // TODO Auto-generated method stub
+                return null;
+            }
+            
+            public Flags getFlags() {
+                // TODO Auto-generated method stub
+                return null;
+            }
+        };
     }
 
 

Modified: james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java?rev=1103358&r1=1103357&r2=1103358&view=diff
==============================================================================
--- james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
(original)
+++ james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
Sun May 15 12:57:43 2011
@@ -184,6 +184,10 @@ public class MailboxEventAnalyserTest {
             // TODO Auto-generated method stub
             return false;
         }
+
+        public boolean supportMultipleNamespaces() {
+            return false;
+        }
     };
     
 



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