Caldav: Do not fail on Inbox access denied, just return an empty folder

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@718 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2009-09-15 08:34:13 +00:00
parent f6649d7217
commit 4549201d0b
3 changed files with 26 additions and 10 deletions

View File

@ -390,6 +390,16 @@ public class CaldavConnection extends AbstractConnection {
* @throws IOException on error * @throws IOException on error
*/ */
public void appendInbox(CaldavResponse response, CaldavRequest request, String subFolder) throws IOException { public void appendInbox(CaldavResponse response, CaldavRequest request, String subFolder) throws IOException {
String ctag = "0";
String etag = "0";
String exchangeFolderPath = request.getExchangeFolderPath(subFolder);
try {
ctag = base64Encode(session.getFolderCtag(exchangeFolderPath));
etag = session.getFolderResourceTag(exchangeFolderPath);
} catch (HttpException e) {
// unauthorized access, probably an inbox on shared calendar
DavGatewayTray.debug(new BundleMessage("LOG_ACCESS_FORBIDDEN", exchangeFolderPath, e.getMessage()));
}
response.startResponse(URIUtil.encodePath(request.getPath(subFolder))); response.startResponse(URIUtil.encodePath(request.getPath(subFolder)));
response.startPropstat(); response.startPropstat();
@ -401,11 +411,10 @@ public class CaldavConnection extends AbstractConnection {
response.appendProperty("D:getcontenttype", "text/calendar; component=vevent"); response.appendProperty("D:getcontenttype", "text/calendar; component=vevent");
} }
if (request.hasProperty("getctag")) { if (request.hasProperty("getctag")) {
response.appendProperty("CS:getctag", "CS=\"http://calendarserver.org/ns/\"", response.appendProperty("CS:getctag", "CS=\"http://calendarserver.org/ns/\"", ctag);
base64Encode(session.getFolderCtag(request.getExchangeFolderPath(subFolder))));
} }
if (request.hasProperty("getetag")) { if (request.hasProperty("getetag")) {
response.appendProperty("D:getetag", session.getFolderResourceTag(request.getExchangeFolderPath(subFolder))); response.appendProperty("D:getetag", etag);
} }
if (request.hasProperty("displayname")) { if (request.hasProperty("displayname")) {
response.appendProperty("D:displayname", "inbox"); response.appendProperty("D:displayname", "inbox");
@ -468,10 +477,15 @@ public class CaldavConnection extends AbstractConnection {
response.startMultistatus(); response.startMultistatus();
appendInbox(response, request, null); appendInbox(response, request, null);
if (request.getDepth() == 1) { if (request.getDepth() == 1) {
DavGatewayTray.debug(new BundleMessage("LOG_SEARCHING_CALENDAR_MESSAGES")); try {
List<ExchangeSession.Event> events = session.getEventMessages(request.getExchangeFolderPath()); DavGatewayTray.debug(new BundleMessage("LOG_SEARCHING_CALENDAR_MESSAGES"));
DavGatewayTray.debug(new BundleMessage("LOG_FOUND_CALENDAR_MESSAGES", events.size())); List<ExchangeSession.Event> events = session.getEventMessages(request.getExchangeFolderPath());
appendEventsResponses(response, request, events); DavGatewayTray.debug(new BundleMessage("LOG_FOUND_CALENDAR_MESSAGES", events.size()));
appendEventsResponses(response, request, events);
} catch (HttpException e) {
// unauthorized access, probably an inbox on shared calendar
DavGatewayTray.debug(new BundleMessage("LOG_ACCESS_FORBIDDEN", request.getExchangeFolderPath(), e.getMessage()));
}
} }
response.endMultistatus(); response.endMultistatus();
response.close(); response.close();
@ -510,7 +524,7 @@ public class CaldavConnection extends AbstractConnection {
// TODO append sub calendars // TODO append sub calendars
List<ExchangeSession.Folder> folderList = session.getSubCalendarFolders(folderPath, false); List<ExchangeSession.Folder> folderList = session.getSubCalendarFolders(folderPath, false);
for (ExchangeSession.Folder folder : folderList) { for (ExchangeSession.Folder folder : folderList) {
appendCalendar(response, request, folder.folderPath.substring(folder.folderPath.indexOf('/')+1)); appendCalendar(response, request, folder.folderPath.substring(folder.folderPath.indexOf('/') + 1));
} }
} }
response.endMultistatus(); response.endMultistatus();
@ -1285,7 +1299,7 @@ public class CaldavConnection extends AbstractConnection {
if ("users".equals(getPathElement(1))) { if ("users".equals(getPathElement(1))) {
StringBuilder calendarPath = new StringBuilder(); StringBuilder calendarPath = new StringBuilder();
calendarPath.append(getPathElement(3)); calendarPath.append(getPathElement(3));
for (int i=4;i<getPathLength()-1;i++) { for (int i = 4; i < getPathLength() - 1; i++) {
calendarPath.append('/').append(getPathElement(i)); calendarPath.append('/').append(getPathElement(i));
} }
return session.buildCalendarPath(getPathElement(2), calendarPath.toString()); return session.buildCalendarPath(getPathElement(2), calendarPath.toString());

View File

@ -133,6 +133,7 @@ LOG_UNABLE_TO_SET_SYSTEM_LOOK_AND_FEEL=Unable to set system look and feel
LOG_UNABLE_TO_STORE_SETTINGS=Unable to store settings: LOG_UNABLE_TO_STORE_SETTINGS=Unable to store settings:
LOG_UNSUPORTED_REQUEST=Unsupported request: {0} LOG_UNSUPORTED_REQUEST=Unsupported request: {0}
LOG_INVALID_TIMEZONE=Invalid timezone: {0} LOG_INVALID_TIMEZONE=Invalid timezone: {0}
LOG_ACCESS_FORBIDDEN=Access to {0} forbidden: {1}
UI_ABOUT=About... UI_ABOUT=About...
UI_ABOUT_DAVMAIL=About DavMail Gateway UI_ABOUT_DAVMAIL=About DavMail Gateway
UI_ABOUT_DAVMAIL_AUTHOR=<html><b>DavMail Gateway</b><br>By Mickaël Guessant<br><br> UI_ABOUT_DAVMAIL_AUTHOR=<html><b>DavMail Gateway</b><br>By Mickaël Guessant<br><br>

View File

@ -226,3 +226,4 @@ LOG_GATEWAY_INTERRUPTED=Arr
LOG_GATEWAY_STOP=Passerelle DavMail arrêtée LOG_GATEWAY_STOP=Passerelle DavMail arrêtée
LOG_INVALID_TIMEZONE=Fuseau horaire invalide : {0} LOG_INVALID_TIMEZONE=Fuseau horaire invalide : {0}
MEETING_REQUEST=Invitation MEETING_REQUEST=Invitation
LOG_ACCESS_FORBIDDEN=Accès à {0} non autorisé: {1}