From 37aa6db3f269a5dffbf63a2657836e4bc99000b1 Mon Sep 17 00:00:00 2001 From: mguessan Date: Mon, 29 Mar 2010 08:50:39 +0000 Subject: [PATCH] Caldav: exclude private events on shared or public calendar PROPFIND git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@974 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- src/java/davmail/exchange/ExchangeSession.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/java/davmail/exchange/ExchangeSession.java b/src/java/davmail/exchange/ExchangeSession.java index 3e0957ae..27f13ea5 100644 --- a/src/java/davmail/exchange/ExchangeSession.java +++ b/src/java/davmail/exchange/ExchangeSession.java @@ -2525,6 +2525,12 @@ public class ExchangeSession { dateCondition = " AND \"urn:schemas:calendar:dtstart\" > '" + formatSearchDate(cal.getTime()) + "'\n"; } + String privateCondition = ""; + if (!isSharedFolder(folderPath)) { + LOGGER.debug("Shared or public calendar: exclude private events"); + privateCondition = " AND \"http://schemas.microsoft.com/exchange/sensitivity\" = 0\n"; + } + String searchQuery = "Select \"DAV:getetag\", \"http://schemas.microsoft.com/exchange/permanenturl\", \"urn:schemas:calendar:instancetype\"" + " FROM Scope('SHALLOW TRAVERSAL OF \"" + folderPath + "\"')\n" + " WHERE (" + @@ -2534,6 +2540,7 @@ public class ExchangeSession { " OR (\"urn:schemas:calendar:instancetype\" = 0\n" + dateCondition + " )) AND \"DAV:contentclass\" = 'urn:content-classes:appointment'\n" + + privateCondition + " ORDER BY \"urn:schemas:calendar:dtstart\" DESC\n"; return getEvents(folderPath, searchQuery); } @@ -2553,6 +2560,7 @@ public class ExchangeSession { for (MultiStatusResponse response : responses) { String instancetype = getPropertyIfExists(response.getProperties(HttpStatus.SC_OK), "instancetype", Namespace.getNamespace("urn:schemas:calendar:")); Event event = buildEvent(response); + //noinspection VariableNotUsedInsideIf if (instancetype == null) { // check ics content try { @@ -2863,6 +2871,16 @@ public class ExchangeSession { return buffer.toString(); } + /** + * Test if folderPath is inside user mailbox. + * + * @param folderPath absolute folder path + * @return true if folderPath is a public or shared folder + */ + public boolean isSharedFolder(String folderPath) { + return !folderPath.startsWith(mailPath); + } + /** * Build base path for cmd commands (galfind, gallookup). * This does not work with freebusy, which requires /public/