james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r1078698 - in /james/mailbox/trunk: jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMessageMapper.java store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java
Date Mon, 07 Mar 2011 07:04:23 GMT
Author: norman
Date: Mon Mar  7 07:04:22 2011
New Revision: 1078698

URL: http://svn.apache.org/viewvc?rev=1078698&view=rev
Log:
Replace tabs with spaces

Modified:
    james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMessageMapper.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java

Modified: james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMessageMapper.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMessageMapper.java?rev=1078698&r1=1078697&r2=1078698&view=diff
==============================================================================
--- james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMessageMapper.java
(original)
+++ james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMessageMapper.java
Mon Mar  7 07:04:22 2011
@@ -64,39 +64,40 @@ public class JPAMessageMapper extends JP
             final long to = set.getUidTo();
             final int batchSize = set.getBatchSize();
             final Type type = set.getType();
-            
-    		// when batch is specified fetch data in chunks and send back in batches
-    		do {
-	            switch (type) {
-	                default:
-	                case ALL:
-	                    results = findMessagesInMailbox(mailbox, batchSize);
-	                    break;
-	                case FROM:
-	                    results = findMessagesInMailboxAfterUID(mailbox, from, batchSize);
-	                    break;
-	                case ONE:
-	                    results = findMessagesInMailboxWithUID(mailbox, from);
-	                    break;
-	                case RANGE:
-	                    results = findMessagesInMailboxBetweenUIDs(mailbox, from, to, batchSize);
-	                    break;       
-	            }
-	            
-	            if(results.size() > 0) {
-					callback.onMailboxMembers(results);
-					
-					// move the start UID behind the last fetched message UID
-					from = results.get(results.size()-1).getUid()+1;
-				}
-					
-			} while(results.size() > 0 && batchSize > 0);
-	            
+
+            // when batch is specified fetch data in chunks and send back in
+            // batches
+            do {
+                switch (type) {
+                default:
+                case ALL:
+                    results = findMessagesInMailbox(mailbox, batchSize);
+                    break;
+                case FROM:
+                    results = findMessagesInMailboxAfterUID(mailbox, from, batchSize);
+                    break;
+                case ONE:
+                    results = findMessagesInMailboxWithUID(mailbox, from);
+                    break;
+                case RANGE:
+                    results = findMessagesInMailboxBetweenUIDs(mailbox, from, to, batchSize);
+                    break;
+                }
+
+                if (results.size() > 0) {
+                    callback.onMailboxMembers(results);
+
+                    // move the start UID behind the last fetched message UID
+                    from = results.get(results.size() - 1).getUid() + 1;
+                }
+
+            } while (results.size() > 0 && batchSize > 0);
+
         } catch (PersistenceException e) {
             throw new MailboxException("Search of MessageRange " + set + " failed in mailbox
" + mailbox, e);
         }
     }
-    
+
     @SuppressWarnings("unchecked")
     private List<MailboxMembership<Long>> findMessagesInMailboxAfterUID(Mailbox<Long>
mailbox, long uid, int batchSize) {
         Query query = getEntityManager().createNamedQuery("findMessagesInMailboxAfterUID")
@@ -118,14 +119,11 @@ public class JPAMessageMapper extends JP
 
     @SuppressWarnings("unchecked")
     private List<MailboxMembership<Long>> findMessagesInMailboxBetweenUIDs(Mailbox<Long>
mailbox, long from, long to, int batchSize) {
-        Query query = getEntityManager().createNamedQuery("findMessagesInMailboxBetweenUIDs")
-        .setParameter("idParam", mailbox.getMailboxId())
-        .setParameter("fromParam", from)
-        .setParameter("toParam", to);
-        
-        if(batchSize > 0)
-        	query.setMaxResults(batchSize);
-        
+        Query query = getEntityManager().createNamedQuery("findMessagesInMailboxBetweenUIDs").setParameter("idParam",
mailbox.getMailboxId()).setParameter("fromParam", from).setParameter("toParam", to);
+
+        if (batchSize > 0)
+            query.setMaxResults(batchSize);
+
         return query.getResultList();
     }
 
@@ -357,32 +355,31 @@ public class JPAMessageMapper extends JP
      * @see org.apache.james.mailbox.store.mail.MessageMapper#updateFlags(org.apache.james.mailbox.store.mail.model.Mailbox,
javax.mail.Flags, boolean, boolean, org.apache.james.mailbox.MessageRange)
      */
     public Iterator<UpdatedFlags> updateFlags(Mailbox<Long> mailbox, final Flags
flags, final boolean value, final boolean replace, MessageRange set) throws MailboxException
{
-        
+
         final List<UpdatedFlags> updatedFlags = new ArrayList<UpdatedFlags>();
         findInMailbox(mailbox, set, new MailboxMembershipCallback<Long>() {
-			
-			public void onMailboxMembers(List<MailboxMembership<Long>> members)
-					throws MailboxException {
-		        for (final MailboxMembership<Long> member:members) {
-		            Flags originalFlags = member.createFlags();
-		            if (replace) {
-		                member.setFlags(flags);
-		            } else {
-		                Flags current = member.createFlags();
-		                if (value) {
-		                    current.add(flags);
-		                } else {
-		                    current.remove(flags);
-		                }
-		                member.setFlags(current);
-		            }
-		            Flags newFlags = member.createFlags();
-		            getEntityManager().persist(member);
-		            updatedFlags.add(new UpdatedFlags(member.getUid(),originalFlags, newFlags));
-		        }
-				
-			}
-		});
+
+            public void onMailboxMembers(List<MailboxMembership<Long>> members)
throws MailboxException {
+                for (final MailboxMembership<Long> member : members) {
+                    Flags originalFlags = member.createFlags();
+                    if (replace) {
+                        member.setFlags(flags);
+                    } else {
+                        Flags current = member.createFlags();
+                        if (value) {
+                            current.add(flags);
+                        } else {
+                            current.remove(flags);
+                        }
+                        member.setFlags(current);
+                    }
+                    Flags newFlags = member.createFlags();
+                    getEntityManager().persist(member);
+                    updatedFlags.add(new UpdatedFlags(member.getUid(), originalFlags, newFlags));
+                }
+
+            }
+        });
 
         return updatedFlags.iterator();
 

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=1078698&r1=1078697&r2=1078698&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
Mon Mar  7 07:04:22 2011
@@ -42,7 +42,6 @@ import org.apache.james.mailbox.MailboxE
 import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageRange;
