james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joac...@apache.org
Subject svn commit: r481811 - in /james/server/trunk/src: java/org/apache/james/imapserver/ java/org/apache/james/mailboxmanager/manager/ java/org/apache/james/mailboxmanager/repository/ java/org/apache/james/mailboxmanager/torque/ test/org/apache/james/mailbo...
Date Sun, 03 Dec 2006 17:00:08 GMT
Author: joachim
Date: Sun Dec  3 09:00:05 2006
New Revision: 481811

URL: http://svn.apache.org/viewvc?view=rev&rev=481811
Log:
 - INBOX is not autocreated anymore
 - added createInbox(User)

Modified:
    james/server/trunk/src/java/org/apache/james/imapserver/ImapSessionImpl.java
    james/server/trunk/src/java/org/apache/james/mailboxmanager/manager/MailboxManager.java
    james/server/trunk/src/java/org/apache/james/mailboxmanager/manager/MailboxManagerProvider.java
    james/server/trunk/src/java/org/apache/james/mailboxmanager/repository/MailboxManagerMailRepository.java
    james/server/trunk/src/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java
    james/server/trunk/src/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManagerProvider.java
    james/server/trunk/src/test/org/apache/james/mailboxmanager/torque/repository/TorqueMailboxManagerMailRepositoryNativeTestCase.java

Modified: james/server/trunk/src/java/org/apache/james/imapserver/ImapSessionImpl.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/imapserver/ImapSessionImpl.java?view=diff&rev=481811&r1=481810&r2=481811
==============================================================================
--- james/server/trunk/src/java/org/apache/james/imapserver/ImapSessionImpl.java (original)
+++ james/server/trunk/src/java/org/apache/james/imapserver/ImapSessionImpl.java Sun Dec 
3 09:00:05 2006
@@ -209,6 +209,7 @@
                 mailboxManager.close();
             }
             mailboxManager=mailboxManagerProvider.getMailboxManagerInstance(user);
+            mailboxManager.createInbox(user);
         }
         return mailboxManager;
     }

