mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-13 19:22:22 -05:00
Caldav: do not delete calendar messages in INBOX, move to trash instead
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@422 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
07db3c685e
commit
578f78b60b
@ -912,6 +912,28 @@ public class ExchangeSession {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void moveToTrash(String messageUrl) throws IOException {
|
||||||
|
String destination = deleteditemsUrl + messageUrl.substring(messageUrl.lastIndexOf("/"));
|
||||||
|
LOGGER.debug("Deleting : " + messageUrl + " to " + destination);
|
||||||
|
MoveMethod method = new MoveMethod(URIUtil.encodePath(messageUrl),
|
||||||
|
URIUtil.encodePath(destination));
|
||||||
|
method.addRequestHeader("Overwrite", "f");
|
||||||
|
method.addRequestHeader("Allow-rename", "t");
|
||||||
|
|
||||||
|
int status = wdr.retrieveSessionInstance().executeMethod(method);
|
||||||
|
if (status != HttpStatus.SC_CREATED) {
|
||||||
|
HttpException ex = new HttpException();
|
||||||
|
ex.setReasonCode(status);
|
||||||
|
ex.setReason(method.getStatusText());
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
if (method.getResponseHeader("Location") != null) {
|
||||||
|
destination = method.getResponseHeader("Location").getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
LOGGER.debug("Deleted to :" + destination + " " + wdr.getStatusCode() + " " + wdr.getStatusMessage());
|
||||||
|
}
|
||||||
|
|
||||||
public static class Folder {
|
public static class Folder {
|
||||||
public String folderUrl;
|
public String folderUrl;
|
||||||
public int unreadCount;
|
public int unreadCount;
|
||||||
@ -1055,29 +1077,12 @@ public class ExchangeSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void moveToTrash() throws IOException {
|
public void moveToTrash() throws IOException {
|
||||||
String destination = deleteditemsUrl + messageUrl.substring(messageUrl.lastIndexOf("/"));
|
|
||||||
LOGGER.debug("Deleting : " + messageUrl + " to " + destination);
|
|
||||||
// mark message as read
|
// mark message as read
|
||||||
HashMap<String, String> properties = new HashMap<String, String>();
|
HashMap<String, String> properties = new HashMap<String, String>();
|
||||||
properties.put("read", "1");
|
properties.put("read", "1");
|
||||||
updateMessage(this, properties);
|
updateMessage(this, properties);
|
||||||
MoveMethod method = new MoveMethod(URIUtil.encodePath(messageUrl),
|
|
||||||
URIUtil.encodePath(destination));
|
|
||||||
method.addRequestHeader("Overwrite", "f");
|
|
||||||
method.addRequestHeader("Allow-rename", "t");
|
|
||||||
|
|
||||||
int status = wdr.retrieveSessionInstance().executeMethod(method);
|
ExchangeSession.this.moveToTrash(messageUrl);
|
||||||
if (status != HttpStatus.SC_CREATED) {
|
|
||||||
HttpException ex = new HttpException();
|
|
||||||
ex.setReasonCode(status);
|
|
||||||
ex.setReason(method.getStatusText());
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
if (method.getResponseHeader("Location") != null) {
|
|
||||||
destination = method.getResponseHeader("Location").getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
LOGGER.debug("Deleted to :" + destination + " " + wdr.getStatusCode() + " " + wdr.getStatusMessage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int compareTo(Object message) {
|
public int compareTo(Object message) {
|
||||||
@ -1579,7 +1584,12 @@ public class ExchangeSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int deleteEvent(String path) throws IOException {
|
public int deleteEvent(String path) throws IOException {
|
||||||
wdr.deleteMethod(getFolderPath(URIUtil.decode(path)));
|
if (path.startsWith("INBOX")) {
|
||||||
|
// do not delete calendar messages, move to trash
|
||||||
|
moveToTrash(getFolderPath(URIUtil.decode(path)));
|
||||||
|
} else {
|
||||||
|
wdr.deleteMethod(getFolderPath(URIUtil.decode(path)));
|
||||||
|
}
|
||||||
return wdr.getStatusCode();
|
return wdr.getStatusCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user