mirror of
https://github.com/moparisthebest/davmail
synced 2025-01-07 11:48:02 -05:00
Carddav: Remove missing properties on update
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1193 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
e407485e9b
commit
c4631c5dc4
@ -89,6 +89,9 @@ public abstract class ExchangeSession {
|
|||||||
|
|
||||||
protected static final String PUBLIC_ROOT = "/public";
|
protected static final String PUBLIC_ROOT = "/public";
|
||||||
protected static final String CALENDAR = "calendar";
|
protected static final String CALENDAR = "calendar";
|
||||||
|
/**
|
||||||
|
* Contacts folder logical name
|
||||||
|
*/
|
||||||
public static final String CONTACTS = "contacts";
|
public static final String CONTACTS = "contacts";
|
||||||
protected static final String ADDRESSBOOK = "addressbook";
|
protected static final String ADDRESSBOOK = "addressbook";
|
||||||
protected static final String INBOX = "INBOX";
|
protected static final String INBOX = "INBOX";
|
||||||
@ -189,6 +192,10 @@ public abstract class ExchangeSession {
|
|||||||
return dateFormatter.format(date);
|
return dateFormatter.format(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return standard zulu date formatter.
|
||||||
|
* @return zulu date formatter
|
||||||
|
*/
|
||||||
public static SimpleDateFormat getZuluDateFormat() {
|
public static SimpleDateFormat getZuluDateFormat() {
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat(YYYYMMDD_T_HHMMSS_Z, Locale.ENGLISH);
|
SimpleDateFormat dateFormat = new SimpleDateFormat(YYYYMMDD_T_HHMMSS_Z, Locale.ENGLISH);
|
||||||
dateFormat.setTimeZone(GMT_TIMEZONE);
|
dateFormat.setTimeZone(GMT_TIMEZONE);
|
||||||
@ -903,9 +910,10 @@ public abstract class ExchangeSession {
|
|||||||
* Send message in reader to recipients.
|
* Send message in reader to recipients.
|
||||||
* Detect visible recipients in message body to determine bcc recipients
|
* Detect visible recipients in message body to determine bcc recipients
|
||||||
*
|
*
|
||||||
* @param recipients recipients list
|
* @param rcptToRecipients recipients list
|
||||||
* @param reader message stream
|
* @param mimeMessage mime message
|
||||||
* @throws IOException on error
|
* @throws IOException on error
|
||||||
|
* @throws MessagingException on error
|
||||||
*/
|
*/
|
||||||
public void sendMessage(List<String> rcptToRecipients, MimeMessage mimeMessage) throws IOException, MessagingException {
|
public void sendMessage(List<String> rcptToRecipients, MimeMessage mimeMessage) throws IOException, MessagingException {
|
||||||
// Exchange 2007 : skip From: header
|
// Exchange 2007 : skip From: header
|
||||||
@ -1616,10 +1624,6 @@ public abstract class ExchangeSession {
|
|||||||
return itemName;
|
return itemName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPermanentUrl() {
|
|
||||||
return permanentUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get event etag (last change tag).
|
* Get event etag (last change tag).
|
||||||
*
|
*
|
||||||
@ -1635,6 +1639,11 @@ public abstract class ExchangeSession {
|
|||||||
return new HttpException(message);
|
return new HttpException(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set item href.
|
||||||
|
*
|
||||||
|
* @param href item href
|
||||||
|
*/
|
||||||
public void setHref(String href) {
|
public void setHref(String href) {
|
||||||
int index = href.lastIndexOf('/');
|
int index = href.lastIndexOf('/');
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
@ -1645,6 +1654,11 @@ public abstract class ExchangeSession {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return item href.
|
||||||
|
*
|
||||||
|
* @return item href
|
||||||
|
*/
|
||||||
public String getHref() {
|
public String getHref() {
|
||||||
return folderPath + '/' + itemName;
|
return folderPath + '/' + itemName;
|
||||||
}
|
}
|
||||||
@ -1766,7 +1780,7 @@ public abstract class ExchangeSession {
|
|||||||
if ("1".equals(get("haspicture"))) {
|
if ("1".equals(get("haspicture"))) {
|
||||||
try {
|
try {
|
||||||
ContactPhoto contactPhoto = getContactPhoto(this);
|
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) {
|
} catch (IOException e) {
|
||||||
LOGGER.warn("Unable to get photo from contact " + this.get("cn"));
|
LOGGER.warn("Unable to get photo from contact " + this.get("cn"));
|
||||||
}
|
}
|
||||||
@ -1977,7 +1991,7 @@ public abstract class ExchangeSession {
|
|||||||
hasCdoBusyStatus = true;
|
hasCdoBusyStatus = true;
|
||||||
} else if ("BEGIN:VTIMEZONE".equals(line)) {
|
} else if ("BEGIN:VTIMEZONE".equals(line)) {
|
||||||
hasTimezone = true;
|
hasTimezone = true;
|
||||||
} else if (key.equals("METHOD")) {
|
} else if ("METHOD".equals(key)) {
|
||||||
method = value;
|
method = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2463,7 +2477,10 @@ public abstract class ExchangeSession {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Set<String> ITEM_PROPERTIES = new HashSet<String>();
|
/**
|
||||||
|
* Common item properties
|
||||||
|
*/
|
||||||
|
protected static final Set<String> ITEM_PROPERTIES = new HashSet<String>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ITEM_PROPERTIES.add("etag");
|
ITEM_PROPERTIES.add("etag");
|
||||||
@ -2576,8 +2593,17 @@ public abstract class ExchangeSession {
|
|||||||
*/
|
*/
|
||||||
public abstract Item getItem(String folderPath, String itemName) throws IOException;
|
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;
|
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_ADR_OTHER_PROPERTIES = {"otherpostofficebox", null, "otherstreet", "othercity", "otherstate", "otherpostalcode", "othercountry"};
|
||||||
protected static final String[] VCARD_ORG_PROPERTIES = {"o", "department"};
|
protected static final String[] VCARD_ORG_PROPERTIES = {"o", "department"};
|
||||||
|
|
||||||
protected static final String[] EMPTY_PROPERTIES = {"description", "keywords"};
|
|
||||||
|
|
||||||
protected void convertContactProperties(Map<String, String> properties, String[] contactProperties, List<String> values) {
|
protected void convertContactProperties(Map<String, String> properties, String[] contactProperties, List<String> values) {
|
||||||
for (int i = 0; i < values.size() && i < contactProperties.length; i++) {
|
for (int i = 0; i < values.size() && i < contactProperties.length; i++) {
|
||||||
if (contactProperties[i] != null) {
|
if (contactProperties[i] != null) {
|
||||||
@ -2791,9 +2815,10 @@ public abstract class ExchangeSession {
|
|||||||
properties.put("photo", property.getValue());
|
properties.put("photo", property.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// detect empty values
|
// reset missing properties to null
|
||||||
for (String key : EMPTY_PROPERTIES) {
|
for (String key : CONTACT_ATTRIBUTES) {
|
||||||
if (!properties.containsKey(key)) {
|
if (!"imapUid".equals(key) && !"etag".equals(key) && !"urlcompname".equals(key) &&
|
||||||
|
!properties.containsKey(key)) {
|
||||||
properties.put(key, null);
|
properties.put(key, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3085,6 +3110,9 @@ public abstract class ExchangeSession {
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Full Contact attribute list
|
||||||
|
*/
|
||||||
public static final Set<String> CONTACT_ATTRIBUTES = new HashSet<String>();
|
public static final Set<String> CONTACT_ATTRIBUTES = new HashSet<String>();
|
||||||
|
|
||||||
static {
|
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() {
|
public VTimezone getVTimezone() {
|
||||||
if (vTimezone == null) {
|
if (vTimezone == null) {
|
||||||
// need to load Timezone info from OWA
|
// need to load Timezone info from OWA
|
||||||
|
Loading…
Reference in New Issue
Block a user