mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-13 03:02:22 -05:00
EWS: new failovers on Timezone settings: use davmail.timezoneId setting or default to GMT Standard Time
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1648 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
00a1baba41
commit
16617d8141
@ -18,6 +18,7 @@
|
||||
*/
|
||||
package davmail.exchange.ews;
|
||||
|
||||
import davmail.Settings;
|
||||
import davmail.exception.DavMailAuthenticationException;
|
||||
import davmail.exception.DavMailException;
|
||||
import davmail.exception.HttpNotFoundException;
|
||||
@ -1570,29 +1571,37 @@ public class EwsExchangeSession extends ExchangeSession {
|
||||
} else {
|
||||
timezoneId = getTimezoneidFromOptions();
|
||||
}
|
||||
if (timezoneId != null) {
|
||||
createCalendarFolder("davmailtemp", null);
|
||||
EWSMethod.Item item = new EWSMethod.Item();
|
||||
item.type = "CalendarItem";
|
||||
if ("Exchange2010".equals(serverVersion)) {
|
||||
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ENGLISH);
|
||||
dateFormatter.setTimeZone(GMT_TIMEZONE);
|
||||
Calendar cal = Calendar.getInstance();
|
||||
item.put("Start", dateFormatter.format(cal.getTime()));
|
||||
cal.add(Calendar.DAY_OF_MONTH, 1);
|
||||
item.put("End", dateFormatter.format(cal.getTime()));
|
||||
item.put("StartTimeZone", timezoneId);
|
||||
} else {
|
||||
item.put("MeetingTimeZone", timezoneId);
|
||||
}
|
||||
CreateItemMethod createItemMethod = new CreateItemMethod(MessageDisposition.SaveOnly, SendMeetingInvitations.SendToNone, getFolderId("davmailtemp"), item);
|
||||
executeMethod(createItemMethod);
|
||||
item = createItemMethod.getResponseItem();
|
||||
VCalendar vCalendar = new VCalendar(getContent(new ItemId(item)), email, null);
|
||||
this.vTimezone = vCalendar.getVTimezone();
|
||||
// delete temporary folder
|
||||
deleteFolder("davmailtemp");
|
||||
// failover: use timezone id from settings file
|
||||
if (timezoneId == null) {
|
||||
timezoneId = Settings.getProperty("davmail.timezoneId");
|
||||
}
|
||||
// last failover: use GMT
|
||||
if (timezoneId == null) {
|
||||
LOGGER.warn("Unable to get user timezone, using GMT Standard Time. Set davmail.timezoneId setting to override this.");
|
||||
timezoneId = "GMT Standard Time";
|
||||
}
|
||||
|
||||
createCalendarFolder("davmailtemp", null);
|
||||
EWSMethod.Item item = new EWSMethod.Item();
|
||||
item.type = "CalendarItem";
|
||||
if ("Exchange2010".equals(serverVersion)) {
|
||||
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ENGLISH);
|
||||
dateFormatter.setTimeZone(GMT_TIMEZONE);
|
||||
Calendar cal = Calendar.getInstance();
|
||||
item.put("Start", dateFormatter.format(cal.getTime()));
|
||||
cal.add(Calendar.DAY_OF_MONTH, 1);
|
||||
item.put("End", dateFormatter.format(cal.getTime()));
|
||||
item.put("StartTimeZone", timezoneId);
|
||||
} else {
|
||||
item.put("MeetingTimeZone", timezoneId);
|
||||
}
|
||||
CreateItemMethod createItemMethod = new CreateItemMethod(MessageDisposition.SaveOnly, SendMeetingInvitations.SendToNone, getFolderId("davmailtemp"), item);
|
||||
executeMethod(createItemMethod);
|
||||
item = createItemMethod.getResponseItem();
|
||||
VCalendar vCalendar = new VCalendar(getContent(new ItemId(item)), email, null);
|
||||
this.vTimezone = vCalendar.getVTimezone();
|
||||
// delete temporary folder
|
||||
deleteFolder("davmailtemp");
|
||||
} catch (IOException e) {
|
||||
LOGGER.warn("Unable to get VTIMEZONE info: " + e, e);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user