EWS: fix 3263905 ErrorInvalidPropertyRequest, do not update message:IsRead on appointments

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1957 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2012-05-10 22:08:22 +00:00
parent 8a8e8f1a6c
commit 7d6ee0d27e
1 changed files with 24 additions and 18 deletions

View File

@ -437,11 +437,16 @@ public class EwsExchangeSession extends ExchangeSession {
@Override @Override
public void updateMessage(ExchangeSession.Message message, Map<String, String> properties) throws IOException { public void updateMessage(ExchangeSession.Message message, Map<String, String> properties) throws IOException {
UpdateItemMethod updateItemMethod = new UpdateItemMethod(MessageDisposition.SaveOnly, if (properties.containsKey("read") && "urn:content-classes:appointment".equals(message.contentClass)) {
ConflictResolution.AlwaysOverwrite, properties.remove("read");
SendMeetingInvitationsOrCancellations.SendToNone, }
((EwsExchangeSession.Message) message).itemId, buildProperties(properties)); if (!properties.isEmpty()) {
executeMethod(updateItemMethod); UpdateItemMethod updateItemMethod = new UpdateItemMethod(MessageDisposition.SaveOnly,
ConflictResolution.AlwaysOverwrite,
SendMeetingInvitationsOrCancellations.SendToNone,
((EwsExchangeSession.Message) message).itemId, buildProperties(properties));
executeMethod(updateItemMethod);
}
} }
@Override @Override
@ -509,7 +514,7 @@ public class EwsExchangeSession extends ExchangeSession {
executeMethod(getItemMethod); executeMethod(getItemMethod);
mimeContent = getItemMethod.getMimeContent(); mimeContent = getItemMethod.getMimeContent();
} catch (EWSException e) { } catch (EWSException e) {
LOGGER.warn("GetItem with MimeContent failed: "+e.getMessage()); LOGGER.warn("GetItem with MimeContent failed: " + e.getMessage());
} }
if (mimeContent == null) { if (mimeContent == null) {
LOGGER.warn("MimeContent not available, trying to rebuild from properties"); LOGGER.warn("MimeContent not available, trying to rebuild from properties");
@ -992,7 +997,7 @@ public class EwsExchangeSession extends ExchangeSession {
@Override @Override
public int updateFolder(String folderPath, Map<String, String> properties) throws IOException { public int updateFolder(String folderPath, Map<String, String> properties) throws IOException {
ArrayList<FieldUpdate> updates = new ArrayList<FieldUpdate>(); ArrayList<FieldUpdate> updates = new ArrayList<FieldUpdate>();
for (Map.Entry<String,String> entry:properties.entrySet()) { for (Map.Entry<String, String> entry : properties.entrySet()) {
updates.add(new FieldUpdate(Field.get(entry.getKey()), entry.getValue())); updates.add(new FieldUpdate(Field.get(entry.getKey()), entry.getValue()));
} }
UpdateFolderMethod updateFolderMethod = new UpdateFolderMethod(internalGetFolder(folderPath).folderId, updates); UpdateFolderMethod updateFolderMethod = new UpdateFolderMethod(internalGetFolder(folderPath).folderId, updates);
@ -1258,7 +1263,7 @@ public class EwsExchangeSession extends ExchangeSession {
String type; String type;
boolean isException; boolean isException;
protected Event(EWSMethod.Item response) { protected Event(EWSMethod.Item response) {
itemId = new ItemId(response); itemId = new ItemId(response);
type = response.type; type = response.type;
@ -1425,10 +1430,10 @@ public class EwsExchangeSession extends ExchangeSession {
String ownerPartStat = property.getParamValue("PARTSTAT"); String ownerPartStat = property.getParamValue("PARTSTAT");
if ("ACCEPTED".equals(ownerPartStat)) { if ("ACCEPTED".equals(ownerPartStat)) {
ownerResponseReply = "AcceptItem"; ownerResponseReply = "AcceptItem";
// do not send DeclineItem to avoid deleting target event // do not send DeclineItem to avoid deleting target event
//} else if ("DECLINED".equals(ownerPartStat)) { //} else if ("DECLINED".equals(ownerPartStat)) {
// ownerResponseReply = "DeclineItem"; // ownerResponseReply = "DeclineItem";
} else if ("TENTATIVE".equals(ownerPartStat)) { } else if ("TENTATIVE".equals(ownerPartStat)) {
ownerResponseReply = "TentativelyAcceptItem"; ownerResponseReply = "TentativelyAcceptItem";
} }
} }
@ -1455,7 +1460,7 @@ public class EwsExchangeSession extends ExchangeSession {
updates.add(Field.createFieldUpdate("to", StringUtil.join(requiredAttendees, ", "))); updates.add(Field.createFieldUpdate("to", StringUtil.join(requiredAttendees, ", ")));
} }
if (optionalAttendees.size() > 0) { if (optionalAttendees.size() > 0) {
updates.add(Field.createFieldUpdate("cc", StringUtil.join(optionalAttendees, ", "))); updates.add(Field.createFieldUpdate("cc", StringUtil.join(optionalAttendees, ", ")));
} }
} }
@ -1610,7 +1615,7 @@ public class EwsExchangeSession extends ExchangeSession {
for (EWSMethod.Attendee attendee : attendees) { for (EWSMethod.Attendee attendee : attendees) {
VProperty attendeeProperty = new VProperty("ATTENDEE", "mailto:" + attendee.email); VProperty attendeeProperty = new VProperty("ATTENDEE", "mailto:" + attendee.email);
attendeeProperty.addParam("CN", attendee.name); attendeeProperty.addParam("CN", attendee.name);
String myResponseType = getItemMethod.getResponseItem().get(Field.get("myresponsetype").getResponseName()); String myResponseType = getItemMethod.getResponseItem().get(Field.get("myresponsetype").getResponseName());
if ("Exchange2007_SP1".equals(serverVersion) && email.equalsIgnoreCase(attendee.email) && myResponseType != null) { if ("Exchange2007_SP1".equals(serverVersion) && email.equalsIgnoreCase(attendee.email) && myResponseType != null) {
attendeeProperty.addParam("PARTSTAT", EWSMethod.responseTypeToPartstat(myResponseType)); attendeeProperty.addParam("PARTSTAT", EWSMethod.responseTypeToPartstat(myResponseType));
} else { } else {
@ -1726,6 +1731,7 @@ public class EwsExchangeSession extends ExchangeSession {
* Common item properties * Common item properties
*/ */
protected static final Set<String> ITEM_PROPERTIES = new HashSet<String>(); protected static final Set<String> ITEM_PROPERTIES = new HashSet<String>();
static { static {
ITEM_PROPERTIES.add("etag"); ITEM_PROPERTIES.add("etag");
ITEM_PROPERTIES.add("displayname"); ITEM_PROPERTIES.add("displayname");
@ -2120,8 +2126,8 @@ public class EwsExchangeSession extends ExchangeSession {
} }
ewsMethod.checkSuccess(); ewsMethod.checkSuccess();
} catch (SocketException e) { } catch (SocketException e) {
LOGGER.error(e+" "+e.getMessage(), e); LOGGER.error(e + " " + e.getMessage(), e);
throw new EWSException(e+" "+e.getMessage()); throw new EWSException(e + " " + e.getMessage());
} finally { } finally {
ewsMethod.releaseConnection(); ewsMethod.releaseConnection();
} }