From c4631c5dc4840d97c6aa10f885f91be2ec8d1f53 Mon Sep 17 00:00:00 2001 From: mguessan Date: Sun, 18 Jul 2010 19:59:13 +0000 Subject: [PATCH] Carddav: Remove missing properties on update git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1193 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- .../davmail/exchange/ExchangeSession.java | 67 ++++++++++++++----- 1 file changed, 50 insertions(+), 17 deletions(-) diff --git a/src/java/davmail/exchange/ExchangeSession.java b/src/java/davmail/exchange/ExchangeSession.java index 1c13b930..45743672 100644 --- a/src/java/davmail/exchange/ExchangeSession.java +++ b/src/java/davmail/exchange/ExchangeSession.java @@ -89,6 +89,9 @@ public abstract class ExchangeSession { protected static final String PUBLIC_ROOT = "/public"; protected static final String CALENDAR = "calendar"; + /** + * Contacts folder logical name + */ public static final String CONTACTS = "contacts"; protected static final String ADDRESSBOOK = "addressbook"; protected static final String INBOX = "INBOX"; @@ -189,6 +192,10 @@ public abstract class ExchangeSession { return dateFormatter.format(date); } + /** + * Return standard zulu date formatter. + * @return zulu date formatter + */ public static SimpleDateFormat getZuluDateFormat() { SimpleDateFormat dateFormat = new SimpleDateFormat(YYYYMMDD_T_HHMMSS_Z, Locale.ENGLISH); dateFormat.setTimeZone(GMT_TIMEZONE); @@ -903,9 +910,10 @@ public abstract class ExchangeSession { * Send message in reader to recipients. * Detect visible recipients in message body to determine bcc recipients * - * @param recipients recipients list - * @param reader message stream + * @param rcptToRecipients recipients list + * @param mimeMessage mime message * @throws IOException on error + * @throws MessagingException on error */ public void sendMessage(List rcptToRecipients, MimeMessage mimeMessage) throws IOException, MessagingException { // Exchange 2007 : skip From: header @@ -1616,10 +1624,6 @@ public abstract class ExchangeSession { return itemName; } - public String getPermanentUrl() { - return permanentUrl; - } - /** * Get event etag (last change tag). * @@ -1635,6 +1639,11 @@ public abstract class ExchangeSession { return new HttpException(message); } + /** + * Set item href. + * + * @param href item href + */ public void setHref(String href) { int index = href.lastIndexOf('/'); if (index >= 0) { @@ -1645,6 +1654,11 @@ public abstract class ExchangeSession { } } + /** + * Return item href. + * + * @return item href + */ public String getHref() { return folderPath + '/' + itemName; } @@ -1766,7 +1780,7 @@ public abstract class ExchangeSession { if ("1".equals(get("haspicture"))) { try { ContactPhoto contactPhoto = getContactPhoto(this); - writer.appendProperty("PHOTO;TYPE=\"" + contactPhoto.type + "\";ENCODING=\"b\"", contactPhoto.content); + writer.appendProperty("PHOTO;TYPE=\"" + contactPhoto.contentType + "\";ENCODING=\"b\"", contactPhoto.content); } catch (IOException e) { LOGGER.warn("Unable to get photo from contact " + this.get("cn")); } @@ -1977,7 +1991,7 @@ public abstract class ExchangeSession { hasCdoBusyStatus = true; } else if ("BEGIN:VTIMEZONE".equals(line)) { hasTimezone = true; - } else if (key.equals("METHOD")) { + } else if ("METHOD".equals(key)) { method = value; } } @@ -2463,7 +2477,10 @@ public abstract class ExchangeSession { } - public static final Set ITEM_PROPERTIES = new HashSet(); + /** + * Common item properties + */ + protected static final Set ITEM_PROPERTIES = new HashSet(); static { ITEM_PROPERTIES.add("etag"); @@ -2576,8 +2593,17 @@ public abstract class ExchangeSession { */ public abstract Item getItem(String folderPath, String itemName) throws IOException; - public class ContactPhoto { - public String type; + /** + * Contact picture + */ + public static class ContactPhoto { + /** + * Contact picture content type (always image/jpeg on read) + */ + public String contentType; + /** + * Base64 encoded picture content + */ public String content; } @@ -2678,8 +2704,6 @@ public abstract class ExchangeSession { protected static final String[] VCARD_ADR_OTHER_PROPERTIES = {"otherpostofficebox", null, "otherstreet", "othercity", "otherstate", "otherpostalcode", "othercountry"}; protected static final String[] VCARD_ORG_PROPERTIES = {"o", "department"}; - protected static final String[] EMPTY_PROPERTIES = {"description", "keywords"}; - protected void convertContactProperties(Map properties, String[] contactProperties, List values) { for (int i = 0; i < values.size() && i < contactProperties.length; i++) { if (contactProperties[i] != null) { @@ -2791,9 +2815,10 @@ public abstract class ExchangeSession { properties.put("photo", property.getValue()); } } - // detect empty values - for (String key : EMPTY_PROPERTIES) { - if (!properties.containsKey(key)) { + // reset missing properties to null + for (String key : CONTACT_ATTRIBUTES) { + if (!"imapUid".equals(key) && !"etag".equals(key) && !"urlcompname".equals(key) && + !properties.containsKey(key)) { properties.put(key, null); } } @@ -3085,6 +3110,9 @@ public abstract class ExchangeSession { return results; } + /** + * Full Contact attribute list + */ public static final Set CONTACT_ATTRIBUTES = new HashSet(); static { @@ -3338,8 +3366,13 @@ public abstract class ExchangeSession { } - public VTimezone vTimezone; + protected VTimezone vTimezone; + /** + * Load and return current user OWA timezone. + * + * @return current timezone + */ public VTimezone getVTimezone() { if (vTimezone == null) { // need to load Timezone info from OWA