From 50d0bc585afc9b2ea2123f8beaba96ca2763ac4c Mon Sep 17 00:00:00 2001 From: mguessan Date: Mon, 8 Aug 2011 20:11:15 +0000 Subject: [PATCH] Caldav: implement task categories over EWS git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1769 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- .../davmail/exchange/dav/DavExchangeSession.java | 4 ++-- .../davmail/exchange/ews/EwsExchangeSession.java | 13 ++++++++----- src/java/davmail/exchange/ews/Field.java | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/java/davmail/exchange/dav/DavExchangeSession.java b/src/java/davmail/exchange/dav/DavExchangeSession.java index 12f6ee48..c8918bfa 100644 --- a/src/java/davmail/exchange/dav/DavExchangeSession.java +++ b/src/java/davmail/exchange/dav/DavExchangeSession.java @@ -1363,7 +1363,7 @@ public class DavExchangeSession extends ExchangeSession { } private byte[] getICSFromItemProperties() throws IOException { - byte[] result = null; + byte[] result; // experimental: build VCALENDAR from properties @@ -1482,7 +1482,7 @@ public class DavExchangeSession extends ExchangeSession { // Parse attendee list String toHeader = getPropertyIfExists(davPropertySet, "to"); - if (toHeader != null && !organizerEmail.equals(toHeader)) { + if (toHeader != null && !toHeader.equals(organizerEmail)) { InternetAddress[] attendees = InternetAddress.parseHeader(toHeader, false); for (InternetAddress attendee : attendees) { if (!attendee.getAddress().equalsIgnoreCase(organizerEmail)) { diff --git a/src/java/davmail/exchange/ews/EwsExchangeSession.java b/src/java/davmail/exchange/ews/EwsExchangeSession.java index 3c762cb8..1abc9c4d 100644 --- a/src/java/davmail/exchange/ews/EwsExchangeSession.java +++ b/src/java/davmail/exchange/ews/EwsExchangeSession.java @@ -399,7 +399,6 @@ public class EwsExchangeSession extends ExchangeSession { @Override public void createMessage(String folderPath, String messageName, HashMap properties, MimeMessage mimeMessage) throws IOException { EWSMethod.Item item = new EWSMethod.Item(); - item.type = "Message"; ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { mimeMessage.writeTo(baos); @@ -1248,10 +1247,11 @@ public class EwsExchangeSession extends ExchangeSession { updates.add(Field.createFieldUpdate("percentcomplete", percentComplete)); String vTodoStatus = vCalendar.getFirstVeventPropertyValue("STATUS"); if (vTodoStatus == null) { - updates.add(Field.createFieldUpdate("status", "NotStarted")); + updates.add(Field.createFieldUpdate("taskstatus", "NotStarted")); } else { - updates.add(Field.createFieldUpdate("status", vTodoToTaskStatusMap.get(vTodoStatus))); + updates.add(Field.createFieldUpdate("taskstatus", vTodoToTaskStatusMap.get(vTodoStatus))); } + updates.add(Field.createFieldUpdate("keywords", vCalendar.getFirstVeventPropertyValue("CATEGORIES"))); updates.add(Field.createFieldUpdate("duedate", convertCalendarDateToExchange(vCalendar.getFirstVeventPropertyValue("DUE")))); if (currentItemId != null) { // update @@ -1381,8 +1381,9 @@ public class EwsExchangeSession extends ExchangeSession { getItemMethod.addAdditionalProperty(Field.get("calendaruid")); getItemMethod.addAdditionalProperty(Field.get("description")); getItemMethod.addAdditionalProperty(Field.get("percentcomplete")); - getItemMethod.addAdditionalProperty(Field.get("status")); + getItemMethod.addAdditionalProperty(Field.get("taskstatus")); getItemMethod.addAdditionalProperty(Field.get("duedate")); + getItemMethod.addAdditionalProperty(Field.get("keywords")); } else if (!"Message".equals(type)) { getItemMethod = new GetItemMethod(BaseShape.ID_ONLY, itemId, true); getItemMethod.addAdditionalProperty(Field.get("reminderset")); @@ -1415,7 +1416,9 @@ public class EwsExchangeSession extends ExchangeSession { vTodo.setPropertyValue("SUMMARY", getItemMethod.getResponseItem().get(Field.get("subject").getResponseName())); vTodo.setPropertyValue("DESCRIPTION", getItemMethod.getResponseItem().get(Field.get("description").getResponseName())); vTodo.setPropertyValue("PERCENT-COMPLETE", getItemMethod.getResponseItem().get(Field.get("percentcomplete").getResponseName())); - vTodo.setPropertyValue("STATUS", taskTovTodoStatusMap.get(getItemMethod.getResponseItem().get(Field.get("status").getResponseName()))); + vTodo.setPropertyValue("STATUS", taskTovTodoStatusMap.get(getItemMethod.getResponseItem().get(Field.get("taskstatus").getResponseName()))); + vTodo.setPropertyValue("CATEGORIES", getItemMethod.getResponseItem().get(Field.get("keywords").getResponseName())); + VProperty vProperty = new VProperty("DUE", convertDateFromExchange(getItemMethod.getResponseItem().get(Field.get("duedate").getResponseName()))); vProperty.setParam("TZID", vTimezone.getPropertyValue("TZID")); vTodo.addProperty(vProperty); diff --git a/src/java/davmail/exchange/ews/Field.java b/src/java/davmail/exchange/ews/Field.java index 9c8bbfb6..deb6d005 100644 --- a/src/java/davmail/exchange/ews/Field.java +++ b/src/java/davmail/exchange/ews/Field.java @@ -209,7 +209,7 @@ public final class Field { // task FIELD_MAP.put("percentcomplete", new UnindexedFieldURI("task:PercentComplete")); - FIELD_MAP.put("status", new UnindexedFieldURI("task:Status")); + FIELD_MAP.put("taskstatus", new UnindexedFieldURI("task:Status")); FIELD_MAP.put("duedate", new UnindexedFieldURI("task:DueDate")); // attachments