From 20ca74fb88b1e18b9bd99d943666a2427fc67473 Mon Sep 17 00:00:00 2001 From: mguessan Date: Sat, 31 Jul 2010 23:21:07 +0000 Subject: [PATCH] Caldav: fix regressions and do not filter on outlookmessageclass git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1323 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- .../davmail/exchange/ExchangeSession.java | 15 ++++++--- src/java/davmail/exchange/VCalendar.java | 32 ++++++++++++++++--- .../exchange/dav/DavExchangeSession.java | 2 +- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/src/java/davmail/exchange/ExchangeSession.java b/src/java/davmail/exchange/ExchangeSession.java index 6d64d110..c6ca95b3 100644 --- a/src/java/davmail/exchange/ExchangeSession.java +++ b/src/java/davmail/exchange/ExchangeSession.java @@ -1957,7 +1957,7 @@ public abstract class ExchangeSession { // Make sure invites have a proper subject line // TODO: get current user attendee status, i18n - String subject = vCalendar.getFirstVevent().getPropertyValue("SUMMARY"); + String subject = vCalendar.getFirstVeventPropertyValue("SUMMARY"); if (subject == null) { subject = BundleMessage.format("MEETING_REQUEST"); } @@ -1982,7 +1982,15 @@ public abstract class ExchangeSession { return null; } } - + if (LOGGER.isDebugEnabled()) { + StringBuilder logBuffer = new StringBuilder("Sending notification"); + if (recipients.attendees != null) { + logBuffer.append("to: ").append(recipients.attendees); + } + if (recipients.optionalAttendees != null) { + logBuffer.append("cc: ").append(recipients.optionalAttendees); + } + } } else { // need to parse attendees and organizer to build recipients VCalendar.Recipients recipients = vCalendar.getRecipients(false); @@ -2017,7 +2025,7 @@ public abstract class ExchangeSession { // Write a part of the message that contains the // ICS description so that invites contain the description text - String description = vCalendar.getFirstVevent().getPropertyValue("DESCRIPTION"); + String description = vCalendar.getFirstVeventPropertyValue("DESCRIPTION"); if (description != null && description.length() > 0) { writer.writeHeader("Content-Type", "text/plain;\r\n" + @@ -2169,7 +2177,6 @@ public abstract class ExchangeSession { and(or(isNull("instancetype"), isEqualTo("instancetype", 1), and(isEqualTo("instancetype", 0), dateCondition)), - isEqualTo("outlookmessageclass", "IPM.Appointment"), privateCondition)); } diff --git a/src/java/davmail/exchange/VCalendar.java b/src/java/davmail/exchange/VCalendar.java index 5b4ddaad..bd706f12 100644 --- a/src/java/davmail/exchange/VCalendar.java +++ b/src/java/davmail/exchange/VCalendar.java @@ -334,7 +334,7 @@ public class VCalendar extends VObject { * @return X-CALENDARSERVER-ACCESS value */ protected String getCalendarServerAccess() { - String eventClass = firstVevent.getPropertyValue("CLASS"); + String eventClass = getFirstVeventPropertyValue("CLASS"); if ("PRIVATE".equalsIgnoreCase(eventClass)) { return "CONFIDENTIAL"; } else if ("CONFIDENTIAL".equalsIgnoreCase(eventClass)) { @@ -344,8 +344,29 @@ public class VCalendar extends VObject { } } - public VObject getFirstVevent() { - return firstVevent; + public String getFirstVeventPropertyValue(String name) { + if (firstVevent == null) { + return null; + } else { + return firstVevent.getPropertyValue(name); + } + } + + protected VProperty getFirstVeventProperty(String name) { + if (firstVevent == null) { + return null; + } else { + return firstVevent.getProperty(name); + } + } + + + protected List getFirstVeventProperties(String name) { + if (firstVevent == null) { + return null; + } else { + return firstVevent.getProperties(name); + } } class Recipients { @@ -360,7 +381,7 @@ public class VCalendar extends VObject { HashSet optionalAttendees = new HashSet(); // get recipients from first VEVENT - List attendeeProperties = firstVevent.getProperties("ATTENDEE"); + List attendeeProperties = getFirstVeventProperties("ATTENDEE"); if (attendeeProperties != null) { for (VProperty property : attendeeProperties) { // exclude current user and invalid values from recipients @@ -389,9 +410,10 @@ public class VCalendar extends VObject { } } Recipients recipients = new Recipients(); - recipients.organizer = getEmailValue(firstVevent.getProperty("ORGANIZER")); + recipients.organizer = getEmailValue(getFirstVeventProperty("ORGANIZER")); recipients.attendees = StringUtil.join(attendees, ", "); recipients.optionalAttendees = StringUtil.join(optionalAttendees, ", "); return recipients; } + } diff --git a/src/java/davmail/exchange/dav/DavExchangeSession.java b/src/java/davmail/exchange/dav/DavExchangeSession.java index dab6aac5..58f90868 100644 --- a/src/java/davmail/exchange/dav/DavExchangeSession.java +++ b/src/java/davmail/exchange/dav/DavExchangeSession.java @@ -1268,7 +1268,7 @@ public class DavExchangeSession extends ExchangeSession { event.getBody(); // getBody success => add event or task events.add(event); - } catch (HttpException e) { + } catch (IOException e) { // invalid event: exclude from list LOGGER.warn("Invalid event " + event.displayName + " found at " + response.getHref(), e); }