1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-13 19:22:22 -05:00

Disable galLookup on error (not supported by Exchange 2007)

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@245 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2008-12-23 15:20:50 +00:00
parent 441955eadc
commit 738ff861ea

View File

@ -83,6 +83,8 @@ public class ExchangeSession {
private final ExchangeSessionFactory.PoolKey poolKey; private final ExchangeSessionFactory.PoolKey poolKey;
private boolean disableGalLookup = false;
ExchangeSessionFactory.PoolKey getPoolKey() { ExchangeSessionFactory.PoolKey getPoolKey() {
return poolKey; return poolKey;
} }
@ -304,7 +306,7 @@ public class ExchangeSession {
String result = null; String result = null;
// get user mail URL from html body // get user mail URL from html body
BufferedReader optionsPageReader = null; BufferedReader optionsPageReader = null;
GetMethod optionsMethod = new GetMethod(path+"?ae=Options&t=About"); GetMethod optionsMethod = new GetMethod(path + "?ae=Options&t=About");
try { try {
wdr.retrieveSessionInstance().executeMethod(optionsMethod); wdr.retrieveSessionInstance().executeMethod(optionsMethod);
optionsPageReader = new BufferedReader(new InputStreamReader(optionsMethod.getResponseBodyAsStream())); optionsPageReader = new BufferedReader(new InputStreamReader(optionsMethod.getResponseBodyAsStream()));
@ -317,7 +319,7 @@ public class ExchangeSession {
if (line != null) { if (line != null) {
int start = line.toLowerCase().indexOf(MAILBOX_BASE) + MAILBOX_BASE.length(); int start = line.toLowerCase().indexOf(MAILBOX_BASE) + MAILBOX_BASE.length();
int end = line.indexOf("<", start); int end = line.indexOf("<", start);
result = "/exchange/"+line.substring(start, end)+"/"; result = "/exchange/" + line.substring(start, end) + "/";
} }
} catch (IOException e) { } catch (IOException e) {
LOGGER.error("Error parsing options page at " + optionsMethod.getPath()); LOGGER.error("Error parsing options page at " + optionsMethod.getPath());
@ -1200,6 +1202,7 @@ public class ExchangeSession {
} }
public void galLookup(Map<String, String> person) { public void galLookup(Map<String, String> person) {
if (!disableGalLookup) {
GetMethod getMethod = null; GetMethod getMethod = null;
try { try {
getMethod = new GetMethod(URIUtil.encodePathQuery("/public/?Cmd=gallookup&ADDR=" + person.get("EM"))); getMethod = new GetMethod(URIUtil.encodePathQuery("/public/?Cmd=gallookup&ADDR=" + person.get("EM")));
@ -1216,13 +1219,15 @@ public class ExchangeSession {
} }
} }
} catch (IOException e) { } catch (IOException e) {
LOGGER.warn("Unable to gallookup person: " + person); LOGGER.warn("Unable to gallookup person: " + person + ", disable GalLookup");
disableGalLookup = true;
} finally { } finally {
if (getMethod != null) { if (getMethod != null) {
getMethod.releaseConnection(); getMethod.releaseConnection();
} }
} }
} }
}
public String getFreebusy(Map<String, String> valueMap) throws IOException { public String getFreebusy(Map<String, String> valueMap) throws IOException {
String result = null; String result = null;