commits@javamail.java.net

[javamail~mercurial:720] Fix link to JavaMail specification.

From: <shannon_at_java.net>
Date: Fri, 29 May 2015 23:33:13 +0000

Project: javamail
Repository: mercurial
Revision: 720
Author: shannon
Date: 2015-05-29 19:31:14 UTC
Link:

Log Message:
------------
Sigh. Can't use @Override with interfaces in JDK 1.5.
Add logf method for printf-style log messages.
IMAP provider should support the MOVE extension (RFC 6851) - bug 6824
MODSEQ should be stored in IMAPMessage if CONDSTORE is enabled - bug 6840
Fix link to JavaMail specification.


Revisions:
----------
716
717
718
719
720


Modified Paths:
---------------
mail/src/main/java/com/sun/mail/imap/IdleManager.java
mail/src/main/java/com/sun/mail/util/MailLogger.java
doc/release/CHANGES.txt
mail/src/main/java/com/sun/mail/imap/AppendUID.java
mail/src/main/java/com/sun/mail/imap/CopyUID.java
mail/src/main/java/com/sun/mail/imap/IMAPFolder.java
mail/src/main/java/com/sun/mail/imap/package.html
mail/src/main/java/com/sun/mail/imap/protocol/IMAPProtocol.java
mail/src/main/java/com/sun/mail/imap/IMAPMessage.java
mail/src/main/java/javax/mail/package.html
mail/src/main/java/overview.html


