james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joac...@apache.org
Subject svn commit: r481795 - in /james/server/sandbox/mailbox-namespaces/src: conf/ java/org/apache/james/imapserver/ java/org/apache/james/mailboxmanager/impl/ java/org/apache/james/mailboxmanager/mailstore/ java/org/apache/james/mailboxmanager/manager/ java...
Date Sun, 03 Dec 2006 16:33:25 GMT
Author: joachim
Date: Sun Dec  3 08:33:23 2006
New Revision: 481795

URL: http://svn.apache.org/viewvc?view=rev&rev=481795
Log:
 - MailboxManagerMailRepository works for all namespaces now
 - INBOX is not autocreated anymore
 - added createInbox(User)

Added:
    james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/repository/
    james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/repository/MailboxManagerMailRepositoryTest.java
Modified:
    james/server/sandbox/mailbox-namespaces/src/conf/james-config.xml
    james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/imapserver/ImapSessionImpl.java
    james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/impl/DefaultMailboxManagerProvider.java
    james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/impl/VirtualMailboxManager.java
    james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MailStoreMailboxManager.java
    james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/manager/MailboxManager.java
    james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/manager/MailboxManagerProvider.java
    james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/repository/MailboxManagerMailRepository.java
    james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java
    james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/torque/repository/TorqueMailboxManagerMailRepositoryNativeTestCase.java

Modified: james/server/sandbox/mailbox-namespaces/src/conf/james-config.xml
URL: http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/conf/james-config.xml?view=diff&rev=481795&r1=481794&r2=481795
==============================================================================
--- james/server/sandbox/mailbox-namespaces/src/conf/james-config.xml (original)
+++ james/server/sandbox/mailbox-namespaces/src/conf/james-config.xml Sun Dec  3 08:33:23
2006
@@ -74,7 +74,7 @@
       <inboxRepository>
          <repository destinationURL="dbfile://maildb/inbox/" type="MAIL"/>
       </inboxRepository>
-      -->		  
+      -->         
       <!-- TEMPORARY DEFAULT: dbfile using Derby  -->
 
       <!-- Alternative inbox repository definition for mbox use. -->
@@ -90,7 +90,8 @@
       -->
       <!-- Experimental IMAP support -->
       <inboxRepository>
-         <repository destinationURL="mailboxmanager://users/" type="MAIL" />
+         <repository destinationURL="mailboxmanager://#mail/" 
+                     postfix=".INBOX" translateDelimiters="true" type="MAIL" />
       </inboxRepository>
    </James>
 
@@ -139,7 +140,7 @@
                         <repository destinationURL="file://var/mail/system/"
                             type="MAIL"/>
                     </target>
-                </mount>  				
+                </mount>                
                 <mount>
                     <point point="#mail.user1"/>
                     <target
@@ -1256,8 +1257,8 @@
    </mailstore>
 
 
-   <!-- The Mailstore block used by mailboxmanager --> 	
-	
+   <!-- The Mailstore block used by mailboxmanager -->  
+    
    <mailboxmanager-mailstore>
       <repositories>
         <repository class="org.apache.james.mailboxmanager.repository.MailboxManagerMailRepository">
@@ -1397,7 +1398,7 @@
       
    </mailboxmanager-mailstore>
 
-	
+    
    <!-- The User Storage block -->
    <users-store>
       <!-- Configure User Repositories here. -->

Modified: james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/imapserver/ImapSessionImpl.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/imapserver/ImapSessionImpl.java?view=diff&rev=481795&r1=481794&r2=481795
==============================================================================
--- james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/imapserver/ImapSessionImpl.java
(original)
+++ james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/imapserver/ImapSessionImpl.java
Sun Dec  3 08:33:23 2006
@@ -209,6 +209,7 @@
                 mailboxManager.close();
             }
             mailboxManager=mailboxManagerProvider.getMailboxManagerInstance(user);
+            mailboxManager.createInbox(user);
         }
         return mailboxManager;
     }

Modified: james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/impl/DefaultMailboxManagerProvider.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/impl/DefaultMailboxManagerProvider.java?view=diff&rev=481795&r1=481794&r2=481795
==============================================================================
--- james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/impl/DefaultMailboxManagerProvider.java
(original)
+++ james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/impl/DefaultMailboxManagerProvider.java
Sun Dec  3 08:33:23 2006
@@ -68,7 +68,7 @@
     }
 
     public MailboxSession getInboxSession(User user) throws MailboxManagerException {
-        return getMailboxManagerInstance(user).getMailboxSession(getInboxName(user));
+        return getMailboxManagerInstance(user).getMailboxSession(getInboxName(user),true);
     }
 
     public MailboxManager getMailboxManagerInstance(User user)
