james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r1092665 - in /james/mailbox/trunk: api/src/main/java/org/apache/james/mailbox/ store/src/main/java/org/apache/james/mailbox/store/
Date Fri, 15 Apr 2011 11:26:58 GMT
Author: norman
Date: Fri Apr 15 11:26:58 2011
New Revision: 1092665

URL: http://svn.apache.org/viewvc?rev=1092665&view=rev
Log:
Make it possible to see if the MailboxSession was created by the "System" of because of a
user logged in. See MAILBOX-54

Modified:
    james/mailbox/trunk/api/src/main/java/org/apache/james/mailbox/MailboxSession.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/SimpleMailboxSession.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java

Modified: james/mailbox/trunk/api/src/main/java/org/apache/james/mailbox/MailboxSession.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/api/src/main/java/org/apache/james/mailbox/MailboxSession.java?rev=1092665&r1=1092664&r2=1092665&view=diff
==============================================================================
--- james/mailbox/trunk/api/src/main/java/org/apache/james/mailbox/MailboxSession.java (original)
+++ james/mailbox/trunk/api/src/main/java/org/apache/james/mailbox/MailboxSession.java Fri
Apr 15 11:26:58 2011
@@ -31,6 +31,26 @@ import org.slf4j.Logger;
  */
 public interface MailboxSession {
 
+
+    public static enum SessionType {
+        /**
+         * Session was created via the System
+         */
+        System,
+        
+        /**
+         * Session belongs to a specific user which was authenticated somehow
+         */
+        User
+    }
+    
+    /**
+     * Return if the {@link MailboxSession} is of type {@link SessionType#User} or {@link
SessionType#System}
+     * 
+     * @return type
+     */
+    public SessionType getType();
+    
     /**
      * Gets the session ID.
      * 

Modified: james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/SimpleMailboxSession.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/SimpleMailboxSession.java?rev=1092665&r1=1092664&r2=1092665&view=diff
==============================================================================
--- james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/SimpleMailboxSession.java
(original)
+++ james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/SimpleMailboxSession.java
Fri Apr 15 11:26:58 2011
@@ -57,20 +57,23 @@ public class SimpleMailboxSession implem
     
     private final char pathSeparator;
 
+    private final SessionType type;
+
+    
     public SimpleMailboxSession(final long sessionId, final String userName, final String
password,
-            final Logger log, final List<Locale> localePreferences, char pathSeparator)
{
-        this(sessionId, userName, password, log, localePreferences, new ArrayList<String>(),
null, pathSeparator);
+            final Logger log, final List<Locale> localePreferences, char pathSeparator,
SessionType type) {
+        this(sessionId, userName, password, log, localePreferences, new ArrayList<String>(),
null, pathSeparator, type);
     }
 
     public SimpleMailboxSession(final long sessionId, final String userName, final String
password,
-            final Logger log, final List<Locale> localePreferences, List<String>
sharedSpaces, String otherUsersSpace, char pathSeparator) {
+            final Logger log, final List<Locale> localePreferences, List<String>
sharedSpaces, String otherUsersSpace, char pathSeparator, SessionType type) {
         this.sessionId = sessionId;
         this.log = log;
         this.userName = userName;
         this.password = password;
         this.otherUsersSpace = otherUsersSpace;
         this.sharedSpaces = sharedSpaces;
-
+        this.type = type;
         if (otherUsersSpace == null && (sharedSpaces == null || sharedSpaces.isEmpty()))
{
             this.personalSpace = "";
         } else {
@@ -192,8 +195,16 @@ public class SimpleMailboxSession implem
     /**
      * @see org.apache.james.mailbox.MailboxSession#getPathDelimiter()
      */
-	public char getPathDelimiter() {
-		return pathSeparator;
-	}
+    public char getPathDelimiter() {
+        return pathSeparator;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.mailbox.MailboxSession#getType()
+     */
+    public SessionType getType() {
+        return type;
+    }
 
 }

Modified: james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java?rev=1092665&r1=1092664&r2=1092665&view=diff
==============================================================================
--- james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
(original)
+++ james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
Fri Apr 15 11:26:58 2011
@@ -42,6 +42,7 @@ import org.apache.james.mailbox.RequestA
 import org.apache.james.mailbox.StandardMailboxMetaDataComparator;
 import org.apache.james.mailbox.MailboxMetaData.Selectability;
 import org.apache.james.mailbox.MailboxPathLocker.LockAwareExecution;
+import org.apache.james.mailbox.MailboxSession.SessionType;
 import org.apache.james.mailbox.store.mail.MailboxMapper;
 import org.apache.james.mailbox.store.mail.MailboxMapperFactory;
 import org.apache.james.mailbox.store.mail.UidProvider;
@@ -140,7 +141,7 @@ public abstract class StoreMailboxManage
      * @see org.apache.james.mailbox.MailboxManager#createSystemSession(java.lang.String,
org.slf4j.Logger)
      */
     public MailboxSession createSystemSession(String userName, Logger log) {
-        return createSession(userName, null, log);
+        return createSession(userName, null, log, SessionType.System);
     }
 
     /**
@@ -150,8 +151,8 @@ public abstract class StoreMailboxManage
      * @param log
      * @return session
      */
-    private MailboxSession createSession(String userName, String password, Logger log) {
-        return new SimpleMailboxSession(randomId(), userName, password, log, new ArrayList<Locale>(),
getDelimiter());
+    private MailboxSession createSession(String userName, String password, Logger log, SessionType
type) {
+        return new SimpleMailboxSession(randomId(), userName, password, log, new ArrayList<Locale>(),
getDelimiter(), type);
     }
 
     /**
@@ -188,7 +189,7 @@ public abstract class StoreMailboxManage
      */
     public MailboxSession login(String userid, String passwd, Logger log) throws BadCredentialsException,
MailboxException {
         if (login(userid, passwd)) {
-            return createSession(userid, passwd, log);
+            return createSession(userid, passwd, log, SessionType.User);
         } else {
             throw new BadCredentialsException();
         }



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