james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r773355 - in /james/imap/trunk: mailbox/src/main/java/org/apache/james/imap/mailbox/ mailbox/src/main/java/org/apache/james/imap/mailbox/util/ message/src/main/java/org/apache/james/imap/message/response/ processor/src/main/java/org/apache/...
Date Sun, 10 May 2009 15:44:10 GMT
Author: rdonkin
Date: Sun May 10 15:44:09 2009
New Revision: 773355

URL: http://svn.apache.org/viewvc?rev=773355&view=rev
Log:
Allow mailboxes to use session implementation to describe their namespace support. Note that
until IMAP-70 is completed, there may be some inconsistencies if Mailbox implementations do
not use the standard deliminators. IMAP-80 https://issues.apache.org/jira/browse/IMAP-80

Added:
    james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/SimpleMailboxNamespace.java
  (with props)
Modified:
    james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxSession.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/NamespaceResponse.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/NamespaceProcessorTest.java
    james/imap/trunk/store/src/main/java/org/apache/james/imap/store/SimpleMailboxSession.java
    james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailboxManager.java
    james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java
    james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailboxSession.java

Modified: james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxSession.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxSession.java?rev=773355&r1=773354&r2=773355&view=diff
==============================================================================
--- james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxSession.java
(original)
+++ james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxSession.java
Sun May 10 15:44:09 2009
@@ -19,6 +19,8 @@
 
 package org.apache.james.imap.mailbox;
 
+import java.util.Collection;
+
 import org.apache.commons.logging.Log;
 
 /**
@@ -68,4 +70,51 @@
          */
         public String getUserName();
     }
+    
+    /**
+     * Gets the <a href='http://www.isi.edu/in-notes/rfc2342.txt' rel='tag'>RFC 2342</a>

+     * personal namespace for the current session.
+     * Note that though servers may offer multiple personal namespaces,
+     * support is not offered through this API. This decision may be revised if reasonable
+     * use cases emerge.
+     * @return Personal Namespace, not null
+     */
+    public Namespace getPersonalSpace();
+    
+    /**
+     * Gets the <a href='http://www.isi.edu/in-notes/rfc2342.txt' rel='tag'>RFC 2342</a>

+     * other users namespace for the current session.
+     * Note that though servers may offer multiple other users namespaces,
+     * support is not offered through this API. This decision may be revised if reasonable
+     * use cases emerge.
+     * @return Other Users Namespace 
+     * or null when there is non available
+     */
+    public Namespace getOtherUsersSpace();
+    
+    /**
+     * Iterates the <a href='http://www.isi.edu/in-notes/rfc2342.txt' rel='tag'>RFC
2342</a>
+     * Shared Namespaces available for the current session.
+     * @return not null though possibly empty
+     */
+    public Collection<Namespace> getSharedSpaces();
+    
+    /**
+     * Describes a <a href='http://www.isi.edu/in-notes/rfc2342.txt' rel='tag'>RFC
2342</a> namespace.
+     */
+    public interface Namespace {
+        
+        /**
+         * Gets the hierachy deliminator for this namespace.
+         * @return character that delimits this hierarchy
+         */
+        public char getDeliminator();
+        
+        /**
+         * Gets the prefix for this namespace.
+         * Clients will prefix 
+         * @return not null, though may be empty
+         */
+        public String getPrefix();
+    }
 }

Added: james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/SimpleMailboxNamespace.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/SimpleMailboxNamespace.java?rev=773355&view=auto
==============================================================================
--- james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/SimpleMailboxNamespace.java
(added)
+++ james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/SimpleMailboxNamespace.java
Sun May 10 15:44:09 2009
@@ -0,0 +1,52 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.imap.mailbox.util;
+
+import org.apache.james.imap.mailbox.MailboxSession;
+
+/**
+ * Immutable implementation.
+ */
+public class SimpleMailboxNamespace implements MailboxSession.Namespace {
+
+    private final char deliminator;
+    private final String prefix;
+
+    public SimpleMailboxNamespace(final char deliminator, final String prefix) {
+        super();
+        this.deliminator = deliminator;
+        this.prefix = prefix;
+    }
+
+    /**
+     * @see {@link MailboxSession.Namespace#getDeliminator()}
+     */
+    public char getDeliminator() {
+        return deliminator;
+    }
+
+    /**
+     * @see {@link MailboxSession.Namespace#getPrefix()}
+     */
+    public String getPrefix() {
+        return prefix;
+    }
+
+}

