james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r770455 - in /james/imap/trunk: mailbox/src/main/java/org/apache/james/imap/mailbox/ processor/src/main/java/org/apache/james/imap/processor/ processor/src/main/java/org/apache/james/imap/processor/base/ processor/src/test/java/org/apache/j...
Date Thu, 30 Apr 2009 21:34:59 GMT
Author: rdonkin
Date: Thu Apr 30 21:34:59 2009
New Revision: 770455

URL: http://svn.apache.org/viewvc?rev=770455&view=rev
Log:
Move user into MailboxSession. User information is a more natural part of mailbox. This will
enable more elegant management of mailbox naming. IMAP-71 https://issues.apache.org/jira/browse/IMAP-71

Modified:
    james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxManager.java
    james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxSession.java
    james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/LoginProcessor.java
    james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/ImapSessionUtils.java
    james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/LSubProcessorTest.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/MailboxManager.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxManager.java?rev=770455&r1=770454&r2=770455&view=diff
==============================================================================
--- james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxManager.java
(original)
+++ james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxManager.java
Thu Apr 30 21:34:59 2009
@@ -98,8 +98,7 @@
      */
     void createMailbox(String mailboxName) throws MailboxException;
 
-    void deleteMailbox(String mailboxName, MailboxSession session)
-            throws MailboxException;
+    void deleteMailbox(String mailboxName, MailboxSession session) throws MailboxException;
 
     /**
      * Renames a mailbox.
@@ -143,11 +142,11 @@
 
     /**
      * Creates a new session.
-     * @param log TODO
-     * 
+     * @param userName the name of the user whose session is being created
+     * @param log context sensitive log
      * @return <code>MailboxSession</code>, not null
      */
-    public MailboxSession createSession(Log log);
+    public MailboxSession createSession(String userName, Log log);
 
     /**
      * Autenticates the given user against the given password.

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=770455&r1=770454&r2=770455&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
Thu Apr 30 21:34:59 2009
@@ -50,4 +50,10 @@
      * @return not null
      */
     public Log getLog();
