diff --git a/src/java/davmail/exchange/ews/EwsExchangeSession.java b/src/java/davmail/exchange/ews/EwsExchangeSession.java index 75a15376..4cb6fa70 100644 --- a/src/java/davmail/exchange/ews/EwsExchangeSession.java +++ b/src/java/davmail/exchange/ews/EwsExchangeSession.java @@ -1660,12 +1660,39 @@ public class EwsExchangeSession extends ExchangeSession { GALFIND_ATTRIBUTE_MAP.put("email1", "EmailAddress1"); GALFIND_ATTRIBUTE_MAP.put("email2", "EmailAddress2"); GALFIND_ATTRIBUTE_MAP.put("email3", "EmailAddress3"); + + GALFIND_ATTRIBUTE_MAP.put("roomnumber", "OfficeLocation"); + GALFIND_ATTRIBUTE_MAP.put("street", "BusinessStreet"); + GALFIND_ATTRIBUTE_MAP.put("l", "BusinessCity"); + GALFIND_ATTRIBUTE_MAP.put("o", "CompanyName"); + GALFIND_ATTRIBUTE_MAP.put("postalcode", "BusinessPostalCode"); + + GALFIND_ATTRIBUTE_MAP.put("manager", "Manager"); + GALFIND_ATTRIBUTE_MAP.put("middlename", "Initials"); + GALFIND_ATTRIBUTE_MAP.put("title", "JobTitle"); + GALFIND_ATTRIBUTE_MAP.put("department", "Department"); + + GALFIND_ATTRIBUTE_MAP.put("otherTelephone", "AssistantPhone"); + GALFIND_ATTRIBUTE_MAP.put("telephoneNumber", "BusinessPhone"); + } + + protected static final HashSet IGNORE_ATTRIBUTE_SET = new HashSet(); + static { + IGNORE_ATTRIBUTE_SET.add("ContactSource"); + IGNORE_ATTRIBUTE_SET.add("Culture"); } protected Contact buildGalfindContact(EWSMethod.Item response) { Contact contact = new Contact(); contact.setName(response.get("Name")); contact.put("imapUid", response.get("Name")); + if (LOGGER.isDebugEnabled()) { + for (String key : response.keySet()) { + if (!IGNORE_ATTRIBUTE_SET.contains(key) && !GALFIND_ATTRIBUTE_MAP.containsValue(key)) { + LOGGER.debug("Unsupported ResolveNames response attribute: " + key + " value: " + response.get(key)); + } + } + } for (Map.Entry entry : GALFIND_ATTRIBUTE_MAP.entrySet()) { String attributeValue = response.get(entry.getValue()); if (attributeValue != null) { diff --git a/src/java/davmail/exchange/ews/ResolveNamesMethod.java b/src/java/davmail/exchange/ews/ResolveNamesMethod.java index 82067ef2..eb4d2f3b 100644 --- a/src/java/davmail/exchange/ews/ResolveNamesMethod.java +++ b/src/java/davmail/exchange/ews/ResolveNamesMethod.java @@ -93,12 +93,26 @@ public class ResolveNamesMethod extends EWSMethod { } } + protected void handlePhysicalAddress(XMLStreamReader reader, Item responseItem, String addressType) throws XMLStreamException { + while (reader.hasNext() && !XMLStreamUtil.isEndTag(reader, "Entry")) { + reader.next(); + if (XMLStreamUtil.isStartTag(reader)) { + String tagLocalName = reader.getLocalName(); + String value = XMLStreamUtil.getElementText(reader); + responseItem.put(addressType+tagLocalName, value); + } + } + } + protected void handlePhysicalAddresses(XMLStreamReader reader, Item responseItem) throws XMLStreamException { while (reader.hasNext() && !XMLStreamUtil.isEndTag(reader, "PhysicalAddresses")) { reader.next(); if (XMLStreamUtil.isStartTag(reader)) { String tagLocalName = reader.getLocalName(); - // TODO + if ("Entry".equals(tagLocalName)) { + String key = getAttributeValue(reader, "Key"); + handlePhysicalAddress(reader, responseItem, key); + } } } } @@ -108,7 +122,11 @@ public class ResolveNamesMethod extends EWSMethod { reader.next(); if (XMLStreamUtil.isStartTag(reader)) { String tagLocalName = reader.getLocalName(); - // TODO + if ("Entry".equals(tagLocalName)) { + String key = getAttributeValue(reader, "Key"); + String value = XMLStreamUtil.getElementText(reader); + responseItem.put(key, value); + } } } }