Propchange: james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/SimpleMailboxNamespace.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/NamespaceResponse.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/NamespaceResponse.java?rev=773355&r1=773354&r2=773355&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/NamespaceResponse.java
(original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/NamespaceResponse.java
Sun May 10 15:44:09 2009
@@ -98,5 +98,89 @@
         public String getPrefix() {
             return prefix;
         }
+
+        @Override
+        public int hashCode() {
+            final int PRIME = 31;
+            int result = 1;
+            result = PRIME * result + deliminator;
+            result = PRIME * result + ((prefix == null) ? 0 : prefix.hashCode());
+            return result;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj)
+                return true;
+            if (obj == null)
+                return false;
+            if (getClass() != obj.getClass())
+                return false;
+            final Namespace other = (Namespace) obj;
+            if (deliminator != other.deliminator)
+                return false;
+            if (prefix == null) {
+                if (other.prefix != null)
+                    return false;
+            } else if (!prefix.equals(other.prefix))
+                return false;
+            return true;
+        }
+        
+        @Override
+        public String toString() {
+            return "Namespace [prefix=" + prefix + ", delim=" + deliminator + "]";
+        }
+    }
+
+    @Override
+    public int hashCode() {
+        final int PRIME = 31;
+        int result = 1;
+        result = PRIME * result + ((personal == null) ? 0 : personal.hashCode());
+        result = PRIME * result + ((shared == null) ? 0 : shared.hashCode());
+        result = PRIME * result + ((users == null) ? 0 : users.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        final NamespaceResponse other = (NamespaceResponse) obj;
+        if (personal == null) {
+            if (other.personal != null)
+                return false;
+        } else if (!personal.equals(other.personal))
+            return false;
+        if (shared == null) {
+            if (other.shared != null)
+                return false;
+        } else if (!shared.equals(other.shared))
+            return false;
+        if (users == null) {
+            if (other.users != null)
+                return false;
+        } else if (!users.equals(other.users))
+            return false;
+        return true;
+    }
+
+    /**
+     * Renders object suitably for logging.
+     * @return a <code>String</code> representation 
+     * of this object.
+     */
+    public String toString()
+    {
+        return "NamespaceResponse ["  
+            + "personal = " + this.personal + " "
+            + "users = " + this.users + " "
+            + "shared = " + this.shared + " "
+            + " ]";
     }
 }

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=773355&r1=773354&r2=773355&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 10 15:44:09 2009
@@ -19,6 +19,7 @@
 package org.apache.james.imap.processor;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 
 import org.apache.james.imap.api.ImapCommand;
@@ -29,33 +30,71 @@
 import org.apache.james.imap.api.process.ImapSession;
 import org.apache.james.imap.message.request.NamespaceRequest;
 import org.apache.james.imap.message.response.NamespaceResponse;
-import org.apache.james.imap.mailbox.MailboxManager;
 import org.apache.james.imap.mailbox.MailboxManagerProvider;
