EWS: rely on uid (PR_SEARCH_KEY) instead of permanentUrl to detect imap uid changes

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1120 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-07-01 16:19:24 +00:00
parent 72ee220550
commit 190a39cad7
1 changed files with 6 additions and 8 deletions

View File

@ -25,8 +25,6 @@ import davmail.exception.DavMailException;
import davmail.http.DavGatewayHttpClientFacade;
import davmail.http.DavGatewayOTPPrompt;
import davmail.util.StringUtil;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
@ -1099,9 +1097,9 @@ public abstract class ExchangeSession {
*/
public ExchangeSession.MessageList messages;
/**
* PermanentURL to UID map.
* Permanent uid (PR_SEARCH_KEY) to IMAP UID map.
*/
private final HashMap<String, Long> uidUrlHashMap = new HashMap<String, Long>();
private final HashMap<String, Long> uidToImapUidMap = new HashMap<String, Long>();
/**
* Get IMAP folder flags.
@ -1149,16 +1147,16 @@ public abstract class ExchangeSession {
protected void fixUids(MessageList messages) {
boolean sortNeeded = false;
for (Message message : messages) {
if (uidUrlHashMap.containsKey(message.getPermanentUrl())) {
long previousUid = uidUrlHashMap.get(message.getPermanentUrl());
if (uidToImapUidMap.containsKey(message.getUid())) {
long previousUid = uidToImapUidMap.get(message.getUid());
if (message.getImapUid() != previousUid) {
LOGGER.debug("Restoring IMAP uid " + message.getImapUid() + " -> " + previousUid + " for message " + message.getPermanentUrl() + " (" + message.messageUrl + ')');
LOGGER.debug("Restoring IMAP uid " + message.getImapUid() + " -> " + previousUid + " for message uid " + message.getUid());
message.setImapUid(previousUid);
sortNeeded = true;
}
} else {
// add message to uid map
uidUrlHashMap.put(message.getPermanentUrl(), message.getImapUid());
uidToImapUidMap.put(message.getUid(), message.getImapUid());
}
}
if (sortNeeded) {