Caldav: Experimental GET ics on folder and fix regression on public folder access

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@819 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2009-11-04 22:57:08 +00:00
parent 6b23e40b4e
commit ad0ca0c875
1 changed files with 20 additions and 3 deletions

View File

@ -22,6 +22,7 @@ import davmail.AbstractConnection;
import davmail.BundleMessage;
import davmail.Settings;
import davmail.DavGateway;
import davmail.util.StringUtil;
import davmail.exception.DavMailAuthenticationException;
import davmail.exception.DavMailException;
import davmail.exchange.ExchangeSession;
@ -268,8 +269,22 @@ public class CaldavConnection extends AbstractConnection {
int status = session.deleteEvent(request.getExchangeFolderPath(), lastPath);
sendHttpResponse(status);
} else if (request.isGet()) {
ExchangeSession.Event event = session.getEvent(request.getExchangeFolderPath(), lastPath);
sendHttpResponse(HttpStatus.SC_OK, buildEtagHeader(event.getEtag()), "text/calendar;charset=UTF-8", event.getICS(), true);
if (request.path.endsWith("/")) {
// GET request on a folder => build ics content of all folder events
String folderPath = request.getExchangeFolderPath();
List<ExchangeSession.Event> events = session.getAllEvents(folderPath);
StringBuilder buffer = new StringBuilder();
buffer.append("BEGIN:VCALENDAR");
for (ExchangeSession.Event event : events) {
String icsContent = StringUtil.getToken(event.getICS(), "BEGIN:VCALENDAR", "END:VCALENDAR");
buffer.append(icsContent);
}
buffer.append("END:VCALENDAR");
sendHttpResponse(HttpStatus.SC_OK, buildEtagHeader(session.getFolderCtag(folderPath)), "text/calendar;charset=UTF-8", buffer.toString(), true);
} else {
ExchangeSession.Event event = session.getEvent(request.getExchangeFolderPath(), lastPath);
sendHttpResponse(HttpStatus.SC_OK, buildEtagHeader(event.getEtag()), "text/calendar;charset=UTF-8", event.getICS(), true);
}
} else if (request.isHead()) {
// test event
ExchangeSession.Event event = session.getEvent(request.getExchangeFolderPath(), lastPath);
@ -1319,7 +1334,9 @@ public class CaldavConnection extends AbstractConnection {
} else {
StringBuilder calendarPath = new StringBuilder();
for (int i = 0; i < endIndex; i++) {
calendarPath.append('/').append(getPathElement(i));
if (getPathElement(i).length() > 0) {
calendarPath.append('/').append(getPathElement(i));
}
}
return calendarPath.toString();
}