+import org.apache.james.imap.mailbox.MailboxSession;
+import org.apache.james.imap.mailbox.MailboxSession.Namespace;
+import org.apache.james.imap.processor.base.ImapSessionUtils;
 
 /**
  * Processes a NAMESPACE command into a suitable set of responses.
  */
 public class NamespaceProcessor extends AbstractMailboxProcessor {
-
-    private final NamespaceResponse response;
     
     public NamespaceProcessor(ImapProcessor next,
             MailboxManagerProvider mailboxManagerProvider,
             StatusResponseFactory factory) {
         super(next, mailboxManagerProvider, factory);
-        final List<NamespaceResponse.Namespace> personalSpaces = new ArrayList<NamespaceResponse.Namespace>();
-        personalSpaces.add(new NamespaceResponse.Namespace("", MailboxManager.HIERARCHY_DELIMITER));
-        response = new NamespaceResponse(personalSpaces, null, null);
     }
 
     @Override
     protected void doProcess(ImapRequest message, ImapSession session,
             String tag, ImapCommand command, Responder responder) {
+        final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session);
+        final List<NamespaceResponse.Namespace> personalSpaces = buildPersonalNamespaces(mailboxSession);
+        
+        final MailboxSession.Namespace otherUsersSpace = mailboxSession.getOtherUsersSpace();
+        final List<NamespaceResponse.Namespace> otherUsersSpaces = buildOtherUsersSpaces(otherUsersSpace);
+        
+        final Collection<Namespace> sharedSpaces = mailboxSession.getSharedSpaces();
+        final List<NamespaceResponse.Namespace> sharedNamespaces;
+        if (sharedSpaces.isEmpty()) {
+            sharedNamespaces = null;
+        } else {
+            sharedNamespaces = new ArrayList<NamespaceResponse.Namespace>(sharedSpaces.size());
+            for (MailboxSession.Namespace space: sharedSpaces) {
+                sharedNamespaces.add(new NamespaceResponse.Namespace(space.getPrefix(), space.getDeliminator()));
+            }    
+        }
+        
+        final NamespaceResponse response = new NamespaceResponse(personalSpaces, otherUsersSpaces,
sharedNamespaces);
         responder.respond(response);
         unsolicitedResponses(session, responder, false);
         okComplete(command, tag, responder);
     }
 
