2010-07-28 13:11:18 -04:00
|
|
|
/*
|
|
|
|
* DavMail POP/IMAP/SMTP/CalDav/LDAP Exchange Gateway
|
|
|
|
* Copyright (C) 2010 Mickael Guessant
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
package davmail.exchange.ews;
|
|
|
|
|
2010-08-28 16:21:31 -04:00
|
|
|
import davmail.exchange.XMLStreamUtil;
|
|
|
|
|
2010-07-28 13:11:18 -04:00
|
|
|
import javax.xml.stream.XMLStreamException;
|
|
|
|
import javax.xml.stream.XMLStreamReader;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.Writer;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GetUserAvailability method.
|
|
|
|
*/
|
|
|
|
public class GetUserAvailabilityMethod extends EWSMethod {
|
2010-09-24 04:30:40 -04:00
|
|
|
protected final String attendee;
|
|
|
|
protected final String start;
|
|
|
|
protected final String end;
|
2010-07-28 13:11:18 -04:00
|
|
|
protected String mergedFreeBusy;
|
2010-09-24 04:30:40 -04:00
|
|
|
protected final int interval;
|
2010-07-28 13:11:18 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Build EWS method
|
|
|
|
*
|
|
|
|
* @param attendee attendee email address
|
|
|
|
* @param start start date in Exchange zulu format
|
|
|
|
* @param end end date in Exchange zulu format
|
|
|
|
* @param interval freebusy interval in minutes
|
|
|
|
*/
|
|
|
|
public GetUserAvailabilityMethod(String attendee, String start, String end, int interval) {
|
|
|
|
super("FreeBusy", "GetUserAvailabilityRequest");
|
|
|
|
this.attendee = attendee;
|
|
|
|
this.start = start;
|
|
|
|
this.end = end;
|
|
|
|
this.interval = interval;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void writeSoapBody(Writer writer) throws IOException {
|
|
|
|
// write UTC timezone
|
|
|
|
writer.write("<t:TimeZone>" +
|
|
|
|
"<t:Bias>0</t:Bias>" +
|
|
|
|
"<t:StandardTime>" +
|
|
|
|
"<t:Bias>0</t:Bias>" +
|
2011-04-06 17:17:24 -04:00
|
|
|
"<t:Time>02:00:00</t:Time>" +
|
2010-07-28 13:11:18 -04:00
|
|
|
"<t:DayOrder>1</t:DayOrder>" +
|
2011-04-06 17:17:24 -04:00
|
|
|
"<t:Month>3</t:Month>" +
|
2010-07-28 13:11:18 -04:00
|
|
|
"<t:DayOfWeek>Sunday</t:DayOfWeek>" +
|
|
|
|
"</t:StandardTime>" +
|
|
|
|
"<t:DaylightTime>" +
|
|
|
|
"<t:Bias>0</t:Bias>" +
|
2011-04-06 17:17:24 -04:00
|
|
|
"<t:Time>02:00:00</t:Time>" +
|
2010-07-28 13:11:18 -04:00
|
|
|
"<t:DayOrder>1</t:DayOrder>" +
|
2011-04-06 17:17:24 -04:00
|
|
|
"<t:Month>10</t:Month>" +
|
2010-07-28 13:11:18 -04:00
|
|
|
"<t:DayOfWeek>Sunday</t:DayOfWeek>" +
|
|
|
|
"</t:DaylightTime>" +
|
|
|
|
"</t:TimeZone>");
|
|
|
|
// write attendee address
|
|
|
|
writer.write("<m:MailboxDataArray>" +
|
|
|
|
"<t:MailboxData>" +
|
|
|
|
"<t:Email>" +
|
|
|
|
"<t:Address>");
|
|
|
|
writer.write(attendee);
|
|
|
|
writer.write("</t:Address>" +
|
|
|
|
"</t:Email>" +
|
|
|
|
"<t:AttendeeType>Required</t:AttendeeType>" +
|
|
|
|
"</t:MailboxData>" +
|
|
|
|
"</m:MailboxDataArray>");
|
|
|
|
// freebusy range
|
|
|
|
writer.write("<t:FreeBusyViewOptions>" +
|
|
|
|
"<t:TimeWindow>" +
|
|
|
|
"<t:StartTime>");
|
|
|
|
writer.write(start);
|
|
|
|
writer.write("</t:StartTime>" +
|
|
|
|
"<t:EndTime>");
|
|
|
|
writer.write(end);
|
|
|
|
writer.write("</t:EndTime>" +
|
|
|
|
"</t:TimeWindow>" +
|
2010-09-24 04:44:13 -04:00
|
|
|
"<t:MergedFreeBusyIntervalInMinutes>" + interval + "</t:MergedFreeBusyIntervalInMinutes>" +
|
2010-07-28 13:11:18 -04:00
|
|
|
"<t:RequestedView>MergedOnly</t:RequestedView>" +
|
|
|
|
"</t:FreeBusyViewOptions>");
|
|
|
|
}
|
|
|
|
|
2010-08-18 06:33:25 -04:00
|
|
|
@Override
|
|
|
|
protected void handleCustom(XMLStreamReader reader) throws XMLStreamException {
|
2010-08-28 16:21:31 -04:00
|
|
|
if (XMLStreamUtil.isStartTag(reader, "MergedFreeBusy")) {
|
2010-10-05 05:41:04 -04:00
|
|
|
this.mergedFreeBusy = XMLStreamUtil.getElementText(reader);
|
2010-08-18 06:33:25 -04:00
|
|
|
}
|
2010-07-28 13:11:18 -04:00
|
|
|
}
|
|
|
|
|
2010-09-24 04:44:13 -04:00
|
|
|
/**
|
|
|
|
* Get merged freebusy string.
|
|
|
|
*
|
|
|
|
* @return freebusy string
|
|
|
|
*/
|
2010-07-28 13:11:18 -04:00
|
|
|
public String getMergedFreeBusy() {
|
|
|
|
return mergedFreeBusy;
|
|
|
|
}
|
|
|
|
}
|