Modified: james/server/trunk/src/java/org/apache/james/mailboxmanager/manager/MailboxManager.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/mailboxmanager/manager/MailboxManager.java?view=diff&rev=481811&r1=481810&r2=481811
==============================================================================
--- james/server/trunk/src/java/org/apache/james/mailboxmanager/manager/MailboxManager.java
(original)
+++ james/server/trunk/src/java/org/apache/james/mailboxmanager/manager/MailboxManager.java
Sun Dec  3 09:00:05 2006
@@ -65,6 +65,10 @@
  */
 
 public interface MailboxManager {
+    
+    public static final char HIERARCHY_DELIMITER='.';
+    
+    public static final String USER_NAMESPACE="#mail";
 
     /**
      * get a session mailbox 
@@ -74,7 +78,8 @@
      * @return
      * @throws MailboxManagerException 
      */
-    MailboxSession getMailboxSession(String mailboxName) throws MailboxManagerException;
+    MailboxSession getMailboxSession(String mailboxName, boolean autoCreate)
+            throws MailboxManagerException;
     
     /**
      * Supports 
@@ -160,6 +165,9 @@
     boolean existsMailbox(String mailboxName) throws MailboxManagerException;
 
     void close();
+
+    // TODO maybe move createInbox to provider
+    boolean createInbox(User user) throws MailboxManagerException;
 
 }
 

Modified: james/server/trunk/src/java/org/apache/james/mailboxmanager/manager/MailboxManagerProvider.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/mailboxmanager/manager/MailboxManagerProvider.java?view=diff&rev=481811&r1=481810&r2=481811
==============================================================================
--- james/server/trunk/src/java/org/apache/james/mailboxmanager/manager/MailboxManagerProvider.java
(original)
+++ james/server/trunk/src/java/org/apache/james/mailboxmanager/manager/MailboxManagerProvider.java
Sun Dec  3 09:00:05 2006
@@ -39,11 +39,14 @@
     
     MailboxSession getInboxSession(User user);
 
-    /** @param authUser the authorized User for checking credentials 
-        @param mailboxName a logical/hierarchical mailbox name **/ 
+    /** 
+     *  @param authUser the authorized User for checking credentials 
+     *  @param mailboxName a logical/hierarchical mailbox name *
+     *  @throws MailboxManagerException 
+     */ 
 
-    MailboxSession getMailboxSession(
-         User authUser, String mailboxName);
+    MailboxSession getMailboxSession(User authUser, String mailboxName,
+            boolean autoCreate) throws MailboxManagerException;
     
     /**
      * removes all data (mailboxes, quota, acls...) that is associated 

Modified: james/server/trunk/src/java/org/apache/james/mailboxmanager/repository/MailboxManagerMailRepository.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/mailboxmanager/repository/MailboxManagerMailRepository.java?view=diff&rev=481811&r1=481810&r2=481811
==============================================================================
--- james/server/trunk/src/java/org/apache/james/mailboxmanager/repository/MailboxManagerMailRepository.java
(original)
+++ james/server/trunk/src/java/org/apache/james/mailboxmanager/repository/MailboxManagerMailRepository.java
Sun Dec  3 09:00:05 2006
@@ -348,6 +348,7 @@
 
                 String inbox = ns.getName() + ns.getHierarchyDelimter()
                         + "INBOX";
+                getMailboxManager().createInbox(user);
                 mailboxSession = getMailboxManager().getImapMailboxSession(
                         inbox);
             }

Modified: james/server/trunk/src/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java?view=diff&rev=481811&r1=481810&r2=481811
==============================================================================
--- james/server/trunk/src/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java
(original)
+++ james/server/trunk/src/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java
Sun Dec  3 09:00:05 2006
@@ -68,8 +68,12 @@
         this.log=log;
     }
     
-    public MailboxSession getMailboxSession(String mailboxName)
-    throws MailboxManagerException {
+    public MailboxSession getMailboxSession(String mailboxName,
+            boolean autoCreate) throws MailboxManagerException {
+        if (autoCreate && !existsMailbox(mailboxName)) {
+            getLog().info("autocreated mailbox  " + mailboxName);
+            createMailbox(mailboxName);
+        }
         return getImapMailboxSession(mailboxName);
     }
     
@@ -80,34 +84,28 @@
         return getImapMailboxSession(mailboxName);
     }
     
+    public boolean createInbox(User user) throws MailboxManagerException {
+        // TODO should access getPersonalDefaultNameSpace...
+        String userInbox=USER_NAMESPACE+HIERARCHY_DELIMITER+user.getUserName()+HIERARCHY_DELIMITER+"INBOX";
+        if (!existsMailbox(userInbox)) {
+            createMailbox(userInbox);
+            getLog().info("autocreated Inbox  " + userInbox);
+            return true;    
+        }  else {
+            getLog().debug("Inbox already exists " + userInbox);
+            return false;    
+        }
+    }
+    
+    
+    
     public ImapMailboxSession getImapMailboxSession(String mailboxName)
             throws MailboxManagerException {
-        
-        // prepare to auto-create users Inbox
-        
-        // TODO inbox-auto-creation for authUser is not optimal. Use a autocreate boolean
in getSessionMailbox?
-        String userInbox=getPersonalDefaultNamespace(authUser).getName()+HIERARCHY_DELIMITER+"INBOX";
-        if (userInbox.length()==mailboxName.length()) {
-            int del=userInbox.length()-5;
-            if (userInbox.substring(0,del).equals(mailboxName.substring(0,del))) {
-                if (userInbox.substring(del).equalsIgnoreCase(mailboxName.substring(del)))
{
-                    mailboxName=userInbox;
-                }
-            }
-        }
 
         try {
             synchronized (getMailboxCache()) {
                 MailboxRow mailboxRow = MailboxRowPeer
                         .retrieveByName(mailboxName);
-                if (mailboxRow == null) {
-                    if (userInbox.equals(mailboxName)) {
-                        // do auto creation
-                        createMailbox(mailboxName);
-                        mailboxRow = MailboxRowPeer.retrieveByName(mailboxName);
-                        getLog().info("autocreated Inbox  " + mailboxName);
-                    }
-                }
 
                 if (mailboxRow != null) {
                     UidChangeTracker tracker = (UidChangeTracker) getMailboxCache()

Modified: james/server/trunk/src/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManagerProvider.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManagerProvider.java?view=diff&rev=481811&r1=481810&r2=481811
==============================================================================
--- james/server/trunk/src/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManagerProvider.java
(original)
+++ james/server/trunk/src/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManagerProvider.java
Sun Dec  3 09:00:05 2006
@@ -232,7 +232,7 @@
         return null;
     }
 
-    public MailboxSession getMailboxSession(User authUser, String mailboxName) {
+    public MailboxSession getMailboxSession(User authUser, String mailboxName, boolean autoCreate)
{
         // TODO Auto-generated method stub
         return null;
     }

Modified: james/server/trunk/src/test/org/apache/james/mailboxmanager/torque/repository/TorqueMailboxManagerMailRepositoryNativeTestCase.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/test/org/apache/james/mailboxmanager/torque/repository/TorqueMailboxManagerMailRepositoryNativeTestCase.java?view=diff&rev=481811&r1=481810&r2=481811
==============================================================================
--- james/server/trunk/src/test/org/apache/james/mailboxmanager/torque/repository/TorqueMailboxManagerMailRepositoryNativeTestCase.java
(original)
+++ james/server/trunk/src/test/org/apache/james/mailboxmanager/torque/repository/TorqueMailboxManagerMailRepositoryNativeTestCase.java
Sun Dec  3 09:00:05 2006
@@ -37,6 +37,7 @@
 import org.apache.james.mailboxmanager.MessageResult;
 import org.apache.james.mailboxmanager.impl.GeneralMessageSetImpl;
 import org.apache.james.mailboxmanager.mailbox.GeneralMailboxSession;
+import org.apache.james.mailboxmanager.manager.MailboxManager;
 import org.apache.james.mailboxmanager.mock.MockUser;
 import org.apache.james.mailboxmanager.mock.TorqueMailboxManagerProviderSingleton;
 import org.apache.james.mailboxmanager.redundant.AbstractMailRepositoryNativeTestCase;
@@ -45,6 +46,7 @@
 public class TorqueMailboxManagerMailRepositoryNativeTestCase extends
         AbstractMailRepositoryNativeTestCase {
 
+    private static final String TUSER_INBOX = "#mail.tuser.INBOX";
     GeneralMailboxSession shadowMailbox = null;
 
     protected void configureRepository() throws Exception {
@@ -57,8 +59,8 @@
         Configuration conf = db
                 .build(
                         new ByteArrayInputStream(
-                                ("<repository destinationURL=\"mailboxmanager://users/tuser\"
type=\"MAIL\"></repository>").getBytes()),
-                        "repository");
+                                ("<repository destinationURL=\"mailboxmanager://#mail/tuser\"
postfix=\".INBOX\" translateDelimiters=\"true\" type=\"MAIL\"></repository>")
+                                        .getBytes()), "repository");
         mailboxManagerMailRepository.configure(conf);
         mailboxManagerMailRepository.initialize();
         mailboxManagerMailRepository.setMailboxManagerProvider(TorqueMailboxManagerProviderSingleton
@@ -135,10 +137,13 @@
     protected GeneralMailboxSession getShadowMailbox() {
         if (shadowMailbox == null) {
             try {
-                shadowMailbox = TorqueMailboxManagerProviderSingleton
-                        .getTorqueMailboxManagerProviderInstance()
-                        .getMailboxManagerInstance(new MockUser())
-                        .getGeneralMailboxSession("#mail.tuser.INBOX");
+                MailboxManager mailboxManager= TorqueMailboxManagerProviderSingleton
+                .getTorqueMailboxManagerProviderInstance()
+                .getMailboxManagerInstance(new MockUser());
+                if (!mailboxManager.existsMailbox(TUSER_INBOX)) {
+                    mailboxManager.createMailbox(TUSER_INBOX);
+                }
+                shadowMailbox = mailboxManager.getGeneralMailboxSession(TUSER_INBOX);
             } catch (Exception e) {
                 throw new RuntimeException(e);
             }



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