New failover call in checkEndPointUrl

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2208 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2014-01-10 18:15:26 +00:00
parent 93b0f5ecf2
commit aa08c73a70
1 changed files with 11 additions and 1 deletions

View File

@ -169,7 +169,17 @@ public class EwsExchangeSession extends ExchangeSession {
try { try {
int status = DavGatewayHttpClientFacade.executeNoRedirect(httpClient, checkMethod); int status = DavGatewayHttpClientFacade.executeNoRedirect(httpClient, checkMethod);
if (status == HttpStatus.SC_UNAUTHORIZED) { if (status == HttpStatus.SC_UNAUTHORIZED) {
throw new DavMailAuthenticationException("EXCEPTION_AUTHENTICATION_FAILED"); // retry with /ews/exchange.asmx
checkMethod.releaseConnection();
checkMethod = new HeadMethod(endPointUrl);
checkMethod.setFollowRedirects(true);
status = DavGatewayHttpClientFacade.executeNoRedirect(httpClient, checkMethod);
if (status == HttpStatus.SC_UNAUTHORIZED) {
throw new DavMailAuthenticationException("EXCEPTION_AUTHENTICATION_FAILED");
} else if (status != HttpStatus.SC_OK) {
throw new IOException("Ews endpoint not available at " + checkMethod.getURI().toString()+" status "+status);
}
} else if (status != HttpStatus.SC_OK) { } else if (status != HttpStatus.SC_OK) {
throw new IOException("Ews endpoint not available at " + checkMethod.getURI().toString()+" status "+status); throw new IOException("Ews endpoint not available at " + checkMethod.getURI().toString()+" status "+status);
} }