+    private List<NamespaceResponse.Namespace> buildOtherUsersSpaces(final MailboxSession.Namespace
otherUsersSpace) {
+        final List<NamespaceResponse.Namespace> otherUsersSpaces;
+        if (otherUsersSpace == null) {
+            otherUsersSpaces = null;
+        } else {
+            otherUsersSpaces = new ArrayList<NamespaceResponse.Namespace>(1);
+            otherUsersSpaces.add(new NamespaceResponse.Namespace(otherUsersSpace.getPrefix(),
otherUsersSpace.getDeliminator()));
+        }
+        return otherUsersSpaces;
+    }
+
+    /**
+     * Builds personal namespaces from the session.
+     * @param mailboxSession not null
+     * @return personal namespaces, not null
+     */
+    private List<NamespaceResponse.Namespace> buildPersonalNamespaces(final MailboxSession
mailboxSession) {
+        final MailboxSession.Namespace personalNamespace = mailboxSession.getPersonalSpace();
+        final List<NamespaceResponse.Namespace> personalSpaces = new ArrayList<NamespaceResponse.Namespace>();
+        personalSpaces.add(new NamespaceResponse.Namespace(personalNamespace.getPrefix(),
personalNamespace.getDeliminator()));
+        return personalSpaces;
+    }
+
     @Override
     protected boolean isAcceptable(ImapMessage message) {
         return message instanceof NamespaceRequest;

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=773355&r1=773354&r2=773355&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 10 15:44:09 2009
@@ -18,23 +18,82 @@
  ****************************************************************/
 package org.apache.james.imap.processor;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
 import org.apache.james.imap.api.ImapCommand;
 import org.apache.james.imap.api.ImapMessage;
+import org.apache.james.imap.api.ImapSessionState;
+import org.apache.james.imap.api.display.HumanReadableTextKey;
+import org.apache.james.imap.api.message.response.StatusResponse;
 import org.apache.james.imap.api.message.response.StatusResponseFactory;
+import org.apache.james.imap.api.message.response.StatusResponse.ResponseCode;
 import org.apache.james.imap.api.process.ImapProcessor;
+import org.apache.james.imap.api.process.ImapSession;
+import org.apache.james.imap.api.process.ImapProcessor.Responder;
 import org.apache.james.imap.mailbox.MailboxManagerProvider;
+import org.apache.james.imap.mailbox.MailboxSession;
 import org.apache.james.imap.message.request.NamespaceRequest;
+import org.apache.james.imap.message.response.NamespaceResponse;
+import org.apache.james.imap.processor.base.ImapSessionUtils;
+import org.jmock.Expectations;
 import org.jmock.integration.junit3.MockObjectTestCase;
 
 public class NamespaceProcessorTest extends MockObjectTestCase {
 
+    private static final char SHARED_SPACE_DELIMINATOR = '&';
+    private static final String SHARED_PREFIX = "SharedPrefix";
+    private static final String USERS_PREFIX = "UsersPrefix";
+    private static final String PERSONAL_PREFIX = "PersonalPrefix";
+    private static final char USERS_DELIMINATOR = '%';
+    private static final char PERSONAL_DELIMINATOR = '$';
+    
+    
     NamespaceProcessor subject;
-    StatusResponseFactory mockStatusResponse;
+    StatusResponseFactory statusResponseStub;
+    ImapSession imapSessionStub;
+    MailboxSession mailboxSessionStub;
+    MailboxSession.Namespace personalSpaceStub;
+    MailboxSession.Namespace usersSpaceStub;
+    MailboxSession.Namespace sharedSpaceStub;
+    NamespaceRequest namespaceRequest;
+    Collection<MailboxSession.Namespace> sharedSpaces;
     
     protected void setUp() throws Exception {
         super.setUp();
-        mockStatusResponse = mock(StatusResponseFactory.class);
-        subject = new NamespaceProcessor(mock(ImapProcessor.class), mock(MailboxManagerProvider.class),
mockStatusResponse);
+        sharedSpaces = new ArrayList<MailboxSession.Namespace>();
+        statusResponseStub = mock(StatusResponseFactory.class);
+        final MailboxManagerProvider mailboxManagerStub = mock(MailboxManagerProvider.class);
+        subject = new NamespaceProcessor(mock(ImapProcessor.class), mailboxManagerStub, statusResponseStub);
+        imapSessionStub = mock(ImapSession.class);
+        mailboxSessionStub = mock(MailboxSession.class);
+        personalSpaceStub = mock(MailboxSession.Namespace.class, "PersonalNamespace");
+        usersSpaceStub = mock(MailboxSession.Namespace.class, "UsersNamespace");
+        sharedSpaceStub = mock(MailboxSession.Namespace.class, "SharedNamespace");
+     
+        namespaceRequest = new NamespaceRequest(ImapCommand.anyStateCommand("Name"), "TAG");
+        
+        checking (new Expectations() {{
+            allowing(imapSessionStub).getAttribute(ImapSessionUtils.MAILBOX_SESSION_ATTRIBUTE_SESSION_KEY);
will(returnValue(mailboxSessionStub));
+            allowing(personalSpaceStub).getDeliminator(); will(returnValue(PERSONAL_DELIMINATOR));
+            allowing(personalSpaceStub).getPrefix(); will(returnValue(PERSONAL_PREFIX));
+            allowing(usersSpaceStub).getDeliminator(); will(returnValue(USERS_DELIMINATOR));
+            allowing(usersSpaceStub).getPrefix(); will(returnValue(USERS_PREFIX));
+            allowing(sharedSpaceStub).getDeliminator(); will(returnValue(SHARED_SPACE_DELIMINATOR));
+            allowing(sharedSpaceStub).getPrefix(); will(returnValue(SHARED_PREFIX));
+            allowing(mailboxSessionStub).getPersonalSpace(); will(returnValue(personalSpaceStub));
+            allowing(mailboxSessionStub).getOtherUsersSpace(); will(returnValue(usersSpaceStub));
+            allowing(mailboxSessionStub).getSharedSpaces();will(returnValue(sharedSpaces));
+            allowing(imapSessionStub).getState();will(returnValue(ImapSessionState.AUTHENTICATED));
+            allowing(statusResponseStub).taggedOk(
+                    with(any(String.class)), with(any(ImapCommand.class)), 
+                    with(any(HumanReadableTextKey.class)), with(any(ResponseCode.class)));
will(returnValue(mock(StatusResponse.class)));
+            ignoring(imapSessionStub);
+            ignoring(mailboxSessionStub);
+            ignoring(mailboxManagerStub);
+            ignoring(statusResponseStub);
+        }});
     }
 
     protected void tearDown() throws Exception {
@@ -43,6 +102,47 @@
     
     public void testShouldAcceptNamespaceRequests() throws Exception {
         assertFalse(subject.isAcceptable(mock(ImapMessage.class)));
-        assertTrue(subject.isAcceptable(new NamespaceRequest(ImapCommand.anyStateCommand("Name"),
"TAG")));
+        assertTrue(subject.isAcceptable(namespaceRequest));
+    }
+    
+    public void testNamespaceResponseShouldContainPersonalAndUserSpaces() throws Exception
{
+        final NamespaceResponse response = buildResponse(null);
+        
+        final Responder responderMock = expectResponse(response);
+        
+        subject.doProcess(namespaceRequest, responderMock, imapSessionStub);
+    }
+    
+    public void testNamespaceResponseShouldContainSharedSpaces() throws Exception {
+        this.sharedSpaces.add(sharedSpaceStub);
+        
+        
+        final List<NamespaceResponse.Namespace> sharedSpaces = new ArrayList<NamespaceResponse.Namespace>();
+        sharedSpaces.add(new NamespaceResponse.Namespace(SHARED_PREFIX, SHARED_SPACE_DELIMINATOR));
+        final NamespaceResponse response = buildResponse(sharedSpaces);
+        
+        final Responder responderMock = expectResponse(response);
+        
+        subject.doProcess(namespaceRequest, responderMock, imapSessionStub);
+    }
+
+    private NamespaceResponse buildResponse(final List<NamespaceResponse.Namespace>
sharedSpaces) {
+        final List<NamespaceResponse.Namespace> personalSpaces = new ArrayList<NamespaceResponse.Namespace>();
+        personalSpaces.add(new NamespaceResponse.Namespace(PERSONAL_PREFIX, PERSONAL_DELIMINATOR));
+        final List<NamespaceResponse.Namespace> otherUsersSpaces = new ArrayList<NamespaceResponse.Namespace>();
+        otherUsersSpaces.add(new NamespaceResponse.Namespace(USERS_PREFIX, USERS_DELIMINATOR));

+        
+        final NamespaceResponse response = new NamespaceResponse(personalSpaces, otherUsersSpaces,
sharedSpaces);
+        return response;
+    }
+
+    private Responder expectResponse(final NamespaceResponse response) {
+        final Responder responderMock = mock(Responder.class);
+        checking(new Expectations(){{
+            oneOf(responderMock).respond(with(equal(response)));
+            oneOf(responderMock).respond(with(any(StatusResponse.class)));
+        }});
+        return responderMock;
     }
 }
+

Modified: james/imap/trunk/store/src/main/java/org/apache/james/imap/store/SimpleMailboxSession.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/store/src/main/java/org/apache/james/imap/store/SimpleMailboxSession.java?rev=773355&r1=773354&r2=773355&view=diff
==============================================================================
--- james/imap/trunk/store/src/main/java/org/apache/james/imap/store/SimpleMailboxSession.java
(original)
+++ james/imap/trunk/store/src/main/java/org/apache/james/imap/store/SimpleMailboxSession.java
Sun May 10 15:44:09 2009
@@ -19,14 +19,25 @@
 
 package org.apache.james.imap.store;
 
+import java.util.ArrayList;
+import java.util.Collection;
+
 import org.apache.commons.logging.Log;
 import org.apache.james.imap.mailbox.MailboxSession;
+import org.apache.james.imap.mailbox.util.SimpleMailboxNamespace;
 
 /**
  * Describes a mailbox session.
  */
 public class SimpleMailboxSession implements MailboxSession, MailboxSession.User {
 
+
+    private final Collection<Namespace> sharedSpaces;
+
+    private final Namespace otherUsersSpace;
+
+    private final Namespace personalSpace;
+    
     private final long sessionId;
     
     private final Log log;
@@ -35,11 +46,14 @@
     
     private boolean open;
 
-    public SimpleMailboxSession(final long sessionId, final String userName, final Log log)
{
+    public SimpleMailboxSession(final long sessionId, final String userName, final Log log,
char deliminator) {
         super();
         this.sessionId = sessionId;
         this.log = log;
         this.userName = userName;
+        sharedSpaces = new ArrayList<Namespace>();
+        otherUsersSpace = null;
+        personalSpace = new SimpleMailboxNamespace(deliminator, "");
     }
 
     public Log getLog() {
@@ -88,4 +102,25 @@
 		return userName;
 	}
 
+    /**
+     * @see {@link MailboxSession#getOtherUsersSpace()}
+     */
+    public Namespace getOtherUsersSpace() {
+        return otherUsersSpace;
+    }
+
+    /**
+     * @see {@link MailboxSession#getPersonalSpace()}
+     */
+    public Namespace getPersonalSpace() {
+        return personalSpace;
+    }
+
+    /**
+     * @see {@link MailboxSession#getSharedSpace()}
+     */
+    public Collection<Namespace> getSharedSpaces() {
+        return sharedSpaces;
+    }
+
 }

Modified: james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailboxManager.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailboxManager.java?rev=773355&r1=773354&r2=773355&view=diff
==============================================================================
--- james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailboxManager.java
(original)
+++ james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailboxManager.java
Sun May 10 15:44:09 2009
@@ -289,7 +289,7 @@
     }
 
     public MailboxSession createSession(String userName, Log log) {
-        return new SimpleMailboxSession(random.nextLong(), userName, log);
+        return new SimpleMailboxSession(random.nextLong(), userName, log, MailboxManager.HIERARCHY_DELIMITER);
     }
 
     public String resolve(final String userName, String mailboxPath) {

Modified: james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java?rev=773355&r1=773354&r2=773355&view=diff
==============================================================================
--- james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java
(original)
+++ james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java
Sun May 10 15:44:09 2009
@@ -341,7 +341,7 @@
     }
 
     public MailboxSession createSession(String userName, Log log) {
-        return new TorqueMailboxSession(random.nextLong(), log, userName);
+        return new TorqueMailboxSession(random.nextLong(), log, userName, MailboxManager.HIERARCHY_DELIMITER);
     }
 
     public String resolve(final String userName, String mailboxPath) {

Modified: james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailboxSession.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailboxSession.java?rev=773355&r1=773354&r2=773355&view=diff
==============================================================================
--- james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailboxSession.java
(original)
+++ james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailboxSession.java
Sun May 10 15:44:09 2009
@@ -19,14 +19,24 @@
 
 package org.apache.james.mailboxmanager.torque;
 
+import java.util.ArrayList;
+import java.util.Collection;
+
 import org.apache.commons.logging.Log;
 import org.apache.james.imap.mailbox.MailboxSession;
+import org.apache.james.imap.mailbox.util.SimpleMailboxNamespace;
 
 /**
  * Describes a mailbox session.
  */
 public class TorqueMailboxSession implements MailboxSession, MailboxSession.User {
 
+    private final Collection<Namespace> sharedSpaces;
+
+    private final Namespace otherUsersSpace;
+
+    private final Namespace personalSpace;
+    
     private final long sessionId;
     
     private final Log log;
@@ -36,11 +46,14 @@
     private boolean open;
 
 
-    public TorqueMailboxSession(final long sessionId, final Log log, final String userName)
{
+    public TorqueMailboxSession(final long sessionId, final Log log, final String userName,
char deliminator) {
         super();
         this.sessionId = sessionId;
         this.log = log;
         this.userName = userName;
+        sharedSpaces = new ArrayList<Namespace>();
+        otherUsersSpace = null;
+        personalSpace = new SimpleMailboxNamespace(deliminator, "");
     }
     
     
@@ -91,5 +104,25 @@
 	public String getUserName() {
 		return userName;
 	}
+    
+    /**
+     * @see {@link MailboxSession#getOtherUsersSpace()}
+     */
+    public Namespace getOtherUsersSpace() {
+        return otherUsersSpace;
+    }
 
+    /**
+     * @see {@link MailboxSession#getPersonalSpace()}
+     */
+    public Namespace getPersonalSpace() {
+        return personalSpace;
+    }
+
+    /**
+     * @see {@link MailboxSession#getSharedSpace()}
+     */
+    public Collection<Namespace> getSharedSpaces() {
+        return sharedSpaces;
+    }
 }



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