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
This commit is contained in:
mguessan 2009-09-29 11:03:15 +00:00
parent c1fbfa354f
commit 4c70485fc9
1 changed files with 21 additions and 0 deletions

View File

@ -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<DavProperty> propertyList = new ArrayList<DavProperty>();
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;
}