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

@ -168,11 +168,21 @@ public class EwsExchangeSession extends ExchangeSession {
checkMethod.setFollowRedirects(false);
try {
int status = DavGatewayHttpClientFacade.executeNoRedirect(httpClient, checkMethod);
if (status == HttpStatus.SC_UNAUTHORIZED) {
// 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) {
throw new IOException("Ews endpoint not available at " + checkMethod.getURI().toString()+" status "+status);
}
} finally {
checkMethod.releaseConnection();
}