From 4871c9cf3973d7a573baab20e3a97eabfc6bc071 Mon Sep 17 00:00:00 2001 From: mguessan Date: Wed, 11 Mar 2009 12:39:14 +0000 Subject: [PATCH] Fix for bug 2637306: get alias from mailPath display name git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@433 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- .../davmail/exchange/ExchangeSession.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/java/davmail/exchange/ExchangeSession.java b/src/java/davmail/exchange/ExchangeSession.java index c3fa198b..59544809 100644 --- a/src/java/davmail/exchange/ExchangeSession.java +++ b/src/java/davmail/exchange/ExchangeSession.java @@ -58,6 +58,13 @@ public class ExchangeSession { WELL_KNOWN_FOLDERS.add("urn:schemas:httpmail:calendar"); } + protected static final Vector DISPLAY_NAME = new Vector(); + + static { + DISPLAY_NAME.add("DAV:displayname"); + } + + public static final HashMap PRIORITIES = new HashMap(); static { @@ -1687,6 +1694,31 @@ public class ExchangeSession { } } + public String getAliasFromMailboxDisplayName() throws IOException { + if (mailPath == null) { + return null; + } + String alias = null; + Enumeration folderEnum = wdr.propfindMethod(mailPath, 0, DISPLAY_NAME); + if (!folderEnum.hasMoreElements()) { + throw new IOException("Unable to get mail folder"); + } + ResponseEntity mailboxResponse = (ResponseEntity) folderEnum. + nextElement(); + Enumeration mailboxPropsEnum = mailboxResponse.getProperties(); + if (!mailboxPropsEnum.hasMoreElements()) { + throw new IOException("Unable to get mail folder"); + } + while (mailboxPropsEnum.hasMoreElements()) { + Property inboxProp = (Property) mailboxPropsEnum.nextElement(); + if ("displayname".equals(inboxProp.getLocalName())) { + alias = inboxProp.getPropertyAsString(); + } + + } + return alias; + } + public String getEmail(String alias) throws IOException { String emailResult = null; if (alias != null) { @@ -1716,6 +1748,10 @@ public class ExchangeSession { if (email == null) { email = getEmail(getAliasFromMailPath()); } + // another failover : get alias from mailPath display name + if (email == null) { + email = getEmail(getAliasFromMailboxDisplayName()); + } if (email == null) { // failover : get email from Exchange 2007 Options page email = getEmail(getAliasFromOptions(methodPath));