From 15fd928588c1890019815ab40fb24bbb421efb3e Mon Sep 17 00:00:00 2001 From: mguessan Date: Wed, 27 Aug 2014 20:32:47 +0000 Subject: [PATCH] EWS: take paging into account in appendSubFolders git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2311 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- .../exchange/ews/EwsExchangeSession.java | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/java/davmail/exchange/ews/EwsExchangeSession.java b/src/java/davmail/exchange/ews/EwsExchangeSession.java index 65f2282e..04e1ff00 100644 --- a/src/java/davmail/exchange/ews/EwsExchangeSession.java +++ b/src/java/davmail/exchange/ews/EwsExchangeSession.java @@ -1131,27 +1131,30 @@ public class EwsExchangeSession extends ExchangeSession { protected void appendSubFolders(List folders, String parentFolderPath, FolderId parentFolderId, Condition condition, boolean recursive) throws IOException { - FindFolderMethod findFolderMethod = new FindFolderMethod(FolderQueryTraversal.SHALLOW, - BaseShape.ID_ONLY, parentFolderId, FOLDER_PROPERTIES, (SearchExpression) condition); - executeMethod(findFolderMethod); - for (EWSMethod.Item item : findFolderMethod.getResponseItems()) { - Folder folder = buildFolder(item); - if (parentFolderPath.length() > 0) { - if (parentFolderPath.endsWith("/")) { - folder.folderPath = parentFolderPath + item.get(Field.get("folderDisplayName").getResponseName()); + FindFolderMethod findFolderMethod; + do { + findFolderMethod = new FindFolderMethod(FolderQueryTraversal.SHALLOW, + BaseShape.ID_ONLY, parentFolderId, FOLDER_PROPERTIES, (SearchExpression) condition); + executeMethod(findFolderMethod); + for (EWSMethod.Item item : findFolderMethod.getResponseItems()) { + Folder folder = buildFolder(item); + if (parentFolderPath.length() > 0) { + if (parentFolderPath.endsWith("/")) { + folder.folderPath = parentFolderPath + item.get(Field.get("folderDisplayName").getResponseName()); + } else { + folder.folderPath = parentFolderPath + '/' + item.get(Field.get("folderDisplayName").getResponseName()); + } + } else if (folderIdMap.get(folder.folderId.value) != null) { + folder.folderPath = folderIdMap.get(folder.folderId.value); } else { - folder.folderPath = parentFolderPath + '/' + item.get(Field.get("folderDisplayName").getResponseName()); + folder.folderPath = item.get(Field.get("folderDisplayName").getResponseName()); + } + folders.add(folder); + if (recursive && folder.hasChildren) { + appendSubFolders(folders, folder.folderPath, folder.folderId, condition, recursive); } - } else if (folderIdMap.get(folder.folderId.value) != null) { - folder.folderPath = folderIdMap.get(folder.folderId.value); - } else { - folder.folderPath = item.get(Field.get("folderDisplayName").getResponseName()); } - folders.add(folder); - if (recursive && folder.hasChildren) { - appendSubFolders(folders, folder.folderPath, folder.folderId, condition, recursive); - } - } + } while (!(findFolderMethod.includesLastItemInRange)); } /**