mirror of
https://github.com/moparisthebest/davmail
synced 2024-11-15 22:05:02 -05:00
EWS: improve folder paged search
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2318 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
78ccaf6163
commit
1acddc4954
@ -779,10 +779,8 @@ public class EwsExchangeSession extends ExchangeSession {
|
|||||||
FolderId folderId = getFolderId(folderPath);
|
FolderId folderId = getFolderId(folderPath);
|
||||||
FindItemMethod findItemMethod;
|
FindItemMethod findItemMethod;
|
||||||
do {
|
do {
|
||||||
int fetchCount = PAGE_SIZE;
|
|
||||||
|
|
||||||
// search items in folder, do not retrieve all properties
|
// search items in folder, do not retrieve all properties
|
||||||
findItemMethod = new FindItemMethod(folderQueryTraversal, BaseShape.ID_ONLY, folderId, resultCount, fetchCount);
|
findItemMethod = new FindItemMethod(folderQueryTraversal, BaseShape.ID_ONLY, folderId, resultCount, PAGE_SIZE);
|
||||||
for (String attribute : attributes) {
|
for (String attribute : attributes) {
|
||||||
findItemMethod.addAdditionalProperty(Field.get(attribute));
|
findItemMethod.addAdditionalProperty(Field.get(attribute));
|
||||||
}
|
}
|
||||||
@ -812,7 +810,7 @@ public class EwsExchangeSession extends ExchangeSession {
|
|||||||
}
|
}
|
||||||
resultCount = results.size();
|
resultCount = results.size();
|
||||||
if (resultCount > 0 && LOGGER.isDebugEnabled()) {
|
if (resultCount > 0 && LOGGER.isDebugEnabled()) {
|
||||||
LOGGER.debug("Folder " + folderPath + " - Search items current count: " + resultCount + " fetchCount: " + fetchCount
|
LOGGER.debug("Folder " + folderPath + " - Search items current count: " + resultCount + " fetchCount: " + PAGE_SIZE
|
||||||
+ " highest uid: " + results.get(resultCount - 1).get(Field.get("imapUid").getResponseName())
|
+ " highest uid: " + results.get(resultCount - 1).get(Field.get("imapUid").getResponseName())
|
||||||
+ " lowest uid: " + results.get(0).get(Field.get("imapUid").getResponseName()));
|
+ " lowest uid: " + results.get(0).get(Field.get("imapUid").getResponseName()));
|
||||||
}
|
}
|
||||||
@ -1131,12 +1129,14 @@ public class EwsExchangeSession extends ExchangeSession {
|
|||||||
protected void appendSubFolders(List<ExchangeSession.Folder> folders,
|
protected void appendSubFolders(List<ExchangeSession.Folder> folders,
|
||||||
String parentFolderPath, FolderId parentFolderId,
|
String parentFolderPath, FolderId parentFolderId,
|
||||||
Condition condition, boolean recursive) throws IOException {
|
Condition condition, boolean recursive) throws IOException {
|
||||||
|
int resultCount = 0;
|
||||||
FindFolderMethod findFolderMethod;
|
FindFolderMethod findFolderMethod;
|
||||||
do {
|
do {
|
||||||
findFolderMethod = new FindFolderMethod(FolderQueryTraversal.SHALLOW,
|
findFolderMethod = new FindFolderMethod(FolderQueryTraversal.SHALLOW,
|
||||||
BaseShape.ID_ONLY, parentFolderId, FOLDER_PROPERTIES, (SearchExpression) condition);
|
BaseShape.ID_ONLY, parentFolderId, FOLDER_PROPERTIES, (SearchExpression) condition, resultCount, PAGE_SIZE);
|
||||||
executeMethod(findFolderMethod);
|
executeMethod(findFolderMethod);
|
||||||
for (EWSMethod.Item item : findFolderMethod.getResponseItems()) {
|
for (EWSMethod.Item item : findFolderMethod.getResponseItems()) {
|
||||||
|
resultCount++;
|
||||||
Folder folder = buildFolder(item);
|
Folder folder = buildFolder(item);
|
||||||
if (parentFolderPath.length() > 0) {
|
if (parentFolderPath.length() > 0) {
|
||||||
if (parentFolderPath.endsWith("/")) {
|
if (parentFolderPath.endsWith("/")) {
|
||||||
@ -1151,7 +1151,7 @@ public class EwsExchangeSession extends ExchangeSession {
|
|||||||
}
|
}
|
||||||
folders.add(folder);
|
folders.add(folder);
|
||||||
if (recursive && folder.hasChildren) {
|
if (recursive && folder.hasChildren) {
|
||||||
appendSubFolders(folders, folder.folderPath, folder.folderId, condition, recursive);
|
appendSubFolders(folders, folder.folderPath, folder.folderId, condition, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (!(findFolderMethod.includesLastItemInRange));
|
} while (!(findFolderMethod.includesLastItemInRange));
|
||||||
@ -2331,7 +2331,8 @@ public class EwsExchangeSession extends ExchangeSession {
|
|||||||
parentFolderId,
|
parentFolderId,
|
||||||
FOLDER_PROPERTIES,
|
FOLDER_PROPERTIES,
|
||||||
new TwoOperandExpression(TwoOperandExpression.Operator.IsEqualTo,
|
new TwoOperandExpression(TwoOperandExpression.Operator.IsEqualTo,
|
||||||
Field.get("folderDisplayName"), folderName)
|
Field.get("folderDisplayName"), folderName),
|
||||||
|
0, 1
|
||||||
);
|
);
|
||||||
executeMethod(findFolderMethod);
|
executeMethod(findFolderMethod);
|
||||||
EWSMethod.Item item = findFolderMethod.getResponseItem();
|
EWSMethod.Item item = findFolderMethod.getResponseItem();
|
||||||
|
@ -32,15 +32,18 @@ public class FindFolderMethod extends EWSMethod {
|
|||||||
* @param baseShape base shape
|
* @param baseShape base shape
|
||||||
* @param parentFolderId parent folder id
|
* @param parentFolderId parent folder id
|
||||||
* @param additionalProperties folder properties
|
* @param additionalProperties folder properties
|
||||||
|
* @param offset start offset
|
||||||
|
* @param maxCount maximum result count
|
||||||
*/
|
*/
|
||||||
public FindFolderMethod(FolderQueryTraversal traversal, BaseShape baseShape, FolderId parentFolderId, Set<FieldURI> additionalProperties) {
|
public FindFolderMethod(FolderQueryTraversal traversal, BaseShape baseShape, FolderId parentFolderId,
|
||||||
|
Set<FieldURI> additionalProperties, int offset, int maxCount) {
|
||||||
super("Folder", "FindFolder");
|
super("Folder", "FindFolder");
|
||||||
this.traversal = traversal;
|
this.traversal = traversal;
|
||||||
this.baseShape = baseShape;
|
this.baseShape = baseShape;
|
||||||
this.parentFolderId = parentFolderId;
|
this.parentFolderId = parentFolderId;
|
||||||
this.additionalProperties = additionalProperties;
|
this.additionalProperties = additionalProperties;
|
||||||
// force paging mode
|
this.offset = offset;
|
||||||
this.maxCount = 10000;
|
this.maxCount = maxCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -51,10 +54,12 @@ public class FindFolderMethod extends EWSMethod {
|
|||||||
* @param parentFolderId parent folder id
|
* @param parentFolderId parent folder id
|
||||||
* @param additionalProperties folder properties
|
* @param additionalProperties folder properties
|
||||||
* @param searchExpression search expression
|
* @param searchExpression search expression
|
||||||
|
* @param offset start offset
|
||||||
|
* @param maxCount maximum result count
|
||||||
*/
|
*/
|
||||||
public FindFolderMethod(FolderQueryTraversal traversal, BaseShape baseShape, FolderId parentFolderId,
|
public FindFolderMethod(FolderQueryTraversal traversal, BaseShape baseShape, FolderId parentFolderId,
|
||||||
Set<FieldURI> additionalProperties, SearchExpression searchExpression) {
|
Set<FieldURI> additionalProperties, SearchExpression searchExpression, int offset, int maxCount) {
|
||||||
this(traversal, baseShape, parentFolderId, additionalProperties);
|
this(traversal, baseShape, parentFolderId, additionalProperties, offset, maxCount);
|
||||||
this.searchExpression = searchExpression;
|
this.searchExpression = searchExpression;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user