-import org.apache.james.mailbox.MessageRangeException;
 import org.apache.james.mailbox.MessageResult;
 import org.apache.james.mailbox.SearchQuery;
 import org.apache.james.mailbox.MessageResult.FetchGroup;
@@ -477,49 +476,46 @@ public abstract class StoreMessageManage
      * (non-Javadoc)
      * @see org.apache.james.mailbox.Mailbox#getMessages(org.apache.james.mailbox.MessageRange,
org.apache.james.mailbox.MessageResult.FetchGroup, org.apache.james.mailbox.MailboxSession)
      */
-    public Iterator<MessageResult> getMessages(final MessageRange set, FetchGroup fetchGroup,
-            MailboxSession mailboxSession) throws MailboxException {
+    public Iterator<MessageResult> getMessages(final MessageRange set, FetchGroup fetchGroup,
MailboxSession mailboxSession) throws MailboxException {
 
         class InterceptingCallback implements MessageCallback {
-        	Iterator<MessageResult> iterator;
-        	
-			public void onMessages(Iterator<MessageResult> it) throws MailboxException {
-				iterator = it;				
-			}
-			
-			public Iterator<MessageResult> getIterator() {
-				return iterator;
-			}
-        } 
-    	
+            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 
+
+        // intercepting callback
         InterceptingCallback callback = new InterceptingCallback();
-    	this.getMessages(nonBatchedSet, fetchGroup, mailboxSession, callback);
-    	
+        this.getMessages(nonBatchedSet, fetchGroup, mailboxSession, callback);
+
         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)
      */
-	public void getMessages(MessageRange set,
-			final FetchGroup fetchGroup, MailboxSession mailboxSession,
-			final MessageCallback messageCallback) throws MailboxException {
-	
-		mapperFactory.getMessageMapper(mailboxSession).findInMailbox(getMailboxEntity(), set, new
MailboxMembershipCallback<Id>() {
-			public void onMailboxMembers(List<MailboxMembership<Id>> rows) throws MailboxException
{
-				messageCallback.onMessages(new ResultIterator<Id>(rows.iterator(), fetchGroup));
-			}
-		});
-	}
-	
+    public void getMessages(MessageRange set, final FetchGroup fetchGroup, MailboxSession
mailboxSession, final MessageCallback messageCallback) throws MailboxException {
+
+        mapperFactory.getMessageMapper(mailboxSession).findInMailbox(getMailboxEntity(),
set, new MailboxMembershipCallback<Id>() {
+            public void onMailboxMembers(List<MailboxMembership<Id>> rows) throws
MailboxException {
+                messageCallback.onMessages(new ResultIterator<Id>(rows.iterator(),
fetchGroup));
+            }
+        });
+    }
+
     /**
-     * Return a List which holds all uids of recent messages and optional reset the recent
flag on the messages for the uids
+     * Return a List which holds all uids of recent messages and optional reset
+     * the recent flag on the messages for the uids
      * 
      * @param reset
      * @param mailboxSession
@@ -612,18 +608,17 @@ public abstract class StoreMessageManage
     protected Iterator<Long> copy(MessageRange set, final StoreMessageManager<Id>
to, final MailboxSession session) throws MailboxException {
         try {
             MessageMapper<Id> messageMapper = mapperFactory.getMessageMapper(session);
-            
+
             final List<Long> copiedMessages = new ArrayList<Long>();
             messageMapper.findInMailbox(getMailboxEntity(), set, new MailboxMembershipCallback<Id>()
{
 
-				public void onMailboxMembers(List<MailboxMembership<Id>> originalRows)
-						throws MailboxException {
-					Iterator<Long> ids = to.copy(originalRows, session);
-					while(ids.hasNext())
-						copiedMessages.add(ids.next());
-				}
-			});
-            return copiedMessages.iterator(); 
+                public void onMailboxMembers(List<MailboxMembership<Id>> originalRows)
throws MailboxException {
+                    Iterator<Long> ids = to.copy(originalRows, session);
+                    while (ids.hasNext())
+                        copiedMessages.add(ids.next());
+                }
+            });
+            return copiedMessages.iterator();
 
         } catch (MailboxException e) {
             throw new MailboxException("Unable to parse message", 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