james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joac...@apache.org
Subject svn commit: r481870 - in /james/server/trunk: ./ src/conf/ src/java/org/apache/james/core/ src/java/org/apache/james/imapserver/ src/java/org/apache/james/mailboxmanager/impl/ src/java/org/apache/james/mailboxmanager/mailstore/ src/java/org/apache/jame...
Date Sun, 03 Dec 2006 19:59:21 GMT
Author: joachim
Date: Sun Dec  3 11:59:18 2006
New Revision: 481870

URL: http://svn.apache.org/viewvc?view=rev&rev=481870
Log:
Introducing MailboxManagerFactory and VirtualMailboxManager
introducing MailstoreMailboxManager to access legacy MailRepositories
merged revions 471673:481814 from https://svn.apache.org/repos/asf/james/server/sandbox/

Added:
    james/server/trunk/src/java/org/apache/james/mailboxmanager/impl/DefaultMailboxManagerProvider.java
      - copied unchanged from r481814, james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/impl/DefaultMailboxManagerProvider.java
    james/server/trunk/src/java/org/apache/james/mailboxmanager/impl/DefaultMailboxManagerProvider.xinfo
      - copied unchanged from r481814, james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/impl/DefaultMailboxManagerProvider.xinfo
    james/server/trunk/src/java/org/apache/james/mailboxmanager/impl/VirtualMailboxManager.java
      - copied unchanged from r481814, james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/impl/VirtualMailboxManager.java
    james/server/trunk/src/java/org/apache/james/mailboxmanager/impl/VirtualMailboxManagerFactory.java
      - copied unchanged from r481814, james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/impl/VirtualMailboxManagerFactory.java
    james/server/trunk/src/java/org/apache/james/mailboxmanager/mailstore/
      - copied from r481814, james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/
    james/server/trunk/src/java/org/apache/james/mailboxmanager/mailstore/MailStoreMailboxManager.java
      - copied unchanged from r481814, james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MailStoreMailboxManager.java
    james/server/trunk/src/java/org/apache/james/mailboxmanager/mailstore/MailStoreMailboxManagerFactory.java
      - copied unchanged from r481814, james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MailStoreMailboxManagerFactory.java
    james/server/trunk/src/java/org/apache/james/mailboxmanager/mailstore/MailstoreMailboxCache.java
      - copied unchanged from r481814, james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MailstoreMailboxCache.java
    james/server/trunk/src/java/org/apache/james/mailboxmanager/mailstore/MyAvalonMailStore.java
      - copied unchanged from r481814, james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MyAvalonMailStore.java
    james/server/trunk/src/java/org/apache/james/mailboxmanager/mailstore/MyAvalonMailStore.xinfo
      - copied unchanged from r481814, james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/mailstore/MyAvalonMailStore.xinfo
    james/server/trunk/src/java/org/apache/james/mailboxmanager/manager/MailboxManagerFactory.java
      - copied unchanged from r481814, james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/manager/MailboxManagerFactory.java
    james/server/trunk/src/java/org/apache/james/mailboxmanager/repository/MailRepositoryMailboxSession.java
      - copied unchanged from r481814, james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/repository/MailRepositoryMailboxSession.java
    james/server/trunk/src/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManagerFactory.java
      - copied unchanged from r481814, james/server/sandbox/mailbox-namespaces/src/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManagerFactory.java
    james/server/trunk/src/test/org/apache/james/mailboxmanager/impl/DefaultMailboxManagerProviderTest.java
      - copied unchanged from r481814, james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/impl/DefaultMailboxManagerProviderTest.java
    james/server/trunk/src/test/org/apache/james/mailboxmanager/impl/VirtualMailboxManagerFactoryTest.java
      - copied unchanged from r481814, james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/impl/VirtualMailboxManagerFactoryTest.java
    james/server/trunk/src/test/org/apache/james/mailboxmanager/impl/VirtualMailboxManagerIntegrationTest.java
      - copied unchanged from r481814, james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/impl/VirtualMailboxManagerIntegrationTest.java
    james/server/trunk/src/test/org/apache/james/mailboxmanager/impl/VirtualMailboxManagerTest.java
      - copied unchanged from r481814, james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/impl/VirtualMailboxManagerTest.java
    james/server/trunk/src/test/org/apache/james/mailboxmanager/mailstore/
      - copied from r481814, james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/mailstore/
    james/server/trunk/src/test/org/apache/james/mailboxmanager/mailstore/MailStoreMailboxCacheTest.java
      - copied unchanged from r481814, james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/mailstore/MailStoreMailboxCacheTest.java
    james/server/trunk/src/test/org/apache/james/mailboxmanager/mock/MockMailboxManagerFactory.java
      - copied unchanged from r481814, james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/mock/MockMailboxManagerFactory.java
    james/server/trunk/src/test/org/apache/james/mailboxmanager/repository/
      - copied from r481814, james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/repository/
    james/server/trunk/src/test/org/apache/james/mailboxmanager/repository/MailboxManagerMailRepositoryTest.java
      - copied unchanged from r481814, james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/repository/MailboxManagerMailRepositoryTest.java
    james/server/trunk/src/test/org/apache/james/mailboxmanager/testdata/
      - copied from r481814, james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/testdata/
    james/server/trunk/src/test/org/apache/james/mailboxmanager/testdata/DefaultMailboxManagerConf.xml
      - copied unchanged from r481814, james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/testdata/DefaultMailboxManagerConf.xml
    james/server/trunk/src/test/org/apache/james/mailboxmanager/testdata/MixedMailstores.xml
      - copied unchanged from r481814, james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/testdata/MixedMailstores.xml
    james/server/trunk/src/test/org/apache/james/mailboxmanager/testdata/VirtualRepositoryMix.xml
      - copied unchanged from r481814, james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/testdata/VirtualRepositoryMix.xml
