james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r736158 - in /james/protocols/imap/trunk: mailbox/src/main/java/org/apache/james/imap/mailbox/ processor/src/main/java/org/apache/james/imap/processor/imap4rev1/ processor/src/test/java/org/apache/james/imap/processor/imap4rev1/ store/src/m...
Date Tue, 20 Jan 2009 23:03:43 GMT
Author: rdonkin
Date: Tue Jan 20 15:03:42 2009
New Revision: 736158

URL: http://svn.apache.org/viewvc?rev=736158&view=rev
Log:
Simplified API

Modified:
    james/protocols/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/Mailbox.java
    james/protocols/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/imap4rev1/SearchProcessor.java
    james/protocols/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/imap4rev1/SearchProcessorTest.java
    james/protocols/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailbox.java
    james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailbox.java

Modified: james/protocols/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/Mailbox.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/Mailbox.java?rev=736158&r1=736157&r2=736158&view=diff
==============================================================================
--- james/protocols/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/Mailbox.java
(original)
+++ james/protocols/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/Mailbox.java
Tue Jan 20 15:03:42 2009
@@ -36,23 +36,15 @@
     boolean isWriteable();
 
     /**
-     * @param fetchGroup
-     *            which fields to be returned in MessageResult
-     * @param mailboxSession
-     *            TODO
-     * @return MessageResult with the fields defined by <b>result</b>
-     *         <ul>
-     *         <li> IMAP: msn or (msn and uid)</li>
-     *         <li> Javamail Folder: Message[]</li>
-     *         </ul>
-     * @throws MailboxException
-     *             if anything went wrong
+     * Searches for messages matching the given query.
+     * @param mailboxSession not null
+     * @return uid iterator
      * @throws UnsupportedCriteriaException
      *             when any of the search parameters are not supported by this
      *             mailbox
+     * @throws MailboxException when search fails for other reasons
      */
-    Iterator search(SearchQuery searchQuery, FetchGroup fetchGroup,
-            MailboxSession mailboxSession) throws MailboxException;
+    Iterator<Long> search(SearchQuery searchQuery, MailboxSession mailboxSession) throws
MailboxException;
 
     long getUidValidity(MailboxSession mailboxSession)
             throws MailboxException;

Modified: james/protocols/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/imap4rev1/SearchProcessor.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/imap4rev1/SearchProcessor.java?rev=736158&r1=736157&r2=736158&view=diff
==============================================================================
--- james/protocols/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/imap4rev1/SearchProcessor.java
(original)
+++ james/protocols/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/imap4rev1/SearchProcessor.java
Tue Jan 20 15:03:42 2009
@@ -41,11 +41,8 @@
 import org.apache.james.imap.mailbox.Mailbox;
 import org.apache.james.imap.mailbox.MailboxException;
 import org.apache.james.imap.mailbox.MailboxManagerProvider;
-import org.apache.james.imap.mailbox.MessageResult;
 import org.apache.james.imap.mailbox.SearchQuery;
-import org.apache.james.imap.mailbox.MessageResult.FetchGroup;
 import org.apache.james.imap.mailbox.SearchQuery.Criterion;
-import org.apache.james.imap.mailbox.util.FetchGroupImpl;
 import org.apache.james.imap.message.request.imap4rev1.SearchRequest;
 import org.apache.james.imap.message.response.imap4rev1.server.SearchResponse;
 import org.apache.james.imap.processor.base.ImapSessionUtils;
@@ -68,12 +65,10 @@
             final SearchKey searchKey = request.getSearchKey();
             final boolean useUids = request.isUseUids();
             final Mailbox mailbox = getSelectedMailbox(session);
-            final FetchGroup fetchGroup = FetchGroupImpl.MINIMAL;
 
             final SearchQuery query = toQuery(searchKey, session);
 
-            final Collection results = findIds(useUids, session, mailbox,
-                    fetchGroup, query);
+            final Collection results = findIds(useUids, session, mailbox, query);
             final long[] ids = toArray(results);
 
             final SearchResponse response = new SearchResponse(ids);
