1
0
mirror of https://github.com/moparisthebest/davmail synced 2025-01-12 22:18:11 -05:00

Caldav: move to trash on processItem

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1399 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-08-31 22:55:49 +00:00
parent 36e868a97e
commit eece3d6b85
2 changed files with 11 additions and 6 deletions

View File

@ -2247,8 +2247,7 @@ public abstract class ExchangeSession {
*/ */
public List<Event> getEventMessages(String folderPath) throws IOException { public List<Event> getEventMessages(String folderPath) throws IOException {
return searchEvents(folderPath, ITEM_PROPERTIES, return searchEvents(folderPath, ITEM_PROPERTIES,
and(isEqualTo("outlookmessageclass", "IPM.Schedule.Meeting.Request"), and(isEqualTo("outlookmessageclass", "IPM.Schedule.Meeting.Request")));
or(isNull("processed"), isFalse("processed"))));
} }
/** /**

View File

@ -1869,12 +1869,14 @@ public class DavExchangeSession extends ExchangeSession {
@Override @Override
public void processItem(String folderPath, String itemName) throws IOException { public void processItem(String folderPath, String itemName) throws IOException {
String eventPath = URIUtil.encodePath(getFolderPath(folderPath) + '/' + convertItemNameToEML(itemName)); String eventPath = URIUtil.encodePath(getFolderPath(folderPath) + '/' + convertItemNameToEML(itemName));
// do not delete calendar messages, mark read and processed // mark read
ArrayList<DavConstants> list = new ArrayList<DavConstants>(); ArrayList<DavConstants> list = new ArrayList<DavConstants>();
list.add(Field.createDavProperty("processed", "true")); //list.add(Field.createDavProperty("processed", "true"));
list.add(Field.createDavProperty("read", "1")); list.add(Field.createDavProperty("read", "1"));
PropPatchMethod patchMethod = new PropPatchMethod(eventPath, list); PropPatchMethod patchMethod = new PropPatchMethod(eventPath, list);
DavGatewayHttpClientFacade.executeMethod(httpClient, patchMethod); DavGatewayHttpClientFacade.executeMethod(httpClient, patchMethod);
// move to trash
moveToTrash(eventPath);
} }
@Override @Override
@ -2295,9 +2297,13 @@ public class DavExchangeSession extends ExchangeSession {
@Override @Override
protected void moveToTrash(ExchangeSession.Message message) throws IOException { protected void moveToTrash(ExchangeSession.Message message) throws IOException {
moveToTrash(message.permanentUrl);
}
protected void moveToTrash(String messageUrl) throws IOException {
String destination = URIUtil.encodePath(deleteditemsUrl) + '/' + UUID.randomUUID().toString(); String destination = URIUtil.encodePath(deleteditemsUrl) + '/' + UUID.randomUUID().toString();
LOGGER.debug("Deleting : " + message.permanentUrl + " to " + destination); LOGGER.debug("Deleting : " + messageUrl + " to " + destination);
MoveMethod method = new MoveMethod(message.permanentUrl, destination, false); MoveMethod method = new MoveMethod(messageUrl, destination, false);
method.addRequestHeader("Allow-rename", "t"); method.addRequestHeader("Allow-rename", "t");
int status = DavGatewayHttpClientFacade.executeHttpMethod(httpClient, method); int status = DavGatewayHttpClientFacade.executeHttpMethod(httpClient, method);