mirror of
https://github.com/moparisthebest/davmail
synced 2025-01-07 11:48:02 -05:00
Carddav: implement categories support in EWS mode
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1185 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
63324f9a78
commit
641dcaeeb1
@ -576,12 +576,28 @@ public abstract class EWSMethod extends PostMethod {
|
|||||||
String tagLocalName = reader.getLocalName();
|
String tagLocalName = reader.getLocalName();
|
||||||
if ("ExtendedFieldURI".equals(tagLocalName)) {
|
if ("ExtendedFieldURI".equals(tagLocalName)) {
|
||||||
propertyTag = getAttributeValue(reader, "PropertyTag");
|
propertyTag = getAttributeValue(reader, "PropertyTag");
|
||||||
// property name is in PropertyId with DistinguishedPropertySetId
|
// property name is in PropertyId or PropertyName with DistinguishedPropertySetId
|
||||||
if (propertyTag == null) {
|
if (propertyTag == null) {
|
||||||
propertyTag = getAttributeValue(reader, "PropertyId");
|
propertyTag = getAttributeValue(reader, "PropertyId");
|
||||||
}
|
}
|
||||||
|
if (propertyTag == null) {
|
||||||
|
propertyTag = getAttributeValue(reader, "PropertyName");
|
||||||
|
}
|
||||||
} else if ("Value".equals(tagLocalName)) {
|
} else if ("Value".equals(tagLocalName)) {
|
||||||
propertyValue = reader.getElementText();
|
propertyValue = reader.getElementText();
|
||||||
|
} else if ("Values".equals(tagLocalName)) {
|
||||||
|
StringBuilder buffer = new StringBuilder();
|
||||||
|
while (reader.hasNext() && !(isEndTag(reader, "Values"))) {
|
||||||
|
reader.next();
|
||||||
|
if (reader.getEventType() == XMLStreamConstants.START_ELEMENT) {
|
||||||
|
|
||||||
|
if (buffer.length() > 0) {
|
||||||
|
buffer.append(',');
|
||||||
|
}
|
||||||
|
buffer.append(reader.getElementText());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
propertyValue = buffer.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,18 @@ public class ExtendedFieldURI implements FieldURI {
|
|||||||
this.propertyType = PropertyType.String;
|
this.propertyType = PropertyType.String;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create extended field uri.
|
||||||
|
*
|
||||||
|
* @param distinguishedPropertySetId distinguished property set id
|
||||||
|
* @param propertyName property name
|
||||||
|
*/
|
||||||
|
public ExtendedFieldURI(DistinguishedPropertySetType distinguishedPropertySetId, String propertyName, PropertyType propertyType) {
|
||||||
|
this.distinguishedPropertySetId = distinguishedPropertySetId;
|
||||||
|
this.propertyName = propertyName;
|
||||||
|
this.propertyType = propertyType;
|
||||||
|
}
|
||||||
|
|
||||||
public void appendTo(StringBuilder buffer) {
|
public void appendTo(StringBuilder buffer) {
|
||||||
buffer.append("<t:ExtendedFieldURI ");
|
buffer.append("<t:ExtendedFieldURI ");
|
||||||
if (propertyTag != null) {
|
if (propertyTag != null) {
|
||||||
@ -108,9 +120,21 @@ public class ExtendedFieldURI implements FieldURI {
|
|||||||
}
|
}
|
||||||
buffer.append("<t:ExtendedProperty>");
|
buffer.append("<t:ExtendedProperty>");
|
||||||
appendTo(buffer);
|
appendTo(buffer);
|
||||||
buffer.append("<t:Value>");
|
if (propertyType == PropertyType.StringArray) {
|
||||||
buffer.append(value);
|
buffer.append("<t:Values>");
|
||||||
buffer.append("</t:Value>");
|
String[] values = value.split("\n");
|
||||||
|
for (final String singleValue : values) {
|
||||||
|
buffer.append("<t:Value>");
|
||||||
|
buffer.append(singleValue);
|
||||||
|
buffer.append("</t:Value>");
|
||||||
|
|
||||||
|
}
|
||||||
|
buffer.append("</t:Values>");
|
||||||
|
} else {
|
||||||
|
buffer.append("<t:Value>");
|
||||||
|
buffer.append(value);
|
||||||
|
buffer.append("</t:Value>");
|
||||||
|
}
|
||||||
buffer.append("</t:ExtendedProperty>");
|
buffer.append("</t:ExtendedProperty>");
|
||||||
if (itemType != null) {
|
if (itemType != null) {
|
||||||
buffer.append("</t:");
|
buffer.append("</t:");
|
||||||
@ -127,6 +151,8 @@ public class ExtendedFieldURI implements FieldURI {
|
|||||||
public String getResponseName() {
|
public String getResponseName() {
|
||||||
if (propertyTag != null) {
|
if (propertyTag != null) {
|
||||||
return propertyTag;
|
return propertyTag;
|
||||||
|
} else if (propertyName != null) {
|
||||||
|
return propertyName;
|
||||||
} else {
|
} else {
|
||||||
return String.valueOf(propertyId);
|
return String.valueOf(propertyId);
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ public class Field {
|
|||||||
FIELD_MAP.put("othercountry", new ExtendedFieldURI(0x3A60, ExtendedFieldURI.PropertyType.String));
|
FIELD_MAP.put("othercountry", new ExtendedFieldURI(0x3A60, ExtendedFieldURI.PropertyType.String));
|
||||||
FIELD_MAP.put("othercity", new ExtendedFieldURI(0x3A5F, ExtendedFieldURI.PropertyType.String));
|
FIELD_MAP.put("othercity", new ExtendedFieldURI(0x3A5F, ExtendedFieldURI.PropertyType.String));
|
||||||
|
|
||||||
FIELD_MAP.put("keywords", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.PublicStrings, "Keywords"));
|
FIELD_MAP.put("keywords", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.PublicStrings, "Keywords", ExtendedFieldURI.PropertyType.StringArray));
|
||||||
|
|
||||||
FIELD_MAP.put("private", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.Common, 0x8506, ExtendedFieldURI.PropertyType.Boolean));
|
FIELD_MAP.put("private", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.Common, 0x8506, ExtendedFieldURI.PropertyType.Boolean));
|
||||||
FIELD_MAP.put("sensitivity", new ExtendedFieldURI(0x0036, ExtendedFieldURI.PropertyType.Long));
|
FIELD_MAP.put("sensitivity", new ExtendedFieldURI(0x0036, ExtendedFieldURI.PropertyType.Long));
|
||||||
|
@ -61,13 +61,16 @@ public class FieldUpdate {
|
|||||||
writer.write("Field>");
|
writer.write("Field>");
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder buffer = new StringBuilder();
|
// do not try to set empty value on create
|
||||||
if (value == null) {
|
if (itemType != null || value != null) {
|
||||||
fieldURI.appendTo(buffer);
|
StringBuilder buffer = new StringBuilder();
|
||||||
} else {
|
if (value == null) {
|
||||||
fieldURI.appendValue(buffer, itemType, value);
|
fieldURI.appendTo(buffer);
|
||||||
|
} else {
|
||||||
|
fieldURI.appendValue(buffer, itemType, value);
|
||||||
|
}
|
||||||
|
writer.write(buffer.toString());
|
||||||
}
|
}
|
||||||
writer.write(buffer.toString());
|
|
||||||
|
|
||||||
if (itemType != null) {
|
if (itemType != null) {
|
||||||
writer.write("</t:");
|
writer.write("</t:");
|
||||||
|
@ -95,6 +95,7 @@ public class TestExchangeSessionContact extends AbstractExchangeSessionTestCase
|
|||||||
vCardWriter.appendProperty("ROLE", "profession");
|
vCardWriter.appendProperty("ROLE", "profession");
|
||||||
vCardWriter.appendProperty("X-AIM", "im");
|
vCardWriter.appendProperty("X-AIM", "im");
|
||||||
vCardWriter.appendProperty("BDAY", "20000102T000000Z");
|
vCardWriter.appendProperty("BDAY", "20000102T000000Z");
|
||||||
|
vCardWriter.appendProperty("CATEGORIES", "keywords");
|
||||||
|
|
||||||
vCardWriter.appendProperty("X-ASSISTANT", "secretarycn");
|
vCardWriter.appendProperty("X-ASSISTANT", "secretarycn");
|
||||||
vCardWriter.appendProperty("X-MANAGER", "manager");
|
vCardWriter.appendProperty("X-MANAGER", "manager");
|
||||||
@ -169,5 +170,6 @@ public class TestExchangeSessionContact extends AbstractExchangeSessionTestCase
|
|||||||
assertEquals("secretarycn", contact.get("secretarycn"));
|
assertEquals("secretarycn", contact.get("secretarycn"));
|
||||||
assertEquals("manager", contact.get("manager"));
|
assertEquals("manager", contact.get("manager"));
|
||||||
assertEquals("spousecn", contact.get("spousecn"));
|
assertEquals("spousecn", contact.get("spousecn"));
|
||||||
|
assertEquals("keywords", contact.get("keywords"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user