Removed:
    james/server/trunk/src/java/org/apache/james/mailboxmanager/repository/AvalonMailStore.xinfo
    james/server/trunk/src/java/org/apache/james/mailboxmanager/repository/MyAvalonMailStore.java
    james/server/trunk/src/java/org/apache/james/mailboxmanager/repository/MyAvalonMailStore.xinfo
    james/server/trunk/src/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManagerProvider.java
    james/server/trunk/src/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManagerProvider.xinfo
Modified:
    james/server/trunk/build.xml
    james/server/trunk/src/conf/james-assembly.xml
    james/server/trunk/src/conf/james-config.xml
    james/server/trunk/src/conf/mailboxManagerSqlResources.xml
    james/server/trunk/src/java/org/apache/james/core/AvalonMailStore.xinfo
    james/server/trunk/src/java/org/apache/james/imapserver/ImapSession.java
    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/test/org/apache/james/imapserver/mock/MockImapHandlerConfigurationData.java
    james/server/trunk/src/test/org/apache/james/mailboxmanager/mock/TorqueMailboxManagerProviderSingleton.java

Modified: james/server/trunk/build.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/build.xml?view=diff&rev=481870&r1=481869&r2=481870
==============================================================================
--- james/server/trunk/build.xml (original)
+++ james/server/trunk/build.xml Sun Dec  3 11:59:18 2006
@@ -779,6 +779,7 @@
         </javac>
         <copy todir="${build.test.classes}">
             <fileset dir="${junitjava.dir}" includes="**/*.zone" />
+            <fileset dir="${junitjava.dir}" includes="**/*.xml" />        	
         </copy>
     </target>
 

Modified: james/server/trunk/src/conf/james-assembly.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/src/conf/james-assembly.xml?view=diff&rev=481870&r1=481869&r2=481870
==============================================================================
--- james/server/trunk/src/conf/james-assembly.xml (original)
+++ james/server/trunk/src/conf/james-assembly.xml Sun Dec  3 11:59:18 2006
@@ -39,10 +39,19 @@
              role="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector"
/>
   </block>
 
-  <block name="mailboxmanager" class="org.apache.james.mailboxmanager.torque.TorqueMailboxManagerProvider">
-    <provide name="filesystem" role="org.apache.james.services.FileSystem" />
-  </block>  
     
+  <block name="mailboxmanager" class="org.apache.james.mailboxmanager.impl.DefaultMailboxManagerProvider">
+      <provide name="filesystem" role="org.apache.james.services.FileSystem" />
+      <provide name="mailboxmanager-mailstore" role="org.apache.avalon.cornerstone.services.store.Store"
/>      
+  </block>  
+
+  <block name="mailboxmanager-mailstore" class="org.apache.james.mailboxmanager.mailstore.MyAvalonMailStore"
>
+    <provide name="database-connections"
+             role="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector"
/>
+    <provide name="filesystem" role="org.apache.james.services.FileSystem" />     
+  </block>      
+ 
+   
   <!-- The James Spool Manager block  -->
   <block name="spoolmanager" class="org.apache.james.transport.JamesSpoolManager" >
     <provide name="spoolrepository" role="org.apache.james.services.SpoolRepository"/>
