james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r1146862 - in /james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor: AbstractSelectionProcessor.java fetch/FetchProcessor.java
Date Thu, 14 Jul 2011 19:21:51 GMT
Author: norman
Date: Thu Jul 14 19:21:51 2011
New Revision: 1146862

URL: http://svn.apache.org/viewvc?rev=1146862&view=rev
Log:
More work on QRESYNC extension. Still work in progress. Part of IMAP-307

Modified:
    james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractSelectionProcessor.java
    james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/FetchProcessor.java

Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractSelectionProcessor.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractSelectionProcessor.java?rev=1146862&r1=1146861&r2=1146862&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractSelectionProcessor.java
(original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractSelectionProcessor.java
Thu Jul 14 19:21:51 2011
@@ -40,6 +40,7 @@ import org.apache.james.imap.api.process
 import org.apache.james.imap.message.request.AbstractMailboxSelectionRequest;
 import org.apache.james.imap.message.response.ExistsResponse;
 import org.apache.james.imap.message.response.RecentResponse;
+import org.apache.james.imap.message.response.VanishedResponse;
 import org.apache.james.imap.processor.base.FetchGroupImpl;
 import org.apache.james.imap.processor.base.SelectedMailboxImpl;
 import org.apache.james.mailbox.MailboxException;
@@ -48,6 +49,7 @@ import org.apache.james.mailbox.MailboxN
 import org.apache.james.mailbox.MailboxPath;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageManager;
+import org.apache.james.mailbox.MessageRange.Type;
 import org.apache.james.mailbox.SearchQuery;
 import org.apache.james.mailbox.MessageManager.MetaData;
 import org.apache.james.mailbox.SearchQuery.NumericRange;
@@ -151,7 +153,13 @@ abstract class AbstractSelectionProcesso
                 sq.andCriteria(SearchQuery.modSeqGreaterThan(request.getKnownModSeq()));
                 
                 IdRange[] uidSet = request.getUidSet();
-                
+
+                if (uidSet == null) {
+                    // See mailbox had some messages stored before, if not we don't need
to query at all
+                    if (metaData.getUidNext() != 1) {
+                        uidSet = new IdRange[] {new IdRange(1, selected.getLastUid())};
+                    }
+                }
                 // Check if the know uid set was provided. If so we only need to get the
uids of these messages that matched here
                 if (uidSet != null) {
                     NumericRange[] nranges = new NumericRange[uidSet.length];
@@ -176,8 +184,38 @@ abstract class AbstractSelectionProcesso
                     uids.add(uidsIt.next());
                 }
                 if (uids.isEmpty() == false) {
-                    
-                    //TODO: Send also VANISHED responses as stated in QRESYNC RFC
+                    if (uidSet != null) {
+                        List<Long> vanished = new ArrayList<Long>();
+                        for (int i = 0; i < uids.size(); i++) {
+                            long uid = uids.get(i);
+                            boolean match = false;
+                            for (int a = 0; a < uidSet.length; a++) {
+                                if (uidSet[a].includes(uid)) {
+                                    match = true;
+                                    break;
+                                }
+                            }
+                            if (!match) {
+                                vanished.add(uid);
+                            }
+                        }
+                        if (!vanished.isEmpty()) {
+                            List<MessageRange> ranges = MessageRange.toRanges(vanished);
+                            IdRange[] idRanges  = new IdRange[ranges.size()];
+                            for (int i = 0; i < ranges.size(); i++) {
+                                MessageRange r = ranges.get(i);
+                                if (r.getType() == Type.ONE) {
+                                    idRanges[i] = new IdRange(r.getUidFrom());
+                                } else {
+                                    idRanges[i] = new IdRange(r.getUidFrom(), r.getUidTo());
+                                }
+                                
+                            }
+                            //TODO: Send also VANISHED responses as stated in QRESYNC RFC
+                            responder.respond(new VanishedResponse(idRanges, true));
+                        }
+                      
+                    }
                     List<MessageRange> ranges = MessageRange.toRanges(uids);
                     for (int i = 0; i < ranges.size(); i++) {
                         addFlagsResponses(session, selected, responder, true, ranges.get(i),
mailbox, mailboxSession);

Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/FetchProcessor.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/FetchProcessor.java?rev=1146862&r1=1146861&r2=1146862&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/FetchProcessor.java
(original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/FetchProcessor.java
Thu Jul 14 19:21:51 2011
@@ -36,6 +36,7 @@ import org.apache.james.imap.api.process
 import org.apache.james.imap.api.process.ImapSession;
 import org.apache.james.imap.message.request.FetchRequest;
 import org.apache.james.imap.message.response.FetchResponse;
+import org.apache.james.imap.message.response.VanishedResponse;
 import org.apache.james.imap.processor.AbstractMailboxProcessor;
 import org.apache.james.imap.processor.EnableProcessor;
 import org.apache.james.imap.processor.base.FetchGroupImpl;
@@ -104,7 +105,10 @@ public class FetchProcessor extends Abst
                 }
             }
 
-            // TODO: Handle QRESYNC VANISHED responses 
+            if (vanished) {
+                IdRange[] vanishedRanges = getNotIncluded(ranges, idSet);
+                responder.respond(new VanishedResponse(vanishedRanges, true));
+            }
             processMessageRanges(session, mailbox, ranges, fetch, useUids, mailboxSession,
responder);
 
             
@@ -124,6 +128,16 @@ public class FetchProcessor extends Abst
     }
 
     /**
+     * TODO: implement me
+     * 
+     * @param ranges
+     * @param ids
+     * @return vanished
+     */
+    private IdRange[] getNotIncluded(List<MessageRange> ranges, IdRange[] ids) {
+        return new IdRange[0];
+    }
+    /**
      * Process the given message ranges by fetch them and pass them to the
      * {@link Responder}
      * 



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