james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wstrza...@apache.org
Subject svn commit: r1165073 - /james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java
Date Sun, 04 Sep 2011 16:46:33 GMT
Author: wstrzalka
Date: Sun Sep  4 16:46:32 2011
New Revision: 1165073

URL: http://svn.apache.org/viewvc?rev=1165073&view=rev
Log:
Make sure we have an higher uid on each append so we don't generate out of order events and
so are imap compliant. CopyTo(...) method also generates UIDs so should be executed with the
lock granted. See MAILBOX-131

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

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=1165073&r1=1165072&r2=1165073&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 Sep  4 16:46:32 2011
@@ -519,16 +519,21 @@ public class StoreMessageManager<Id> imp
      * @param session
      * @throws MailboxException
      */
-    public List<MessageRange> copyTo(MessageRange set, StoreMessageManager<Id>
toMailbox, MailboxSession session) throws MailboxException {
+    public List<MessageRange> copyTo(final MessageRange set, final StoreMessageManager<Id>
toMailbox, final MailboxSession session) throws MailboxException {
         if (!toMailbox.isWriteable(session)) {
             throw new ReadOnlyException(new StoreMailboxPath<Id>(getMailboxEntity()),session.getPathDelimiter());
         }
         
         try {
-            Map<Long, MessageMetaData> copiedUids = copy(set, toMailbox, session);
-            dispatcher.added(session, copiedUids, toMailbox.getMailboxEntity());
+            return locker.executeWithLock(session, new StoreMailboxPath<Id>(getMailboxEntity()),
new MailboxPathLocker.LockAwareExecution<List<MessageRange>>() {
 
-            return MessageRange.toRanges(new ArrayList<Long>(copiedUids.keySet()));
+                @Override
+                public List<MessageRange> execute() throws MailboxException {
+                    Map<Long, MessageMetaData> copiedUids = copy(set, toMailbox, session);
+                    dispatcher.added(session, copiedUids, toMailbox.getMailboxEntity());
+                    return MessageRange.toRanges(new ArrayList<Long>(copiedUids.keySet()));
+                }
+            }, true);
         } 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