mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-13 03:02:22 -05:00
Caldav: EWS, rebuild attendee list from properties
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1468 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
b418fcbc06
commit
6544a67130
@ -464,6 +464,9 @@ public class VCalendar extends VObject {
|
||||
firstVevent.setPropertyValue(propertyName, propertyValue);
|
||||
}
|
||||
|
||||
public void addFirstVeventProperty(VProperty vProperty) {
|
||||
firstVevent.addProperty(vProperty);
|
||||
}
|
||||
|
||||
/**
|
||||
* VCalendar recipients for notifications
|
||||
|
@ -412,6 +412,13 @@ public abstract class EWSMethod extends PostMethod {
|
||||
this.serverVersion = serverVersion;
|
||||
}
|
||||
|
||||
public static class Attendee {
|
||||
public String role;
|
||||
public String email;
|
||||
public String partstat;
|
||||
public String name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Item
|
||||
*/
|
||||
@ -423,6 +430,7 @@ public abstract class EWSMethod extends PostMethod {
|
||||
protected byte[] mimeContent;
|
||||
protected List<FieldUpdate> fieldUpdates;
|
||||
protected List<FileAttachment> attachments;
|
||||
protected List<Attendee> attendees;
|
||||
protected List<String> fieldNames = new ArrayList<String>();
|
||||
|
||||
@Override
|
||||
@ -556,6 +564,17 @@ public abstract class EWSMethod extends PostMethod {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<Attendee> getAttendees() {
|
||||
return attendees;
|
||||
}
|
||||
|
||||
public void addAttendee(Attendee attendee) {
|
||||
if (attendees == null) {
|
||||
attendees = new ArrayList<Attendee>();
|
||||
}
|
||||
attendees.add(attendee);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -679,6 +698,8 @@ public abstract class EWSMethod extends PostMethod {
|
||||
responseItem.attachments = handleAttachments(reader);
|
||||
} else if ("EmailAddresses".equals(tagLocalName)) {
|
||||
handleEmailAddresses(reader, responseItem);
|
||||
} else if ("RequiredAttendees".equals(tagLocalName) || "OptionalAttendees".equals(tagLocalName)) {
|
||||
handleAttendees(reader, responseItem, tagLocalName);
|
||||
} else {
|
||||
if (tagLocalName.endsWith("Id")) {
|
||||
value = getAttributeValue(reader, "Id");
|
||||
@ -709,6 +730,50 @@ public abstract class EWSMethod extends PostMethod {
|
||||
}
|
||||
}
|
||||
|
||||
protected void handleAttendees(XMLStreamReader reader, Item item, String attendeeType) throws XMLStreamException {
|
||||
while (reader.hasNext() && !(XMLStreamUtil.isEndTag(reader, attendeeType))) {
|
||||
reader.next();
|
||||
if (XMLStreamUtil.isStartTag(reader)) {
|
||||
String tagLocalName = reader.getLocalName();
|
||||
if ("Attendee".equals(tagLocalName)) {
|
||||
handleAttendee(reader, item, attendeeType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void handleAttendee(XMLStreamReader reader, Item item, String attendeeType) throws XMLStreamException {
|
||||
Attendee attendee = new Attendee();
|
||||
if ("RequiredAttendees".equals(attendeeType)) {
|
||||
attendee.role = "REQ-PARTICIPANT";
|
||||
} else {
|
||||
attendee.role = "OPT-PARTICIPANT";
|
||||
}
|
||||
while (reader.hasNext() && !(XMLStreamUtil.isEndTag(reader, "Attendee"))) {
|
||||
reader.next();
|
||||
if (XMLStreamUtil.isStartTag(reader)) {
|
||||
String tagLocalName = reader.getLocalName();
|
||||
if ("EmailAddress".equals(tagLocalName)) {
|
||||
attendee.email = reader.getElementText();
|
||||
} else if ("Name".equals(tagLocalName)) {
|
||||
attendee.name = reader.getElementText();
|
||||
} else if ("ResponseType".equals(tagLocalName)) {
|
||||
String responseType = reader.getElementText();
|
||||
if ("Accept".equals(responseType)) {
|
||||
attendee.partstat = "ACCEPTED";
|
||||
} else if ("Tentative".equals(responseType)) {
|
||||
attendee.partstat = "TENTATIVE";
|
||||
} else if ("Decline".equals(responseType)) {
|
||||
attendee.partstat = "DECLINED";
|
||||
} else {
|
||||
attendee.partstat = "NEEDS-ACTION";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
item.addAttendee(attendee);
|
||||
}
|
||||
|
||||
protected List<FileAttachment> handleAttachments(XMLStreamReader reader) throws XMLStreamException {
|
||||
List<FileAttachment> attachments = new ArrayList<FileAttachment>();
|
||||
while (reader.hasNext() && !(XMLStreamUtil.isEndTag(reader, "Attachments"))) {
|
||||
|
@ -23,6 +23,7 @@ import davmail.exception.DavMailException;
|
||||
import davmail.exception.HttpNotFoundException;
|
||||
import davmail.exchange.ExchangeSession;
|
||||
import davmail.exchange.VCalendar;
|
||||
import davmail.exchange.VProperty;
|
||||
import davmail.http.DavGatewayHttpClientFacade;
|
||||
import davmail.util.IOUtil;
|
||||
import davmail.util.StringUtil;
|
||||
@ -1181,6 +1182,9 @@ public class EwsExchangeSession extends ExchangeSession {
|
||||
GetItemMethod getItemMethod = new GetItemMethod(BaseShape.ID_ONLY, itemId, true);
|
||||
getItemMethod.addAdditionalProperty(Field.get("reminderset"));
|
||||
getItemMethod.addAdditionalProperty(Field.get("calendaruid"));
|
||||
getItemMethod.addAdditionalProperty(Field.get("requiredattendees"));
|
||||
getItemMethod.addAdditionalProperty(Field.get("optionalattendees"));
|
||||
|
||||
executeMethod(getItemMethod);
|
||||
content = getItemMethod.getMimeContent();
|
||||
VCalendar localVCalendar = new VCalendar(content, email, getVTimezone());
|
||||
@ -1192,6 +1196,16 @@ public class EwsExchangeSession extends ExchangeSession {
|
||||
if (calendaruid != null) {
|
||||
localVCalendar.setFirstVeventPropertyValue("UID", calendaruid);
|
||||
}
|
||||
List<EWSMethod.Attendee> attendees = getItemMethod.getResponseItem().getAttendees();
|
||||
if (attendees != null) {
|
||||
for (EWSMethod.Attendee attendee : attendees) {
|
||||
VProperty attendeeProperty = new VProperty("ATTENDEE", "mailto:"+attendee.email);
|
||||
attendeeProperty.addParam("CN", attendee.name);
|
||||
attendeeProperty.addParam("PARTSTAT", attendee.partstat);
|
||||
attendeeProperty.addParam("ROLE", attendee.role);
|
||||
localVCalendar.addFirstVeventProperty(attendeeProperty);
|
||||
}
|
||||
}
|
||||
content = localVCalendar.toString().getBytes("UTF-8");
|
||||
|
||||
} catch (IOException e) {
|
||||
|
@ -193,6 +193,9 @@ public class Field {
|
||||
FIELD_MAP.put("busystatus", new UnindexedFieldURI("calendar:LegacyFreeBusyStatus"));
|
||||
|
||||
|
||||
FIELD_MAP.put("requiredattendees", new UnindexedFieldURI("calendar:RequiredAttendees"));
|
||||
FIELD_MAP.put("optionalattendees", new UnindexedFieldURI("calendar:OptionalAttendees"));
|
||||
|
||||
// attachments
|
||||
FIELD_MAP.put("attachments", new UnindexedFieldURI("item:Attachments"));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user