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:
parent
bc0c0b5b40
commit
5b2a34fd38
|
@ -720,6 +720,14 @@ public class VCalendar extends VObject {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get first VEvent
|
||||||
|
* @return first VEvent
|
||||||
|
*/
|
||||||
|
public VObject getFirstVevent() {
|
||||||
|
return firstVevent;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get recurring VCalendar occurence exceptions.
|
* Get recurring VCalendar occurence exceptions.
|
||||||
*
|
*
|
||||||
|
|
|
@ -477,6 +477,11 @@ public abstract class EWSMethod extends PostMethod {
|
||||||
* Original occurence start date
|
* Original occurence start date
|
||||||
*/
|
*/
|
||||||
public String originalStart;
|
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 {
|
protected void handleOccurrence(XMLStreamReader reader, Item item) throws XMLStreamException {
|
||||||
|
Occurrence occurrence = new Occurrence();
|
||||||
while (reader.hasNext() && !(XMLStreamUtil.isEndTag(reader, "Occurrence"))) {
|
while (reader.hasNext() && !(XMLStreamUtil.isEndTag(reader, "Occurrence"))) {
|
||||||
reader.next();
|
reader.next();
|
||||||
if (XMLStreamUtil.isStartTag(reader)) {
|
if (XMLStreamUtil.isStartTag(reader)) {
|
||||||
String tagLocalName = reader.getLocalName();
|
String tagLocalName = reader.getLocalName();
|
||||||
|
if ("ItemId".equals(tagLocalName)) {
|
||||||
|
occurrence.itemId = new ItemId("ItemId", getAttributeValue(reader, "Id"), getAttributeValue(reader, "ChangeKey"));
|
||||||
|
}
|
||||||
if ("OriginalStart".equals(tagLocalName)) {
|
if ("OriginalStart".equals(tagLocalName)) {
|
||||||
Occurrence occurrence = new Occurrence();
|
|
||||||
occurrence.originalStart = XMLStreamUtil.getElementText(reader);
|
occurrence.originalStart = XMLStreamUtil.getElementText(reader);
|
||||||
item.addOccurrence(occurrence);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
item.addOccurrence(occurrence);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String responseTypeToPartstat(String responseType) {
|
public static String responseTypeToPartstat(String responseType) {
|
||||||
|
|
|
@ -1655,22 +1655,7 @@ public class EwsExchangeSession extends ExchangeSession {
|
||||||
localVCalendar.setFirstVeventPropertyValue("UID", calendaruid);
|
localVCalendar.setFirstVeventPropertyValue("UID", calendaruid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<EWSMethod.Attendee> attendees = getItemMethod.getResponseItem().getAttendees();
|
fixAttendees(getItemMethod, localVCalendar.getFirstVevent());
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// fix UID and RECURRENCE-ID, broken at least on Exchange 2007
|
// fix UID and RECURRENCE-ID, broken at least on Exchange 2007
|
||||||
List<EWSMethod.Occurrence> occurences = getItemMethod.getResponseItem().getOccurrences();
|
List<EWSMethod.Occurrence> occurences = getItemMethod.getResponseItem().getOccurrences();
|
||||||
if (occurences != null) {
|
if (occurences != null) {
|
||||||
|
@ -1678,7 +1663,13 @@ public class EwsExchangeSession extends ExchangeSession {
|
||||||
for (EWSMethod.Occurrence occurrence : occurences) {
|
for (EWSMethod.Occurrence occurrence : occurences) {
|
||||||
if (modifiedOccurrencesIterator.hasNext()) {
|
if (modifiedOccurrencesIterator.hasNext()) {
|
||||||
VObject modifiedOccurrence = modifiedOccurrencesIterator.next();
|
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)) {
|
if ("Exchange2007_SP1".equals(serverVersion)) {
|
||||||
// fix uid, should be the same as main VEVENT
|
// fix uid, should be the same as main VEVENT
|
||||||
|
@ -1714,6 +1705,25 @@ public class EwsExchangeSession extends ExchangeSession {
|
||||||
}
|
}
|
||||||
return content;
|
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
|
@Override
|
||||||
|
|
|
@ -69,6 +69,17 @@ public class ItemId {
|
||||||
this.changeKey = null;
|
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.
|
* Write item id as XML.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue