mirror of
https://github.com/moparisthebest/davmail
synced 2025-02-28 09:21:49 -05:00
Caldav: Another fix on & handling to make it compatible with iCal and Lightning
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@440 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
c819e77d29
commit
1ba82c82de
@ -239,7 +239,7 @@ public class CaldavConnection extends AbstractConnection {
|
||||
&& session.getEmail().equalsIgnoreCase(paths[2])) {
|
||||
String etag = headers.get("if-match");
|
||||
String noneMatch = headers.get("if-none-match");
|
||||
ExchangeSession.EventResult eventResult = session.createOrUpdateEvent(paths[4], body, etag, noneMatch);
|
||||
ExchangeSession.EventResult eventResult = session.createOrUpdateEvent(paths[4].replaceAll("&", "&"), body, etag, noneMatch);
|
||||
if (eventResult.etag != null) {
|
||||
HashMap<String, String> responseHeaders = new HashMap<String, String>();
|
||||
responseHeaders.put("ETag", eventResult.etag);
|
||||
@ -259,7 +259,7 @@ public class CaldavConnection extends AbstractConnection {
|
||||
} else if ("GET".equals(command) && "users".equals(paths[1]) && paths.length == 5 && "calendar".equals(paths[3])
|
||||
// only current user for now
|
||||
&& session.getEmail().equalsIgnoreCase(paths[2])) {
|
||||
ExchangeSession.Event event = session.getEvent(paths[3] + "/" + paths[4]);
|
||||
ExchangeSession.Event event = session.getEvent(paths[3], paths[4]);
|
||||
sendHttpResponse(HttpStatus.SC_OK, null, "text/calendar;charset=UTF-8", event.getICS(), true);
|
||||
|
||||
} else {
|
||||
@ -426,7 +426,7 @@ public class CaldavConnection extends AbstractConnection {
|
||||
if (index < 0) {
|
||||
return null;
|
||||
} else {
|
||||
return path.substring(index + 1);
|
||||
return path.substring(index + 1).replaceAll("&", "&");
|
||||
}
|
||||
}
|
||||
|
||||
@ -444,7 +444,7 @@ public class CaldavConnection extends AbstractConnection {
|
||||
if (eventName == null) {
|
||||
notFound.add(href);
|
||||
} else {
|
||||
events.add(session.getEvent(path + "/" + eventName));
|
||||
events.add(session.getEvent(path, eventName));
|
||||
}
|
||||
} catch (HttpException e) {
|
||||
notFound.add(href);
|
||||
@ -462,7 +462,7 @@ public class CaldavConnection extends AbstractConnection {
|
||||
|
||||
// send not found events errors
|
||||
for (String href : notFound) {
|
||||
response.startResponse(URIUtil.encodeWithinQuery(href));
|
||||
response.startResponse(URIUtil.encodePath(href));
|
||||
response.appendPropstatNotFound();
|
||||
response.endResponse();
|
||||
}
|
||||
|
@ -13,10 +13,7 @@ import org.apache.log4j.Logger;
|
||||
import org.apache.webdav.lib.Property;
|
||||
import org.apache.webdav.lib.ResponseEntity;
|
||||
import org.apache.webdav.lib.WebdavResource;
|
||||
import org.apache.webdav.lib.methods.CopyMethod;
|
||||
import org.apache.webdav.lib.methods.MoveMethod;
|
||||
import org.apache.webdav.lib.methods.PropPatchMethod;
|
||||
import org.apache.webdav.lib.methods.SearchMethod;
|
||||
import org.apache.webdav.lib.methods.*;
|
||||
import org.htmlcleaner.CommentToken;
|
||||
import org.htmlcleaner.HtmlCleaner;
|
||||
import org.htmlcleaner.TagNode;
|
||||
@ -1078,7 +1075,8 @@ public class ExchangeSession {
|
||||
|
||||
public void delete() throws IOException {
|
||||
wdr.deleteMethod(messageUrl);
|
||||
if (wdr.getStatusCode() != HttpStatus.SC_OK) {
|
||||
// do not send error on event not found
|
||||
if (wdr.getStatusCode() != HttpStatus.SC_OK && wdr.getStatusCode() != HttpStatus.SC_NOT_FOUND) {
|
||||
HttpException ex = new HttpException();
|
||||
ex.setReasonCode(wdr.getStatusCode());
|
||||
ex.setReason(wdr.getStatusMessage());
|
||||
@ -1255,8 +1253,17 @@ public class ExchangeSession {
|
||||
return events;
|
||||
}
|
||||
|
||||
public Event getEvent(String path) throws IOException {
|
||||
Enumeration calendarEnum = wdr.propfindMethod(getFolderPath(URIUtil.decode(path)), 0, EVENT_REQUEST_PROPERTIES);
|
||||
public Event getEvent(String path, String eventName) throws IOException {
|
||||
String eventPath = URIUtil.encodePath(getFolderPath(path))+"/"+URIUtil.encodeWithinQuery(eventName);
|
||||
LOGGER.debug("getEvent("+eventPath+"/"+eventName+")");
|
||||
PropFindMethod propFindMethod = new PropFindMethod(eventPath, 0, EVENT_REQUEST_PROPERTIES.elements());
|
||||
int status = wdr.retrieveSessionInstance().executeMethod(propFindMethod);
|
||||
if (status != HttpStatus.SC_MULTI_STATUS) {
|
||||
HttpException ex = new HttpException();
|
||||
ex.setReasonCode(status);
|
||||
throw ex;
|
||||
}
|
||||
Enumeration calendarEnum = propFindMethod.getResponses();
|
||||
if (!calendarEnum.hasMoreElements()) {
|
||||
throw new IOException("Unable to get calendar event");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user