Skip to content

Commit c40a301

Browse files
author
pborissow
committed
- Fixed bug retrieving the full index in the Folder.getIndex() method
git-svn-id: svn://192.168.0.80/JavaXT/javaxt-exchange@1441 2c7b0aa6-e0b2-3c4e-bb4a-8b65b6c465ff
1 parent cad96b1 commit c40a301

File tree

1 file changed

+61
-43
lines changed

1 file changed

+61
-43
lines changed

src/javaxt/exchange/Folder.java

Lines changed: 61 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ protected org.w3c.dom.Document getItems(int offset, int limit, java.util.HashSet
420420
*/
421421
protected org.w3c.dom.Document getItems(String view, java.util.HashSet<FieldURI> additionalProperties, String where, FieldOrder[] sortOrder) throws ExchangeException {
422422

423-
423+
424424
//Parse order by statement
425425
String sort = "";
426426
if (sortOrder!=null){
@@ -490,7 +490,7 @@ protected org.w3c.dom.Document getItems(String view, java.util.HashSet<FieldURI>
490490
+ "<t:FieldURI FieldURI=\"item:ItemClass\"/>"
491491
//+ "<t:FieldURI FieldURI=\"item:LastModifiedTime\"/>" //value="item:LastModifiedTime" //<--This doesn't work...
492492
+ "<t:ExtendedFieldURI PropertyTag=\"0x3008\" PropertyType=\"SystemTime\" />" //<--This returns the LastModifiedTime!
493-
+ props.toString()
493+
+ props.toString()
494494
+ "</t:AdditionalProperties>"
495495
+ "</m:ItemShape>"
496496

@@ -504,7 +504,7 @@ protected org.w3c.dom.Document getItems(String view, java.util.HashSet<FieldURI>
504504
+ "</m:FindItem>"
505505
+ "</soap:Body>"
506506
+ "</soap:Envelope>";
507-
507+
508508
return conn.execute(msg);
509509
}
510510

@@ -517,49 +517,67 @@ protected org.w3c.dom.Document getItems(String view, java.util.HashSet<FieldURI>
517517
*/
518518
public java.util.HashMap<String, javaxt.utils.Date> getIndex() throws ExchangeException {
519519

520-
String msg =
521-
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
522-
+ "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\" xmlns:m=\"http://schemas.microsoft.com/exchange/services/2006/messages\">"
523-
+ "<soap:Body>"
524-
+ "<m:FindItem Traversal=\"Shallow\">"
525-
+ "<m:ItemShape>"
526-
+ "<t:BaseShape>IdOnly</t:BaseShape>" //<--"Default" vs "AllProperties"
527-
+ "<t:AdditionalProperties>"
528-
+ "<t:ExtendedFieldURI PropertyTag=\"0x3008\" PropertyType=\"SystemTime\" />" //<--This returns the LastModifiedTime!
529-
+ "</t:AdditionalProperties>"
530-
+ "</m:ItemShape>"
531-
532-
+ "<m:SortOrder>"
533-
+ "<t:FieldOrder Order=\"Descending\">"
534-
+ "<t:ExtendedFieldURI PropertyTag=\"0x3008\" PropertyType=\"SystemTime\" />"
535-
+ "</t:FieldOrder>"
536-
+ "</m:SortOrder>"
537-
538-
//+ "<m:IndexedPageItemView MaxEntriesReturned=\"1\" Offset=\"0\" BasePoint=\"Beginning\"/>"
539-
+ "<m:ParentFolderIds>"
540-
+ "<t:FolderId Id=\"" + id + "\"/>"
541-
+ "</m:ParentFolderIds>"
542-
+ "</m:FindItem>"
543-
+ "</soap:Body>"
544-
+ "</soap:Envelope>";
545-
546-
org.w3c.dom.Document xml = conn.execute(msg);
547-
//new javaxt.io.File("/temp/exchange-sort.xml").write(xml);
548-
549520
java.util.HashMap<String, javaxt.utils.Date> index = new java.util.HashMap<String, javaxt.utils.Date>();
550521

551-
org.w3c.dom.Node[] items = javaxt.xml.DOM.getElementsByTagName("Items", xml);
552-
if (items.length>0){
553-
org.w3c.dom.NodeList nodes = items[0].getChildNodes();
554-
for (int i=0; i<nodes.getLength(); i++){
555-
org.w3c.dom.Node node = nodes.item(i);
556-
if (node.getNodeType()==1){
557-
FolderItem item = new FolderItem(node);
558-
index.put(item.getID(), item.getLastModifiedTime());
522+
int offset = 0;
523+
int limit = 1000;
524+
525+
526+
while (true){
527+
528+
529+
String msg =
530+
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
531+
+ "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\" xmlns:m=\"http://schemas.microsoft.com/exchange/services/2006/messages\">"
532+
+ "<soap:Body>"
533+
+ "<m:FindItem Traversal=\"Shallow\">"
534+
+ "<m:ItemShape>"
535+
+ "<t:BaseShape>IdOnly</t:BaseShape>" //<--"Default" vs "AllProperties"
536+
+ "<t:AdditionalProperties>"
537+
+ "<t:ExtendedFieldURI PropertyTag=\"0x3008\" PropertyType=\"SystemTime\" />" //<--This returns the LastModifiedTime!
538+
+ "</t:AdditionalProperties>"
539+
+ "</m:ItemShape>"
540+
541+
+ "<m:SortOrder>"
542+
+ "<t:FieldOrder Order=\"Descending\">"
543+
+ "<t:ExtendedFieldURI PropertyTag=\"0x3008\" PropertyType=\"SystemTime\" />"
544+
+ "</t:FieldOrder>"
545+
+ "</m:SortOrder>"
546+
547+
//+ "<m:IndexedPageItemView MaxEntriesReturned=\"1\" Offset=\"0\" BasePoint=\"Beginning\"/>"
548+
+ "<m:IndexedPageItemView MaxEntriesReturned=\"" + limit + "\" Offset=\"" + offset + "\" BasePoint=\"Beginning\"/>"
549+
550+
551+
+ "<m:ParentFolderIds>"
552+
+ "<t:FolderId Id=\"" + id + "\"/>"
553+
+ "</m:ParentFolderIds>"
554+
+ "</m:FindItem>"
555+
+ "</soap:Body>"
556+
+ "</soap:Envelope>";
557+
558+
org.w3c.dom.Document xml = conn.execute(msg);
559+
560+
org.w3c.dom.Node[] items = javaxt.xml.DOM.getElementsByTagName("Items", xml);
561+
int numItems = 0;
562+
if (items.length>0){
563+
org.w3c.dom.NodeList nodes = items[0].getChildNodes();
564+
for (int i=0; i<nodes.getLength(); i++){
565+
org.w3c.dom.Node node = nodes.item(i);
566+
if (node.getNodeType()==1){
567+
FolderItem item = new FolderItem(node);
568+
index.put(item.getID(), item.getLastModifiedTime());
569+
numItems++;
570+
}
559571
}
572+
560573
}
561574

562-
}
575+
offset+=numItems;
576+
577+
//System.out.println("Found " + numItems + " items");
578+
579+
if (numItems==0 || numItems<limit) break;
580+
}
563581

564582
return index;
565583
}
@@ -610,7 +628,7 @@ public static String[] getDistinguishedFolderIds(){
610628
return DistinguishedFolderIds;
611629
}
612630

613-
631+
614632
//**************************************************************************
615633
//** getDistinguishedFolderId
616634
//**************************************************************************
@@ -623,7 +641,7 @@ public static String getDistinguishedFolderId(String folderName){
623641
return null;
624642
}
625643

626-
644+
627645
//**************************************************************************
628646
//** DistinguishedFolderIds
629647
//**************************************************************************

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy