mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-13 19:22:22 -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:
parent
f27a979fee
commit
6ed9845497
@ -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");
|
||||
}
|
30
src/java/davmail/exchange/ews/CopyItemMethod.java
Normal file
30
src/java/davmail/exchange/ews/CopyItemMethod.java
Normal 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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
@ -183,7 +183,10 @@ public class EwsExchangeSession extends ExchangeSession {
|
||||
ItemId itemId = new ItemId(createItemMethod.getResponseItem().get("ItemId"), createItemMethod.getResponseItem().get("ChangeKey"));
|
||||
HashMap<String, String> localProperties = new HashMap<String, String>();
|
||||
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<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);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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<FieldUpdate> updates) {
|
||||
public UpdateItemMethod(MessageDisposition messageDisposition, ConflictResolution conflictResolution,
|
||||
CalendarItemCreateOrDeleteOperation calendarItemCreateOrDeleteOperation,
|
||||
ItemId itemId, Set<FieldUpdate> updates) {
|
||||
super("Item", "UpdateItem");
|
||||
this.itemId = itemId;
|
||||
this.updates = updates;
|
||||
addMethodOption(messageDisposition);
|
||||
addMethodOption(conflictResolution);
|
||||
addMethodOption(calendarItemCreateOrDeleteOperation);
|
||||
}
|
||||
}
|
@ -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");
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user