You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by er...@apache.org on 2010/12/28 15:41:51 UTC

svn commit: r1053359 - in /james/server/trunk/container-spring/src/main: config/james/ config/james/context/ java/org/apache/james/container/spring/tool/

Author: eric
Date: Tue Dec 28 14:41:50 2010
New Revision: 1053359

URL: http://svn.apache.org/viewvc?rev=1053359&view=rev
Log:
Skeleton for james 2.3 import - to be further discussed/developed for conf, packaging,... (JAMES-1052)

Added:
    james/server/trunk/container-spring/src/main/config/james/importjames23-usersrepository.xml
    james/server/trunk/container-spring/src/main/config/james/importjames23.xml
    james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/tool/
    james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/tool/James23Importer.java
Modified:
    james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml

Modified: james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml?rev=1053359&r1=1053358&r2=1053359&view=diff
==============================================================================
--- james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml (original)
+++ james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml Tue Dec 28 14:41:50 2010
@@ -87,6 +87,13 @@
               <!-- no alias needed -->
               <value></value>
             </entry>
+            <entry>
+              <key>
+                <value>importjames23-usersrepository</value>
+              </key>
+<!--               no alias needed -->
+              <value></value>
+            </entry>
           </map>
         </property>
     </bean>
@@ -318,6 +325,11 @@
     <bean id="mailboxcopier" class="org.apache.james.mailbox.copier.MailboxCopierImpl"/>
           
     <!-- 
+      Mailbox Import
+     -->
+    <bean id="importjames23" class="org.apache.james.container.spring.tool.James23Importer"/>
+          
+    <!-- 
     ===========================================================================
        Database DataSource
     ===========================================================================

Added: james/server/trunk/container-spring/src/main/config/james/importjames23-usersrepository.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/config/james/importjames23-usersrepository.xml?rev=1053359&view=auto
==============================================================================
--- james/server/trunk/container-spring/src/main/config/james/importjames23-usersrepository.xml (added)
+++ james/server/trunk/container-spring/src/main/config/james/importjames23-usersrepository.xml Tue Dec 28 14:41:50 2010
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<!--
+  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.                                           
+ -->
+<importjames23-usersrepository class="org.apache.james.user.file.UsersFileRepository">
+  <destination URL="file://var/users/" />
+  <ignoreCase>true</ignoreCase>
+  <enableAliases>true</enableAliases>
+  <enableForwarding>true</enableForwarding>
+  <enableVirtualHosting>false</enableVirtualHosting>
+</importjames23-usersrepository>

Added: james/server/trunk/container-spring/src/main/config/james/importjames23.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/config/james/importjames23.xml?rev=1053359&view=auto
==============================================================================
--- james/server/trunk/container-spring/src/main/config/james/importjames23.xml (added)
+++ james/server/trunk/container-spring/src/main/config/james/importjames23.xml Tue Dec 28 14:41:50 2010
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<!--
+  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.                                           
+ -->
+<importjames23>
+  <repositoryPath>file://var/mail/inboxes</repositoryPath>
+</importjames23>

