james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Norman Maurer <nor...@apache.org>
Subject Re: svn commit: r1051145 - in /james/mailbox/trunk/copier/src: main/java/org/apache/james/mailbox/copier/ test/java/org/apache/james/mailbox/copier/
Date Mon, 20 Dec 2010 15:48:33 GMT
Any reason why you use Boolean and not boolean ?

Bye,
Norman

2010/12/20  <eric@apache.org>:
> Author: eric
> Date: Mon Dec 20 15:32:20 2010
> New Revision: 1051145
>
> URL: http://svn.apache.org/viewvc?rev=1051145&view=rev
> Log:
> Javadoc the mailbox copier project (MAILBOX-19)
>
> Modified:
>    james/mailbox/trunk/copier/src/main/java/org/apache/james/mailbox/copier/MailboxCopier.java
>    james/mailbox/trunk/copier/src/main/java/org/apache/james/mailbox/copier/MailboxCopierImpl.java
>    james/mailbox/trunk/copier/src/main/java/org/apache/james/mailbox/copier/MailboxCopierManagement.java
>    james/mailbox/trunk/copier/src/main/java/org/apache/james/mailbox/copier/MailboxCopierManagementMBean.java
>    james/mailbox/trunk/copier/src/test/java/org/apache/james/mailbox/copier/MailboxCopierTest.java
>
> Modified: james/mailbox/trunk/copier/src/main/java/org/apache/james/mailbox/copier/MailboxCopier.java
> URL: http://svn.apache.org/viewvc/james/mailbox/trunk/copier/src/main/java/org/apache/james/mailbox/copier/MailboxCopier.java?rev=1051145&r1=1051144&r2=1051145&view=diff
> ==============================================================================
> --- james/mailbox/trunk/copier/src/main/java/org/apache/james/mailbox/copier/MailboxCopier.java
(original)
> +++ james/mailbox/trunk/copier/src/main/java/org/apache/james/mailbox/copier/MailboxCopier.java
Mon Dec 20 15:32:20 2010
> @@ -18,8 +18,23 @@
>  ****************************************************************/
>  package org.apache.james.mailbox.copier;
>
> +/**
> + * Interface that exposes a method aimed to copy all
> + * mailboxes from a source mailbox manager to a destination
> + * mailbox manager.
> + *
> + */
>  public interface MailboxCopier {
>
> -       public Boolean copyMailboxes();
> -
> +       /**
> +        * Copy the mailboxes from a mailbox manager to another mailbox manager.
> +        * The implementation is responsible to read all mailboxes form the
> +        * injected srcMailboxManager and to copy all its contents to the
> +        * dstMailboxManager.
> +        *
> +        * @return true if copy is completely successful, false if copy fails
> +        * at any step.
> +        */
> +       Boolean copyMailboxes();
> +
>  }
>
> Modified: james/mailbox/trunk/copier/src/main/java/org/apache/james/mailbox/copier/MailboxCopierImpl.java
> URL: http://svn.apache.org/viewvc/james/mailbox/trunk/copier/src/main/java/org/apache/james/mailbox/copier/MailboxCopierImpl.java?rev=1051145&r1=1051144&r2=1051145&view=diff
> ==============================================================================
> --- james/mailbox/trunk/copier/src/main/java/org/apache/james/mailbox/copier/MailboxCopierImpl.java
(original)
> +++ james/mailbox/trunk/copier/src/main/java/org/apache/james/mailbox/copier/MailboxCopierImpl.java
Mon Dec 20 15:32:20 2010
> @@ -37,14 +37,32 @@ import org.apache.james.mailbox.MessageR
>  import org.apache.james.mailbox.store.streaming.InputStreamContent;
>  import org.apache.james.mailbox.util.FetchGroupImpl;
>
> +/**
> + * Implementation of the {@link MailboxCopier} interface.
> + *
> + */
>  public class MailboxCopierImpl implements MailboxCopier {
>
> +    /**
> +     * The logger.
> +     */
>     private Log log = LogFactory.getLog("org.apache.james.mailbox.copier");
>
> +    /**
> +     * The source MailboxManager from which all mailboxes will be read
> +     * and copied to the destination MailboxManager.
> +     */
>     private MailboxManager srcMailboxManager;
>
> +       /**
> +     * The destination MailboxManager to which all mailboxes read from
> +     * the source MailboxManager and copied to the destination MailboxManager.
> +        */
>        private MailboxManager dstMailboxManager;
>
> +       /* (non-Javadoc)
> +        * @see org.apache.james.mailbox.copier.MailboxCopier#copyMailboxes()
> +        */
>        public Boolean copyMailboxes() {
>
>         MailboxSession srcMailboxSession;
> @@ -54,11 +72,9 @@ public class MailboxCopierImpl implement
>             srcMailboxSession = srcMailboxManager.createSystemSession("manager",
log);
>            } catch (BadCredentialsException e) {
>                log.error(e.getMessage());
> -               e.printStackTrace();
>                return false;
>            } catch (MailboxException e) {
>                log.error(e.getMessage());
> -               e.printStackTrace();
>                return false;
>            }
>
> @@ -74,11 +90,9 @@ public class MailboxCopierImpl implement
>                        dstMailboxSession = dstMailboxManager.createSystemSession(mailboxPath.getUser(),
log);
>                    } catch (BadCredentialsException e) {
>                        log.error(e.getMessage());
> -                       e.printStackTrace();
>                        return false;
>                    } catch (MailboxException e) {
>                        log.error(e.getMessage());
> -                       e.printStackTrace();
>                        return false;
>                    }
>
> @@ -99,11 +113,9 @@ public class MailboxCopierImpl implement
>                            dstMailboxSession = dstMailboxManager.createSystemSession(mailboxPath.getUser(),
log);
>                        } catch (BadCredentialsException e) {
>                            log.error(e.getMessage());
> -                           e.printStackTrace();
>                            return false;
>                        } catch (MailboxException e) {
>                            log.error(e.getMessage());
> -                           e.printStackTrace();
>                            return false;
>                        }
>
> @@ -122,7 +134,6 @@ public class MailboxCopierImpl implement
>
>         } catch (MailboxException e) {
>             log.error(e.getMessage());
> -               e.printStackTrace();
>             return false;
>         } catch (IOException e) {
>             log.error(e.getMessage());
> @@ -135,7 +146,7 @@ public class MailboxCopierImpl implement
>         try {
>                srcMailboxManager.logout(srcMailboxSession, true);
>         } catch (MailboxException e) {
> -               e.printStackTrace();
> +            log.error(e.getMessage());
>                return false;
>         }
>
> @@ -143,10 +154,26 @@ public class MailboxCopierImpl implement
>
>        }
>
> +    /**
> +     * Setter to inject the srcMailboxManager.
> +     *
> +     * All mailboxes from the srcMailboxManager will be copied
> +     * to the dstMailboxManager upon copyMaillboxes method call.
> +     *
> +     * @param srcMailboxManager
> +     */
>     public void setSrcMailboxManager(MailboxManager srcMailboxManager) {
>         this.srcMailboxManager = srcMailboxManager;
>     }
>
> +    /**
> +     * Setter to inject the dstMailboxManager.
> +     *
> +     * All mailboxes from the srcMailboxManager will be copied
> +     * to the dstMailboxManager upon copyMaillboxes method call.
> +     *
> +     * @param dstMailboxManager
> +     */
>     public void setDstMailboxManager(MailboxManager dstMailboxManager) {
>         this.dstMailboxManager = dstMailboxManager;
>     }
>
> Modified: james/mailbox/trunk/copier/src/main/java/org/apache/james/mailbox/copier/MailboxCopierManagement.java
> URL: http://svn.apache.org/viewvc/james/mailbox/trunk/copier/src/main/java/org/apache/james/mailbox/copier/MailboxCopierManagement.java?rev=1051145&r1=1051144&r2=1051145&view=diff
> ==============================================================================
> --- james/mailbox/trunk/copier/src/main/java/org/apache/james/mailbox/copier/MailboxCopierManagement.java
(original)
> +++ james/mailbox/trunk/copier/src/main/java/org/apache/james/mailbox/copier/MailboxCopierManagement.java
Mon Dec 20 15:32:20 2010
> @@ -22,15 +22,30 @@ import javax.annotation.Resource;
>  import javax.management.NotCompliantMBeanException;
>  import javax.management.StandardMBean;
>
> +/**
> + * Implementation of the {@link MailboxCopierManagementMBean} JMX Management interface.
> + *
> + */
>  public class MailboxCopierManagement extends StandardMBean implements MailboxCopierManagementMBean
{
>
> +    /**
> +     * Inject the mailboxCopier bean.
> +     */
>     @Resource(name="mailboxCopier")
>     private MailboxCopier mailboxCopier;
>
> +    /**
> +     * Default Constructor.
> +     *
> +     * @throws NotCompliantMBeanException
> +     */
>     public MailboxCopierManagement() throws NotCompliantMBeanException {
>         super(MailboxCopierManagementMBean.class);
>     }
>
> +    /* (non-Javadoc)
> +     * @see org.apache.james.mailbox.copier.MailboxCopier#copyMailboxes()
> +     */
>     public Boolean copyMailboxes() {
>         return mailboxCopier.copyMailboxes();
>     }
>
> Modified: james/mailbox/trunk/copier/src/main/java/org/apache/james/mailbox/copier/MailboxCopierManagementMBean.java
> URL: http://svn.apache.org/viewvc/james/mailbox/trunk/copier/src/main/java/org/apache/james/mailbox/copier/MailboxCopierManagementMBean.java?rev=1051145&r1=1051144&r2=1051145&view=diff
> ==============================================================================
> --- james/mailbox/trunk/copier/src/main/java/org/apache/james/mailbox/copier/MailboxCopierManagementMBean.java
(original)
> +++ james/mailbox/trunk/copier/src/main/java/org/apache/james/mailbox/copier/MailboxCopierManagementMBean.java
Mon Dec 20 15:32:20 2010
> @@ -18,6 +18,9 @@
>  ****************************************************************/
>  package org.apache.james.mailbox.copier;
>
> +/**
> + * JMX Management interface for the {@link MailboxCopier} interface.
> + */
>  public interface MailboxCopierManagementMBean extends MailboxCopier {
>
>  }
>
> Modified: james/mailbox/trunk/copier/src/test/java/org/apache/james/mailbox/copier/MailboxCopierTest.java
> URL: http://svn.apache.org/viewvc/james/mailbox/trunk/copier/src/test/java/org/apache/james/mailbox/copier/MailboxCopierTest.java?rev=1051145&r1=1051144&r2=1051145&view=diff
> ==============================================================================
> --- james/mailbox/trunk/copier/src/test/java/org/apache/james/mailbox/copier/MailboxCopierTest.java
(original)
> +++ james/mailbox/trunk/copier/src/test/java/org/apache/james/mailbox/copier/MailboxCopierTest.java
Mon Dec 20 15:32:20 2010
> @@ -38,22 +38,52 @@ import org.apache.james.mailbox.inmemory
>  import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
>  import org.apache.james.mailbox.inmemory.mail.InMemoryCachingUidProvider;
>  import org.apache.james.mailbox.store.Authenticator;
> -import org.junit.After;
>  import org.junit.Before;
>  import org.junit.Test;
>
> +/**
> + * Test class for the {@link MailboxCopierImpl} implementation.
> + *
> + * The InMemoryMailboxManager will be used as source and destination
> + * Mailbox Manager.
> + *
> + */
>  public class MailboxCopierTest {
>
> +    /**
> +     * Number of Mailboxes to be created in the source Mailbox Manager.
> +     */
>     private static final int MAILBOX_COUNT = 100;
>
> +    /**
> +     * Number of Messages per Mailbox to be created in the source Mailbox Manager.
> +     */
>     private static final int MESSAGE_PER_MAILBOX_COUNT = 10;
>
> +    /**
> +     * The instance for the test mailboxCopier.
> +     */
>     private MailboxCopierImpl mailboxCopier;
>
> +    /**
> +     * The instance for the source Mailbox Manager.
> +     */
>     private MailboxManager srcMemMailboxManager;
>
> +    /**
> +     * The instance for the destination Mailbox Manager.
> +     */
>     private MailboxManager dstMemMailboxManager;
>
> +    /**
> +     * Setup the mailboxCopier and the source and destination
> +     * Mailbox Manager.
> +     *
> +     * We use a InMemoryMailboxManager implementation.
> +     *
> +     * @throws BadCredentialsException
> +     * @throws MailboxException
> +     */
>     @Before
>     public void setup() throws BadCredentialsException, MailboxException {
>
> @@ -67,12 +97,14 @@ public class MailboxCopierTest {
>
>     }
>
> -    @After
> -    public void tearDown() {
> -    }
> -
>     /**
> -     * @param args
> +     * Feed the source MailboxManager with the number of mailboxes and
> +     * messages per mailbox.
> +     *
> +     * Copy the mailboxes to the destination Mailbox Manager, and assert the number
> +     * of mailboxes and messages per mailbox is the same as in the source
> +     * Mailbox Manager.
> +     *
>      * @throws MailboxException
>      * @throws UnsupportedEncodingException
>      */
> @@ -90,9 +122,11 @@ public class MailboxCopierTest {
>     }
>
>     /**
> +     * Utility method to assert the number of mailboxes and messages per mailbox
> +     * are the ones expected.
> +     *
>      * @throws MailboxException
>      * @throws BadCredentialsException
> -     *
>      */
>     private void assertMailboxManagerSize(MailboxManager mailboxManager) throws BadCredentialsException,
MailboxException {
>
> @@ -110,6 +144,9 @@ public class MailboxCopierTest {
>     }
>
>     /**
> +     * Utility method to feed a Mailbox Manager with a number of
> +     * mailboxes and messages per mailbox.
> +     *
>      * @throws MailboxException
>      * @throws UnsupportedEncodingException
>      */
> @@ -142,7 +179,10 @@ public class MailboxCopierTest {
>     }
>
>     /**
> -     * @return
> +     * Utility method to instanciate a new InMemoryMailboxManger with
> +     * the needed MailboxSessionMapperFactory, Authenticator and UidProvider.
> +     *
> +     * @return a new InMemoryMailboxManager
>      */
>     private MailboxManager newInMemoryMailboxManager() {
>
>
>
>
> ---------------------------------------------------------------------
> 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


Mime
View raw message