1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-14 11:42:23 -05:00

EWS: implement copy method

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1130 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-07-05 15:03:35 +00:00
parent f27a979fee
commit 6ed9845497
6 changed files with 80 additions and 7 deletions

View File

@ -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");
}

View File

@ -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;
}
}

View File

@ -300,9 +300,9 @@ public abstract class EWSMethod extends PostMethod {
startChanges(writer); startChanges(writer);
writeShape(writer); writeShape(writer);
writeRestriction(writer); writeRestriction(writer);
writeItemId(writer);
writeParentFolderId(writer); writeParentFolderId(writer);
writeToFolderId(writer); writeToFolderId(writer);
writeItemId(writer);
writeFolderId(writer); writeFolderId(writer);
writeSavedItemFolderId(writer); writeSavedItemFolderId(writer);
writeItem(writer); writeItem(writer);

View File

@ -183,7 +183,10 @@ public class EwsExchangeSession extends ExchangeSession {
ItemId itemId = new ItemId(createItemMethod.getResponseItem().get("ItemId"), createItemMethod.getResponseItem().get("ChangeKey")); ItemId itemId = new ItemId(createItemMethod.getResponseItem().get("ItemId"), createItemMethod.getResponseItem().get("ChangeKey"));
HashMap<String, String> localProperties = new HashMap<String, String>(); HashMap<String, String> localProperties = new HashMap<String, String>();
localProperties.put("bcc", bcc); 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); executeMethod(updateItemMethod);
} }
@ -191,7 +194,10 @@ 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, 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); executeMethod(updateItemMethod);
} }
@ -588,7 +594,8 @@ public class EwsExchangeSession extends ExchangeSession {
*/ */
@Override @Override
public void copyMessage(ExchangeSession.Message message, String targetFolder) throws IOException { 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);
} }
/** /**

View File

@ -24,11 +24,14 @@ import java.util.Set;
* Uµpdate Item method. * Uµpdate Item method.
*/ */
public class UpdateItemMethod extends EWSMethod { public class UpdateItemMethod extends EWSMethod {
public UpdateItemMethod(MessageDisposition messageDisposition, ConflictResolution conflictResolution, ItemId itemId, Set<FieldUpdate> updates) { public UpdateItemMethod(MessageDisposition messageDisposition, ConflictResolution conflictResolution,
CalendarItemCreateOrDeleteOperation calendarItemCreateOrDeleteOperation,
ItemId itemId, Set<FieldUpdate> updates) {
super("Item", "UpdateItem"); super("Item", "UpdateItem");
this.itemId = itemId; this.itemId = itemId;
this.updates = updates; this.updates = updates;
addMethodOption(messageDisposition); addMethodOption(messageDisposition);
addMethodOption(conflictResolution); addMethodOption(conflictResolution);
addMethodOption(calendarItemCreateOrDeleteOperation);
} }
} }

View File

@ -21,6 +21,7 @@ package davmail;
import davmail.exchange.ExchangeSession; import davmail.exchange.ExchangeSession;
import davmail.http.DavGatewaySSLProtocolSocketFactory; import davmail.http.DavGatewaySSLProtocolSocketFactory;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.log4j.Level;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -64,9 +65,9 @@ public class AbstractDavMailTestCase extends TestCase {
Settings.setProperty("davmail.server", "true"); Settings.setProperty("davmail.server", "true");
// enable WIRE debug log // enable WIRE debug log
//Settings.setLoggingLevel("httpclient.wire", Level.DEBUG); // Settings.setLoggingLevel("httpclient.wire", Level.DEBUG);
// enable EWS support // enable EWS support
//Settings.setProperty("davmail.enableEws", "true"); Settings.setProperty("davmail.enableEws", "true");
} }
} }