@@ -185,15 +194,9 @@
     <provide name="dnsserver" role="org.apache.james.services.DNSServer"/>
   </block>
 
-  <!-- The High Level Storage block 
-  <block name="mailstore" class="org.apache.james.core.AvalonMailStore" >
-    <provide name="database-connections"
-             role="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector"
/>
-    <provide name="filesystem" role="org.apache.james.services.FileSystem" />
-  </block>
-  -->
+  <!-- The High Level Storage block -->
     
-  <block name="mailstore" class="org.apache.james.mailboxmanager.repository.MyAvalonMailStore"
>
+  <block name="mailstore" class="org.apache.james.core.AvalonMailStore" >
     <provide name="database-connections"
              role="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector"
/>
     <provide name="mailboxmanager"

Modified: james/server/trunk/src/conf/james-config.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/src/conf/james-config.xml?view=diff&rev=481870&r1=481869&r2=481870
==============================================================================
--- james/server/trunk/src/conf/james-config.xml (original)
+++ james/server/trunk/src/conf/james-config.xml Sun Dec  3 11:59:18 2006
@@ -70,10 +70,11 @@
 
       <!-- Alternative inbox repository definition for DB use. -->
       <!-- Stores message body in file system, rest in database -->
-      <!-- TEMPORARY DEFAULT: dbfile using Derby  -->
+      <!-- TEMPORARY DEFAULT: dbfile using Derby -->         
       <inboxRepository>
          <repository destinationURL="dbfile://maildb/inbox/" type="MAIL"/>
       </inboxRepository>
+
       <!-- TEMPORARY DEFAULT: dbfile using Derby  -->
 
       <!-- Alternative inbox repository definition for mbox use. -->
@@ -89,10 +90,10 @@
       -->
       <!-- Experimental IMAP support
       <inboxRepository>
-         <repository destinationURL="mailboxmanager://users/" type="MAIL" />
+         <repository destinationURL="mailboxmanager://#mail/" 
+                     postfix=".INBOX" translateDelimiters="true" type="MAIL" />
       </inboxRepository>
-      -->
-      
+       -->
       <!-- Set to true to support virtualHosting. If virtualHosting support is enabled
the server will accept thread every user independ on -->
       <!-- domain level. -->
       <enableVirtualHosting> false </enableVirtualHosting>     
@@ -103,20 +104,77 @@
       
    </James>
 
