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

Caldav: instancetype is null on Exchange 2010, switch to isrecurring in EWS FindItem

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1677 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2011-05-11 10:39:22 +00:00
parent 0c01e83c3c
commit c1f6161c7b
4 changed files with 36 additions and 23 deletions

View File

@ -2516,19 +2516,13 @@ public abstract class ExchangeSession {
}
boolean caldavDisableTasks = Settings.getBooleanProperty("davmail.caldavDisableTasks");
Condition condition;
if (caldavDisableTasks) {
condition = or(isEqualTo("instancetype", 1),
and(isEqualTo("instancetype", 0), dateCondition));
} else {
condition = or(isNull("instancetype"),
isEqualTo("instancetype", 1),
and(isEqualTo("instancetype", 0), dateCondition));
}
Condition condition = getCalendarItemCondition(caldavDisableTasks, dateCondition);
return searchEvents(folderPath, condition);
}
protected abstract Condition getCalendarItemCondition(boolean excludeTasks, Condition dateCondition);
protected Condition getRangeCondition(String timeRangeStart, String timeRangeEnd) throws IOException {
try {
SimpleDateFormat parser = getZuluDateFormat();
@ -2557,15 +2551,7 @@ public abstract class ExchangeSession {
public List<Event> searchEvents(String folderPath, String timeRangeStart, String timeRangeEnd) throws IOException {
Condition dateCondition = getRangeCondition(timeRangeStart, timeRangeEnd);
boolean caldavDisableTasks = Settings.getBooleanProperty("davmail.caldavDisableTasks");
Condition condition;
if (caldavDisableTasks) {
condition = or(isEqualTo("instancetype", 1),
and(isEqualTo("instancetype", 0), dateCondition));
} else {
condition = or(isNull("instancetype"),
isEqualTo("instancetype", 1),
and(isEqualTo("instancetype", 0), dateCondition));
}
Condition condition = getCalendarItemCondition(caldavDisableTasks, dateCondition);
return searchEvents(folderPath, condition);
}
@ -2581,19 +2567,18 @@ public abstract class ExchangeSession {
*/
public List<Event> searchEventsOnly(String folderPath, String timeRangeStart, String timeRangeEnd) throws IOException {
Condition dateCondition = getRangeCondition(timeRangeStart, timeRangeEnd);
return searchEvents(folderPath, or(isEqualTo("instancetype", 1),
and(isEqualTo("instancetype", 0), dateCondition)));
return searchEvents(folderPath, getCalendarItemCondition(true, dateCondition));
}
/**
* Search tasks only (VTODO).
*
* @param folderPath Exchange folder path
* @return list of calendar events
* @return list of tasks
* @throws IOException on error
*/
public List<Event> searchTasksOnly(String folderPath) throws IOException {
return searchEvents(folderPath, isNull("instancetype"));
return searchEvents(folderPath, not(isEqualTo("outlookmessageclass", "IPM.Appointment")));
}
/**
@ -2611,7 +2596,7 @@ public abstract class ExchangeSession {
LOGGER.debug("Shared or public calendar: exclude private events");
privateCondition = isEqualTo("sensitivity", 0);
}
// instancetype 0 single appointment / 1 master recurring appointment
return searchEvents(folderPath, ITEM_PROPERTIES,
and(filter, privateCondition));
}

View File

@ -1867,6 +1867,19 @@ public class DavExchangeSession extends ExchangeSession {
return events;
}
@Override
protected Condition getCalendarItemCondition(boolean excludeTasks, Condition dateCondition) {
// instancetype 0 single appointment / 1 master recurring appointment
if (excludeTasks) {
return or(isEqualTo("instancetype", 1),
and(isEqualTo("instancetype", 0), dateCondition));
} else {
return or(isNull("instancetype"),
isEqualTo("instancetype", 1),
and(isEqualTo("instancetype", 0), dateCondition));
}
}
protected MultiStatusResponse[] searchItems(String folderPath, Set<String> attributes, Condition condition,
FolderQueryTraversal folderQueryTraversal, int maxCount) throws IOException {
String folderUrl = getFolderPath(folderPath);

View File

@ -1393,6 +1393,19 @@ public class EwsExchangeSession extends ExchangeSession {
return contacts;
}
@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));
}
}
@Override
public List<ExchangeSession.Event> getEventMessages(String folderPath) throws IOException {
return searchEvents(folderPath, ITEM_PROPERTIES,

View File

@ -199,6 +199,8 @@ public final class Field {
FIELD_MAP.put("optionalattendees", new UnindexedFieldURI("calendar:OptionalAttendees"));
FIELD_MAP.put("modifiedoccurrences", new UnindexedFieldURI("calendar:ModifiedOccurrences"));
FIELD_MAP.put("isrecurring", new UnindexedFieldURI("calendar:IsRecurring"));
FIELD_MAP.put("xmozlastack", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.PublicStrings, "xmozlastack"));
FIELD_MAP.put("xmozsnoozetime", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.PublicStrings, "xmozsnoozetime"));
FIELD_MAP.put("xmozsendinvitations", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.PublicStrings, "xmozsendinvitations"));