james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wstrza...@apache.org
Subject svn commit: r1078490 - in /james/mailbox/trunk: api/src/main/java/org/apache/james/mailbox/MessageRange.java store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java
Date Sun, 06 Mar 2011 15:31:48 GMT
Author: wstrzalka
Date: Sun Mar  6 15:31:48 2011
New Revision: 1078490

URL: http://svn.apache.org/viewvc?rev=1078490&view=rev
Log:
Minor refactoring to IMAP-258

Modified:
    james/mailbox/trunk/api/src/main/java/org/apache/james/mailbox/MessageRange.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java

Modified: james/mailbox/trunk/api/src/main/java/org/apache/james/mailbox/MessageRange.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/api/src/main/java/org/apache/james/mailbox/MessageRange.java?rev=1078490&r1=1078489&r2=1078490&view=diff
==============================================================================
--- james/mailbox/trunk/api/src/main/java/org/apache/james/mailbox/MessageRange.java (original)
+++ james/mailbox/trunk/api/src/main/java/org/apache/james/mailbox/MessageRange.java Sun Mar
 6 15:31:48 2011
@@ -189,4 +189,11 @@ public class MessageRange {
     public String toString() {
         return "TYPE: " + type + " UID: " + uidFrom + ":" + uidTo + (batchSize > 0 ? "
BATCH: "+batchSize : "");
     }
+
+	public MessageRange getUnlimitedRange() {
+		if(this.batchSize == UNLIMITED_BATCH)
+			return this;
+		else
+			return new MessageRange(type, uidFrom, uidTo, UNLIMITED_BATCH);
+	}
 }

Modified: james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java?rev=1078490&r1=1078489&r2=1078490&view=diff
==============================================================================
--- james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java
(original)
+++ james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java
Sun Mar  6 15:31:48 2011
@@ -479,18 +479,30 @@ public abstract class StoreMessageManage
      */
     public Iterator<MessageResult> getMessages(final MessageRange set, FetchGroup fetchGroup,
             MailboxSession mailboxSession) throws MailboxException {
-        
-    	final List<MailboxMembership<Id>> rows = new ArrayList<MailboxMembership<Id>>();
-    	
-    	mapperFactory.getMessageMapper(mailboxSession).findInMailbox(getMailboxEntity(), set,
new MailboxMembershipCallback<Id>() {
-			public void onMailboxMembers(List<MailboxMembership<Id>> batchRows) throws
MailboxException {
-				rows.addAll(batchRows);
+
+        class InterceptingCallback implements MessageCallback {
+        	Iterator<MessageResult> iterator;
+        	
+			public void onMessages(Iterator<MessageResult> it) throws MailboxException {
+				iterator = it;				
 			}
-		});
+			
+			public Iterator<MessageResult> getIterator() {
+				return iterator;
+			}
+        } 
+    	
+        // if we are intercepting callback - let's make it effective
+        MessageRange nonBatchedSet = set.getUnlimitedRange();
+        
+        // intercepting callback 
+        InterceptingCallback callback = new InterceptingCallback();
+    	this.getMessages(nonBatchedSet, fetchGroup, mailboxSession, callback);
     	
-        return new ResultIterator<Id>(rows.iterator(), fetchGroup);
+        return callback.getIterator();
     }
 
+   
     /*
      * (non-Javadoc)
      * @see org.apache.james.mailbox.MessageManager#getMessages(org.apache.james.mailbox.MessageRange,
org.apache.james.mailbox.MessageResult.FetchGroup, org.apache.james.mailbox.MailboxSession,
int, org.apache.james.mailbox.MessageManager.MessageCallback)



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