mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-14 03:32:22 -05:00
iCal fix : implement GET request on event
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@253 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
7b33fce14b
commit
43f4f632b5
@ -330,6 +330,10 @@ public class CaldavConnection extends AbstractConnection {
|
||||
int status = session.createOrUpdateEvent(path.substring("/calendar/".length()), body, etag);
|
||||
sendHttpResponse(status, true);
|
||||
|
||||
} else if ("GET".equals(command) && path.startsWith("/calendar/")) {
|
||||
ExchangeSession.Event event = session.getEvent(path.substring("/calendar/".length()));
|
||||
sendHttpResponse(HttpStatus.SC_OK, null, "text/calendar;charset=UTF-8", event.getICS(), true);
|
||||
|
||||
} else if ("POST".equals(command) && path.startsWith("/outbox")) {
|
||||
Map<String, String> valueMap = new HashMap<String, String>();
|
||||
Map<String, String> keyMap = new HashMap<String, String>();
|
||||
@ -398,31 +402,35 @@ public class CaldavConnection extends AbstractConnection {
|
||||
int count = 0;
|
||||
for (ExchangeSession.Event event : events) {
|
||||
DavGatewayTray.debug("Retrieving event "+(++count)+"/"+size);
|
||||
String eventPath = event.getPath().replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
||||
buffer.append("<D:response>\n");
|
||||
buffer.append(" <D:href>/calendar").append(eventPath).append("</D:href>\n");
|
||||
buffer.append(" <D:propstat>\n");
|
||||
buffer.append(" <D:prop>\n");
|
||||
if (request.hasProperty("calendar-data")) {
|
||||
String ics = event.getICS();
|
||||
if (ics != null && ics.length() > 0) {
|
||||
ics = ics.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
||||
buffer.append(" <C:calendar-data xmlns:C=\"urn:ietf:params:xml:ns:caldav\"\n");
|
||||
buffer.append(" C:content-type=\"text/calendar\" C:version=\"2.0\">");
|
||||
buffer.append(ics);
|
||||
buffer.append("</C:calendar-data>\n");
|
||||
}
|
||||
}
|
||||
if (request.hasProperty("getetag")) {
|
||||
buffer.append(" <D:getetag>").append(event.getEtag()).append("</D:getetag>\n");
|
||||
}
|
||||
buffer.append(" </D:prop>\n");
|
||||
buffer.append(" <D:status>HTTP/1.1 200 OK</D:status>\n");
|
||||
buffer.append(" </D:propstat>\n");
|
||||
buffer.append(" </D:response>\n");
|
||||
appendEventResponse(buffer, request, event);
|
||||
}
|
||||
}
|
||||
|
||||
protected void appendEventResponse(StringBuilder buffer, CaldavRequest request, ExchangeSession.Event event) throws IOException {
|
||||
String eventPath = event.getPath().replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
||||
buffer.append("<D:response>\n");
|
||||
buffer.append(" <D:href>/calendar").append(eventPath).append("</D:href>\n");
|
||||
buffer.append(" <D:propstat>\n");
|
||||
buffer.append(" <D:prop>\n");
|
||||
if (request.hasProperty("calendar-data")) {
|
||||
String ics = event.getICS();
|
||||
if (ics != null && ics.length() > 0) {
|
||||
ics = ics.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
||||
buffer.append(" <C:calendar-data xmlns:C=\"urn:ietf:params:xml:ns:caldav\"\n");
|
||||
buffer.append(" C:content-type=\"text/calendar\" C:version=\"2.0\">");
|
||||
buffer.append(ics);
|
||||
buffer.append("</C:calendar-data>\n");
|
||||
}
|
||||
}
|
||||
if (request.hasProperty("getetag")) {
|
||||
buffer.append(" <D:getetag>").append(event.getEtag()).append("</D:getetag>\n");
|
||||
}
|
||||
buffer.append(" </D:prop>\n");
|
||||
buffer.append(" <D:status>HTTP/1.1 200 OK</D:status>\n");
|
||||
buffer.append(" </D:propstat>\n");
|
||||
buffer.append(" </D:response>\n");
|
||||
}
|
||||
|
||||
public void sendErr(int status, Exception e) throws IOException {
|
||||
String message = e.getMessage();
|
||||
if (message == null) {
|
||||
|
Loading…
Reference in New Issue
Block a user