-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFolder.java
More file actions
680 lines (574 loc) · 27 KB
/
Folder.java
File metadata and controls
680 lines (574 loc) · 27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
package javaxt.exchange;
//******************************************************************************
//** Folder Class
//******************************************************************************
/**
* Used to represent a folder (e.g. "Inbox", "Contacts", etc.)
*
******************************************************************************/
public class Folder {
private String id;
private String parentID;
private String name;
private String changeKey;
private Integer totalCount;
private Integer unreadCount;
private Integer folderCount;
private Connection conn;
//**************************************************************************
//** Constructor
//**************************************************************************
/** This constructor is provided for application developers who wish to
* extend this class.
*/
protected Folder(){}
//**************************************************************************
//** Constructor
//**************************************************************************
/** Creates a new instance of this class using a folder
*/
protected Folder(Folder folder){
this.id = folder.id;
this.parentID = folder.parentID;
this.name = folder.name;
this.changeKey = folder.changeKey;
this.totalCount = folder.totalCount;
this.unreadCount = folder.unreadCount;
this.folderCount = folder.folderCount;
this.conn = folder.conn;
}
//**************************************************************************
//** Constructor
//**************************************************************************
/** Creates a new instance of this class using a folder name/id.
* @param folderName Name of the exchange folder (e.g. inbox, contacts, etc).
*/
public Folder(String folderName, Connection conn) throws ExchangeException {
this.conn = conn;
String folderID = getDistinguishedFolderId(folderName);
if (folderID==null){
folderID = "<t:FolderId Id=\"" + folderName + "\"/>";
}
else{
folderID = "<t:DistinguishedFolderId Id=\"" + folderID + "\"/>";
}
String msg =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+ "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\">"
+ "<soap:Body>"
+ "<GetFolder xmlns=\"http://schemas.microsoft.com/exchange/services/2006/messages\" xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\">"
+ "<FolderShape>"
+ "<t:BaseShape>Default</t:BaseShape>"
+ "<t:AdditionalProperties>"
//The following returns the LastModifiedTime for the folder. Unfortunately,
//this does not reflect changes made to items in this folder.
//+ "<t:ExtendedFieldURI PropertyTag=\"0x3008\" PropertyType=\"SystemTime\" />"
+ "<t:FieldURI FieldURI=\"folder:ParentFolderId\" />"
+ "</t:AdditionalProperties>"
+ "</FolderShape>"
+ "<FolderIds>" + folderID + "</FolderIds></GetFolder>"
+ "</soap:Body>"
+ "</soap:Envelope>";
parseXML(conn.execute(msg));
}
//**************************************************************************
//** Constructor
//**************************************************************************
/** Private constructor used by the getFolders() method.
*/
private Folder(org.w3c.dom.Node folder, Connection conn) throws ExchangeException {
this.conn = conn;
parseFolderNode(folder);
}
//**************************************************************************
//** getFolders
//**************************************************************************
/** Returns an array of folders found in this folder. Returns a zero length
* array of no folders are found.
*/
public Folder[] getFolders() throws ExchangeException {
return getFolders("Shallow");
}
//**************************************************************************
//** getFolders
//**************************************************************************
/** Returns an array of folders found in this folder. Returns a zero length
* array of no folders are found.
* @param Traversal Possible values include "Deep", "Shallow", "SoftDeleted".
* Defaults to "Shallow" if a null or invalid string is used.
*/
public Folder[] getFolders(String Traversal) throws ExchangeException {
java.util.ArrayList<Folder> folders = new java.util.ArrayList<Folder>();
if (Traversal==null) Traversal = "";
if (Traversal.equalsIgnoreCase("Deep")) Traversal = "Deep";
else if (Traversal.equalsIgnoreCase("SoftDeleted")) Traversal = "SoftDeleted";
else Traversal = "Shallow";
String msg =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+ "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\">"
+ "<soap:Body>"
+ "<FindFolder Traversal=\"" + Traversal + "\" xmlns=\"http://schemas.microsoft.com/exchange/services/2006/messages\" xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\">"
+ "<FolderShape>"
+ "<t:BaseShape>Default</t:BaseShape>"
+ "<t:AdditionalProperties>"
+ "<t:FieldURI FieldURI=\"folder:ParentFolderId\" />"
+ "</t:AdditionalProperties>"
+ "</FolderShape>"
+ "<ParentFolderIds><t:FolderId Id=\"" + id + "\"/></ParentFolderIds>"
+ "</FindFolder>"
+ "</soap:Body>"
+ "</soap:Envelope>";
org.w3c.dom.Document response = conn.execute(msg);
for (org.w3c.dom.Node node : javaxt.xml.DOM.getElementsByTagName("Folder", response)){
folders.add(new Folder(node, conn));
}
return folders.toArray(new Folder[folders.size()]);
}
//**************************************************************************
//** createFolder
//**************************************************************************
/** Used to create a folder within this folder.
*/
public Folder createFolder(String name) throws ExchangeException {
name = name.trim();
String msg =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+ "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\">"
+ "<soap:Body>"
+ "<CreateFolder xmlns=\"http://schemas.microsoft.com/exchange/services/2006/messages\" xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\">"
+ "<ParentFolderId><t:FolderId Id=\"" + id + "\"/></ParentFolderId>"
+ "<Folders><t:Folder><t:DisplayName>" + name + "</t:DisplayName></t:Folder></Folders>"
+ "</CreateFolder>"
+ "</soap:Body>"
+ "</soap:Envelope>";
org.w3c.dom.Document response = conn.execute(msg);
org.w3c.dom.Node[] nodes = javaxt.xml.DOM.getElementsByTagName("Folder", response);
if (nodes.length>0){
Folder folder = new Folder(nodes[0], conn);
folder.name = name;
folder.totalCount = 0;
folder.unreadCount = 0;
folder.folderCount = 0;
folder.parentID = id;
return folder;
}
else throw new ExchangeException("Failed to create folder.");
}
//**************************************************************************
//** rename
//**************************************************************************
/** Used to rename this folder.
*/
public void rename(String name) throws ExchangeException {
changeKey = getChangeKey(conn);
name = name.trim();
String msg =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+ "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\">"
+ "<soap:Body>"
+ "<UpdateFolder xmlns=\"http://schemas.microsoft.com/exchange/services/2006/messages\" xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\">"
+ "<FolderChanges>"
+ "<t:FolderChange>"
+ "<t:FolderId Id=\"" + id + "\" ChangeKey=\"" + changeKey + "\"/>"
+ "<t:Updates>"
+ "<t:SetFolderField>"
+ "<t:FieldURI FieldURI=\"folder:DisplayName\" />"
+ "<t:Folder><t:DisplayName>" + name + "</t:DisplayName></t:Folder>"
+ "</t:SetFolderField>"
+ "</t:Updates>"
+ "</t:FolderChange>"
+ "</FolderChanges>"
+ "</UpdateFolder>"
+ "</soap:Body>"
+ "</soap:Envelope>";
conn.execute(msg);
this.name = name;
}
//**************************************************************************
//** move
//**************************************************************************
/** Used to move this folder to another folder.
*/
public void move(Folder destination) throws ExchangeException {
String msg =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+ "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\">"
+ "<soap:Body>"
+ "<MoveFolder xmlns=\"http://schemas.microsoft.com/exchange/services/2006/messages\" xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\">"
+ "<ToFolderId><t:FolderId Id=\"" + destination.id + "\"/></ToFolderId>"
+ "<FolderIds><t:FolderId Id=\"" + id + "\"/></FolderIds>"
+ "</MoveFolder>"
+ "</soap:Body>"
+ "</soap:Envelope>";
conn.execute(msg);
}
//**************************************************************************
//** delete
//**************************************************************************
/** Used to delete this folder.
*/
public void delete() throws ExchangeException {
String msg =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+ "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\">"
+ "<soap:Body>"
+ "<DeleteFolder DeleteType=\"HardDelete\" xmlns=\"http://schemas.microsoft.com/exchange/services/2006/messages\" xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\">"
+ "<FolderIds><t:FolderId Id=\"" + id + "\"/></FolderIds>"
+ "</DeleteFolder>"
+ "</soap:Body>"
+ "</soap:Envelope>";
conn.execute(msg);
}
//**************************************************************************
//** getChangeKey
//**************************************************************************
/** Used to retrieve the latest ChangeKey for this folder. This method is
* required to update an item.
*/
protected String getChangeKey(Connection conn) throws ExchangeException {
changeKey = new Folder(id, conn).changeKey;
return changeKey;
}
private void parseXML(org.w3c.dom.Document xml) throws ExchangeException {
org.w3c.dom.Node[] nodes = javaxt.xml.DOM.getElementsByTagName("FolderId", xml);
if (nodes.length>0) parseFolderNode(nodes[0].getParentNode());
else throw new ExchangeException("Failed to parse FolderId.");
}
private void parseFolderNode(org.w3c.dom.Node folder) throws ExchangeException {
org.w3c.dom.NodeList properties = folder.getChildNodes();
for (int i=0; i<properties.getLength(); i++){
org.w3c.dom.Node property = properties.item(i);
if (property.getNodeType()==1){
String key = property.getNodeName();
String value = property.getTextContent().trim();
if (key.contains(":")) key = key.substring(key.indexOf(":")+1);
if (key.equalsIgnoreCase("FolderId")){
id = javaxt.xml.DOM.getAttributeValue(property, "Id");
changeKey = javaxt.xml.DOM.getAttributeValue(property, "ChangeKey");
}
else if(key.equalsIgnoreCase("ParentFolderId")){
parentID = javaxt.xml.DOM.getAttributeValue(property, "Id");
//javaxt.xml.DOM.getAttributeValue(property, "ChangeKey");
}
else if(key.equalsIgnoreCase("DisplayName")) name = value;
else if(key.equalsIgnoreCase("TotalCount")) totalCount = cint(value);
else if(key.equalsIgnoreCase("ChildFolderCount")) folderCount = cint(value);
else if(key.equalsIgnoreCase("UnreadCount")) unreadCount = cint(value);
}
}
if (id==null || id.length()==0) throw new ExchangeException("Failed to parse Folder.");
}
private Integer cint(String str){
try{
return Integer.parseInt(str);
}
catch(Exception e){
return null;
}
}
//**************************************************************************
//** getID
//**************************************************************************
/** Returns the unique Exchange ID for this folder. */
public String getID(){
return id;
}
//**************************************************************************
//** getParentID
//**************************************************************************
/** Returns the unique ID for the parent folder. */
public String getParentID(){
return parentID;
}
/*
public String getChangeKey(){
return changeKey;
}
*/
//**************************************************************************
//** getName
//**************************************************************************
/** Returns the name of the folder. */
public String getName(){
return name;
}
//**************************************************************************
//** getTotalCount
//**************************************************************************
/** Returns the total number of items found in this folder. */
public Integer getTotalCount(){
return totalCount;
}
//**************************************************************************
//** getUnreadCount
//**************************************************************************
/** Returns the total number of unread items found in this folder. */
public Integer getUnreadCount(){
return unreadCount;
}
//**************************************************************************
//** getChildFolderCount
//**************************************************************************
/** Returns the total number of folders found in this this folder. */
public Integer getChildFolderCount(){
return folderCount;
}
//**************************************************************************
//** toString
//**************************************************************************
/** Returns the name of the folder. */
public String toString(){
return name;
}
//**************************************************************************
//** getItems
//**************************************************************************
/** Returns an XML document with shallow representations of items found in
* this folder.
* @param offset Item offset. 0 implies no offset.
* @param limit Maximum number of items to return.
*/
protected org.w3c.dom.Document getItems(int offset, int limit, java.util.HashSet<FieldURI> additionalProperties, String where, FieldOrder[] sortOrder) throws ExchangeException {
if (offset<1) offset = 0;
if (limit<1) limit = 1;
return getItems("<m:IndexedPageItemView MaxEntriesReturned=\"" + limit + "\" Offset=\"" + offset + "\" BasePoint=\"Beginning\"/>",
additionalProperties, where, sortOrder);
}
//**************************************************************************
//** getItems
//**************************************************************************
/** Returns an XML document with shallow representations of items found in
* this folder.
*
* @param view XML node representing a page view (e.g. IndexedPageItemView,
* FractionalPageItemView, CalendarView, ContactsView).
*
* @param additionalProperties By default, this method returns a shallow
* representation of each item found in this folder. You can retrieve
* additional attributes by providing a list of properties
* (e.g. "calendar:TimeZone", "item:Sensitivity", etc).
*
* @param sortOrder SQL-style order by clause used to sort the results
* (e.g. "item:DateTimeReceived DESC").
*/
protected org.w3c.dom.Document getItems(String view, java.util.HashSet<FieldURI> additionalProperties, String where, FieldOrder[] sortOrder) throws ExchangeException {
//Parse order by statement
String sort = "";
if (sortOrder!=null){
for (FieldOrder field : sortOrder){
sort += field.toXML();
}
if (sort.length()>0){
sort = "<m:SortOrder>" + sort + "</m:SortOrder>";
}
}
//Parse where clasue and create restriction
if (where==null) where = "";
else where = where.trim();
String restriction = where;
//Update the view xml node. Make sure the node name is prefixed with a "m:" namespace
if (view==null) view = "";
else{
view = view.trim();
String nodeName = view.substring(1, view.indexOf(">"));
if (nodeName.endsWith("/")) nodeName = nodeName.substring(0, nodeName.length()-1);
if (nodeName.contains(" ")) nodeName = nodeName.substring(0, nodeName.indexOf(" "));
nodeName = nodeName.trim();
if (nodeName.contains(":")){
String ns = nodeName.substring(0, nodeName.indexOf(":"));
if (!ns.equals("m")){
String newNodeName = nodeName.substring(ns.length()+1);
view = view.replace("<" + nodeName, "<m:" + newNodeName);
view = view.replace("</" + nodeName, "</m:" + newNodeName);
}
}
else{
view = view.replace("<" + nodeName, "<m:" + nodeName);
view = view.replace("</" + nodeName, "</m:" + nodeName);
}
}
//Pa
StringBuffer props = new StringBuffer();
if (additionalProperties!=null){
java.util.Iterator<FieldURI> it = additionalProperties.iterator();
while (it.hasNext()){
FieldURI prop = it.next();
if (prop!=null){
props.append(prop.toXML("t")); //("<t:FieldURI FieldURI=\"" + prop + "\"/>");
}
}
}
String msg =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+ "<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\">"
+ "<soap:Body>"
+ "<m:FindItem Traversal=\"Shallow\">"
/*
+ "<m:ItemShape><t:BaseShape>Default</t:BaseShape>" //<--"Default" vs "AllProperties"
+ "<t:AdditionalProperties><t:FieldURI FieldURI=\"item:ItemClass\"/></t:AdditionalProperties>"
+ "</m:ItemShape>"
*/
+ "<m:ItemShape>"
+ "<t:BaseShape>Default</t:BaseShape>" //<--"Default" vs "AllProperties"
+ "<t:AdditionalProperties>"
+ "<t:FieldURI FieldURI=\"item:ItemClass\"/>"
//+ "<t:FieldURI FieldURI=\"item:LastModifiedTime\"/>" //value="item:LastModifiedTime" //<--This doesn't work...
+ "<t:ExtendedFieldURI PropertyTag=\"0x3008\" PropertyType=\"SystemTime\" />" //<--This returns the LastModifiedTime!
+ props.toString()
+ "</t:AdditionalProperties>"
+ "</m:ItemShape>"
+ view
+ restriction
+ sort
+ "<m:ParentFolderIds>"
+ "<t:FolderId Id=\"" + id + "\"/>"
+ "</m:ParentFolderIds>"
+ "</m:FindItem>"
+ "</soap:Body>"
+ "</soap:Envelope>";
return conn.execute(msg);
}
//**************************************************************************
//** getIndex
//**************************************************************************
/** Returns a hashmap of all the items found in this folder. The hashmap key
* is the item id and the corresponding value is the last modification date.
*/
public java.util.HashMap<String, javaxt.utils.Date> getIndex() throws ExchangeException {
java.util.HashMap<String, javaxt.utils.Date> index = new java.util.HashMap<String, javaxt.utils.Date>();
int offset = 0;
int limit = 1000;
while (true){
String msg =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+ "<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\">"
+ "<soap:Body>"
+ "<m:FindItem Traversal=\"Shallow\">"
+ "<m:ItemShape>"
+ "<t:BaseShape>IdOnly</t:BaseShape>" //<--"Default" vs "AllProperties"
+ "<t:AdditionalProperties>"
+ "<t:ExtendedFieldURI PropertyTag=\"0x3008\" PropertyType=\"SystemTime\" />" //<--This returns the LastModifiedTime!
+ "</t:AdditionalProperties>"
+ "</m:ItemShape>"
+ "<m:SortOrder>"
+ "<t:FieldOrder Order=\"Descending\">"
+ "<t:ExtendedFieldURI PropertyTag=\"0x3008\" PropertyType=\"SystemTime\" />"
+ "</t:FieldOrder>"
+ "</m:SortOrder>"
//+ "<m:IndexedPageItemView MaxEntriesReturned=\"1\" Offset=\"0\" BasePoint=\"Beginning\"/>"
+ "<m:IndexedPageItemView MaxEntriesReturned=\"" + limit + "\" Offset=\"" + offset + "\" BasePoint=\"Beginning\"/>"
+ "<m:ParentFolderIds>"
+ "<t:FolderId Id=\"" + id + "\"/>"
+ "</m:ParentFolderIds>"
+ "</m:FindItem>"
+ "</soap:Body>"
+ "</soap:Envelope>";
org.w3c.dom.Document xml = conn.execute(msg);
org.w3c.dom.Node[] items = javaxt.xml.DOM.getElementsByTagName("Items", xml);
int numItems = 0;
if (items.length>0){
org.w3c.dom.NodeList nodes = items[0].getChildNodes();
for (int i=0; i<nodes.getLength(); i++){
org.w3c.dom.Node node = nodes.item(i);
if (node.getNodeType()==1){
FolderItem item = new FolderItem(node);
index.put(item.getID(), item.getLastModifiedTime());
numItems++;
}
}
}
offset+=numItems;
//System.out.println("Found " + numItems + " items");
if (numItems==0 || numItems<limit) break;
}
return index;
}
protected void findItem(){
/*
<m:FindItem Traversal="Shallow"
xmlns:m=".../messages"
xmlns:t=".../types">
<m:ItemShape>
<t:BaseShape>IdOnly</t:BaseShape>
<t:AdditionalProperties>
<t:FieldURI FieldURI="item:Subject" />
<t:FieldURI FieldURI="calendar:CalendarItemType" />
</t:AdditionalProperties>
</m:ItemShape>
<m:Restriction>
<t:And>
<t:IsGreaterThan>
<t:FieldURI FieldURI="calendar:Start" />
<t:FieldURIOrConstant>
<t:Constant Value="2006-10-16T00:00:00-08:00" />
</t:FieldURIOrConstant>
</t:IsGreaterThan>
<t:IsLessThan>
<t:FieldURI FieldURI="calendar:End" />
<t:FieldURIOrConstant>
<t:Constant Value="2006-10-20T23:59:59-08:00" />
</t:FieldURIOrConstant>
</t:IsLessThan>
</t:And>
</m:Restriction>
<m:ParentFolderIds>
<t:DistinguishedFolderId Id="calendar"/>
</m:ParentFolderIds>
</m:FindItem>
*/
}
//**************************************************************************
//** getDistinguishedFolderIds
//**************************************************************************
/** Returns a list of Distinguished Folder IDs.
*/
public static String[] getDistinguishedFolderIds(){
return DistinguishedFolderIds;
}
//**************************************************************************
//** getDistinguishedFolderId
//**************************************************************************
/** Returns the DistinguishedFolderID for a given folder.
*/
public static String getDistinguishedFolderId(String folderName){
for (String folderID : DistinguishedFolderIds){
if (folderID.equalsIgnoreCase(folderName)) return folderID;
}
return null;
}
//**************************************************************************
//** DistinguishedFolderIds
//**************************************************************************
/** Static list of Distinguished Folder IDs. Source:
* http://msdn.microsoft.com/en-us/library/exchangewebservices.distinguishedfolderidnametype%28v=exchg.140%29.aspx
*/
private static String[] DistinguishedFolderIds = new String[]{
"archivedeleteditems",
"archivemsgfolderroot",
"archiverecoverableitemsdeletions",
"archiverecoverableitemspurges",
"archiverecoverableitemsroot",
"archiverecoverableitemsversions",
"archiveroot",
"calendar", //Represents the Calendar folder.
"contacts", //Represents the Contacts folder.
"deleteditems", //Represents the Deleted Items folder.
"drafts", //Represents the Drafts folder.
"inbox", //Represents the Inbox folder.
"journal", //Represents the Journal folder.
"junkemail", //Represents the Junk E-mail folder.
"msgfolderroot", //Represents the message folder root.
"notes", //Represents the Notes folder.
"outbox", //Represents the Outbox folder.
"publicfoldersroot",
"recoverableitemsdeletions",
"recoverableitemspurges",
"recoverableitemsroot",
"recoverableitemsversions",
"root", //Represents the root of the mailbox.
"searchfolders", //Represents the Search Folders folder. This is also an alias for the Finder folder.
"sentitems", //Represents the Sent Items folder.
"tasks", //Represents the Tasks folder.
"voicemail" //Represents the Voice Mail folder.
};
}