1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-13 19:22:22 -05:00

EWS: new recurring event filter implementation, exclude recurrence exception in results

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1730 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2011-07-06 22:30:05 +00:00
parent 6fb31025a5
commit d5e669f7de
2 changed files with 18 additions and 10 deletions

View File

@ -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<String> EVENT_REQUEST_PROPERTIES = new HashSet<String>();
static {

View File

@ -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"));