Carddav: bday, assistant, manager and spouse properties

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1142 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-07-06 16:49:57 +00:00
parent 2e3f7bfc0b
commit c5642d4b41
3 changed files with 36 additions and 32 deletions

View File

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

View File

@ -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<String, String> entry : entrySet()) {
String key = entry.getKey();
if (key.startsWith("email")) {
key = "write"+key;
key = "write" + key;
}
list.add(Field.createDavProperty(key, entry.getValue()));
}

View File

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