@@ -76,9 +76,10 @@
         return getMailboxManagerFactory().getMailboxManagerInstance(user);
     }
 
-    public MailboxSession getMailboxSession(User authUser, String mailboxName)
-            throws MailboxManagerException {
-        return getMailboxManagerInstance(authUser).getMailboxSession(mailboxName);
+    public MailboxSession getMailboxSession(User authUser, String mailboxName,
+            boolean autoCreate) throws MailboxManagerException {
+        return getMailboxManagerInstance(authUser).getMailboxSession(
+                mailboxName, autoCreate);
     }
 
     public Namespaces getNamespaces(User forUser) {

Modified: james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/impl/VirtualMailboxManager.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/impl/VirtualMailboxManager.java?view=diff&rev=481795&r1=481794&r2=481795
==============================================================================
--- james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/impl/VirtualMailboxManager.java
(original)
+++ james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/impl/VirtualMailboxManager.java
Sun Dec  3 08:33:23 2006
@@ -123,9 +123,9 @@
                 .getImapMailboxSession(mailboxName);
     }
 
-    public MailboxSession getMailboxSession(String mailboxName)
-            throws MailboxManagerException {
-        return getMailboxManager(mailboxName).getMailboxSession(mailboxName);
+    public MailboxSession getMailboxSession(String mailboxName,
+            boolean autoCreate) throws MailboxManagerException {
+        return getMailboxManager(mailboxName).getMailboxSession(mailboxName, autoCreate);
     }
 
     public ListResult[] list(String base, String expression, boolean subscribed)
@@ -163,6 +163,11 @@
 
     public void setUser(User user) {
         this.user = user;
+    }
+
+    public boolean createInbox(User user) throws MailboxManagerException {
+        String userInbox=USER_NAMESPACE+HIERARCHY_DELIMITER+user.getUserName()+HIERARCHY_DELIMITER+"INBOX";
+        return getMailboxManager(userInbox).createInbox(user);
     }
 
 }

Modified: james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MailStoreMailboxManager.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MailStoreMailboxManager.java?view=diff&rev=481795&r1=481794&r2=481795
==============================================================================
--- james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MailStoreMailboxManager.java
(original)
+++ james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MailStoreMailboxManager.java
Sun Dec  3 08:33:23 2006
@@ -69,8 +69,8 @@
         throw new RuntimeException("operation not supported");
     }
 
-    public MailboxSession getMailboxSession(String mailboxName)
-            throws MailboxManagerException {
+    public MailboxSession getMailboxSession(String mailboxName,
+            boolean autoCreate) throws MailboxManagerException {
         return mailstoreMailboxCache.getMailboxSession(mailboxName);
     }
 
@@ -100,6 +100,10 @@
 
     public void setUser(User user) {
         this.user=user;
+    }
+
+    public boolean createInbox(User user) throws MailboxManagerException {
+        return false;
     }
 
 }

Modified: james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/manager/MailboxManager.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/manager/MailboxManager.java?view=diff&rev=481795&r1=481794&r2=481795
==============================================================================
--- james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/manager/MailboxManager.java
(original)
+++ james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/manager/MailboxManager.java
Sun Dec  3 08:33:23 2006
@@ -26,6 +26,7 @@
 import org.apache.james.mailboxmanager.mailbox.GeneralMailboxSession;
 import org.apache.james.mailboxmanager.mailbox.ImapMailboxSession;
 import org.apache.james.mailboxmanager.mailbox.MailboxSession;