-   <!-- Experimental IMAP support -->
-   <mailboxmanager>
-       <torque-properties>
-           <property name="torque.database.default" value="mailboxmanager" />
-           <property name="torque.database.mailboxmanager.adapter" value="derby" />
-           <property name="torque.dsfactory.mailboxmanager.factory" value="org.apache.torque.dsfactory.SharedPoolDataSourceFactory"
/>
-           <property name="torque.dsfactory.mailboxmanager.connection.driver" value="org.apache.derby.jdbc.EmbeddedDriver"
/>
-           <property name="torque.dsfactory.mailboxmanager.connection.url" value="jdbc:derby:../apps/james/var/mailboxmanager-derbydb;create=true"
/>
-           <property name="torque.dsfactory.mailboxmanager.connection.user" value="app"
/>
-           <property name="torque.dsfactory.mailboxmanager.connection.password" value="app"
/>
-           <property name="torque.dsfactory.mailboxmanager.pool.maxActive" value="100"
/>
-      </torque-properties>  
-   </mailboxmanager>    
-
+    <!--
+        Don't forget to activate mailboxmanager inboxRepository in the 
+        James block, if you want to receive mail in your IMAP mailbox
+    --> 
+    <mailboxmanager>
+        <namespaces>
+            <usernamespace name="#mail" delimiter="."/>
+        </namespaces>
+        <factory
+            class="org.apache.james.mailboxmanager.impl.VirtualMailboxManagerFactory">
+            <mounts>
+                <mount>
+                    <point point="#mail"/>
+                    <target class="org.apache.james.mailboxmanager.torque.TorqueMailboxManagerFactory">
+                        <torque-properties>
+                            <property name="torque.database.default"
+                                value="mailboxmanager"/>
+                            <property
+                                name="torque.database.mailboxmanager.adapter"
+                                value="derby"/>
+                            <property
+                                name="torque.dsfactory.mailboxmanager.factory"
+                                value="org.apache.torque.dsfactory.SharedPoolDataSourceFactory"/>
+                            <property
+                                name="torque.dsfactory.mailboxmanager.connection.driver"
+                                value="org.apache.derby.jdbc.EmbeddedDriver"/>
+                            <property
+                                name="torque.dsfactory.mailboxmanager.connection.url"
+                                value="jdbc:derby:../apps/james/var/mailboxmanager-derbydb;create=true"/>
+                            <property
+                                name="torque.dsfactory.mailboxmanager.connection.user"
+                                value="app"/>
+                            <property
+                                name="torque.dsfactory.mailboxmanager.connection.password"
+                                value="app"/>
+                            <property
+                                name="torque.dsfactory.mailboxmanager.pool.maxActive"
+                                value="100"/>
+                        </torque-properties>
+                    </target>
+                </mount>
+                <!--  You could configure your local-address-error processor with 
+                      the repositoryPath mailboxmanager://#system.address-error/ 
+                 -->
+                <mount>
+                    <point point="#system"/>
+                    <target
+                        class="org.apache.james.mailboxmanager.mailstore.MailStoreMailboxManagerFactory">
+                        <repository destinationURL="file://var/mail/system/"
+                            type="MAIL"/>
+                    </target>
+                </mount>                
+                <!-- Mail to user1 goes to a file repository
+                <mount>
+                    <point point="#mail.user1"/>
+                    <target
+                        class="org.apache.james.mailboxmanager.mailstore.MailStoreMailboxManagerFactory">
+                        <repository destinationURL="file://var/mail/inboxes/user1"
+                            type="MAIL"/>
+                    </target>
+                </mount>        
+                -->
+            </mounts>
+        </factory>
+    </mailboxmanager>
+    
+  <!-- Experimental IMAP support 
+      
+        Don't forget to activate mailboxmanager inboxRepository in the 
+        James block, if you want to receive mail in your IMAP mailbox
+    -->     
    <imap-connections>
       <!-- RFC 3501 requires a minimum timeout of 30 minutes -->
       <idle-timeout>1800000</idle-timeout>
@@ -130,7 +188,6 @@
       <!-- port 993 is the well-known/IANA registered port for IMAPs ie over SSL/TLS -->
       <!-- port 143 is the well-known/IANA registered port for Standard IMAP4 -->
       <port>10143</port>
-
       <handler>
        <!-- RFC 3501 requires a minimum timeout of 30 minutes -->
        <connectiontimeout>1800000</connectiontimeout>         
@@ -1227,6 +1284,148 @@
    </mailstore>
 
 
