Caldav: fix attendees in modified occurences

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2011 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2012-08-30 22:40:28 +00:00
parent bc0c0b5b40
commit 5b2a34fd38
4 changed files with 56 additions and 19 deletions

View File

@ -720,6 +720,14 @@ public class VCalendar extends VObject {
return status;
}
/**
* Get first VEvent
* @return first VEvent
*/
public VObject getFirstVevent() {
return firstVevent;
}
/**
* Get recurring VCalendar occurence exceptions.
*

View File

@ -477,6 +477,11 @@ public abstract class EWSMethod extends PostMethod {
* Original occurence start date
*/
public String originalStart;
/**
* Occurence itemid
*/
public ItemId itemId;
}
/**
@ -867,17 +872,20 @@ public abstract class EWSMethod extends PostMethod {
}
protected void handleOccurrence(XMLStreamReader reader, Item item) throws XMLStreamException {
Occurrence occurrence = new Occurrence();
while (reader.hasNext() && !(XMLStreamUtil.isEndTag(reader, "Occurrence"))) {
reader.next();
if (XMLStreamUtil.isStartTag(reader)) {
String tagLocalName = reader.getLocalName();
if ("ItemId".equals(tagLocalName)) {
occurrence.itemId = new ItemId("ItemId", getAttributeValue(reader, "Id"), getAttributeValue(reader, "ChangeKey"));
}
if ("OriginalStart".equals(tagLocalName)) {
Occurrence occurrence = new Occurrence();
occurrence.originalStart = XMLStreamUtil.getElementText(reader);
item.addOccurrence(occurrence);
}
}
}
item.addOccurrence(occurrence);
}
public static String responseTypeToPartstat(String responseType) {

View File

@ -1655,22 +1655,7 @@ public class EwsExchangeSession extends ExchangeSession {
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);
String myResponseType = getItemMethod.getResponseItem().get(Field.get("myresponsetype").getResponseName());
if ("Exchange2007_SP1".equals(serverVersion) && email.equalsIgnoreCase(attendee.email) && myResponseType != null) {
attendeeProperty.addParam("PARTSTAT", EWSMethod.responseTypeToPartstat(myResponseType));
} else {
attendeeProperty.addParam("PARTSTAT", attendee.partstat);
}
//attendeeProperty.addParam("RSVP", "TRUE");
attendeeProperty.addParam("ROLE", attendee.role);
localVCalendar.addFirstVeventProperty(attendeeProperty);
}
}
fixAttendees(getItemMethod, localVCalendar.getFirstVevent());
// fix UID and RECURRENCE-ID, broken at least on Exchange 2007
List<EWSMethod.Occurrence> occurences = getItemMethod.getResponseItem().getOccurrences();
if (occurences != null) {
@ -1678,7 +1663,13 @@ public class EwsExchangeSession extends ExchangeSession {
for (EWSMethod.Occurrence occurrence : occurences) {
if (modifiedOccurrencesIterator.hasNext()) {
VObject modifiedOccurrence = modifiedOccurrencesIterator.next();
// TODO: fix modified occurences attendees
// fix modified occurrences attendees
GetItemMethod getOccurrenceMethod = new GetItemMethod(BaseShape.ID_ONLY, occurrence.itemId, false);
getOccurrenceMethod.addAdditionalProperty(Field.get("requiredattendees"));
getOccurrenceMethod.addAdditionalProperty(Field.get("optionalattendees"));
getOccurrenceMethod.addAdditionalProperty(Field.get("modifiedoccurrences"));
executeMethod(getOccurrenceMethod);
fixAttendees(getOccurrenceMethod, modifiedOccurrence);
if ("Exchange2007_SP1".equals(serverVersion)) {
// fix uid, should be the same as main VEVENT
@ -1714,6 +1705,25 @@ public class EwsExchangeSession extends ExchangeSession {
}
return content;
}
protected void fixAttendees(GetItemMethod getItemMethod, VObject vEvent) throws EWSException {
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);
String myResponseType = getItemMethod.getResponseItem().get(Field.get("myresponsetype").getResponseName());
if ("Exchange2007_SP1".equals(serverVersion) && email.equalsIgnoreCase(attendee.email) && myResponseType != null) {
attendeeProperty.addParam("PARTSTAT", EWSMethod.responseTypeToPartstat(myResponseType));
} else {
attendeeProperty.addParam("PARTSTAT", attendee.partstat);
}
//attendeeProperty.addParam("RSVP", "TRUE");
attendeeProperty.addParam("ROLE", attendee.role);
vEvent.addProperty(attendeeProperty);
}
}
}
}
@Override

View File

@ -69,6 +69,17 @@ public class ItemId {
this.changeKey = null;
}
/**
* Build Item id object from item id and change key.
*
* @param itemId item id
*/
public ItemId(String name, String itemId, String changeKey) {
this.name = name;
this.id = itemId;
this.changeKey = changeKey;
}
/**
* Write item id as XML.
*