1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-14 11:42:23 -05:00

Caldav: move failover for Exchange 2007 plus encoding issue to Exchange session

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@865 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2009-11-29 21:08:23 +00:00
parent 735542734e
commit ad7a93fcc4

View File

@ -24,7 +24,6 @@ import davmail.DavGateway;
import davmail.Settings; import davmail.Settings;
import davmail.exception.DavMailAuthenticationException; import davmail.exception.DavMailAuthenticationException;
import davmail.exception.DavMailException; import davmail.exception.DavMailException;
import davmail.exception.HttpNotFoundException;
import davmail.exchange.ExchangeSession; import davmail.exchange.ExchangeSession;
import davmail.exchange.ExchangeSessionFactory; import davmail.exchange.ExchangeSessionFactory;
import davmail.exchange.ICSBufferedReader; import davmail.exchange.ICSBufferedReader;
@ -251,6 +250,7 @@ public class CaldavConnection extends AbstractConnection {
sendFreeBusy(request.getBody()); sendFreeBusy(request.getBody());
} else { } else {
int status = session.sendEvent(request.getBody()); int status = session.sendEvent(request.getBody());
// TODO: implement Itip response body
sendHttpResponse(status); sendHttpResponse(status);
} }
} else if (request.isPropFind()) { } else if (request.isPropFind()) {
@ -614,18 +614,7 @@ public class CaldavConnection extends AbstractConnection {
if (eventName != null && eventName.length() > 0 if (eventName != null && eventName.length() > 0
&& !"inbox".equals(eventName) && !"calendar".equals(eventName)) { && !"inbox".equals(eventName) && !"calendar".equals(eventName)) {
ExchangeSession.Event event; ExchangeSession.Event event;
try { event = session.getEvent(folderPath, eventName);
event = session.getEvent(folderPath, eventName);
} catch (HttpNotFoundException hnfe) {
// failover for Exchange 2007 plus encoding issue
String decodedEventName = eventName.replaceAll("_xF8FF_", "/").replaceAll("_x003F_", "?").replaceAll("'", "''");
ExchangeSession.MessageList messages = session.searchMessages(folderPath, " AND \"DAV:displayname\"='"+decodedEventName+ '\'');
if (!messages.isEmpty()) {
event = session.getEvent(messages.get(0).getPermanentUrl());
} else {
throw hnfe;
}
}
appendEventResponse(response, request, event); appendEventResponse(response, request, event);
} }
} catch (HttpException e) { } catch (HttpException e) {
@ -1002,6 +991,8 @@ public class CaldavConnection extends AbstractConnection {
sendClient("Server: DavMail Gateway " + (version == null ? "" : version)); sendClient("Server: DavMail Gateway " + (version == null ? "" : version));
sendClient("DAV: 1, calendar-access, calendar-schedule, calendarserver-private-events"); sendClient("DAV: 1, calendar-access, calendar-schedule, calendarserver-private-events");
SimpleDateFormat formatter = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.ENGLISH); SimpleDateFormat formatter = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.ENGLISH);
// force GMT timezone
formatter.setTimeZone(ExchangeSession.GMT_TIMEZONE);
String now = formatter.format(new Date()); String now = formatter.format(new Date());
sendClient("Date: " + now); sendClient("Date: " + now);
sendClient("Expires: " + now); sendClient("Expires: " + now);