+   <!-- The Mailstore block used by mailboxmanager -->  
+    
+   <mailboxmanager-mailstore>
+      <repositories>
+        <repository class="org.apache.james.mailboxmanager.repository.MailboxManagerMailRepository">
+            <protocols>
+               <protocol>mailboxmanager</protocol>
+            </protocols>
+            <types>
+               <type>MAIL</type>
+            </types>
+            <config>
+               <sqlFile>file://conf/mailboxManagerSqlResources.xml</sqlFile>
+            </config>
+         </repository>
+         <!-- File based repositories.  These repositories store all message data -->
+         <!-- in the file system. -->
+         <repository class="org.apache.james.mailrepository.AvalonMailRepository">
+            <protocols>
+               <protocol>file</protocol>
+            </protocols>
+            <types>
+               <type>MAIL</type>
+            </types>
+            <!-- Set if the messages should be listed sorted. False by default -->
+            <config FIFO="false"/> 
+         </repository>
+         <repository class="org.apache.james.mailrepository.AvalonSpoolRepository">
+            <protocols>
+               <protocol>file</protocol>
+            </protocols>
+            <types>
+               <type>SPOOL</type>
+            </types>
+         </repository>
+
+         <!-- JDBC based repositories.  These repositories store all message data -->
+         <!-- in the database. -->
+         <repository class="org.apache.james.mailrepository.JDBCMailRepository">
+            <protocols>
+               <protocol>db</protocol>
+            </protocols>
+            <types>
+               <type>MAIL</type>
+            </types>
+            <config>
+               <sqlFile>file://conf/sqlResources.xml</sqlFile>
+               <!-- Set the size threshold for in memory handling of storing operations
-->
+               <!-- Default is currently 409600000 due to a bug with mysql and binary
stream -->
+               <!-- currently under investigation. Please change this only if you know
what -->
+               <!-- you do. -->
+               <!--
+               <inMemorySizeLimit>4096</inMemorySizeLimit>
+                -->
+            </config>
+         </repository>
+
+         <repository class="org.apache.james.mailrepository.JDBCSpoolRepository">
+            <protocols>
+               <protocol>db</protocol>
+            </protocols>
+            <types>
+               <type>SPOOL</type>
+            </types>
+            <config>
+               <sqlFile>file://conf/sqlResources.xml</sqlFile>
+               <maxcache>1000</maxcache>
+            </config>
+         </repository>
+
+         <!-- These repositories store message delivery and headers in the DB, and the
body to the filesystem -->
+         <repository class="org.apache.james.mailrepository.JDBCMailRepository">
+            <protocols>
+               <protocol>dbfile</protocol>
+            </protocols>
+            <types>
+               <type>MAIL</type>
+            </types>
+            <config>
+               <sqlFile>file://conf/sqlResources.xml</sqlFile>
+               <filestore>file://var/dbmail</filestore>
+            </config>
+         </repository>
+
+         <repository class="org.apache.james.mailrepository.JDBCSpoolRepository">
+            <protocols>
+               <protocol>dbfile</protocol>
+            </protocols>
+            <types>
+               <type>SPOOL</type>
+            </types>
+            <config>
+               <sqlFile>file://conf/sqlResources.xml</sqlFile>
+               <filestore>file://var/dbmail</filestore>
+               <maxcache>1000</maxcache>
+            </config>
+         </repository>
+
+         <!-- The mbox repository is designed for MAIL only; SPOOL performance would be
less than ideal-->
+         <repository class="org.apache.james.mailrepository.MBoxMailRepository">
+            <protocols>
+               <protocol>mbox</protocol>
+            </protocols>
+            <types>
+               <type>MAIL</type>
+            </types>
+            <!-- Set if the messages should be listed sorted. False by default -->
+            <config FIFO="false"/> 
+         </repository>
+
+         <repository class="org.apache.james.mailrepository.filepair.File_Persistent_Object_Repository">
+            <protocols>
+               <protocol>file</protocol>
+            </protocols>
+            <types>
+               <type>OBJECT</type>
+            </types>
+            <models>
+               <model>SYNCHRONOUS</model>
+               <model>ASYNCHRONOUS</model>
+               <model>CACHE</model>
+            </models>
+         </repository>
+
+         <repository class="org.apache.james.mailrepository.filepair.File_Persistent_Stream_Repository">
+            <protocols>
+               <protocol>file</protocol>
+            </protocols>
+            <types>
+               <type>STREAM</type>
+            </types>
+            <models>
+               <model>SYNCHRONOUS</model>
+               <model>ASYNCHRONOUS</model>
+               <model>CACHE</model>
+            </models>
+         </repository>
+      </repositories>
+      
+   </mailboxmanager-mailstore>
+
+    
    <!-- The User Storage block -->
    <users-store>
       <!-- Configure User Repositories here. -->

Modified: james/server/trunk/src/conf/mailboxManagerSqlResources.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/src/conf/mailboxManagerSqlResources.xml?view=diff&rev=481870&r1=481869&r2=481870
==============================================================================
--- james/server/trunk/src/conf/mailboxManagerSqlResources.xml (original)
+++ james/server/trunk/src/conf/mailboxManagerSqlResources.xml Sun Dec  3 11:59:18 2006
@@ -22,7 +22,7 @@
 
   <dbOptions>
   </dbOptions>
-  <sqlDefs name="org.apache.james.mailboxmanager.torque.TorqueMailboxManagerProvider">
+  <sqlDefs name="org.apache.james.mailboxmanager.torque.TorqueMailboxManagerFactory">
 
     <sql name="tableName">${table}</sql>
 

Modified: james/server/trunk/src/java/org/apache/james/core/AvalonMailStore.xinfo
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/core/AvalonMailStore.xinfo?view=diff&rev=481870&r1=481869&r2=481870
==============================================================================
--- james/server/trunk/src/java/org/apache/james/core/AvalonMailStore.xinfo (original)
+++ james/server/trunk/src/java/org/apache/james/core/AvalonMailStore.xinfo Sun Dec  3 11:59:18
2006
@@ -19,6 +19,9 @@
     <dependency>
       <service name="org.apache.james.services.FileSystem" version="1.0"/>
     </dependency>