+    
+    /**
+     * Gets the name of the user executing this session.
+     * @return not null
+     */
+    public String getUserName();
 }

Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/LoginProcessor.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/LoginProcessor.java?rev=770455&r1=770454&r2=770455&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/LoginProcessor.java
(original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/LoginProcessor.java
Thu Apr 30 21:34:59 2009
@@ -63,11 +63,10 @@
             final MailboxManager mailboxManager = getMailboxManager();
             if (mailboxManager.isAuthentic(userid, passwd)) {
                 session.authenticated();
-                final MailboxSession mailboxSession = mailboxManager.createSession(session.getLog());
+                final MailboxSession mailboxSession = mailboxManager.createSession(userid,
session.getLog());
                 session.setAttribute(
                         ImapSessionUtils.MAILBOX_SESSION_ATTRIBUTE_SESSION_KEY,
                         mailboxSession);
-                ImapSessionUtils.setUserName(session, userid);
                 final String inboxName = buildFullName(session, MailboxManager.INBOX);
                 if (mailboxManager.mailboxExists(inboxName)) {
                     session.getLog().debug("INBOX exists. No need to create it.");

Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/ImapSessionUtils.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/ImapSessionUtils.java?rev=770455&r1=770454&r2=770455&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/ImapSessionUtils.java
(original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/ImapSessionUtils.java
Thu Apr 30 21:34:59 2009
@@ -34,14 +34,14 @@
         return result;
     }
 
-    public static String getUserName(final ImapSession session) {
-        final String result = (String) session
-                .getAttribute(MAILBOX_USER_ATTRIBUTE_SESSION_KEY);
+    public static String getUserName(final ImapSession imapSession) {
+        final String result;
+        final MailboxSession mailboxSession = getMailboxSession(imapSession);
+        if (imapSession == null) {
+            result = null;
+        } else {
+            result = mailboxSession.getUserName();
+        }
         return result;
     }
-
-    public static void setUserName(final ImapSession session, final String user) {
-        session.setAttribute(MAILBOX_USER_ATTRIBUTE_SESSION_KEY, user);
-    }
-
 }

Modified: james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/LSubProcessorTest.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/LSubProcessorTest.java?rev=770455&r1=770454&r2=770455&view=diff
==============================================================================
--- james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/LSubProcessorTest.java
(original)
+++ james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/LSubProcessorTest.java
Thu Apr 30 21:34:59 2009
@@ -32,6 +32,7 @@
 import org.apache.james.imap.mailbox.MailboxManager;
 import org.apache.james.imap.mailbox.MailboxManagerProvider;
 import org.apache.james.imap.mailbox.MailboxMetaData;
+import org.apache.james.imap.mailbox.MailboxSession;
 import org.apache.james.imap.message.request.LsubRequest;
 import org.apache.james.imap.message.response.LSubResponse;
 import org.apache.james.imap.processor.LSubProcessor;
@@ -75,6 +76,8 @@
     MailboxMetaData result;
 
     ImapSession session;
+    
+    MailboxSession mailboxSession;
 
     StatusResponseFactory serverResponseFactory;
 
@@ -98,6 +101,7 @@
         statusResponse = mock(StatusResponse.class);
         responderImpl = responder;
         manager = mock(MailboxManager.class);
+        mailboxSession = mock(MailboxSession.class);
         processor = new LSubProcessor(next, provider, serverResponseFactory);
         checking(new Expectations() {{
             atMost(1).of(provider).getMailboxManager(); will(returnValue(manager));
@@ -232,8 +236,9 @@
 
     private void expectSubscriptions() throws Exception {
         checking(new Expectations() {{
-            oneOf(session).getAttribute(
-                    with(equal(ImapSessionUtils.MAILBOX_USER_ATTRIBUTE_SESSION_KEY)));
+            oneOf(session).getAttribute(ImapSessionUtils.MAILBOX_SESSION_ATTRIBUTE_SESSION_KEY);
+                    will(returnValue(mailboxSession));
+            oneOf(mailboxSession).getUserName();
                     will(returnValue(USER));
             oneOf(manager).subscriptions(with(same(USER)));will(returnValue(subscriptions));
    
         }});

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=770455&r1=770454&r2=770455&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
Thu Apr 30 21:34:59 2009
@@ -31,12 +31,15 @@
     
     private final Log log;
 
+    private final String userName;
+    
     private boolean open;
 
-    public SimpleMailboxSession(final long sessionId, final Log log) {
+    public SimpleMailboxSession(final long sessionId, final String userName, final Log log)
{
         super();
         this.sessionId = sessionId;
         this.log = log;
+        this.userName = userName;
     }
 
     public Log getLog() {
@@ -69,4 +72,12 @@
         return retValue;
     }
 
+    /**
+     * Gets the name of the user executing this session.
+     * @return not null
+     */
+	public String getUserName() {
+		return userName;
+	}
+
 }

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=770455&r1=770454&r2=770455&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
Thu Apr 30 21:34:59 2009
@@ -288,8 +288,8 @@
         mailboxes.clear();
     }
 
-    public MailboxSession createSession(Log log) {
-        return new SimpleMailboxSession(random.nextLong(), log);
+    public MailboxSession createSession(String userName, Log log) {
+        return new SimpleMailboxSession(random.nextLong(), userName, log);
     }
 
     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=770455&r1=770454&r2=770455&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
Thu Apr 30 21:34:59 2009
@@ -340,8 +340,8 @@
         return log;
     }
 
-    public MailboxSession createSession(Log log) {
-        return new TorqueMailboxSession(random.nextLong(), log);
+    public MailboxSession createSession(String userName, Log log) {
+        return new TorqueMailboxSession(random.nextLong(), log, userName);
     }
 
     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=770455&r1=770454&r2=770455&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
Thu Apr 30 21:34:59 2009
@@ -31,12 +31,16 @@
     
     private final Log log;
 
+    private final String userName;
+    
     private boolean open;
 
-    public TorqueMailboxSession(final long sessionId, final Log log) {
+
+    public TorqueMailboxSession(final long sessionId, final Log log, final String userName)
{
         super();
         this.sessionId = sessionId;
         this.log = log;
+        this.userName = userName;
     }
     
     
@@ -72,4 +76,13 @@
         return retValue;
     }
 
+
+    /**
+     * Gets the name of the user executing this session.
+     * @return not null
+     */
+	public String getUserName() {
+		return userName;
+	}
+
 }



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