@@ -97,20 +92,20 @@
     }
 
     private Collection findIds(final boolean useUids,
-            final ImapSession session, Mailbox mailbox,
-            final FetchGroup fetchGroup, final SearchQuery query)
+            final ImapSession session, Mailbox mailbox, final SearchQuery query)
             throws MailboxException {
-        final Iterator it = mailbox.search(query, fetchGroup, ImapSessionUtils
+        final Iterator<Long> it = mailbox.search(query, ImapSessionUtils
                 .getMailboxSession(session));
 
         final Collection<Long> results = new TreeSet<Long>();
+  
         while (it.hasNext()) {
-            final MessageResult result = (MessageResult) it.next();
+            final long uid = it.next();
             final Long number;
             if (useUids) {
-                number = new Long(result.getUid());
+                number = new Long(uid);
             } else {
-                final int msn = session.getSelected().msn(result.getUid());
+                final int msn = session.getSelected().msn(uid);
                 number = new Long(msn);
             }
             results.add(number);

Modified: james/protocols/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/imap4rev1/SearchProcessorTest.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/imap4rev1/SearchProcessorTest.java?rev=736158&r1=736157&r2=736158&view=diff
==============================================================================
--- james/protocols/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/imap4rev1/SearchProcessorTest.java
(original)
+++ james/protocols/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/imap4rev1/SearchProcessorTest.java
Tue Jan 20 15:03:42 2009
@@ -42,7 +42,6 @@
 import org.apache.james.imap.mailbox.MailboxSession;
 import org.apache.james.imap.mailbox.SearchQuery;
 import org.apache.james.imap.mailbox.SearchQuery.Criterion;
-import org.apache.james.imap.mailbox.util.FetchGroupImpl;
 import org.apache.james.imap.message.request.imap4rev1.SearchRequest;
 import org.apache.james.imap.message.response.imap4rev1.server.SearchResponse;
 import org.apache.james.imap.processor.base.ImapSessionUtils;
@@ -419,9 +418,8 @@
                     with(equal(ImapSessionUtils.MAILBOX_SESSION_ATTRIBUTE_SESSION_KEY)));
will(returnValue((MailboxSession) mailboxSession));
             oneOf(mailbox).search(
                     with(equal(query)),
-                    with(equal(FetchGroupImpl.MINIMAL)), 
                     with(equal(mailboxSession)));will(
-                            returnValue(new ArrayList().iterator()));
+                            returnValue(new ArrayList<Long>().iterator()));
             oneOf(responder).respond(with(equal(new SearchResponse(EMPTY))));
             
         }});

Modified: james/protocols/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailbox.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailbox.java?rev=736158&r1=736157&r2=736158&view=diff
==============================================================================
--- james/protocols/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailbox.java
(original)
+++ james/protocols/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailbox.java
Tue Jan 20 15:03:42 2009
@@ -28,6 +28,8 @@
 import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
 
 import javax.mail.Flags;
 import javax.mail.MessagingException;
@@ -366,15 +368,14 @@
         return tracker;
     }
 
-    public Iterator search(SearchQuery query, FetchGroup fetchGroup,
-            MailboxSession mailboxSession) throws MailboxException {
+    public Iterator<Long> search(SearchQuery query, MailboxSession mailboxSession)
throws MailboxException {
         final MessageMapper messageMapper = createMessageMapper();
         final List<MailboxMembership> members = messageMapper.searchMailbox(mailboxId,
query);
-        final List<MailboxMembership> filteredMessages = new ArrayList<MailboxMembership>(members.size());
+        final Set<Long> uids = new TreeSet<Long>();
         for (MailboxMembership member:members) {
             try {
                 if (searches.isMatch(query, member)) {
-                    filteredMessages.add(member);
+                    uids.add(member.getUid());
                 }
             } catch (MailboxException e) {
                 getLog()
@@ -386,7 +387,7 @@
             }
         }
 
-        return getResults(fetchGroup, filteredMessages);
+        return uids.iterator();
     }
 
     public boolean isWriteable() {

Modified: james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailbox.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailbox.java?rev=736158&r1=736157&r2=736158&view=diff
==============================================================================
--- james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailbox.java
(original)
+++ james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailbox.java
Tue Jan 20 15:03:42 2009
@@ -24,13 +24,14 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.sql.SQLException;
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
 import java.util.Enumeration;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
 
 import javax.mail.Flags;
 import javax.mail.MessagingException;
@@ -40,8 +41,8 @@
 import org.apache.commons.logging.Log;
 import org.apache.james.api.imap.AbstractLogEnabled;
 import org.apache.james.imap.mailbox.Mailbox;
-import org.apache.james.imap.mailbox.MailboxListener;
 import org.apache.james.imap.mailbox.MailboxException;
+import org.apache.james.imap.mailbox.MailboxListener;
 import org.apache.james.imap.mailbox.MailboxSession;
 import org.apache.james.imap.mailbox.MessageRange;
 import org.apache.james.imap.mailbox.MessageResult;
@@ -656,8 +657,7 @@
         this.mailboxRow = mailboxRow;
     }
 
-    public Iterator search(SearchQuery query, FetchGroup fetchGroup,
-            MailboxSession mailboxSession) throws MailboxException {
+    public Iterator<Long> search(SearchQuery query, MailboxSession mailboxSession)
throws MailboxException {
         try {
             lock.readLock().acquire();
             try {
@@ -666,12 +666,12 @@
                 final Criteria criterion = preSelect(query);
                 final List rows = MessageRowPeer
                         .doSelectJoinMessageFlags(criterion);
-                final List filteredMessages = new ArrayList();
+                final Set<Long> uids = new TreeSet<Long>();
                 for (Iterator it = rows.iterator(); it.hasNext();) {
                     final MessageRow row = (MessageRow) it.next();
                     try {
                         if (searches.isMatch(query, row)) {
-                            filteredMessages.add(row);
+                            uids.add(row.getUid());
                         }
                     } catch (TorqueException e) {
                         getLog()
@@ -683,7 +683,7 @@
                     }
                 }
 
-                return getResults(fetchGroup, filteredMessages);
+                return uids.iterator();
             } catch (TorqueException e) {
                 throw new MailboxException(e);
             } finally {



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