+    <dependency>
+      <service name="org.apache.james.mailboxmanager.manager.MailboxManagerProvider" version="1.0"/>
+    </dependency>    
   </dependencies>
 
 </blockinfo>

Modified: james/server/trunk/src/java/org/apache/james/imapserver/ImapSession.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/imapserver/ImapSession.java?view=diff&rev=481870&r1=481869&r2=481870
==============================================================================
--- james/server/trunk/src/java/org/apache/james/imapserver/ImapSession.java (original)
+++ james/server/trunk/src/java/org/apache/james/imapserver/ImapSession.java Sun Dec  3 11:59:18
2006
@@ -115,8 +115,9 @@
 
     /**
      * closes the Mailbox if needed
+     * @throws MailboxManagerException 
      */
-    void closeMailbox();
+    void closeMailbox() throws MailboxManagerException;
 
     MailboxManager getMailboxManager() throws MailboxManagerException;
 

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=481870&r1=481869&r2=481870
==============================================================================
--- 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 11:59:18 2006
@@ -218,7 +218,7 @@
 
     public String buildFullName(String mailboxName) throws MailboxManagerException {
         if (!mailboxName.startsWith(NAMESPACE_PREFIX)) {
-            mailboxName = getMailboxManager().getPersonalDefaultNamespace(user).getName()+HIERARCHY_DELIMITER+mailboxName;
+            mailboxName = mailboxManagerProvider.getPersonalDefaultNamespace(user).getName()+HIERARCHY_DELIMITER+mailboxName;
         }
         return mailboxName;
     }

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=481870&r1=481869&r2=481870
==============================================================================
--- 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 11:59:18 2006
@@ -22,8 +22,6 @@
 import org.apache.james.mailboxmanager.GeneralMessageSet;
 import org.apache.james.mailboxmanager.ListResult;
 import org.apache.james.mailboxmanager.MailboxManagerException;
-import org.apache.james.mailboxmanager.Namespace;
-import org.apache.james.mailboxmanager.Namespaces;
 import org.apache.james.mailboxmanager.mailbox.GeneralMailbox;
 import org.apache.james.mailboxmanager.mailbox.GeneralMailboxSession;
 import org.apache.james.mailboxmanager.mailbox.ImapMailboxSession;
@@ -92,28 +90,6 @@
     GeneralMailboxSession getGeneralMailboxSession(String mailboxName) throws MailboxManagerException;
     
     ImapMailboxSession getImapMailboxSession(String mailboxName) throws MailboxManagerException;
-
-    /**
-     * The Namespaces a user has access to.
-     * @param forUser TODO
-     * @param user
-     * 
-     * @return
-     */
-    Namespaces getNamespaces(User forUser);
-
-    /**
-     * To get the Inbox you can just to a mailbox
-     * defaultNameSpace=ImapMailboxRepository.getPersonalDefaultNameSpace(user)
-     * inbox=defaultNameSpace.getName()+defaultNameSpace.getHierarchyDelimter()+"INBOX";
-     * TODO add a convinience method to get directly a session mailbox for a users inbox
-     * @param forUser TODO
-     * 
-     * @return
-     */
-    Namespace getPersonalDefaultNamespace(User forUser);
-    
-    
 
     void createMailbox(String mailboxName) 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=481870&r1=481869&r2=481870
==============================================================================
--- 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 11:59:18 2006
@@ -22,6 +22,8 @@
 import java.util.Map;
 
 import org.apache.james.mailboxmanager.MailboxManagerException;
+import org.apache.james.mailboxmanager.Namespace;
+import org.apache.james.mailboxmanager.Namespaces;
 import org.apache.james.mailboxmanager.mailbox.MailboxSession;
 import org.apache.james.services.User;
 
@@ -37,7 +39,7 @@
      */
     public void deleteEverything() throws MailboxManagerException;
     
-    MailboxSession getInboxSession(User user);
+    MailboxSession getInboxSession(User user) throws MailboxManagerException;
 
     /** 
      *  @param authUser the authorized User for checking credentials 
@@ -57,8 +59,27 @@
      */
     
     void deleteAllUserData(User authUser,User targetUser);
