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

Ews: improve ResolveNames implementation, parse addresses and phone attributes

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1522 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-11-03 22:31:36 +00:00
parent c0abc93ac5
commit 92c8802dc2
2 changed files with 47 additions and 2 deletions

View File

@ -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<String> IGNORE_ATTRIBUTE_SET = new HashSet<String>();
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<String, String> entry : GALFIND_ATTRIBUTE_MAP.entrySet()) {
String attributeValue = response.get(entry.getValue());
if (attributeValue != null) {

View File

@ -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);
}
}
}
}