1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package davmail.exchange.ews;
20
21 import davmail.exchange.XMLStreamUtil;
22
23 import javax.xml.stream.XMLStreamReader;
24 import java.io.IOException;
25 import java.io.Writer;
26
27
28
29
30 public class GetUserAvailabilityMethod extends EWSMethod {
31 protected final String attendee;
32 protected final String start;
33 protected final String end;
34 protected String mergedFreeBusy;
35 protected final int interval;
36
37
38
39
40
41
42
43
44
45 public GetUserAvailabilityMethod(String attendee, String start, String end, int interval) {
46 super("FreeBusy", "GetUserAvailabilityRequest");
47 this.attendee = attendee;
48 this.start = start;
49 this.end = end;
50 this.interval = interval;
51 }
52
53 @Override
54 protected void writeSoapBody(Writer writer) throws IOException {
55
56 writer.write("<t:TimeZone>" +
57 "<t:Bias>0</t:Bias>" +
58 "<t:StandardTime>" +
59 "<t:Bias>0</t:Bias>" +
60 "<t:Time>02:00:00</t:Time>" +
61 "<t:DayOrder>1</t:DayOrder>" +
62 "<t:Month>3</t:Month>" +
63 "<t:DayOfWeek>Sunday</t:DayOfWeek>" +
64 "</t:StandardTime>" +
65 "<t:DaylightTime>" +
66 "<t:Bias>0</t:Bias>" +
67 "<t:Time>02:00:00</t:Time>" +
68 "<t:DayOrder>1</t:DayOrder>" +
69 "<t:Month>10</t:Month>" +
70 "<t:DayOfWeek>Sunday</t:DayOfWeek>" +
71 "</t:DaylightTime>" +
72 "</t:TimeZone>");
73
74 writer.write("<m:MailboxDataArray>" +
75 "<t:MailboxData>" +
76 "<t:Email>" +
77 "<t:Address>");
78 writer.write(attendee);
79 writer.write("</t:Address>" +
80 "</t:Email>" +
81 "<t:AttendeeType>Required</t:AttendeeType>" +
82 "</t:MailboxData>" +
83 "</m:MailboxDataArray>");
84
85 writer.write("<t:FreeBusyViewOptions>" +
86 "<t:TimeWindow>" +
87 "<t:StartTime>");
88 writer.write(start);
89 writer.write("</t:StartTime>" +
90 "<t:EndTime>");
91 writer.write(end);
92 writer.write("</t:EndTime>" +
93 "</t:TimeWindow>" +
94 "<t:MergedFreeBusyIntervalInMinutes>" + interval + "</t:MergedFreeBusyIntervalInMinutes>" +
95 "<t:RequestedView>MergedOnly</t:RequestedView>" +
96 "</t:FreeBusyViewOptions>");
97 }
98
99 @Override
100 protected void handleCustom(XMLStreamReader reader) {
101 if (XMLStreamUtil.isStartTag(reader, "MergedFreeBusy")) {
102 this.mergedFreeBusy = XMLStreamUtil.getElementText(reader);
103 }
104 }
105
106
107
108
109
110
111 public String getMergedFreeBusy() {
112 return mergedFreeBusy;
113 }
114 }