-    
-    
+
+    /**
+     * The Namespaces a user has access to.
+     * @param forUser TODO
+     * @param user
+     * 
+     * @return
+     */
+    Namespaces getNamespaces(User forUser);
+
+    /**
+     * To get the Inbox you can just to a mailbox
+     * defaultNameSpace=ImapMailboxRepository.getPersonalDefaultNameSpace(user)
+     * inbox=defaultNameSpace.getName()+defaultNameSpace.getHierarchyDelimter()+"INBOX";
+     * TODO add a convinience method to get directly a session mailbox for a users inbox
+     * @param forUser TODO
+     * 
+     * @return
+     */
+    Namespace getPersonalDefaultNamespace(User forUser);
+
     /**
      * key: <b>String</b> - mailbox name <br />
      * value: <b>Integer</b> - count of open sessions <br />
@@ -68,5 +89,4 @@
      */
     
     Map getOpenMailboxSessionCountMap();
-
 }

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=481870&r1=481869&r2=481870
==============================================================================
--- 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 11:59:18 2006
@@ -37,10 +37,8 @@
 import org.apache.commons.logging.impl.SimpleLog;
 import org.apache.james.core.MailImpl;
 import org.apache.james.mailboxmanager.MailboxManagerException;
-import org.apache.james.mailboxmanager.Namespace;
 import org.apache.james.mailboxmanager.mailbox.Mailbox;
 import org.apache.james.mailboxmanager.mailbox.MailboxSession;
-import org.apache.james.mailboxmanager.manager.MailboxManager;
 import org.apache.james.mailboxmanager.manager.MailboxManagerProvider;
 import org.apache.james.services.User;
 import org.apache.james.userrepository.DefaultJamesUser;
@@ -55,18 +53,21 @@
 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
      */
     private KeyBidiMap keyBidiMap = null;
 
-    private MailboxManager mailboxManager;
-
     private MailboxGateKeeper mailboxGateKeeper;
 
     private MailboxManagerProvider mailboxManagerProvider;
-
-    private User user;
+    
+    private String mailboxName;
 
     protected String addMessage(MimeMessage message) throws MessagingException {
         try {
@@ -343,36 +344,13 @@
                 throw new RuntimeException("use<1 !");
             }
             if (mailboxSession == null) {
-                Namespace ns = getMailboxManager().getPersonalDefaultNamespace(
-                        user);
-
-                String inbox = ns.getName() + ns.getHierarchyDelimter()
-                        + "INBOX";
-                getMailboxManager().createInbox(user);
-                mailboxSession = getMailboxManager().getImapMailboxSession(
-                        inbox);
+                mailboxSession = getMailboxManagerProvider().getMailboxSession(
+                        null, mailboxName, true);
             }
             return mailboxSession;
         }
     }
 
-    /**
-     * lazy loads a MailboxManager from MailboxManagerProvider
-     * 
-     */
-
-    protected MailboxManager getMailboxManager() throws MessagingException,
-            MailboxManagerException {
-        if (mailboxManager == null) {
-            if (user == null) {
-                throw new MessagingException("user is null");
-            }
-            mailboxManager = getMailboxManagerProvider()
-                    .getMailboxManagerInstance(user);
-        }
-        return mailboxManager;
-    }
-
     protected MailboxManagerProvider getMailboxManagerProvider() {
         return mailboxManagerProvider;
     }
@@ -385,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 {
@@ -417,6 +411,14 @@
             log = new SimpleLog("MailboxManagerMailRepository");
         }
         return log;
+    }
+
+    String getMailboxName() {
+        return mailboxName;
+    }
+
+    public void setMailboxName(String mailboxName) {
+        this.mailboxName = mailboxName;
     }
 
 }

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=481870&r1=481869&r2=481870
==============================================================================
--- 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 11:59:18 2006
@@ -29,11 +29,7 @@
 import org.apache.james.mailboxmanager.ListResult;
 import org.apache.james.mailboxmanager.MailboxManagerException;
 import org.apache.james.mailboxmanager.MessageResult;
-import org.apache.james.mailboxmanager.Namespace;
-import org.apache.james.mailboxmanager.Namespaces;
 import org.apache.james.mailboxmanager.impl.ListResultImpl;
-import org.apache.james.mailboxmanager.impl.NamespaceImpl;
-import org.apache.james.mailboxmanager.impl.NamespacesImpl;
 import org.apache.james.mailboxmanager.mailbox.GeneralMailbox;
 import org.apache.james.mailboxmanager.mailbox.GeneralMailboxSession;
 import org.apache.james.mailboxmanager.mailbox.ImapMailboxSession;
