mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-13 19:22:22 -05:00
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:
parent
cf98558e81
commit
3e9bca74e5
@ -2548,8 +2548,17 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void copyMessage(ExchangeSession.Message message, String targetFolder) throws IOException {
|
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();
|
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
|
// allow rename if a message with the same name exists
|
||||||
method.addRequestHeader("Allow-Rename", "t");
|
method.addRequestHeader("Allow-Rename", "t");
|
||||||
try {
|
try {
|
||||||
|
@ -36,6 +36,7 @@ import org.apache.commons.httpclient.util.IdleConnectionTimeoutThread;
|
|||||||
import org.apache.commons.httpclient.util.URIUtil;
|
import org.apache.commons.httpclient.util.URIUtil;
|
||||||
import org.apache.jackrabbit.webdav.DavException;
|
import org.apache.jackrabbit.webdav.DavException;
|
||||||
import org.apache.jackrabbit.webdav.MultiStatusResponse;
|
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.DavMethodBase;
|
||||||
import org.apache.jackrabbit.webdav.client.methods.PropFindMethod;
|
import org.apache.jackrabbit.webdav.client.methods.PropFindMethod;
|
||||||
import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
|
import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
|
||||||
@ -638,6 +639,9 @@ public final class DavGatewayHttpClientFacade {
|
|||||||
message.append(status).append(' ').append(method.getStatusText());
|
message.append(status).append(' ').append(method.getStatusText());
|
||||||
try {
|
try {
|
||||||
message.append(" at ").append(method.getURI().getURI());
|
message.append(" at ").append(method.getURI().getURI());
|
||||||
|
if (method instanceof CopyMethod) {
|
||||||
|
message.append(" to ").append(method.getRequestHeader("Destination"));
|
||||||
|
}
|
||||||
} catch (URIException e) {
|
} catch (URIException e) {
|
||||||
message.append(method.getPath());
|
message.append(method.getPath());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user