Diffs:
------
diff -r 109444121a8a -r a58c6241857b mail/src/main/java/com/sun/mail/imap/IdleManager.java
--- a/mail/src/main/java/com/sun/mail/imap/IdleManager.java Fri May 08 16:07:14 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/IdleManager.java Fri May 08 17:02:18 2015 -0700
@@ -357,7 +357,7 @@
                 toWatch.remove(folder);
                 final IMAPFolder folder0 = folder;
                 es.execute(new Runnable() {
- @Override
+ //_at_Override
                     public void run() {
                         // send the DONE and wait for the response
                         folder0.idleAbortWait();


diff -r a58c6241857b -r 1b847aea9726 mail/src/main/java/com/sun/mail/util/MailLogger.java
--- a/mail/src/main/java/com/sun/mail/util/MailLogger.java Fri May 08 17:02:18 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/util/MailLogger.java Mon May 18 15:21:38 2015 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 2012-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012-2015 Oracle and/or its affiliates. All rights reserved.
  *
  * The contents of this file are subject to the terms of either the GNU
  * General Public License Version 2 only ("GPL") or the Common Development
@@ -275,15 +275,19 @@
         }
     }
 
- /*
- * Maybe for JavaMail 1.5...
+ /**
+ * Log the message at the specified level using a format string.
+ * @param level the log level.
+ * @param msg the message format string.
+ * @param params the message parameters.
      *
+ * @since JavaMail 1.5.4
+ */
     public void logf(Level level, String msg, Object... params) {
         msg = String.format(msg, params);
         ifDebugOut(msg);
         logger.log(level, msg);
     }
- */
 
     /**
      * Log the message at the specified level.


diff -r 1b847aea9726 -r 95279d08ffdb doc/release/CHANGES.txt
--- a/doc/release/CHANGES.txt Mon May 18 15:21:38 2015 -0700
+++ b/doc/release/CHANGES.txt Fri May 29 12:06:53 2015 -0700
@@ -20,6 +20,7 @@
 
 K 6804 IdleManager can deadlock with frequent notifications
 K 6817 IdleManager can deadlock when connection fails
+K 6824 IMAP provider should support the MOVE extension (RFC 6851)
 
 
                   CHANGES IN THE 1.5.3 RELEASE

diff -r 1b847aea9726 -r 95279d08ffdb mail/src/main/java/com/sun/mail/imap/AppendUID.java
--- a/mail/src/main/java/com/sun/mail/imap/AppendUID.java Mon May 18 15:21:38 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/AppendUID.java Fri May 29 12:06:53 2015 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
  *
  * The contents of this file are subject to the terms of either the GNU
  * General Public License Version 2 only ("GPL") or the Common Development
@@ -45,7 +45,7 @@
 /**
  * Information from the APPENDUID response code
  * defined by the UIDPLUS extension -
- * <A HREF="http://www.ietf.org/rfc/rfc2359.txt">RFC 2359</A>.
+ * <A HREF="http://www.ietf.org/rfc/rfc4315.txt">RFC 4315</A>.
  *
  * @author Bill Shannon
  */

diff -r 1b847aea9726 -r 95279d08ffdb mail/src/main/java/com/sun/mail/imap/CopyUID.java
--- a/mail/src/main/java/com/sun/mail/imap/CopyUID.java Mon May 18 15:21:38 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/CopyUID.java Fri May 29 12:06:53 2015 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
  *
  * The contents of this file are subject to the terms of either the GNU
  * General Public License Version 2 only ("GPL") or the Common Development
@@ -45,7 +45,7 @@
 /**
  * Information from the COPYUID response code
  * defined by the UIDPLUS extension -
- * <A HREF="http://www.ietf.org/rfc/rfc2359.txt">RFC 2359</A>.
+ * <A HREF="http://www.ietf.org/rfc/rfc4315.txt">RFC 4315</A>.
  *
  * @author Bill Shannon
  */

diff -r 1b847aea9726 -r 95279d08ffdb mail/src/main/java/com/sun/mail/imap/IMAPFolder.java
--- a/mail/src/main/java/com/sun/mail/imap/IMAPFolder.java Mon May 18 15:21:38 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/IMAPFolder.java Fri May 29 12:06:53 2015 -0700
@@ -1794,7 +1794,7 @@
      *
      * Depends on the APPENDUID response code defined by the
      * UIDPLUS extension -
- * <A HREF="http://www.ietf.org/rfc/rfc2359.txt">RFC 2359</A>.
+ * <A HREF="http://www.ietf.org/rfc/rfc4315.txt">RFC 4315</A>.
      *
      * @param msgs the messages to append
      * @return array of AppendUID objects
@@ -1856,7 +1856,7 @@
      *
      * Depends on the APPENDUID response code defined by the
      * UIDPLUS extension -
- * <A HREF="http://www.ietf.org/rfc/rfc2359.txt">RFC 2359</A>.
+ * <A HREF="http://www.ietf.org/rfc/rfc4315.txt">RFC 4315</A>.
      *
      * @param msgs the messages to add
      * @return the messages in this folder
@@ -1889,6 +1889,87 @@
      */
     public synchronized void copyMessages(Message[] msgs, Folder folder)
                         throws MessagingException {
+ copymoveMessages(msgs, folder, false);
+ }
+
+ /**
+ * Copy the specified messages from this folder, to the
+ * specified destination.
+ * Return array of AppendUID objects containing
+ * UIDs of these messages in the destination folder.
+ * Each element of the returned array corresponds to
+ * an element of the <code>msgs</code> array. A null
+ * element means the server didn't return UID information
+ * for the copied message. <p>
+ *
+ * Depends on the COPYUID response code defined by the
+ * UIDPLUS extension -
+ * <A HREF="http://www.ietf.org/rfc/rfc4315.txt">RFC 4315</A>.
+ *
+ * @param msgs the messages to copy
+ * @param folder the folder to copy the messages to
+ * @return array of AppendUID objects
+ * @exception MessagingException for failures
+ * @since JavaMail 1.5.1
+ */
+ public synchronized AppendUID[] copyUIDMessages(Message[] msgs,
+ Folder folder) throws MessagingException {
+ return copymoveUIDMessages(msgs, folder, false);
+ }
+
+ /**
+ * Copy the specified messages from this folder, to the
+ * specified destination.
+ *
+ * Depends on the MOVE extension
+ * (<A HREF="http://www.ietf.org/rfc/rfc6851.txt">RFC 6851</A>).
+ *
+ * @param msgs the messages to move
+ * @param folder the folder to move the messages to
+ * @exception MessagingException for failures
+ *
+ * @since JavaMail 1.5.4
+ */
+ public synchronized void moveMessages(Message[] msgs, Folder folder)
+ throws MessagingException {
+ copymoveMessages(msgs, folder, true);
+ }
+
+ /**
+ * Copy the specified messages from this folder, to the
+ * specified destination.
+ * Return array of AppendUID objects containing
+ * UIDs of these messages in the destination folder.
+ * Each element of the returned array corresponds to
+ * an element of the <code>msgs</code> array. A null
+ * element means the server didn't return UID information
+ * for the copied message. <p>
+ *
+ * Depends on the MOVE extension
+ * (<A HREF="http://www.ietf.org/rfc/rfc6851.txt">RFC 6851</A>)
+ * and the COPYUID response code defined by the
+ * UIDPLUS extension
+ * (<A HREF="http://www.ietf.org/rfc/rfc4315.txt">RFC 4315</A>).
+ *
+ * @param msgs the messages to copy
+ * @param folder the folder to copy the messages to
+ * @return array of AppendUID objects
+ * @exception MessagingException for failures
+ * @since JavaMail 1.5.4
+ */
+ public synchronized AppendUID[] moveUIDMessages(Message[] msgs,
+ Folder folder) throws MessagingException {
+ return copymoveUIDMessages(msgs, folder, true);
+ }
+
+ /**
+ * Copy or move the specified messages from this folder, to the
+ * specified destination.
+ *
+ * @since JavaMail 1.5.4
+ */
+ private synchronized void copymoveMessages(Message[] msgs, Folder folder,
+ boolean move) throws MessagingException {
         checkOpened();
 
         if (msgs.length == 0) // boundary condition
@@ -1903,7 +1984,10 @@
                     if (ms == null)
                         throw new MessageRemovedException(
                                         "Messages have been removed");
- p.copy(ms, folder.getFullName());
+ if (move)
+ p.move(ms, folder.getFullName());
+ else
+ p.copy(ms, folder.getFullName());
                 } catch (CommandFailedException cfx) {
                     if (cfx.getMessage().indexOf("TRYCREATE") != -1)
                         throw new FolderNotFoundException(
@@ -1919,11 +2003,15 @@
                     }
             }
         } else // destination is a different store.
