EWS: implement batch move items

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2319 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2014-09-05 15:12:05 +00:00
parent 1acddc4954
commit 4a918cd22e
2 changed files with 43 additions and 0 deletions

View File

@ -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<ItemId> itemIds, FolderId toFolderId) {
super("Item", "CopyItem");
this.itemIds = itemIds;
this.toFolderId = toFolderId;
}
}

View File

@ -1234,6 +1234,20 @@ public class EwsExchangeSession extends ExchangeSession {
executeMethod(moveItemMethod);
}
/**
* @inheritDoc
*/
@Override
public void moveMessages(List<ExchangeSession.Message> messages, String targetFolder) throws IOException {
ArrayList<ItemId> itemIds = new ArrayList<ItemId>();
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<ExchangeSession.Message> messages, String targetFolder) throws IOException {
ArrayList<ItemId> itemIds = new ArrayList<ItemId>();
for (ExchangeSession.Message message: messages) {
itemIds.add(((EwsExchangeSession.Message) message).itemId);
}
CopyItemMethod copyItemMethod = new CopyItemMethod(itemIds, getFolderId(targetFolder));
executeMethod(copyItemMethod);
}
/**
* @inheritDoc
*/