diff --git a/src/java/davmail/exchange/ews/EwsExchangeSession.java b/src/java/davmail/exchange/ews/EwsExchangeSession.java index 3b96a120..95fa1b26 100644 --- a/src/java/davmail/exchange/ews/EwsExchangeSession.java +++ b/src/java/davmail/exchange/ews/EwsExchangeSession.java @@ -1149,6 +1149,7 @@ public class EwsExchangeSession extends ExchangeSession { // item id ItemId itemId; String type; + boolean isException; protected Event(EWSMethod.Item response) { itemId = new ItemId(response); @@ -1164,6 +1165,10 @@ public class EwsExchangeSession extends ExchangeSession { if (itemName == null) { itemName = StringUtil.base64ToUrl(itemId.id) + ".EML"; } + String instancetype = response.get(Field.get("instancetype").getResponseName()); + boolean isrecurring = "true".equals(response.get(Field.get("isrecurring").getResponseName())); + String calendaritemtype = response.get(Field.get("calendaritemtype").getResponseName()); + isException = "3".equals(instancetype) || (isrecurring && "Single".equals(calendaritemtype)); } /** @@ -1187,7 +1192,7 @@ public class EwsExchangeSession extends ExchangeSession { if (currentItem != null) { currentItemId = new ItemId(currentItem); currentEtag = currentItem.get(Field.get("etag").getResponseName()); - LOGGER.debug("Existing item found with etag: " + currentEtag + " client etag: "+etag+" id: " + currentItemId.id); + LOGGER.debug("Existing item found with etag: " + currentEtag + " client etag: " + etag + " id: " + currentItemId.id); } if ("*".equals(noneMatch)) { // create requested @@ -1402,15 +1407,9 @@ public class EwsExchangeSession extends ExchangeSession { @Override protected Condition getCalendarItemCondition(boolean excludeTasks, Condition dateCondition) { - // instancetype 0 single appointment / 1 master recurring appointment - if (excludeTasks) { - return or(isTrue("isrecurring"), - and(isFalse("isrecurring"), dateCondition)); - } else { - return or(not(isEqualTo("outlookmessageclass", "IPM.Appointment")), - isTrue("isrecurring"), - and(isFalse("isrecurring"), dateCondition)); - } + // tasks in calendar not supported over EWS + return or(isTrue("isrecurring"), + and(isFalse("isrecurring"), dateCondition)); } @Override @@ -1436,6 +1435,9 @@ public class EwsExchangeSession extends ExchangeSession { } catch (HttpException e) { LOGGER.warn("Ignore invalid event " + event.getHref()); } + // exclude exceptions + } else if (event.isException) { + LOGGER.debug("Exclude recurrence exception " + event.getHref()); } else { events.add(event); } @@ -1445,6 +1447,11 @@ public class EwsExchangeSession extends ExchangeSession { return events; } + static { + ITEM_PROPERTIES.add("calendaritemtype"); + ITEM_PROPERTIES.add("isrecurring"); + } + protected static final HashSet EVENT_REQUEST_PROPERTIES = new HashSet(); static { diff --git a/src/java/davmail/exchange/ews/Field.java b/src/java/davmail/exchange/ews/Field.java index cf80f5ff..c9c4a503 100644 --- a/src/java/davmail/exchange/ews/Field.java +++ b/src/java/davmail/exchange/ews/Field.java @@ -200,6 +200,7 @@ public final class Field { FIELD_MAP.put("modifiedoccurrences", new UnindexedFieldURI("calendar:ModifiedOccurrences")); FIELD_MAP.put("isrecurring", new UnindexedFieldURI("calendar:IsRecurring")); + FIELD_MAP.put("calendaritemtype", new UnindexedFieldURI("calendar:CalendarItemType")); FIELD_MAP.put("xmozlastack", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.PublicStrings, "xmozlastack")); FIELD_MAP.put("xmozsnoozetime", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.PublicStrings, "xmozsnoozetime"));