+import org.apache.james.services.User;
 
 
 /**
@@ -62,6 +63,10 @@
  */
 
 public interface MailboxManager {
+    
+    public static final char HIERARCHY_DELIMITER='.';
+    
+    public static final String USER_NAMESPACE="#mail";
 
     /**
      * get a session mailbox 
@@ -71,7 +76,8 @@
      * @return
      * @throws MailboxManagerException 
      */
-    MailboxSession getMailboxSession(String mailboxName) throws MailboxManagerException;
+    MailboxSession getMailboxSession(String mailboxName, boolean autoCreate)
+            throws MailboxManagerException;
     
     /**
      * Supports 
@@ -135,6 +141,9 @@
     boolean existsMailbox(String mailboxName) throws MailboxManagerException;
 
     void close();
+
+    // TODO maybe move createInbox to provider
+    boolean createInbox(User user) throws MailboxManagerException;
 
 }
 

Modified: james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/manager/MailboxManagerProvider.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/manager/MailboxManagerProvider.java?view=diff&rev=481795&r1=481794&r2=481795
==============================================================================
--- james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/manager/MailboxManagerProvider.java
(original)
+++ james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/manager/MailboxManagerProvider.java
Sun Dec  3 08:33:23 2006
@@ -47,8 +47,8 @@
      *  @throws MailboxManagerException 
      */ 
 
-    MailboxSession getMailboxSession(
-         User authUser, String mailboxName) throws MailboxManagerException;
+    MailboxSession getMailboxSession(User authUser, String mailboxName,
+            boolean autoCreate) throws MailboxManagerException;
     
     /**
      * removes all data (mailboxes, quota, acls...) that is associated 

Modified: james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/repository/MailboxManagerMailRepository.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/repository/MailboxManagerMailRepository.java?view=diff&rev=481795&r1=481794&r2=481795
==============================================================================
--- james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/repository/MailboxManagerMailRepository.java
(original)
+++ james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/repository/MailboxManagerMailRepository.java
Sun Dec  3 08:33:23 2006
@@ -53,6 +53,11 @@
 public class MailboxManagerMailRepository extends AbstractMailRepository
         implements Configurable, Serviceable {
 
+    private static final String PREFIX = "mailboxmanager://";
+    
+    // TODO extract delimiter from namespaces
+    private static final String DL = ".";
+
     /**
      * used to map keys to uid and vice versa
      */
@@ -61,8 +66,8 @@
     private MailboxGateKeeper mailboxGateKeeper;
 
     private MailboxManagerProvider mailboxManagerProvider;
-
-    private User user;
+    
+    private String mailboxName;
 
     protected String addMessage(MimeMessage message) throws MessagingException {
         try {
@@ -339,7 +344,8 @@
                 throw new RuntimeException("use<1 !");
             }
             if (mailboxSession == null) {
-                mailboxSession = getMailboxManagerProvider().getInboxSession(user);
+                mailboxSession = getMailboxManagerProvider().getMailboxSession(
+                        null, mailboxName, true);
             }
             return mailboxSession;
         }
@@ -357,22 +363,38 @@
     public void configure(Configuration conf) throws ConfigurationException {
 
         // fetch user name
-
-        String destinationUrl = conf.getAttribute("destinationURL");
-        if (destinationUrl.endsWith("/")) {
-            destinationUrl = destinationUrl.substring(0, destinationUrl
-                    .length() - 1);
+        String destinationURL = conf.getAttribute("destinationURL");
+        String postfix = conf.getAttribute("postfix", null);
+        boolean translateDelimiter=conf.getAttributeAsBoolean("translateDelimiters",false);
+
+        // transform the URL
+        String name = destinationURL;
+        
+        // remove protocol prefix
+        if (!name.startsWith(PREFIX)) {
+            throw new ConfigurationException("url has to start with "+PREFIX);
+        }
+        name=name.substring(PREFIX.length());                
+        
+        
+        // translate delimiter
+        if (translateDelimiter) {
+            // remove trailing /
+            if (name.endsWith("/")) {
+                name = name.substring(0, name.length() - 1);
+            }
+            name=name.replaceAll("/", DL);
+        }
+        
+        // append postfix
+        if (postfix!=null) {
+            name += postfix;
         }
-        String userName = destinationUrl.substring(destinationUrl
-                .lastIndexOf('/') + 1);
+        
         getLogger().info(
-                "Configured for user: '" + userName + "' URL: '"
-                        + destinationUrl + "'");
-        setUser(new DefaultJamesUser(userName, "none"));
-    }
-
-    public void setUser(User user) {
-        this.user = user;
+                "Configured for mailbox: '" + name + "' URL: '"
+                        + destinationURL + "' translateDelimiter: "+translateDelimiter);
+        setMailboxName(name);
     }
 
     public void service(ServiceManager serviceManager) throws ServiceException {
@@ -389,6 +411,14 @@
             log = new SimpleLog("MailboxManagerMailRepository");
         }
         return log;
+    }
+
+    String getMailboxName() {
+        return mailboxName;
+    }
+
+    public void setMailboxName(String mailboxName) {
+        this.mailboxName = mailboxName;
     }
 
 }

Modified: james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java?view=diff&rev=481795&r1=481794&r2=481795
==============================================================================
--- james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java
(original)
+++ james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java
Sun Dec  3 08:33:23 2006
@@ -46,10 +46,6 @@
 import org.apache.torque.util.Criteria;
 
 public class TorqueMailboxManager implements MailboxManager {
-    
-    public static final char HIERARCHY_DELIMITER='.';
-    
-    public static final String USER_NAMESPACE="#mail";
 
     private static Random random;
     private MailboxCache mailboxCache;
@@ -64,8 +60,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);
     }
     