- super.copyMessages(msgs, folder);
+ if (move)
+ throw new MessagingException(
+ "Move between stores not supported");
+ else
+ super.copyMessages(msgs, folder);
     }
 
     /**
- * Copy the specified messages from this folder, to the
+ * Copy or move the specified messages from this folder, to the
      * specified destination.
      * Return array of AppendUID objects containing
      * UIDs of these messages in the destination folder.
@@ -1934,95 +2022,126 @@
      *
      * Depends on the COPYUID response code defined by the
      * UIDPLUS extension -
- * <A HREF="http://www.ietf.org/rfc/rfc2359.txt">RFC 2359</A>.
+ * <A HREF="http://www.ietf.org/rfc/rfc4315.txt">RFC 4315</A>.
+ * Move depends on the MOVE extension -
+ * <A HREF="http://www.ietf.org/rfc/rfc6851.txt">RFC 6851</A>.
      *
      * @param msgs the messages to copy
      * @param folder the folder to copy the messages to
+ * @param move move instead of copy?
      * @return array of AppendUID objects
      * @exception MessagingException for failures
- * @since JavaMail 1.5.1
+ * @since JavaMail 1.5.4
      */
- public synchronized AppendUID[] copyUIDMessages(Message[] msgs,
- Folder folder) throws MessagingException {
+ private synchronized AppendUID[] copymoveUIDMessages(Message[] msgs,
+ Folder folder, boolean move) throws MessagingException {
         checkOpened();
 
         if (msgs.length == 0) // boundary condition
             return null;
 
         // the destination must belong to our same store
- if (folder.getStore() == store) {
- synchronized (messageCacheLock) {
- try {
- IMAPProtocol p = getProtocol();
- // XXX - messages have to be from this Folder, who checks?
- MessageSet[] ms = Utility.toMessageSet(msgs, null);
- if (ms == null)
- throw new MessageRemovedException(
- "Messages have been removed");
- CopyUID cuid = p.copyuid(ms, folder.getFullName());
-
- /*
- * Correlate source UIDs with destination UIDs.
- * This won't be time or space efficient if there's
- * a lot of messages.
- *
- * In order to make sense of the returned UIDs, we need
- * the UIDs for every one of the original messages.
- * If we already have them, great, otherwise we need
- * to fetch them from the server.
- *
- * Assume the common case is that the messages are
- * in order by UID. Map the returned source
- * UIDs to their corresponding Message objects.
- * Step through the msgs array looking for the
- * Message object in the returned source message
- * list. Most commonly the source message (UID)
- * for the Nth original message will be in the Nth
- * position in the returned source message (UID)
- * list. Thus, the destination UID is in the Nth
- * position in the returned destination UID list.
- * But if the source message isn't where expected,
- * we have to search the entire source message
- * list, starting from where we expect it and
- * wrapping around until we've searched it all.
- */
- long[] srcuids = UIDSet.toArray(cuid.src);
- long[] dstuids = UIDSet.toArray(cuid.dst);
- // map source UIDs to Message objects
- // XXX - could inline/optimize this
- Message[] srcmsgs = getMessagesByUID(srcuids);
- AppendUID[] result = new AppendUID[msgs.length];
- for (int i = 0; i < msgs.length; i++) {
- int j = i;
- do {
- if (msgs[i] == srcmsgs[j]) {
- result[i] = new AppendUID(
- cuid.uidvalidity, dstuids[j]);
- break;
- }
- j++;
- if (j >= srcmsgs.length)
- j = 0;
- } while (j != i);
- }
- return result;
- } catch (CommandFailedException cfx) {
- if (cfx.getMessage().indexOf("TRYCREATE") != -1)
- throw new FolderNotFoundException(
- folder,
- folder.getFullName() + " does not exist"
- );
- else
- throw new MessagingException(cfx.getMessage(), cfx);
- } catch (ConnectionException cex) {
- throw new FolderClosedException(this, cex.getMessage());
- } catch (ProtocolException pex) {
- throw new MessagingException(pex.getMessage(), pex);
- }
+ if (folder.getStore() != store) // destination is a different store.
+ throw new MessagingException(
+ move ?
+ "can't moveUIDMessages to a different store" :
+ "can't copyUIDMessages to a different store");
+
+ // call fetch to make sure we have all the UIDs
+ // necessary to interpret the COPYUID response
+ FetchProfile fp = new FetchProfile();
+ fp.add(UIDFolder.FetchProfileItem.UID);
+ fetch(msgs, fp);
+ // XXX - could pipeline the FETCH with the COPY/MOVE below
+
+ synchronized (messageCacheLock) {
+ try {
+ IMAPProtocol p = getProtocol();
+ // XXX - messages have to be from this Folder, who checks?
+ MessageSet[] ms = Utility.toMessageSet(msgs, null);
+ if (ms == null)
+ throw new MessageRemovedException(
+ "Messages have been removed");
+ CopyUID cuid;
+ if (move)
+ cuid = p.moveuid(ms, folder.getFullName());
+ else
+ cuid = p.copyuid(ms, folder.getFullName());
+
+ /*
+ * Correlate source UIDs with destination UIDs.
+ * This won't be time or space efficient if there's
+ * a lot of messages.
+ *
+ * In order to make sense of the returned UIDs, we need
+ * the UIDs for every one of the original messages.
+ * We fetch them above, to make sure we have them.
+ * This is critical for MOVE since after the MOVE the
+ * messages are gone/expunged.
+ *
+ * Assume the common case is that the messages are
+ * in order by UID. Map the returned source
+ * UIDs to their corresponding Message objects.
+ * Step through the msgs array looking for the
+ * Message object in the returned source message
+ * list. Most commonly the source message (UID)
+ * for the Nth original message will be in the Nth
+ * position in the returned source message (UID)
+ * list. Thus, the destination UID is in the Nth
+ * position in the returned destination UID list.
+ * But if the source message isn't where expected,
+ * we have to search the entire source message
+ * list, starting from where we expect it and
+ * wrapping around until we've searched it all.
+ * (Gmail will often return the lists in an unexpected order.)
+ *
+ * A possible optimization:
+ * If the number of UIDs returned is the same as the
+ * number of messages being copied/moved, we could
+ * sort the source messages by message number, sort
+ * the source and destination parallel arrays by source
+ * UID, and the resulting message and destination UID
+ * arrays will correspond.
+ *
+ * If the returned UID array size is different, some
+ * message was expunged while we were trying to copy/move it.
+ * This should be rare but would mean falling back to the
+ * general algorithm.
+ */
+ long[] srcuids = UIDSet.toArray(cuid.src);
+ long[] dstuids = UIDSet.toArray(cuid.dst);
+ // map source UIDs to Message objects
+ // XXX - could inline/optimize this
+ Message[] srcmsgs = getMessagesByUID(srcuids);
+ AppendUID[] result = new AppendUID[msgs.length];
+ for (int i = 0; i < msgs.length; i++) {
+ int j = i;
+ do {
+ if (msgs[i] == srcmsgs[j]) {
+ result[i] = new AppendUID(
+ cuid.uidvalidity, dstuids[j]);
+ break;
+ }
+ j++;
+ if (j >= srcmsgs.length)
+ j = 0;
+ } while (j != i);
+ }
+ return result;
+ } catch (CommandFailedException cfx) {
+ if (cfx.getMessage().indexOf("TRYCREATE") != -1)
+ throw new FolderNotFoundException(
+ folder,
+ folder.getFullName() + " does not exist"
+ );
+ else
+ throw new MessagingException(cfx.getMessage(), cfx);
+ } catch (ConnectionException cex) {
+ throw new FolderClosedException(this, cex.getMessage());
+ } catch (ProtocolException pex) {
+ throw new MessagingException(pex.getMessage(), pex);
             }
- } else // destination is a different store.
- throw new MessagingException(
- "can't copyUIDMessages to a different store");
+ }
     }
 
     /**
@@ -2036,7 +2155,7 @@
      * Expunge the indicated messages, which must have been marked as DELETED.
      *
      * Depends on the UIDPLUS extension -
- * <A HREF="http://www.ietf.org/rfc/rfc2359.txt">RFC 2359</A>.
+ * <A HREF="http://www.ietf.org/rfc/rfc4315.txt">RFC 4315</A>.
      *
      * @param msgs the messages to expunge
      * @return the expunged messages

diff -r 1b847aea9726 -r 95279d08ffdb mail/src/main/java/com/sun/mail/imap/package.html
--- a/mail/src/main/java/com/sun/mail/imap/package.html Mon May 18 15:21:38 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/package.html Fri May 29 12:06:53 2015 -0700
@@ -5,7 +5,7 @@
 
     DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 
- Copyright (c) 1997-2014 Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
 
     The contents of this file are subject to the terms of either the GNU
     General Public License Version 2 only ("GPL") or the Common Development
@@ -59,6 +59,21 @@
 {_at_link com.sun.mail.imap.IMAPStore#hasCapability IMAPStore hasCapability}
 method using the capability name defined by the extension
 (see the appropriate RFC) after connecting to the server.
+<H4>UIDPLUS Support</H4>
+<P>
+The IMAP UIDPLUS extension
+(<A HREF="http://www.ietf.org/rfc/rfc4315.txt" TARGET="_top">RFC 4315</A>)
+is supported via the IMAPFolder methods
+{_at_link com.sun.mail.imap.IMAPFolder#addMessages addMessages},
+{_at_link com.sun.mail.imap.IMAPFolder#appendUIDMessages appendUIDMessages}, and
+{_at_link com.sun.mail.imap.IMAPFolder#copyUIDMessages copyUIDMessages}.
+<H4>MOVE Support</H4>
+<P>
+The IMAP MOVE extension
+(<A HREF="http://www.ietf.org/rfc/rfc6851.txt" TARGET="_top">RFC 6851</A>)
+is supported via the IMAPFolder methods
+{_at_link com.sun.mail.imap.IMAPFolder#moveMessages moveMessages} and
+{_at_link com.sun.mail.imap.IMAPFolder#moveUIDMessages moveUIDMessages}.
 <H4>SASL Support</H4>
 <P>
 The IMAP protocol provider can use SASL

diff -r 1b847aea9726 -r 95279d08ffdb mail/src/main/java/com/sun/mail/imap/protocol/IMAPProtocol.java
--- a/mail/src/main/java/com/sun/mail/imap/protocol/IMAPProtocol.java Mon May 18 15:21:38 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/protocol/IMAPProtocol.java Fri May 29 12:06:53 2015 -0700
@@ -1368,7 +1368,7 @@
     /**
      * UID EXPUNGE Command.
      *
- * @see "RFC2359, section 4.1"
+ * @see "RFC4315, section 2"
      */
     public void uidexpunge(UIDSet[] set) throws ProtocolException {
         if (!hasCapability("UIDPLUS"))
@@ -1757,7 +1757,7 @@
     /**
      * COPY Command, return uid from COPYUID response code.
      *
- * @see "RFC2359, section 4.3"
+ * @see "RFC 4315, section 3"
      */
     public CopyUID copyuid(MessageSet[] msgsets, String mbox)
                         throws ProtocolException {
@@ -1790,7 +1790,89 @@
         handleResult(r[r.length-1]);
 
         if (uid)
- return getCopyUID(r[r.length-1]);
+ return getCopyUID(r);
+ else
+ return null;
+ }
+
+ /**
+ * MOVE command.
+ *
+ * @see "RFC 6851"
+ * @since JavaMail 1.5.4
+ */
+ public void move(MessageSet[] msgsets, String mbox)
+ throws ProtocolException {
+ moveuid(MessageSet.toString(msgsets), mbox, false);
+ }
+
+ /**
+ * MOVE command.
+ *
+ * @see "RFC 6851"
+ * @since JavaMail 1.5.4
+ */
+ public void move(int start, int end, String mbox)
+ throws ProtocolException {
+ moveuid(String.valueOf(start) + ":" + String.valueOf(end),
+ mbox, false);
+ }
+
+ /**
+ * MOVE Command, return uid from COPYUID response code.
+ *
+ * @see "RFC 6851"
+ * @see "RFC 4315, section 3"
+ * @since JavaMail 1.5.4
+ */
+ public CopyUID moveuid(MessageSet[] msgsets, String mbox)
+ throws ProtocolException {
+ return moveuid(MessageSet.toString(msgsets), mbox, true);
+ }
+
+ /**
+ * MOVE Command, return uid from COPYUID response code.
+ *
+ * @see "RFC 6851"
+ * @see "RFC 4315, section 3"
+ * @since JavaMail 1.5.4
+ */
+ public CopyUID moveuid(int start, int end, String mbox)
+ throws ProtocolException {
+ return moveuid(String.valueOf(start) + ":" + String.valueOf(end),
+ mbox, true);
+ }
+
+ /**
+ * MOVE Command, return uid from COPYUID response code.
+ *
+ * @see "RFC 6851"
+ * @see "RFC 4315, section 3"
+ * @since JavaMail 1.5.4
+ */
+ public CopyUID moveuid(String msgSequence, String mbox, boolean uid)
+ throws ProtocolException {
+ if (!hasCapability("MOVE"))
+ throw new BadCommandException("MOVE not supported");
+ if (uid && !hasCapability("UIDPLUS"))
+ throw new BadCommandException("UIDPLUS not supported");
+ // encode the mbox as per RFC2060
+ mbox = BASE64MailboxEncoder.encode(mbox);
+
+ Argument args = new Argument();
+ args.writeAtom(msgSequence);
+ args.writeString(mbox);
+
+ Response[] r = command("MOVE", args);
+
+ // dispatch untagged responses
+ notifyResponseHandlers(r);
+
+ // Handle result of this command
+ handleResult(r[r.length-1]);
+
+ if (uid)
+ return getCopyUID(r);
         else
             return null;
     }
@@ -1798,27 +1880,32 @@
     /**
      * If the response contains a COPYUID response code, extract
      * it and return a CopyUID object with the information.
+ * XXX - need to merge more than one response for MOVE?
      */
- private CopyUID getCopyUID(Response r) {
- if (!r.isOK())
- return null;
- byte b;
- while ((b = r.readByte()) > 0 && b != (byte)'[')
- ;
- if (b == 0)
- return null;
- String s;
- s = r.readAtom();
- if (!s.equalsIgnoreCase("COPYUID"))
- return null;
+ private CopyUID getCopyUID(Response[] rr) {
+ for (int i = rr.length - 1; i >= 0; i--) {
+ Response r = rr[i];
+ if (r == null || !r.isOK())
+ continue;
+ byte b;
+ while ((b = r.readByte()) > 0 && b != (byte)'[')
+ ;
+ if (b == 0)
+ continue;
+ String s;
+ s = r.readAtom();
+ if (!s.equalsIgnoreCase("COPYUID"))
+ continue;
 
- long uidvalidity = r.readLong();
- String src = r.readAtom();
- String dst = r.readAtom();
- return new CopyUID(uidvalidity,
+ long uidvalidity = r.readLong();
+ String src = r.readAtom();
+ String dst = r.readAtom();
+ return new CopyUID(uidvalidity,
                             UIDSet.parseUIDSets(src), UIDSet.parseUIDSets(dst));
+ }
+ return null;
     }
-
+
     public void storeFlags(MessageSet[] msgsets, Flags flags, boolean set)
                         throws ProtocolException {
         storeFlags(MessageSet.toString(msgsets), flags, set);


diff -r 95279d08ffdb -r 6762edc51183 doc/release/CHANGES.txt
--- a/doc/release/CHANGES.txt Fri May 29 12:06:53 2015 -0700
+++ b/doc/release/CHANGES.txt Fri May 29 12:07:52 2015 -0700
@@ -21,6 +21,7 @@
 K 6804 IdleManager can deadlock with frequent notifications
 K 6817 IdleManager can deadlock when connection fails
 K 6824 IMAP provider should support the MOVE extension (RFC 6851)
+K 6840 MODSEQ should be stored in IMAPMessage if CONDSTORE is enabled
 
 
                   CHANGES IN THE 1.5.3 RELEASE

diff -r 95279d08ffdb -r 6762edc51183 mail/src/main/java/com/sun/mail/imap/IMAPMessage.java
--- a/mail/src/main/java/com/sun/mail/imap/IMAPMessage.java Fri May 29 12:06:53 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/IMAPMessage.java Fri May 29 12:07:52 2015 -0700
@@ -1196,6 +1196,8 @@
             receivedDate = ((INTERNALDATE)item).getDate();
         else if (item instanceof RFC822SIZE)
             size = ((RFC822SIZE)item).size;
+ else if (item instanceof MODSEQ)
+ modseq = ((MODSEQ)item).modseq;
 
         // Check for the BODYSTRUCTURE item
         else if (item instanceof BODYSTRUCTURE)


diff -r 6762edc51183 -r 1d89be816e09 mail/src/main/java/javax/mail/package.html
--- a/mail/src/main/java/javax/mail/package.html Fri May 29 12:07:52 2015 -0700
+++ b/mail/src/main/java/javax/mail/package.html Fri May 29 12:31:14 2015 -0700
@@ -5,7 +5,7 @@
 
     DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 
- Copyright (c) 1997-2014 Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
 
     The contents of this file are subject to the terms of either the GNU
     General Public License Version 2 only ("GPL") or the Common Development
@@ -54,11 +54,9 @@
 to mail systems based on internet standards such as MIME, SMTP, POP3, and IMAP.
 The JavaMail API includes the <code>javax.mail</code> package and subpackages.
 <P>
-For an overview of the JavaMail API, read the JavaMail specification
-<A HREF="../../../JavaMail-1.5.pdf" TARGET="_top">
-included in the download bundle</A> or
-<A HREF="http://www.oracle.com/technetwork/java/javamail-1-149769.pdf" TARGET="_top">
-available on the JavaMail web site</A>.
+For an overview of the JavaMail API, read the
+<A HREF="http://javamail.java.net/nonav/docs/JavaMail-1.5.pdf" TARGET="_top">
+JavaMail specification</A>.
 <P>
 The code to send a plain text message can be as simple as the following:
 <PRE>

diff -r 6762edc51183 -r 1d89be816e09 mail/src/main/java/overview.html
--- a/mail/src/main/java/overview.html Fri May 29 12:07:52 2015 -0700
+++ b/mail/src/main/java/overview.html Fri May 29 12:31:14 2015 -0700
@@ -5,7 +5,7 @@
 
     DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 
- Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
 
     The contents of this file are subject to the terms of either the GNU
     General Public License Version 2 only ("GPL") or the Common Development
@@ -54,11 +54,9 @@
 to mail systems based on internet standards such as MIME, SMTP, POP3, and IMAP.
 The JavaMail API includes the <code>javax.mail</code> package and subpackages.
 <P>
-For an overview of the JavaMail API, read the JavaMail specification
-<A HREF="../JavaMail-1.5.pdf" TARGET="_top">
-included in the download bundle</A> or
-<A HREF="http://www.oracle.com/technetwork/java/javamail-1-149769.pdf" TARGET="_top">
-available on the JavaMail web site</A>.
+For an overview of the JavaMail API, read the
+<A HREF="http://javamail.java.net/nonav/docs/JavaMail-1.5.pdf" TARGET="_top">
+JavaMail specification</A>.
 <P>
 The code to send a plain text message can be as simple as the following:
 <PRE>
@@ -258,6 +256,34 @@
 </TD>
 </TR>
 
+<TR>
+<TD>mail.event.scope</TD>
+<TD>String</TD>
+<TD>
+Controls the scope of events. (See the javax.mail.event package.)
+By default, a separate event queue and thread is used for events for each
+Store, Transport, or Folder.
+If this property is set to "session", all such events are put in a single
+event queue processed by a single thread for the current session.
+If this property is set to "application", all such events are put in a single
+event queue processed by a single thread for the current application.
+(Applications are distinguished by their context class loader.)
+</TD>
+</TR>
+
+<TR>
+<TD>mail.event.executor</TD>
+<TD>java.util.concurrent.Executor</TD>
+<TD>
+By default, a new Thread is created for each event queue.
+This thread is used to call the listeners for these events.
+If this property is set to an instance of an Executor, the
+Executor.execute method is used to run the event dispatcher
+for an event queue. The event dispatcher runs until the
+event queue is no longer in use.
+</TD>
+</TR>
+
 </TABLE>
 
 <P>
@@ -282,6 +308,31 @@
 those providers. The package documentation for the
 {_at_link com.sun.mail.imap IMAP}, {_at_link com.sun.mail.pop3 POP3},
 and {_at_link com.sun.mail.smtp SMTP} packages provide details.
+<P>
+In addition to printing debugging output as controlled by the
+{_at_link javax.mail.Session Session} configuration, the current
+implementation of classes in this package log the same information using
+{_at_link java.util.logging.Logger} as described in the following table:
+<P>
+<TABLE BORDER>
+<TR>
+<TH>Logger Name</TH>
+<TH>Logging Level</TH>
+<TH>Purpose</TH>
+</TR>
+
+<TR>
+<TD>javax.mail</TD>
+<TD>CONFIG</TD>
+<TD>Configuration of the Session</TD>
+</TR>
+
+<TR>
+<TD>javax.mail</TD>
+<TD>FINE</TD>
+<TD>General debugging output</TD>
+</TR>
+</TABLE>
 
 </BODY>
 </HTML>