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,12 +437,17 @@ 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 {
if (properties.containsKey("read") && "urn:content-classes:appointment".equals(message.contentClass)) {
properties.remove("read");
}
if (!properties.isEmpty()) {
UpdateItemMethod updateItemMethod = new UpdateItemMethod(MessageDisposition.SaveOnly, UpdateItemMethod updateItemMethod = new UpdateItemMethod(MessageDisposition.SaveOnly,
ConflictResolution.AlwaysOverwrite, ConflictResolution.AlwaysOverwrite,
SendMeetingInvitationsOrCancellations.SendToNone, SendMeetingInvitationsOrCancellations.SendToNone,
((EwsExchangeSession.Message) message).itemId, buildProperties(properties)); ((EwsExchangeSession.Message) message).itemId, buildProperties(properties));
executeMethod(updateItemMethod); executeMethod(updateItemMethod);
} }
}
@Override @Override
public void deleteMessage(ExchangeSession.Message message) throws IOException { public void deleteMessage(ExchangeSession.Message message) throws IOException {
@ -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);
@ -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();
} }