@@ -50,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;
@@ -135,20 +127,6 @@
        return mailboxCache;
     }
     
-    public Namespaces getNamespaces(User forUser) {
-        NamespacesImpl nameSpaces=new NamespacesImpl();
-        nameSpaces.setShared(new Namespace[0]);
-        Namespace userNamespace=new NamespaceImpl(""+HIERARCHY_DELIMITER,USER_NAMESPACE);
-        nameSpaces.setUser(new Namespace[] {userNamespace}); 
-        Namespace personalDefault = getPersonalDefaultNamespace(forUser);
-        nameSpaces.setPersonal(new Namespace[] {personalDefault}); 
-        nameSpaces.setPersonalDefault(personalDefault);
-        return nameSpaces;
-    }
-
-    public Namespace getPersonalDefaultNamespace(User forUser) {
-        return new NamespaceImpl("" + HIERARCHY_DELIMITER,USER_NAMESPACE+HIERARCHY_DELIMITER+forUser.getUserName());
-    }
 
     public void createMailbox(String namespaceName)
             throws MailboxManagerException {

Modified: james/server/trunk/src/test/org/apache/james/imapserver/mock/MockImapHandlerConfigurationData.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/test/org/apache/james/imapserver/mock/MockImapHandlerConfigurationData.java?view=diff&rev=481870&r1=481869&r2=481870
==============================================================================
--- james/server/trunk/src/test/org/apache/james/imapserver/mock/MockImapHandlerConfigurationData.java
(original)
+++ james/server/trunk/src/test/org/apache/james/imapserver/mock/MockImapHandlerConfigurationData.java
Sun Dec  3 11:59:18 2006
@@ -1,3 +1,22 @@
+/****************************************************************
+ * 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.imapserver.mock;
 
 import org.apache.james.imapserver.ImapHandlerConfigurationData;

Modified: james/server/trunk/src/test/org/apache/james/mailboxmanager/mock/TorqueMailboxManagerProviderSingleton.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/test/org/apache/james/mailboxmanager/mock/TorqueMailboxManagerProviderSingleton.java?view=diff&rev=481870&r1=481869&r2=481870
==============================================================================
--- james/server/trunk/src/test/org/apache/james/mailboxmanager/mock/TorqueMailboxManagerProviderSingleton.java
(original)
+++ james/server/trunk/src/test/org/apache/james/mailboxmanager/mock/TorqueMailboxManagerProviderSingleton.java
Sun Dec  3 11:59:18 2006
@@ -1,22 +1,45 @@
+/****************************************************************
+ * 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.mock;
 
-import org.apache.james.mailboxmanager.torque.TorqueMailboxManagerProvider;
+import org.apache.james.mailboxmanager.impl.DefaultMailboxManagerProvider;
+import org.apache.james.mailboxmanager.manager.MailboxManagerProvider;
+import org.apache.james.mailboxmanager.torque.TorqueMailboxManagerFactory;
 import org.apache.james.test.mock.james.MockFileSystem;
 
 public class TorqueMailboxManagerProviderSingleton {
     
     
-    private static TorqueMailboxManagerProvider torqueMailboxManagerProvider;
+    private static DefaultMailboxManagerProvider defaultMailboxManagerProvider;
 
-    public synchronized static TorqueMailboxManagerProvider getTorqueMailboxManagerProviderInstance()
throws Exception {
-        if (torqueMailboxManagerProvider==null) {
-            torqueMailboxManagerProvider=new TorqueMailboxManagerProvider() {{
+    public synchronized static MailboxManagerProvider getTorqueMailboxManagerProviderInstance()
throws Exception {
+        if (defaultMailboxManagerProvider==null) {
+            TorqueMailboxManagerFactory torqueMailboxManagerFactory=new TorqueMailboxManagerFactory()
{{
                 setFileSystem(new MockFileSystem());
             }};
-            torqueMailboxManagerProvider.configureDefaults();
-            torqueMailboxManagerProvider.initialize();
+            torqueMailboxManagerFactory.configureDefaults();
+            torqueMailboxManagerFactory.initialize();
+            defaultMailboxManagerProvider=new DefaultMailboxManagerProvider();
+            defaultMailboxManagerProvider.setMailboxManagerFactory(torqueMailboxManagerFactory);
         }
-        return torqueMailboxManagerProvider;
+        return defaultMailboxManagerProvider;
         
     }
 



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