diff --git a/src/java/davmail/exchange/ews/CalendarItemCreateOrDeleteOperation.java b/src/java/davmail/exchange/ews/CalendarItemCreateOrDeleteOperation.java new file mode 100644 index 00000000..ffd4efd5 --- /dev/null +++ b/src/java/davmail/exchange/ews/CalendarItemCreateOrDeleteOperation.java @@ -0,0 +1,32 @@ +/* + * DavMail POP/IMAP/SMTP/CalDav/LDAP Exchange Gateway + * Copyright (C) 2010 Mickael Guessant + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package davmail.exchange.ews; + +/** + * Item update option. + */ +public class CalendarItemCreateOrDeleteOperation extends AttributeOption { + private CalendarItemCreateOrDeleteOperation(String value) { + super("SendMeetingInvitationsOrCancellations", value); + } + + public static final CalendarItemCreateOrDeleteOperation SendToNone = new CalendarItemCreateOrDeleteOperation("SendToNone"); + public static final CalendarItemCreateOrDeleteOperation SendOnlyToAll = new CalendarItemCreateOrDeleteOperation("SendOnlyToAll"); + public static final CalendarItemCreateOrDeleteOperation SendToAllAndSaveCopy = new CalendarItemCreateOrDeleteOperation("SendToAllAndSaveCopy"); +} diff --git a/src/java/davmail/exchange/ews/CopyItemMethod.java b/src/java/davmail/exchange/ews/CopyItemMethod.java new file mode 100644 index 00000000..84d031b0 --- /dev/null +++ b/src/java/davmail/exchange/ews/CopyItemMethod.java @@ -0,0 +1,30 @@ +/* + * DavMail POP/IMAP/SMTP/CalDav/LDAP Exchange Gateway + * Copyright (C) 2010 Mickael Guessant + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package davmail.exchange.ews; + +/** + * Copy item to another folder. + */ +public class CopyItemMethod extends EWSMethod { + public CopyItemMethod(ItemId itemId, FolderId toFolderId) { + super("Item", "CopyItem"); + this.itemId = itemId; + this.toFolderId = toFolderId; + } +} diff --git a/src/java/davmail/exchange/ews/EWSMethod.java b/src/java/davmail/exchange/ews/EWSMethod.java index 4497fa8a..3a676fa4 100644 --- a/src/java/davmail/exchange/ews/EWSMethod.java +++ b/src/java/davmail/exchange/ews/EWSMethod.java @@ -300,9 +300,9 @@ public abstract class EWSMethod extends PostMethod { startChanges(writer); writeShape(writer); writeRestriction(writer); - writeItemId(writer); writeParentFolderId(writer); writeToFolderId(writer); + writeItemId(writer); writeFolderId(writer); writeSavedItemFolderId(writer); writeItem(writer); diff --git a/src/java/davmail/exchange/ews/EwsExchangeSession.java b/src/java/davmail/exchange/ews/EwsExchangeSession.java index 4b7dc2a9..a5d549fe 100644 --- a/src/java/davmail/exchange/ews/EwsExchangeSession.java +++ b/src/java/davmail/exchange/ews/EwsExchangeSession.java @@ -183,7 +183,10 @@ public class EwsExchangeSession extends ExchangeSession { ItemId itemId = new ItemId(createItemMethod.getResponseItem().get("ItemId"), createItemMethod.getResponseItem().get("ChangeKey")); HashMap localProperties = new HashMap(); localProperties.put("bcc", bcc); - UpdateItemMethod updateItemMethod = new UpdateItemMethod(MessageDisposition.SaveOnly, ConflictResolution.AlwaysOverwrite, itemId, buildProperties(localProperties)); + UpdateItemMethod updateItemMethod = new UpdateItemMethod(MessageDisposition.SaveOnly, + ConflictResolution.AlwaysOverwrite, + CalendarItemCreateOrDeleteOperation.SendToNone, + itemId, buildProperties(localProperties)); executeMethod(updateItemMethod); } @@ -191,7 +194,10 @@ public class EwsExchangeSession extends ExchangeSession { @Override public void updateMessage(ExchangeSession.Message message, Map properties) throws IOException { - UpdateItemMethod updateItemMethod = new UpdateItemMethod(MessageDisposition.SaveOnly, ConflictResolution.AlwaysOverwrite, ((EwsExchangeSession.Message) message).itemId, buildProperties(properties)); + UpdateItemMethod updateItemMethod = new UpdateItemMethod(MessageDisposition.SaveOnly, + ConflictResolution.AlwaysOverwrite, + CalendarItemCreateOrDeleteOperation.SendToNone, + ((EwsExchangeSession.Message) message).itemId, buildProperties(properties)); executeMethod(updateItemMethod); } @@ -588,7 +594,8 @@ public class EwsExchangeSession extends ExchangeSession { */ @Override public void copyMessage(ExchangeSession.Message message, String targetFolder) throws IOException { - throw new UnsupportedOperationException(); + CopyItemMethod copyItemMethod = new CopyItemMethod(((EwsExchangeSession.Message) message).itemId, getFolderId(targetFolder)); + executeMethod(copyItemMethod); } /** diff --git a/src/java/davmail/exchange/ews/UpdateItemMethod.java b/src/java/davmail/exchange/ews/UpdateItemMethod.java index 50097868..94ef19f9 100644 --- a/src/java/davmail/exchange/ews/UpdateItemMethod.java +++ b/src/java/davmail/exchange/ews/UpdateItemMethod.java @@ -24,11 +24,14 @@ import java.util.Set; * Uµpdate Item method. */ public class UpdateItemMethod extends EWSMethod { - public UpdateItemMethod(MessageDisposition messageDisposition, ConflictResolution conflictResolution, ItemId itemId, Set updates) { + public UpdateItemMethod(MessageDisposition messageDisposition, ConflictResolution conflictResolution, + CalendarItemCreateOrDeleteOperation calendarItemCreateOrDeleteOperation, + ItemId itemId, Set updates) { super("Item", "UpdateItem"); this.itemId = itemId; this.updates = updates; addMethodOption(messageDisposition); addMethodOption(conflictResolution); + addMethodOption(calendarItemCreateOrDeleteOperation); } } \ No newline at end of file diff --git a/src/test/davmail/AbstractDavMailTestCase.java b/src/test/davmail/AbstractDavMailTestCase.java index 15a93416..7a9f2da9 100644 --- a/src/test/davmail/AbstractDavMailTestCase.java +++ b/src/test/davmail/AbstractDavMailTestCase.java @@ -21,6 +21,7 @@ package davmail; import davmail.exchange.ExchangeSession; import davmail.http.DavGatewaySSLProtocolSocketFactory; import junit.framework.TestCase; +import org.apache.log4j.Level; import java.io.File; import java.io.IOException; @@ -64,9 +65,9 @@ public class AbstractDavMailTestCase extends TestCase { Settings.setProperty("davmail.server", "true"); // enable WIRE debug log - //Settings.setLoggingLevel("httpclient.wire", Level.DEBUG); + // Settings.setLoggingLevel("httpclient.wire", Level.DEBUG); // enable EWS support - //Settings.setProperty("davmail.enableEws", "true"); + Settings.setProperty("davmail.enableEws", "true"); } }