@@ -76,35 +76,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?
-        // FIXME should access getPersonalDefaultNameSpace...
-        String userInbox=USER_NAMESPACE+HIERARCHY_DELIMITER+authUser.getUserName()+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()

Added: james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/repository/MailboxManagerMailRepositoryTest.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/repository/MailboxManagerMailRepositoryTest.java?view=auto&rev=481795
==============================================================================
--- james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/repository/MailboxManagerMailRepositoryTest.java
(added)
+++ james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/repository/MailboxManagerMailRepositoryTest.java
Sun Dec  3 08:33:23 2006
@@ -0,0 +1,109 @@
+/****************************************************************
+ * 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.mailboxmanager.repository;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import junit.framework.TestCase;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
+import org.apache.avalon.framework.container.ContainerUtil;
+import org.apache.james.test.mock.avalon.MockLogger;
+import org.xml.sax.SAXException;
+
+public class MailboxManagerMailRepositoryTest extends TestCase {
+
+    protected MailboxManagerMailRepository mailboxManagerMailRepository;
+
+    public void setUp() {
+        mailboxManagerMailRepository = new MailboxManagerMailRepository();
+        ContainerUtil.enableLogging(mailboxManagerMailRepository,
+                new MockLogger());
+    }
+
+    public void testConfigurePostfix() throws ConfigurationException,
+            SAXException, IOException {
+        mailboxManagerMailRepository.configure(get(
+                "mailboxmanager://#mail/tuser/", ".INBOX", true));
+        assertEquals("#mail.tuser.INBOX", mailboxManagerMailRepository
+                .getMailboxName());
+        
+        mailboxManagerMailRepository.configure(get(
+                "mailboxmanager://#mail/tuser", ".NEWBOX", true));
+        assertEquals("#mail.tuser.NEWBOX", mailboxManagerMailRepository
+                .getMailboxName());
+        
+        mailboxManagerMailRepository.configure(get(
+                "mailboxmanager://#mail/tuser", ".NEWBOX", false));
+        assertEquals("#mail/tuser.NEWBOX", mailboxManagerMailRepository
+                .getMailboxName());
+        
+        mailboxManagerMailRepository.configure(get(
+                "mailboxmanager://#mail/tuser/", ".NEWBOX", false));
+        assertEquals("#mail/tuser/.NEWBOX", mailboxManagerMailRepository
+                .getMailboxName());
+    }
+
+    public void testConfigure() throws ConfigurationException,
+            SAXException, IOException {
+        mailboxManagerMailRepository.configure(get(
+                "mailboxmanager://#system/tuser/", null, true));
+        assertEquals("#system.tuser", mailboxManagerMailRepository
+                .getMailboxName());
+        
+        mailboxManagerMailRepository.configure(get(
+                "mailboxmanager://#system/tuser", null, true));
+        assertEquals("#system.tuser", mailboxManagerMailRepository
+                .getMailboxName());
+        
+        mailboxManagerMailRepository.configure(get(
+                "mailboxmanager://#system/tuser", null, false));
+        assertEquals("#system/tuser", mailboxManagerMailRepository
+                .getMailboxName());
+        
+        mailboxManagerMailRepository.configure(get(
+                "mailboxmanager://#system/tuser/", null, false));
+        assertEquals("#system/tuser/", mailboxManagerMailRepository
+                .getMailboxName());
+    }
+
+    protected Configuration get(String url, String postfix,
+            boolean translateDelimiter) throws ConfigurationException,
+            SAXException, IOException {
+        String trans = "";
+        if (translateDelimiter) {
+            trans = "translateDelimiters=\"true\" ";
+        }
+        if (postfix != null) {
+            postfix = "postfix=\"" + postfix + "\" ";
+        } else {
+            postfix = "";
+        }
+        String configXml = "<repository destinationURL=\"" + url + "\" " + postfix
+                + trans + "type=\"MAIL\" />";
+        InputStream stream=new ByteArrayInputStream(configXml.getBytes());
+        return new DefaultConfigurationBuilder().build(stream);
+    }
+
+}

Modified: james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/torque/repository/TorqueMailboxManagerMailRepositoryNativeTestCase.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/torque/repository/TorqueMailboxManagerMailRepositoryNativeTestCase.java?view=diff&rev=481795&r1=481794&r2=481795
==============================================================================
--- james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/torque/repository/TorqueMailboxManagerMailRepositoryNativeTestCase.java
(original)
+++ james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/torque/repository/TorqueMailboxManagerMailRepositoryNativeTestCase.java
Sun Dec  3 08:33:23 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