IMAP: failover in message copyon 404 not found

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1518 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-10-27 08:52:27 +00:00
parent cf98558e81
commit 3e9bca74e5
2 changed files with 14 additions and 1 deletions

View File

@ -2548,8 +2548,17 @@ public class DavExchangeSession extends ExchangeSession {
*/
@Override
public void copyMessage(ExchangeSession.Message message, String targetFolder) throws IOException {
try {
copyMessage(message.permanentUrl, targetFolder);
} catch (HttpNotFoundException e) {
LOGGER.debug("404 not found at permanenturl: " + message.permanentUrl + ", retry with messageurl");
copyMessage(message.messageUrl, targetFolder);
}
}
protected void copyMessage(String sourceUrl, String targetFolder) throws IOException {
String targetPath = URIUtil.encodePath(getFolderPath(targetFolder)) + '/' + UUID.randomUUID().toString();
CopyMethod method = new CopyMethod(message.permanentUrl, targetPath, false);
CopyMethod method = new CopyMethod(sourceUrl, targetPath, false);
// allow rename if a message with the same name exists
method.addRequestHeader("Allow-Rename", "t");
try {

View File

@ -36,6 +36,7 @@ import org.apache.commons.httpclient.util.IdleConnectionTimeoutThread;
import org.apache.commons.httpclient.util.URIUtil;
import org.apache.jackrabbit.webdav.DavException;
import org.apache.jackrabbit.webdav.MultiStatusResponse;
import org.apache.jackrabbit.webdav.client.methods.CopyMethod;
import org.apache.jackrabbit.webdav.client.methods.DavMethodBase;
import org.apache.jackrabbit.webdav.client.methods.PropFindMethod;
import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
@ -638,6 +639,9 @@ public final class DavGatewayHttpClientFacade {
message.append(status).append(' ').append(method.getStatusText());
try {
message.append(" at ").append(method.getURI().getURI());
if (method instanceof CopyMethod) {
message.append(" to ").append(method.getRequestHeader("Destination"));
}
} catch (URIException e) {
message.append(method.getPath());
}