From 4a918cd22e2fbea8c9082cc78a6e0ece3acd6d0b Mon Sep 17 00:00:00 2001 From: mguessan Date: Fri, 5 Sep 2014 15:12:05 +0000 Subject: [PATCH] EWS: implement batch move items git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2319 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- .../davmail/exchange/ews/CopyItemMethod.java | 15 ++++++++++ .../exchange/ews/EwsExchangeSession.java | 28 +++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/src/java/davmail/exchange/ews/CopyItemMethod.java b/src/java/davmail/exchange/ews/CopyItemMethod.java index 1d0d7f8b..ceca95ba 100644 --- a/src/java/davmail/exchange/ews/CopyItemMethod.java +++ b/src/java/davmail/exchange/ews/CopyItemMethod.java @@ -18,6 +18,8 @@ */ package davmail.exchange.ews; +import java.util.List; + /** * Copy item to another folder. */ @@ -33,4 +35,17 @@ public class CopyItemMethod extends EWSMethod { this.itemId = itemId; this.toFolderId = toFolderId; } + + /** + * Copy items to target folder. + * + * @param itemIds item id list + * @param toFolderId target folder id + */ + public CopyItemMethod(List itemIds, FolderId toFolderId) { + super("Item", "CopyItem"); + this.itemIds = itemIds; + this.toFolderId = toFolderId; + } + } diff --git a/src/java/davmail/exchange/ews/EwsExchangeSession.java b/src/java/davmail/exchange/ews/EwsExchangeSession.java index 9aa58fb3..fad20447 100644 --- a/src/java/davmail/exchange/ews/EwsExchangeSession.java +++ b/src/java/davmail/exchange/ews/EwsExchangeSession.java @@ -1234,6 +1234,20 @@ public class EwsExchangeSession extends ExchangeSession { executeMethod(moveItemMethod); } + /** + * @inheritDoc + */ + @Override + public void moveMessages(List messages, String targetFolder) throws IOException { + ArrayList itemIds = new ArrayList(); + for (ExchangeSession.Message message: messages) { + itemIds.add(((EwsExchangeSession.Message) message).itemId); + } + + MoveItemMethod moveItemMethod = new MoveItemMethod(itemIds, getFolderId(targetFolder)); + executeMethod(moveItemMethod); + } + /** * @inheritDoc */ @@ -1243,6 +1257,20 @@ public class EwsExchangeSession extends ExchangeSession { executeMethod(copyItemMethod); } + /** + * @inheritDoc + */ + @Override + public void copyMessages(List messages, String targetFolder) throws IOException { + ArrayList itemIds = new ArrayList(); + for (ExchangeSession.Message message: messages) { + itemIds.add(((EwsExchangeSession.Message) message).itemId); + } + + CopyItemMethod copyItemMethod = new CopyItemMethod(itemIds, getFolderId(targetFolder)); + executeMethod(copyItemMethod); + } + /** * @inheritDoc */