Caldav: Fixed regression in allday event handling

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1455 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-09-16 21:33:20 +00:00
parent 82eb331997
commit 904adf7d20
2 changed files with 34 additions and 29 deletions

View File

@ -54,7 +54,7 @@ public class VCalendar extends VObject {
} }
this.email = email; this.email = email;
// set OWA timezone information // set OWA timezone information
if (this.vTimezone == null) { if (this.vTimezone == null && vTimezone != null) {
this.vObjects.add(0, vTimezone); this.vObjects.add(0, vTimezone);
this.vTimezone = vTimezone; this.vTimezone = vTimezone;
} }
@ -239,17 +239,19 @@ public class VCalendar extends VObject {
} }
protected void setServerAllday(VProperty property) { protected void setServerAllday(VProperty property) {
// set TZID param if (vTimezone != null) {
if (!property.hasParam("TZID")) { // set TZID param
property.addParam("TZID", vTimezone.getPropertyValue("TZID")); if (!property.hasParam("TZID")) {
property.addParam("TZID", vTimezone.getPropertyValue("TZID"));
}
// remove VALUE
property.removeParam("VALUE");
String value = property.getValue();
if (value.length() != 8) {
LOGGER.warn("Invalid date value in allday event: " + value);
}
property.setValue(property.getValue() + "T000000");
} }
// remove VALUE
property.removeParam("VALUE");
String value = property.getValue();
if (value.length() != 8) {
LOGGER.warn("Invalid date value in allday event: " + value);
}
property.setValue(property.getValue() + "T000000");
} }
protected void setClientAllday(VProperty property) { protected void setClientAllday(VProperty property) {
@ -423,7 +425,7 @@ public class VCalendar extends VObject {
public void removeVAlarm() { public void removeVAlarm() {
if (vObjects != null) { if (vObjects != null) {
for (VObject vObject:vObjects) { for (VObject vObject : vObjects) {
if ("VEVENT".equals(vObject.type)) { if ("VEVENT".equals(vObject.type)) {
if (vObject.vObjects != null) { if (vObject.vObjects != null) {
vObject.vObjects = null; vObject.vObjects = null;
@ -435,7 +437,7 @@ public class VCalendar extends VObject {
public boolean hasVAlarm() { public boolean hasVAlarm() {
if (vObjects != null) { if (vObjects != null) {
for (VObject vObject:vObjects) { for (VObject vObject : vObjects) {
if ("VEVENT".equals(vObject.type)) { if ("VEVENT".equals(vObject.type)) {
if (vObject.vObjects != null) { if (vObject.vObjects != null) {
return true; return true;

View File

@ -375,20 +375,8 @@ public class EwsExchangeSession extends ExchangeSession {
*/ */
protected byte[] getContent(ItemId itemId) throws IOException { protected byte[] getContent(ItemId itemId) throws IOException {
GetItemMethod getItemMethod = new GetItemMethod(BaseShape.ID_ONLY, itemId, true); GetItemMethod getItemMethod = new GetItemMethod(BaseShape.ID_ONLY, itemId, true);
getItemMethod.addAdditionalProperty(Field.get("reminderset"));
getItemMethod.addAdditionalProperty(Field.get("calendaruid"));
executeMethod(getItemMethod); executeMethod(getItemMethod);
byte[] mimeContent = getItemMethod.getMimeContent(); return getItemMethod.getMimeContent();
VCalendar vCalendar = new VCalendar(mimeContent, email, getVTimezone());
// remove additional reminder
if (!"true".equals(getItemMethod.getResponseItem().get(Field.get("reminderset").getResponseName()))) {
vCalendar.removeVAlarm();
}
String calendaruid = getItemMethod.getResponseItem().get(Field.get("calendaruid").getResponseName());
if (calendaruid != null) {
vCalendar.setFirstVeventPropertyValue("UID", calendaruid);
}
return vCalendar.toString().getBytes("UTF-8");
} }
protected Message buildMessage(EWSMethod.Item response) throws DavMailException { protected Message buildMessage(EWSMethod.Item response) throws DavMailException {
@ -1146,10 +1134,25 @@ public class EwsExchangeSession extends ExchangeSession {
public byte[] getEventContent() throws IOException { public byte[] getEventContent() throws IOException {
byte[] content; byte[] content;
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Get event: " + folderPath + '/' + itemName); LOGGER.debug("Get event: " + itemName);
} }
try { try {
content = getContent(itemId); GetItemMethod getItemMethod = new GetItemMethod(BaseShape.ID_ONLY, itemId, true);
getItemMethod.addAdditionalProperty(Field.get("reminderset"));
getItemMethod.addAdditionalProperty(Field.get("calendaruid"));
executeMethod(getItemMethod);
content = getItemMethod.getMimeContent();
VCalendar vCalendar = new VCalendar(content, email, getVTimezone());
// remove additional reminder
if (!"true".equals(getItemMethod.getResponseItem().get(Field.get("reminderset").getResponseName()))) {
vCalendar.removeVAlarm();
}
String calendaruid = getItemMethod.getResponseItem().get(Field.get("calendaruid").getResponseName());
if (calendaruid != null) {
vCalendar.setFirstVeventPropertyValue("UID", calendaruid);
}
content = vCalendar.toString().getBytes("UTF-8");
} catch (IOException e) { } catch (IOException e) {
throw buildHttpException(e); throw buildHttpException(e);
} }
@ -1353,7 +1356,7 @@ public class EwsExchangeSession extends ExchangeSession {
timezoneId = item.get("timezone"); timezoneId = item.get("timezone");
} }
} else { } else {
getTimezoneidFromOptions(); timezoneId = getTimezoneidFromOptions();
} }
if (timezoneId != null) { if (timezoneId != null) {
createCalendarFolder("davmailtemp", null); createCalendarFolder("davmailtemp", null);