Added: james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/tool/James23Importer.java
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/tool/James23Importer.java?rev=1053359&view=auto
==============================================================================
--- james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/tool/James23Importer.java (added)
+++ james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/tool/James23Importer.java Tue Dec 28 14:41:50 2010
@@ -0,0 +1,118 @@
+/****************************************************************
+ * 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.container.spring.tool;
+
+import java.util.Iterator;
+
+import javax.annotation.Resource;
+import javax.mail.MessagingException;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.james.lifecycle.api.Configurable;
+import org.apache.james.lifecycle.api.LogEnabled;
+import org.apache.james.mailbox.MailboxManager;
+import org.apache.james.mailrepository.api.MailRepository;
+import org.apache.james.mailrepository.api.MailRepositoryStore;
+import org.apache.james.mailrepository.api.MailRepositoryStore.MailRepostoryStoreException;
+import org.apache.james.user.api.UsersRepository;
+import org.apache.mailet.Mail;
+
+public class James23Importer implements Configurable, LogEnabled {
+    
+    /**
+     * The logger.
+     */
+    private Log log;
+    
+    /**
+     * The configuration.
+     */
+    private HierarchicalConfiguration config;
+
+    /**
+     * James 2.3 user repository defined by configuration.
+     */
+    @Resource(name = "importjames23-usersrepository")
+    private UsersRepository james23UsersRepository;
+    
+    /**
+     * James 3.0 users repository.
+     */
+    @Resource(name="usersrepository")
+    private UsersRepository usersRepository;
+
+    /**
+     * The mail repository store needed to select the james 2.3 mail repository.
+     */
+    @Resource(name="mailrepositorystore")
+    private MailRepositoryStore mailRepositoryStore;
+
+    /**
+     * The mailbox manager needed to copy the mails to.
+     */
+    @Resource(name="mailboxmanager")
+    private MailboxManager mailboxManager;
+
+    /**
+     * Copy 2.3 users to 3.0 users (taking virtualDomains into account)
+     * Copy 2.3 mails to 3.0 mails.
+     * 
+     * TODO: This is just a skeleton to talk about the architecture (conf,...)
+     * 
+     * @throws MailRepostoryStoreException
+     * @throws MessagingException
+     */
+    public void importFromJames23() throws MailRepostoryStoreException, MessagingException {
+        
+        String james23MailRepositoryPath = config.getString("repositoryPath");
+        
+        Iterator<String> j23uIt = james23UsersRepository.list();
+        
+        while (j23uIt.hasNext()) {
+            String user = j23uIt.next();
+            System.out.println("James 2.3 user:" + user);
+            MailRepository mailRepository = mailRepositoryStore.select(james23MailRepositoryPath + "/" + user);
+            Iterator<String> sr = mailRepository.list();
+            while (sr.hasNext()) {
+                Mail mail = mailRepository.retrieve(sr.next());
+                System.out.println(mail.getMessage().getSubject() 
+                        + ": " + mail.getMessage().getSize() 
+                        + " - " + mail.getMessage().getLineCount());
+            }
+        }
+        
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.james.lifecycle.api.LogEnabled#setLog(org.apache.commons.logging.Log)
+     */
+    public void setLog(Log log) {
+        this.log = log;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.james.lifecycle.api.Configurable#configure(org.apache.commons.configuration.HierarchicalConfiguration)
+     */
+    public void configure(HierarchicalConfiguration config) throws ConfigurationException {
+        this.config = config;
+    }
+    
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Re: svn commit: r1053359 - in /james/server/trunk/container-spring/src/main: config/james/ config/james/context/ java/org/apache/james/container/spring/tool/

Posted by Eric Charles <er...@apache.org>.
Hi,

This is a quick-draft to  import users and mails from james 2.3.
We should first discuss the conf which is for now in two separate files.
(I tried to configure to have a single file, but came to issue regarding 
the class loading, the class attribute being handled by the 
ConfigurationBeanFactoryPostProcessor).

Tks,

Eric


On 28/12/2010 15:41, eric@apache.org wrote:
>      james/server/trunk/container-spring/src/main/config/james/importjames23-usersrepository.xml
>      james/server/trunk/container-spring/src/main/config/james/importjames23.xml
>      james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/tool/
>      james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Re: svn commit: r1053359 - in /james/server/trunk/container-spring/src/main: config/james/ config/james/context/ java/org/apache/james/container/spring/tool/

Posted by Eric Charles <er...@apache.org>.
Yeah, tmp conf is not the best thing.
I will give another try via params.
Tks,
Eric

On 29/12/2010 17:17, Norman Maurer wrote:
> Could we not just pass all config params via jmx ? Having an
> "temporary" config is a bit hacky IMHO..
>
> Bye,
> Norman
>
> 2010/12/29 Eric Charles<er...@apache.org>:
>> Hi Norman,
>>
>> We need:
>> fromUsersRepository ->  toUsersRepository
>> fromMailRepository ->  toMailboxManager
>>
>> The to* are the ones defined by existing config. no worry about that.
>>
>> The fromMailRepository can be passed as parameter to the method (from jmx
>> client for example), and it will be used to select from MailRepositoryStore.
>>
>> The fromUsersRepository is for example a FileUsersRepository copied from
>> James 2.3 that needs to be injected (with some logic around the
>> defaultDomain) in a JPAUsersRepository for example (the James 3.0 one). This
>> is why I thought to have an additional config file. If we use the existing
>> usersrepository.xml one, we only have a toUsersRepository and not a
>> fromUsersRepository.
>>
>> Wdyt?
>> Tks,
>> Eric
>>
>>
>> On 29/12/2010 14:54, Norman Maurer wrote:
>>> Hi there,
>>>
>>> I think this makes sense. Anyway I think we could just use the
>>> "usersrepository" as source and not the
>>> "importjames23-usersrepository". There is not need for the
>>> importjames-23-* stuff as the user can just use his old
>>> UsersRepository config for users while importing. I think we also
>>> could just use param for the method for the url....
>>>
>>>> +    public void importFromJames23() throws MailRepostoryStoreException,
>>>> MessagingException {
>>> Should be :
>>>
>>>> +    public void importFromJames23(String url) throws
>>>> MailRepostoryStoreException, MessagingException {
>>> So no need for inject a config..
>>>
>>> Bye,
>>> Norman
>>>
>>> 2010/12/28<er...@apache.org>:
>>>> Author: eric
>>>> Date: Tue Dec 28 14:41:50 2010
>>>> New Revision: 1053359
>>>>
>>>> URL: http://svn.apache.org/viewvc?rev=1053359&view=rev
>>>> Log:
>>>> Skeleton for james 2.3 import - to be further discussed/developed for
>>>> conf, packaging,... (JAMES-1052)
>>>>
>>>> Added:
>>>>
>>>>   james/server/trunk/container-spring/src/main/config/james/importjames23-usersrepository.xml
>>>>
>>>>   james/server/trunk/container-spring/src/main/config/james/importjames23.xml
>>>>
>>>>   james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/tool/
>>>>
>>>>   james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/tool/James23Importer.java
>>>> Modified:
>>>>
>>>>   james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml
>>>>
>>>> Modified:
>>>> james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml
>>>> URL:
>>>> http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml?rev=1053359&r1=1053358&r2=1053359&view=diff
>>>>
>>>> ==============================================================================
>>>> ---
>>>> james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml
>>>> (original)
>>>> +++
>>>> james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml
>>>> Tue Dec 28 14:41:50 2010
>>>> @@ -87,6 +87,13 @@
>>>>                <!-- no alias needed -->
>>>>                <value></value>
>>>>              </entry>
>>>> +<entry>
>>>> +<key>
>>>> +<value>importjames23-usersrepository</value>
>>>> +</key>
>>>> +<!--               no alias needed -->
>>>> +<value></value>
>>>> +</entry>
>>>>            </map>
>>>>          </property>
>>>>      </bean>
>>>> @@ -318,6 +325,11 @@
>>>>      <bean id="mailboxcopier"
>>>> class="org.apache.james.mailbox.copier.MailboxCopierImpl"/>
>>>>
>>>>      <!--
>>>> +      Mailbox Import
>>>> +     -->
>>>> +<bean id="importjames23"
>>>> class="org.apache.james.container.spring.tool.James23Importer"/>
>>>> +
>>>> +<!--
>>>>
>>>> ===========================================================================
>>>>         Database DataSource
>>>>
>>>> ===========================================================================
>>>>
>>>> Added:
>>>> james/server/trunk/container-spring/src/main/config/james/importjames23-usersrepository.xml
>>>> URL:
>>>> http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/config/james/importjames23-usersrepository.xml?rev=1053359&view=auto
>>>>
>>>> ==============================================================================
>>>> ---
>>>> james/server/trunk/container-spring/src/main/config/james/importjames23-usersrepository.xml
>>>> (added)
>>>> +++
>>>> james/server/trunk/container-spring/src/main/config/james/importjames23-usersrepository.xml
>>>> Tue Dec 28 14:41:50 2010
>>>> @@ -0,0 +1,26 @@
>>>> +<?xml version="1.0"?>
>>>> +<!--
>>>> +  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.
>>>> + -->
>>>> +<importjames23-usersrepository
>>>> class="org.apache.james.user.file.UsersFileRepository">
>>>> +<destination URL="file://var/users/" />
>>>> +<ignoreCase>true</ignoreCase>
>>>> +<enableAliases>true</enableAliases>
>>>> +<enableForwarding>true</enableForwarding>
>>>> +<enableVirtualHosting>false</enableVirtualHosting>
>>>> +</importjames23-usersrepository>
>>>>
>>>> Added:
>>>> james/server/trunk/container-spring/src/main/config/james/importjames23.xml
>>>> URL:
>>>> http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/config/james/importjames23.xml?rev=1053359&view=auto
>>>>
>>>> ==============================================================================
>>>> ---
>>>> james/server/trunk/container-spring/src/main/config/james/importjames23.xml
>>>> (added)
>>>> +++
>>>> james/server/trunk/container-spring/src/main/config/james/importjames23.xml
>>>> Tue Dec 28 14:41:50 2010
>>>> @@ -0,0 +1,22 @@
>>>> +<?xml version="1.0"?>
>>>> +<!--
>>>> +  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.
>>>> + -->
>>>> +<importjames23>
>>>> +<repositoryPath>file://var/mail/inboxes</repositoryPath>
>>>> +</importjames23>
>>>>
>>>> Added:
>>>> james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/tool/James23Importer.java
>>>> URL:
>>>> http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/tool/James23Importer.java?rev=1053359&view=auto
>>>>
>>>> ==============================================================================
>>>> ---
>>>> james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/tool/James23Importer.java
>>>> (added)
>>>> +++
>>>> james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/tool/James23Importer.java
>>>> Tue Dec 28 14:41:50 2010
>>>> @@ -0,0 +1,118 @@
>>>> +/****************************************************************
>>>> + * 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.container.spring.tool;
>>>> +
>>>> +import java.util.Iterator;
>>>> +
>>>> +import javax.annotation.Resource;
>>>> +import javax.mail.MessagingException;
>>>> +
>>>> +import org.apache.commons.configuration.ConfigurationException;
>>>> +import org.apache.commons.configuration.HierarchicalConfiguration;
>>>> +import org.apache.commons.logging.Log;
>>>> +import org.apache.james.lifecycle.api.Configurable;
>>>> +import org.apache.james.lifecycle.api.LogEnabled;
>>>> +import org.apache.james.mailbox.MailboxManager;
>>>> +import org.apache.james.mailrepository.api.MailRepository;
>>>> +import org.apache.james.mailrepository.api.MailRepositoryStore;
>>>> +import
>>>> org.apache.james.mailrepository.api.MailRepositoryStore.MailRepostoryStoreException;
>>>> +import org.apache.james.user.api.UsersRepository;
>>>> +import org.apache.mailet.Mail;
>>>> +
>>>> +public class James23Importer implements Configurable, LogEnabled {
>>>> +
>>>> +    /**
>>>> +     * The logger.
>>>> +     */
>>>> +    private Log log;
>>>> +
>>>> +    /**
>>>> +     * The configuration.
>>>> +     */
>>>> +    private HierarchicalConfiguration config;
>>>> +
>>>> +    /**
>>>> +     * James 2.3 user repository defined by configuration.
>>>> +     */
>>>> +    @Resource(name = "importjames23-usersrepository")
>>>> +    private UsersRepository james23UsersRepository;
>>>> +
>>>> +    /**
>>>> +     * James 3.0 users repository.
>>>> +     */
>>>> +    @Resource(name="usersrepository")
>>>> +    private UsersRepository usersRepository;
>>>> +
>>>> +    /**
>>>> +     * The mail repository store needed to select the james 2.3 mail
>>>> repository.
>>>> +     */
>>>> +    @Resource(name="mailrepositorystore")
>>>> +    private MailRepositoryStore mailRepositoryStore;
>>>> +
>>>> +    /**
>>>> +     * The mailbox manager needed to copy the mails to.
>>>> +     */
>>>> +    @Resource(name="mailboxmanager")
>>>> +    private MailboxManager mailboxManager;
>>>> +
>>>> +    /**
>>>> +     * Copy 2.3 users to 3.0 users (taking virtualDomains into account)
>>>> +     * Copy 2.3 mails to 3.0 mails.
>>>> +     *
>>>> +     * TODO: This is just a skeleton to talk about the architecture
>>>> (conf,...)
>>>> +     *
>>>> +     * @throws MailRepostoryStoreException
>>>> +     * @throws MessagingException
>>>> +     */
>>>> +    public void importFromJames23() throws MailRepostoryStoreException,
>>>> MessagingException {
>>>> +
>>>> +        String james23MailRepositoryPath =
>>>> config.getString("repositoryPath");
>>>> +
>>>> +        Iterator<String>    j23uIt = james23UsersRepository.list();
>>>> +
>>>> +        while (j23uIt.hasNext()) {
>>>> +            String user = j23uIt.next();
>>>> +            System.out.println("James 2.3 user:" + user);
>>>> +            MailRepository mailRepository =
>>>> mailRepositoryStore.select(james23MailRepositoryPath + "/" + user);
>>>> +            Iterator<String>    sr = mailRepository.list();
>>>> +            while (sr.hasNext()) {
>>>> +                Mail mail = mailRepository.retrieve(sr.next());
>>>> +                System.out.println(mail.getMessage().getSubject()
>>>> +                        + ": " + mail.getMessage().getSize()
>>>> +                        + " - " + mail.getMessage().getLineCount());
>>>> +            }
>>>> +        }
>>>> +
>>>> +    }
>>>> +
>>>> +    /* (non-Javadoc)
>>>> +     * @see
>>>> org.apache.james.lifecycle.api.LogEnabled#setLog(org.apache.commons.logging.Log)
>>>> +     */
>>>> +    public void setLog(Log log) {
>>>> +        this.log = log;
>>>> +    }
>>>> +
>>>> +    /* (non-Javadoc)
>>>> +     * @see
>>>> org.apache.james.lifecycle.api.Configurable#configure(org.apache.commons.configuration.HierarchicalConfiguration)
>>>> +     */
>>>> +    public void configure(HierarchicalConfiguration config) throws
>>>> ConfigurationException {
>>>> +        this.config = config;
>>>> +    }
>>>> +
>>>> +}
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
>>>> For additional commands, e-mail: server-dev-help@james.apache.org
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
>>> For additional commands, e-mail: server-dev-help@james.apache.org
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
>> For additional commands, e-mail: server-dev-help@james.apache.org
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
> For additional commands, e-mail: server-dev-help@james.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Re: svn commit: r1053359 - in /james/server/trunk/container-spring/src/main: config/james/ config/james/context/ java/org/apache/james/container/spring/tool/

Posted by Norman Maurer <no...@apache.org>.
Could we not just pass all config params via jmx ? Having an
"temporary" config is a bit hacky IMHO..

Bye,
Norman

2010/12/29 Eric Charles <er...@apache.org>:
> Hi Norman,
>
> We need:
> fromUsersRepository -> toUsersRepository
> fromMailRepository -> toMailboxManager
>
> The to* are the ones defined by existing config. no worry about that.
>
> The fromMailRepository can be passed as parameter to the method (from jmx
> client for example), and it will be used to select from MailRepositoryStore.
>
> The fromUsersRepository is for example a FileUsersRepository copied from
> James 2.3 that needs to be injected (with some logic around the
> defaultDomain) in a JPAUsersRepository for example (the James 3.0 one). This
> is why I thought to have an additional config file. If we use the existing
> usersrepository.xml one, we only have a toUsersRepository and not a
> fromUsersRepository.
>
> Wdyt?
> Tks,
> Eric
>
>
> On 29/12/2010 14:54, Norman Maurer wrote:
>>
>> Hi there,
>>
>> I think this makes sense. Anyway I think we could just use the
>> "usersrepository" as source and not the
>> "importjames23-usersrepository". There is not need for the
>> importjames-23-* stuff as the user can just use his old
>> UsersRepository config for users while importing. I think we also
>> could just use param for the method for the url....
>>
>>> +    public void importFromJames23() throws MailRepostoryStoreException,
>>> MessagingException {
>>
>> Should be :
>>
>>> +    public void importFromJames23(String url) throws
>>> MailRepostoryStoreException, MessagingException {
>>
>> So no need for inject a config..
>>
>> Bye,
>> Norman
>>
>> 2010/12/28<er...@apache.org>:
>>>
>>> Author: eric
>>> Date: Tue Dec 28 14:41:50 2010
>>> New Revision: 1053359
>>>
>>> URL: http://svn.apache.org/viewvc?rev=1053359&view=rev
>>> Log:
>>> Skeleton for james 2.3 import - to be further discussed/developed for
>>> conf, packaging,... (JAMES-1052)
>>>
>>> Added:
>>>
>>>  james/server/trunk/container-spring/src/main/config/james/importjames23-usersrepository.xml
>>>
>>>  james/server/trunk/container-spring/src/main/config/james/importjames23.xml
>>>
>>>  james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/tool/
>>>
>>>  james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/tool/James23Importer.java
>>> Modified:
>>>
>>>  james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml
>>>
>>> Modified:
>>> james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml
>>> URL:
>>> http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml?rev=1053359&r1=1053358&r2=1053359&view=diff
>>>
>>> ==============================================================================
>>> ---
>>> james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml
>>> (original)
>>> +++
>>> james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml
>>> Tue Dec 28 14:41:50 2010
>>> @@ -87,6 +87,13 @@
>>>               <!-- no alias needed -->
>>>               <value></value>
>>>             </entry>
>>> +<entry>
>>> +<key>
>>> +<value>importjames23-usersrepository</value>
>>> +</key>
>>> +<!--               no alias needed -->
>>> +<value></value>
>>> +</entry>
>>>           </map>
>>>         </property>
>>>     </bean>
>>> @@ -318,6 +325,11 @@
>>>     <bean id="mailboxcopier"
>>> class="org.apache.james.mailbox.copier.MailboxCopierImpl"/>
>>>
>>>     <!--
>>> +      Mailbox Import
>>> +     -->
>>> +<bean id="importjames23"
>>> class="org.apache.james.container.spring.tool.James23Importer"/>
>>> +
>>> +<!--
>>>
>>> ===========================================================================
>>>        Database DataSource
>>>
>>> ===========================================================================
>>>
>>> Added:
>>> james/server/trunk/container-spring/src/main/config/james/importjames23-usersrepository.xml
>>> URL:
>>> http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/config/james/importjames23-usersrepository.xml?rev=1053359&view=auto
>>>
>>> ==============================================================================
>>> ---
>>> james/server/trunk/container-spring/src/main/config/james/importjames23-usersrepository.xml
>>> (added)
>>> +++
>>> james/server/trunk/container-spring/src/main/config/james/importjames23-usersrepository.xml
>>> Tue Dec 28 14:41:50 2010
>>> @@ -0,0 +1,26 @@
>>> +<?xml version="1.0"?>
>>> +<!--
>>> +  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.
>>> + -->
>>> +<importjames23-usersrepository
>>> class="org.apache.james.user.file.UsersFileRepository">
>>> +<destination URL="file://var/users/" />
>>> +<ignoreCase>true</ignoreCase>
>>> +<enableAliases>true</enableAliases>
>>> +<enableForwarding>true</enableForwarding>
>>> +<enableVirtualHosting>false</enableVirtualHosting>
>>> +</importjames23-usersrepository>
>>>
>>> Added:
>>> james/server/trunk/container-spring/src/main/config/james/importjames23.xml
>>> URL:
>>> http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/config/james/importjames23.xml?rev=1053359&view=auto
>>>
>>> ==============================================================================
>>> ---
>>> james/server/trunk/container-spring/src/main/config/james/importjames23.xml
>>> (added)
>>> +++
>>> james/server/trunk/container-spring/src/main/config/james/importjames23.xml
>>> Tue Dec 28 14:41:50 2010
>>> @@ -0,0 +1,22 @@
>>> +<?xml version="1.0"?>
>>> +<!--
>>> +  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.
>>> + -->
>>> +<importjames23>
>>> +<repositoryPath>file://var/mail/inboxes</repositoryPath>
>>> +</importjames23>
>>>
>>> Added:
>>> james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/tool/James23Importer.java
>>> URL:
>>> http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/tool/James23Importer.java?rev=1053359&view=auto
>>>
>>> ==============================================================================
>>> ---
>>> james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/tool/James23Importer.java
>>> (added)
>>> +++
>>> james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/tool/James23Importer.java
>>> Tue Dec 28 14:41:50 2010
>>> @@ -0,0 +1,118 @@
>>> +/****************************************************************
>>> + * 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.container.spring.tool;
>>> +
>>> +import java.util.Iterator;
>>> +
>>> +import javax.annotation.Resource;
>>> +import javax.mail.MessagingException;
>>> +
>>> +import org.apache.commons.configuration.ConfigurationException;
>>> +import org.apache.commons.configuration.HierarchicalConfiguration;
>>> +import org.apache.commons.logging.Log;
>>> +import org.apache.james.lifecycle.api.Configurable;
>>> +import org.apache.james.lifecycle.api.LogEnabled;
>>> +import org.apache.james.mailbox.MailboxManager;
>>> +import org.apache.james.mailrepository.api.MailRepository;
>>> +import org.apache.james.mailrepository.api.MailRepositoryStore;
>>> +import
>>> org.apache.james.mailrepository.api.MailRepositoryStore.MailRepostoryStoreException;
>>> +import org.apache.james.user.api.UsersRepository;
>>> +import org.apache.mailet.Mail;
>>> +
>>> +public class James23Importer implements Configurable, LogEnabled {
>>> +
>>> +    /**
>>> +     * The logger.
>>> +     */
>>> +    private Log log;
>>> +
>>> +    /**
>>> +     * The configuration.
>>> +     */
>>> +    private HierarchicalConfiguration config;
>>> +
>>> +    /**
>>> +     * James 2.3 user repository defined by configuration.
>>> +     */
>>> +    @Resource(name = "importjames23-usersrepository")
>>> +    private UsersRepository james23UsersRepository;
>>> +
>>> +    /**
>>> +     * James 3.0 users repository.
>>> +     */
>>> +    @Resource(name="usersrepository")
>>> +    private UsersRepository usersRepository;
>>> +
>>> +    /**
>>> +     * The mail repository store needed to select the james 2.3 mail
>>> repository.
>>> +     */
>>> +    @Resource(name="mailrepositorystore")
>>> +    private MailRepositoryStore mailRepositoryStore;
>>> +
>>> +    /**
>>> +     * The mailbox manager needed to copy the mails to.
>>> +     */
>>> +    @Resource(name="mailboxmanager")
>>> +    private MailboxManager mailboxManager;
>>> +
>>> +    /**
>>> +     * Copy 2.3 users to 3.0 users (taking virtualDomains into account)
>>> +     * Copy 2.3 mails to 3.0 mails.
>>> +     *
>>> +     * TODO: This is just a skeleton to talk about the architecture
>>> (conf,...)
>>> +     *
>>> +     * @throws MailRepostoryStoreException
>>> +     * @throws MessagingException
>>> +     */
>>> +    public void importFromJames23() throws MailRepostoryStoreException,
>>> MessagingException {
>>> +
>>> +        String james23MailRepositoryPath =
>>> config.getString("repositoryPath");
>>> +
>>> +        Iterator<String>  j23uIt = james23UsersRepository.list();
>>> +
>>> +        while (j23uIt.hasNext()) {
>>> +            String user = j23uIt.next();
>>> +            System.out.println("James 2.3 user:" + user);
>>> +            MailRepository mailRepository =
>>> mailRepositoryStore.select(james23MailRepositoryPath + "/" + user);
>>> +            Iterator<String>  sr = mailRepository.list();
>>> +            while (sr.hasNext()) {
>>> +                Mail mail = mailRepository.retrieve(sr.next());
>>> +                System.out.println(mail.getMessage().getSubject()
>>> +                        + ": " + mail.getMessage().getSize()
>>> +                        + " - " + mail.getMessage().getLineCount());
>>> +            }
>>> +        }
>>> +
>>> +    }
>>> +
>>> +    /* (non-Javadoc)
>>> +     * @see
>>> org.apache.james.lifecycle.api.LogEnabled#setLog(org.apache.commons.logging.Log)
>>> +     */
>>> +    public void setLog(Log log) {
>>> +        this.log = log;
>>> +    }
>>> +
>>> +    /* (non-Javadoc)
>>> +     * @see
>>> org.apache.james.lifecycle.api.Configurable#configure(org.apache.commons.configuration.HierarchicalConfiguration)
>>> +     */
>>> +    public void configure(HierarchicalConfiguration config) throws
>>> ConfigurationException {
>>> +        this.config = config;
>>> +    }
>>> +
>>> +}
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
>>> For additional commands, e-mail: server-dev-help@james.apache.org
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
>> For additional commands, e-mail: server-dev-help@james.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
> For additional commands, e-mail: server-dev-help@james.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Re: svn commit: r1053359 - in /james/server/trunk/container-spring/src/main: config/james/ config/james/context/ java/org/apache/james/container/spring/tool/

Posted by Eric Charles <er...@apache.org>.
Hi Norman,

We need:
fromUsersRepository -> toUsersRepository
fromMailRepository -> toMailboxManager

The to* are the ones defined by existing config. no worry about that.

The fromMailRepository can be passed as parameter to the method (from 
jmx client for example), and it will be used to select from 
MailRepositoryStore.

The fromUsersRepository is for example a FileUsersRepository copied from 
James 2.3 that needs to be injected (with some logic around the 
defaultDomain) in a JPAUsersRepository for example (the James 3.0 one). 
This is why I thought to have an additional config file. If we use the 
existing usersrepository.xml one, we only have a toUsersRepository and 
not a fromUsersRepository.

Wdyt?
Tks,
Eric


On 29/12/2010 14:54, Norman Maurer wrote:
> Hi there,
>
> I think this makes sense. Anyway I think we could just use the
> "usersrepository" as source and not the
> "importjames23-usersrepository". There is not need for the
> importjames-23-* stuff as the user can just use his old
> UsersRepository config for users while importing. I think we also
> could just use param for the method for the url....
>
>> +    public void importFromJames23() throws MailRepostoryStoreException, MessagingException {
> Should be :
>
>> +    public void importFromJames23(String url) throws MailRepostoryStoreException, MessagingException {
> So no need for inject a config..
>
> Bye,
> Norman
>
> 2010/12/28<er...@apache.org>:
>> Author: eric
>> Date: Tue Dec 28 14:41:50 2010
>> New Revision: 1053359
>>
>> URL: http://svn.apache.org/viewvc?rev=1053359&view=rev
>> Log:
>> Skeleton for james 2.3 import - to be further discussed/developed for conf, packaging,... (JAMES-1052)
>>
>> Added:
>>     james/server/trunk/container-spring/src/main/config/james/importjames23-usersrepository.xml
>>     james/server/trunk/container-spring/src/main/config/james/importjames23.xml
>>     james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/tool/
>>     james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/tool/James23Importer.java
>> Modified:
>>     james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml
>>
>> Modified: james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml
>> URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml?rev=1053359&r1=1053358&r2=1053359&view=diff
>> ==============================================================================
>> --- james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml (original)
>> +++ james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml Tue Dec 28 14:41:50 2010
>> @@ -87,6 +87,13 @@
>>                <!-- no alias needed -->
>>                <value></value>
>>              </entry>
>> +<entry>
>> +<key>
>> +<value>importjames23-usersrepository</value>
>> +</key>
>> +<!--               no alias needed -->
>> +<value></value>
>> +</entry>
>>            </map>
>>          </property>
>>      </bean>
>> @@ -318,6 +325,11 @@
>>      <bean id="mailboxcopier" class="org.apache.james.mailbox.copier.MailboxCopierImpl"/>
>>
>>      <!--
>> +      Mailbox Import
>> +     -->
>> +<bean id="importjames23" class="org.apache.james.container.spring.tool.James23Importer"/>
>> +
>> +<!--
>>      ===========================================================================
>>         Database DataSource
>>      ===========================================================================
>>
>> Added: james/server/trunk/container-spring/src/main/config/james/importjames23-usersrepository.xml
>> URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/config/james/importjames23-usersrepository.xml?rev=1053359&view=auto
>> ==============================================================================
>> --- james/server/trunk/container-spring/src/main/config/james/importjames23-usersrepository.xml (added)
>> +++ james/server/trunk/container-spring/src/main/config/james/importjames23-usersrepository.xml Tue Dec 28 14:41:50 2010
>> @@ -0,0 +1,26 @@
>> +<?xml version="1.0"?>
>> +<!--
>> +  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.
>> + -->
>> +<importjames23-usersrepository class="org.apache.james.user.file.UsersFileRepository">
>> +<destination URL="file://var/users/" />
>> +<ignoreCase>true</ignoreCase>
>> +<enableAliases>true</enableAliases>
>> +<enableForwarding>true</enableForwarding>
>> +<enableVirtualHosting>false</enableVirtualHosting>
>> +</importjames23-usersrepository>
>>
>> Added: james/server/trunk/container-spring/src/main/config/james/importjames23.xml
>> URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/config/james/importjames23.xml?rev=1053359&view=auto
>> ==============================================================================
>> --- james/server/trunk/container-spring/src/main/config/james/importjames23.xml (added)
>> +++ james/server/trunk/container-spring/src/main/config/james/importjames23.xml Tue Dec 28 14:41:50 2010
>> @@ -0,0 +1,22 @@
>> +<?xml version="1.0"?>
>> +<!--
>> +  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.
>> + -->
>> +<importjames23>
>> +<repositoryPath>file://var/mail/inboxes</repositoryPath>
>> +</importjames23>
>>
>> Added: james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/tool/James23Importer.java
>> URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/tool/James23Importer.java?rev=1053359&view=auto
>> ==============================================================================
>> --- james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/tool/James23Importer.java (added)
>> +++ james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/tool/James23Importer.java Tue Dec 28 14:41:50 2010
>> @@ -0,0 +1,118 @@
>> +/****************************************************************
>> + * 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.container.spring.tool;
>> +
>> +import java.util.Iterator;
>> +
>> +import javax.annotation.Resource;
>> +import javax.mail.MessagingException;
>> +
>> +import org.apache.commons.configuration.ConfigurationException;
>> +import org.apache.commons.configuration.HierarchicalConfiguration;
>> +import org.apache.commons.logging.Log;
>> +import org.apache.james.lifecycle.api.Configurable;
>> +import org.apache.james.lifecycle.api.LogEnabled;
>> +import org.apache.james.mailbox.MailboxManager;
>> +import org.apache.james.mailrepository.api.MailRepository;
>> +import org.apache.james.mailrepository.api.MailRepositoryStore;
>> +import org.apache.james.mailrepository.api.MailRepositoryStore.MailRepostoryStoreException;
>> +import org.apache.james.user.api.UsersRepository;
>> +import org.apache.mailet.Mail;
>> +
>> +public class James23Importer implements Configurable, LogEnabled {
>> +
>> +    /**
>> +     * The logger.
>> +     */
>> +    private Log log;
>> +
>> +    /**
>> +     * The configuration.
>> +     */
>> +    private HierarchicalConfiguration config;
>> +
>> +    /**
>> +     * James 2.3 user repository defined by configuration.
>> +     */
>> +    @Resource(name = "importjames23-usersrepository")
>> +    private UsersRepository james23UsersRepository;
>> +
>> +    /**
>> +     * James 3.0 users repository.
>> +     */
>> +    @Resource(name="usersrepository")
>> +    private UsersRepository usersRepository;
>> +
>> +    /**
>> +     * The mail repository store needed to select the james 2.3 mail repository.
>> +     */
>> +    @Resource(name="mailrepositorystore")
>> +    private MailRepositoryStore mailRepositoryStore;
>> +
>> +    /**
>> +     * The mailbox manager needed to copy the mails to.
>> +     */
>> +    @Resource(name="mailboxmanager")
>> +    private MailboxManager mailboxManager;
>> +
>> +    /**
>> +     * Copy 2.3 users to 3.0 users (taking virtualDomains into account)
>> +     * Copy 2.3 mails to 3.0 mails.
>> +     *
>> +     * TODO: This is just a skeleton to talk about the architecture (conf,...)
>> +     *
>> +     * @throws MailRepostoryStoreException
>> +     * @throws MessagingException
>> +     */
>> +    public void importFromJames23() throws MailRepostoryStoreException, MessagingException {
>> +
>> +        String james23MailRepositoryPath = config.getString("repositoryPath");
>> +
>> +        Iterator<String>  j23uIt = james23UsersRepository.list();
>> +
>> +        while (j23uIt.hasNext()) {
>> +            String user = j23uIt.next();
>> +            System.out.println("James 2.3 user:" + user);
>> +            MailRepository mailRepository = mailRepositoryStore.select(james23MailRepositoryPath + "/" + user);
>> +            Iterator<String>  sr = mailRepository.list();
>> +            while (sr.hasNext()) {
>> +                Mail mail = mailRepository.retrieve(sr.next());
>> +                System.out.println(mail.getMessage().getSubject()
>> +                        + ": " + mail.getMessage().getSize()
>> +                        + " - " + mail.getMessage().getLineCount());
>> +            }
>> +        }
>> +
>> +    }
>> +
>> +    /* (non-Javadoc)
>> +     * @see org.apache.james.lifecycle.api.LogEnabled#setLog(org.apache.commons.logging.Log)
>> +     */
>> +    public void setLog(Log log) {
>> +        this.log = log;
>> +    }
>> +
>> +    /* (non-Javadoc)
>> +     * @see org.apache.james.lifecycle.api.Configurable#configure(org.apache.commons.configuration.HierarchicalConfiguration)
>> +     */
>> +    public void configure(HierarchicalConfiguration config) throws ConfigurationException {
>> +        this.config = config;
>> +    }
>> +
>> +}
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
>> For additional commands, e-mail: server-dev-help@james.apache.org
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
> For additional commands, e-mail: server-dev-help@james.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Re: svn commit: r1053359 - in /james/server/trunk/container-spring/src/main: config/james/ config/james/context/ java/org/apache/james/container/spring/tool/

Posted by Norman Maurer <no...@apache.org>.
Hi there,

I think this makes sense. Anyway I think we could just use the
"usersrepository" as source and not the
"importjames23-usersrepository". There is not need for the
importjames-23-* stuff as the user can just use his old
UsersRepository config for users while importing. I think we also
could just use param for the method for the url....

> +    public void importFromJames23() throws MailRepostoryStoreException, MessagingException {

Should be :

> +    public void importFromJames23(String url) throws MailRepostoryStoreException, MessagingException {

So no need for inject a config..

Bye,
Norman

2010/12/28  <er...@apache.org>:
> Author: eric
> Date: Tue Dec 28 14:41:50 2010
> New Revision: 1053359
>
> URL: http://svn.apache.org/viewvc?rev=1053359&view=rev
> Log:
> Skeleton for james 2.3 import - to be further discussed/developed for conf, packaging,... (JAMES-1052)
>
> Added:
>    james/server/trunk/container-spring/src/main/config/james/importjames23-usersrepository.xml
>    james/server/trunk/container-spring/src/main/config/james/importjames23.xml
>    james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/tool/
>    james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/tool/James23Importer.java
> Modified:
>    james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml
>
> Modified: james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml
> URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml?rev=1053359&r1=1053358&r2=1053359&view=diff
> ==============================================================================
> --- james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml (original)
> +++ james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml Tue Dec 28 14:41:50 2010
> @@ -87,6 +87,13 @@
>               <!-- no alias needed -->
>               <value></value>
>             </entry>
> +            <entry>
> +              <key>
> +                <value>importjames23-usersrepository</value>
> +              </key>
> +<!--               no alias needed -->
> +              <value></value>
> +            </entry>
>           </map>
>         </property>
>     </bean>
> @@ -318,6 +325,11 @@
>     <bean id="mailboxcopier" class="org.apache.james.mailbox.copier.MailboxCopierImpl"/>
>
>     <!--
> +      Mailbox Import
> +     -->
> +    <bean id="importjames23" class="org.apache.james.container.spring.tool.James23Importer"/>
> +
> +    <!--
>     ===========================================================================
>        Database DataSource
>     ===========================================================================
>
> Added: james/server/trunk/container-spring/src/main/config/james/importjames23-usersrepository.xml
> URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/config/james/importjames23-usersrepository.xml?rev=1053359&view=auto
> ==============================================================================
> --- james/server/trunk/container-spring/src/main/config/james/importjames23-usersrepository.xml (added)
> +++ james/server/trunk/container-spring/src/main/config/james/importjames23-usersrepository.xml Tue Dec 28 14:41:50 2010
> @@ -0,0 +1,26 @@
> +<?xml version="1.0"?>
> +<!--
> +  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.
> + -->
> +<importjames23-usersrepository class="org.apache.james.user.file.UsersFileRepository">
> +  <destination URL="file://var/users/" />
> +  <ignoreCase>true</ignoreCase>
> +  <enableAliases>true</enableAliases>
> +  <enableForwarding>true</enableForwarding>
> +  <enableVirtualHosting>false</enableVirtualHosting>
> +</importjames23-usersrepository>
>
> Added: james/server/trunk/container-spring/src/main/config/james/importjames23.xml
> URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/config/james/importjames23.xml?rev=1053359&view=auto
> ==============================================================================
> --- james/server/trunk/container-spring/src/main/config/james/importjames23.xml (added)
> +++ james/server/trunk/container-spring/src/main/config/james/importjames23.xml Tue Dec 28 14:41:50 2010
> @@ -0,0 +1,22 @@
> +<?xml version="1.0"?>
> +<!--
> +  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.
> + -->
> +<importjames23>
> +  <repositoryPath>file://var/mail/inboxes</repositoryPath>
> +</importjames23>
>
> Added: james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/tool/James23Importer.java
> URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/tool/James23Importer.java?rev=1053359&view=auto
> ==============================================================================
> --- james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/tool/James23Importer.java (added)
> +++ james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/tool/James23Importer.java Tue Dec 28 14:41:50 2010
> @@ -0,0 +1,118 @@
> +/****************************************************************
> + * 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.container.spring.tool;
> +
> +import java.util.Iterator;
> +
> +import javax.annotation.Resource;
> +import javax.mail.MessagingException;
> +
> +import org.apache.commons.configuration.ConfigurationException;
> +import org.apache.commons.configuration.HierarchicalConfiguration;
> +import org.apache.commons.logging.Log;
> +import org.apache.james.lifecycle.api.Configurable;
> +import org.apache.james.lifecycle.api.LogEnabled;
> +import org.apache.james.mailbox.MailboxManager;
> +import org.apache.james.mailrepository.api.MailRepository;
> +import org.apache.james.mailrepository.api.MailRepositoryStore;
> +import org.apache.james.mailrepository.api.MailRepositoryStore.MailRepostoryStoreException;
> +import org.apache.james.user.api.UsersRepository;
> +import org.apache.mailet.Mail;
> +
> +public class James23Importer implements Configurable, LogEnabled {
> +
> +    /**
> +     * The logger.
> +     */
> +    private Log log;
> +
> +    /**
> +     * The configuration.
> +     */
> +    private HierarchicalConfiguration config;
> +
> +    /**
> +     * James 2.3 user repository defined by configuration.
> +     */
> +    @Resource(name = "importjames23-usersrepository")
> +    private UsersRepository james23UsersRepository;
> +
> +    /**
> +     * James 3.0 users repository.
> +     */
> +    @Resource(name="usersrepository")
> +    private UsersRepository usersRepository;
> +
> +    /**
> +     * The mail repository store needed to select the james 2.3 mail repository.
> +     */
> +    @Resource(name="mailrepositorystore")
> +    private MailRepositoryStore mailRepositoryStore;
> +
> +    /**
> +     * The mailbox manager needed to copy the mails to.
> +     */
> +    @Resource(name="mailboxmanager")
> +    private MailboxManager mailboxManager;
> +
> +    /**
> +     * Copy 2.3 users to 3.0 users (taking virtualDomains into account)
> +     * Copy 2.3 mails to 3.0 mails.
> +     *
> +     * TODO: This is just a skeleton to talk about the architecture (conf,...)
> +     *
> +     * @throws MailRepostoryStoreException
> +     * @throws MessagingException
> +     */
> +    public void importFromJames23() throws MailRepostoryStoreException, MessagingException {
> +
> +        String james23MailRepositoryPath = config.getString("repositoryPath");
> +
> +        Iterator<String> j23uIt = james23UsersRepository.list();
> +
> +        while (j23uIt.hasNext()) {
> +            String user = j23uIt.next();
> +            System.out.println("James 2.3 user:" + user);
> +            MailRepository mailRepository = mailRepositoryStore.select(james23MailRepositoryPath + "/" + user);
> +            Iterator<String> sr = mailRepository.list();
> +            while (sr.hasNext()) {
> +                Mail mail = mailRepository.retrieve(sr.next());
> +                System.out.println(mail.getMessage().getSubject()
> +                        + ": " + mail.getMessage().getSize()
> +                        + " - " + mail.getMessage().getLineCount());
> +            }
> +        }
> +
> +    }
> +
> +    /* (non-Javadoc)
> +     * @see org.apache.james.lifecycle.api.LogEnabled#setLog(org.apache.commons.logging.Log)
> +     */
> +    public void setLog(Log log) {
> +        this.log = log;
> +    }
> +
> +    /* (non-Javadoc)
> +     * @see org.apache.james.lifecycle.api.Configurable#configure(org.apache.commons.configuration.HierarchicalConfiguration)
> +     */
> +    public void configure(HierarchicalConfiguration config) throws ConfigurationException {
> +        this.config = config;
> +    }
> +
> +}
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
> For additional commands, e-mail: server-dev-help@james.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org