From 4c70485fc948bd58d93554e2f520d61d37f628a8 Mon Sep 17 00:00:00 2001 From: mguessan Date: Tue, 29 Sep 2009 11:03:15 +0000 Subject: [PATCH] Caldav: fix Bug 2686125, PROPPATCH event after PUT to trigger activeSync PUSH, tested with iPhone 3 using activeSync git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@760 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- .../davmail/exchange/ExchangeSession.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/java/davmail/exchange/ExchangeSession.java b/src/java/davmail/exchange/ExchangeSession.java index 3bacfa30..0c08c538 100644 --- a/src/java/davmail/exchange/ExchangeSession.java +++ b/src/java/davmail/exchange/ExchangeSession.java @@ -1676,6 +1676,10 @@ public class ExchangeSession { */ public Event getEvent(String folderPath, String eventName) throws IOException { String eventPath = URIUtil.encodePath(folderPath + '/' + eventName); + return getEvent(eventPath); + } + + protected Event getEvent(String eventPath) throws IOException { MultiStatusResponse[] responses = DavGatewayHttpClientFacade.executePropFindMethod(httpClient, eventPath, 0, EVENT_REQUEST_PROPERTIES); if (responses.length == 0) { throw new DavMailException("EXCEPTION_EVENT_NOT_FOUND"); @@ -2345,6 +2349,23 @@ public class ExchangeSession { if (putmethod.getResponseHeader("GetETag") != null) { eventResult.etag = putmethod.getResponseHeader("GetETag").getValue(); } + + // trigger activeSync push event + if (status == HttpStatus.SC_OK || status == HttpStatus.SC_CREATED) { + ArrayList propertyList = new ArrayList(); + propertyList.add(new DefaultDavProperty(DavPropertyName.create("contentclass", Namespace.getNamespace("DAV:")), contentClass)); + PropPatchMethod propPatchMethod = new PropPatchMethod(messageUrl, propertyList); + int patchStatus = DavGatewayHttpClientFacade.executeHttpMethod(httpClient, propPatchMethod); + if (patchStatus != HttpStatus.SC_MULTI_STATUS) { + LOGGER.warn("Unable to patch event to trigger activeSync push"); + } else { + // Need to get event again to get updated etag + Event event = getEvent(messageUrl); + if (event.getEtag() != null) { + eventResult.etag = event.getEtag(); + } + } + } return eventResult; }