diff --git a/src/java/davmail/exchange/ExchangeSession.java b/src/java/davmail/exchange/ExchangeSession.java index 870f0726..30eabdc9 100644 --- a/src/java/davmail/exchange/ExchangeSession.java +++ b/src/java/davmail/exchange/ExchangeSession.java @@ -1785,19 +1785,12 @@ public abstract class ExchangeSession { writer.appendProperty("BDAY", get("bday")); - writer.appendProperty("X-EVOLUTION-ASSISTANT", get("secretarycn")); - writer.appendProperty("X-EVOLUTION-MANAGER", get("manager")); - writer.appendProperty("X-EVOLUTION-SPOUSE", get("spousecn")); + writer.appendProperty("X-ASSISTANT", get("secretarycn")); + writer.appendProperty("X-MANAGER", get("manager")); + writer.appendProperty("X-SPOUSE", get("spousecn")); + writer.appendProperty("REV", get("lastmodified")); - String lastModified = get("lastmodified"); - if (lastModified != null) { - try { - writer.appendProperty("REV", getZuluDateFormat().format(getExchangeZuluDateFormatMillisecond().parse(lastModified))); - } catch (ParseException e) { - LOGGER.warn("Invalid date: " + lastModified); - } - } writer.endCard(); return writer.toString(); } @@ -2715,26 +2708,21 @@ public abstract class ExchangeSession { } else if ("X-AIM".equals(property.getKey())) { properties.put("im", property.getValue()); } else if ("BDAY".equals(property.getKey())) { - properties.put("bday", property.getValue()); - } - /* - - writer.appendProperty("X-EVOLUTION-ASSISTANT", get("secretarycn")); - writer.appendProperty("X-EVOLUTION-MANAGER", get("manager")); - writer.appendProperty("X-EVOLUTION-SPOUSE", get("spousecn")); - - - String lastModified = get("lastmodified"); - if (lastModified != null) { - try { - writer.appendProperty("REV", getZuluDateFormat().format(getExchangeZuluDateFormatMillisecond().parse(lastModified))); - } catch (ParseException e) { - LOGGER.warn("Invalid date: " + lastModified); + String value = property.getValue(); + if (value != null) { + try { + properties.put("bday", ExchangeSession.getExchangeZuluDateFormatMillisecond().format(ExchangeSession.getZuluDateFormat().parse(value))); + } catch (ParseException e) { + LOGGER.warn("Invalid date: " + value); + } } + } else if ("X-ASSISTANT".equals(property.getKey())) { + properties.put("secretarycn", property.getValue()); + } else if ("X-MANAGER".equals(property.getKey())) { + properties.put("manager", property.getValue()); + } else if ("X-SPOUSE".equals(property.getKey())) { + properties.put("spousecn", property.getValue()); } - writer.endCard(); - - */ } return internalCreateOrUpdateContact(folderPath, itemName, properties, etag, noneMatch); } diff --git a/src/java/davmail/exchange/dav/DavExchangeSession.java b/src/java/davmail/exchange/dav/DavExchangeSession.java index 4192ecfb..e02bc27d 100644 --- a/src/java/davmail/exchange/dav/DavExchangeSession.java +++ b/src/java/davmail/exchange/dav/DavExchangeSession.java @@ -52,6 +52,7 @@ import java.net.HttpURLConnection; import java.net.NoRouteToHostException; import java.net.URL; import java.net.UnknownHostException; +import java.text.ParseException; import java.util.*; import java.util.zip.GZIPInputStream; @@ -568,6 +569,13 @@ public class DavExchangeSession extends ExchangeSession { for (String attributeName : CONTACT_ATTRIBUTES) { String value = getPropertyIfExists(properties, attributeName); if (value != null) { + if ("bday".equals(attributeName) || "lastmodified".equals(attributeName)) { + try { + value = ExchangeSession.getZuluDateFormat().format(ExchangeSession.getExchangeZuluDateFormatMillisecond().parse(value)); + } catch (ParseException e) { + LOGGER.warn("Invalid date: " + value); + } + } put(attributeName, value); } } @@ -585,7 +593,7 @@ public class DavExchangeSession extends ExchangeSession { for (Map.Entry entry : entrySet()) { String key = entry.getKey(); if (key.startsWith("email")) { - key = "write"+key; + key = "write" + key; } list.add(Field.createDavProperty(key, entry.getValue())); } diff --git a/src/test/davmail/exchange/TestExchangeSessionContact.java b/src/test/davmail/exchange/TestExchangeSessionContact.java index 27f55dd5..686ede5d 100644 --- a/src/test/davmail/exchange/TestExchangeSessionContact.java +++ b/src/test/davmail/exchange/TestExchangeSessionContact.java @@ -94,7 +94,11 @@ public class TestExchangeSessionContact extends AbstractExchangeSessionTestCase vCardWriter.appendProperty("ROLE", "profession"); vCardWriter.appendProperty("X-AIM", "im"); - //vCardWriter.appendProperty("BDAY", "bday"); + vCardWriter.appendProperty("BDAY", "20000102T000000Z"); + + vCardWriter.appendProperty("X-ASSISTANT", "secretarycn"); + vCardWriter.appendProperty("X-MANAGER", "manager"); + vCardWriter.appendProperty("X-SPOUSE", "spousecn"); vCardWriter.endCard(); @@ -153,7 +157,7 @@ public class TestExchangeSessionContact extends AbstractExchangeSessionTestCase assertEquals("profession", contact.get("profession")); assertEquals("im", contact.get("im")); - //assertEquals("bday", contact.get("bday")); + assertEquals("20000102T000000Z", contact.get("bday")); assertEquals("otherpostofficebox", contact.get("otherpostofficebox")); assertEquals("otherstreet", contact.get("otherstreet")); @@ -161,5 +165,9 @@ public class TestExchangeSessionContact extends AbstractExchangeSessionTestCase assertEquals("otherstate", contact.get("otherstate")); assertEquals("otherpostalcode", contact.get("otherpostalcode")); assertEquals("othercountry", contact.get("othercountry")); + + assertEquals("secretarycn", contact.get("secretarycn")); + assertEquals("manager", contact.get("manager")); + assertEquals("spousecn", contact.get("spousecn")); } }