1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-13 03:02:22 -05:00

fix event uri encoding/decoding issue and if-match on update

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@201 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2008-12-05 08:47:54 +00:00
parent aa2274b1b2
commit 0bea11cb12
2 changed files with 18 additions and 13 deletions

View File

@ -18,6 +18,7 @@ import java.io.IOException;
import java.io.StringReader;
import java.net.Socket;
import java.net.SocketTimeoutException;
import java.net.SocketException;
import java.text.SimpleDateFormat;
import java.util.*;
@ -123,6 +124,8 @@ public class CaldavConnection extends AbstractConnection {
}
} catch (SocketTimeoutException e) {
DavGatewayTray.debug("Closing connection on timeout");
} catch (SocketException e) {
DavGatewayTray.debug("Connection closed");
} catch (IOException e) {
DavGatewayTray.error(e);
try {
@ -254,9 +257,10 @@ public class CaldavConnection extends AbstractConnection {
inHref = true;
} else if (event == XMLStreamConstants.CHARACTERS && inHref) {
try {
events.add(session.getEvent(URIUtil.decode(reader.getText().substring("/calendar/".length()))));
events.add(session.getEvent(reader.getText().substring("/calendar/".length())));
} catch (HttpException e) {
notFound.add(reader.getText().substring("/calendar/".length()));
String href = reader.getText();
notFound.add(href);
}
inHref = false;
}
@ -294,17 +298,18 @@ public class CaldavConnection extends AbstractConnection {
buffer.append(" </D:prop>\n");
buffer.append(" <D:status>HTTP/1.1 200 OK</D:status>\n");
buffer.append(" </D:propstat>\n");
if (notFound.size() > 0) {
buffer.append(" <D:propstat>\n");
for (String href : notFound) {
buffer.append(" <D:href>").append(href).append("</D:href>\n");
}
buffer.append(" <D:status>HTTP/1.1 404 Not Found</D:status>\n");
buffer.append(" </D:propstat>\n");
}
buffer.append(" </D:response>").append((char) 13).append((char) 10);
buffer.append(" </D:response>\n");
}
// TODO : handle not found
for (String href : notFound) {
buffer.append("<D:response>\n");
buffer.append(" <D:href>").append(href).append("</D:href>\n");
buffer.append(" <D:propstat>\n");
buffer.append(" <D:status>HTTP/1.1 404 Not Found</D:status>\n");
buffer.append(" </D:propstat>\n");
buffer.append(" </D:response>\n");
}
buffer.append("</D:multistatus>");
sendHttpResponse(HttpStatus.SC_MULTI_STATUS, null, "text/xml;charset=UTF-8", buffer.toString(), true);

View File

@ -805,6 +805,7 @@ public class ExchangeSession {
" </d:sql>\n" +
"</d:searchrequest>";
SearchMethod searchMethod = new SearchMethod(calendarUrl, searchRequest);
//searchMethod.setDebug(4);
try {
int status = wdr.retrieveSessionInstance().executeMethod(searchMethod);
// Also accept OK sent by buggy servers.
@ -870,7 +871,6 @@ public class ExchangeSession {
putmethod.setRequestHeader("Translate", "f");
putmethod.setRequestHeader("Overwrite", "f");
if (etag != null) {
// TODO
putmethod.setRequestHeader("If-Match", etag);
}
putmethod.setRequestHeader("Content-Type", "message/rfc822");
@ -899,7 +899,7 @@ public class ExchangeSession {
if (status == HttpURLConnection.HTTP_OK) {
LOGGER.warn("Overwritten event " + messageUrl);
} else if (status != HttpURLConnection.HTTP_CREATED) {
throw new IOException("Unable to create message " + status + " " + putmethod.getStatusLine());
LOGGER.warn("Unable to create or update message " + status + " " + putmethod.getStatusLine());
}
} finally {
putmethod.releaseConnection();