james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject svn commit: r1045179 - in /james/mailbox/trunk: store/src/main/java/org/apache/james/mailbox/store/ store/src/main/java/org/apache/james/mailbox/store/mail/ torque/src/main/java/org/apache/james/mailbox/torque/
Date Mon, 13 Dec 2010 15:40:09 GMT
Author: eric
Date: Mon Dec 13 15:40:09 2010
New Revision: 1045179

URL: http://svn.apache.org/viewvc?rev=1045179&view=rev
Log:
Add a list method on MailboxManager to obtain all the existing mailboxpath (MAILBOX-19)

Modified:
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/MailboxMapper.java
    james/mailbox/trunk/torque/src/main/java/org/apache/james/mailbox/torque/TorqueMailboxManager.java

Modified: james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java?rev=1045179&r1=1045178&r2=1045179&view=diff
==============================================================================
--- james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
(original)
+++ james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
Mon Dec 13 15:40:09 2010
@@ -73,7 +73,7 @@ public abstract class StoreMailboxManage
     private final Authenticator authenticator;
     private final static Random RANDOM = new Random();
     
-    private Log log = LogFactory.getLog("org.apache.james.imap");
+    private Log log = LogFactory.getLog("org.apache.james.mailbox");
 
     private MailboxPathLocker locker;
 
@@ -430,6 +430,21 @@ public abstract class StoreMailboxManage
         // do nothing
         
     }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.mailbox.MailboxManager#list(org.apache.james.mailbox.MailboxSession)
+     */
+    public List<MailboxPath> list(MailboxSession session) throws MailboxException {
+        List<MailboxPath> mList = new ArrayList<MailboxPath>();
+        List<Mailbox<Id>> mailboxes = mailboxSessionMapperFactory.getMailboxMapper(session).list();
+        for (int i = 0; i < mailboxes.size(); i++) {
+            Mailbox<Id> m = mailboxes.get(i);
+            mList.add(new MailboxPath(m.getNamespace(), m.getUser(), m.getName()));
+        }
+        return Collections.unmodifiableList(mList);
+        
+    }
     
     
 

Modified: james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/MailboxMapper.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/MailboxMapper.java?rev=1045179&r1=1045178&r2=1045179&view=diff
==============================================================================
--- james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/MailboxMapper.java
(original)
+++ james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/MailboxMapper.java
Mon Dec 13 15:40:09 2010
@@ -81,4 +81,12 @@ public interface MailboxMapper<Id> exten
      */
     public abstract boolean hasChildren(Mailbox<Id> mailbox)
             throws MailboxException, MailboxNotFoundException;
+    
+    /**
+     * Return a unmodifable {@link List} of all {@link Mailbox} 
+     * 
+     * @return mailboxList
+     * @throws MailboxException 
+     */
+    public abstract List<Mailbox<Id>> list() throws MailboxException;
 }
\ No newline at end of file

Modified: james/mailbox/trunk/torque/src/main/java/org/apache/james/mailbox/torque/TorqueMailboxManager.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/torque/src/main/java/org/apache/james/mailbox/torque/TorqueMailboxManager.java?rev=1045179&r1=1045178&r2=1045179&view=diff
==============================================================================
--- james/mailbox/trunk/torque/src/main/java/org/apache/james/mailbox/torque/TorqueMailboxManager.java
(original)
+++ james/mailbox/trunk/torque/src/main/java/org/apache/james/mailbox/torque/TorqueMailboxManager.java
Mon Dec 13 15:40:09 2010
@@ -471,5 +471,27 @@ public class TorqueMailboxManager implem
         
     }
 
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.mailbox.MailboxManager#list(org.apache.james.mailbox.MailboxSession)
+     */
+    public List<MailboxPath> list(MailboxSession session) throws MailboxException {
+        Criteria c = new Criteria();
+        c.setAll();
+        try {
+            List<MailboxPath> pList = new ArrayList<MailboxPath>();
+            List mailboxes = MailboxRowPeer.doSelect(c);
+            for (int i = 0; i < mailboxes.size(); i++) {
+                final MailboxRow mailboxRow = (MailboxRow) mailboxes.get(i);
+                final MailboxPath sPath = getMailboxPath(mailboxRow.getName());
+                pList.add(sPath);
+            }
+            return pList;
+        } catch (TorqueException e) {
+            throw new MailboxException("select of all mailboxes failed", e);
+
+        }
+    }
+
 
 }



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


Mime
View raw message