mirror of
https://github.com/moparisthebest/davmail
synced 2025-02-28 17:31:52 -05:00
EWS: Implement CreateFolder, DeleteFolder and CreateItem, refactor options
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1062 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
b81fa5331a
commit
c32f615222
@ -22,19 +22,23 @@ import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
/**
|
||||
* Folder Id.
|
||||
* Generic attribute option.
|
||||
*/
|
||||
public class FolderIdType {
|
||||
protected final String value;
|
||||
public abstract class AttributeOption extends Option {
|
||||
|
||||
public FolderIdType(String value) {
|
||||
this.value = value;
|
||||
protected AttributeOption(String name, String value) {
|
||||
super(name, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public void write(Writer writer) throws IOException {
|
||||
writer.write("<t:FolderId Id=\"");
|
||||
writer.write(" ");
|
||||
writer.write(name);
|
||||
writer.write("=\"");
|
||||
writer.write(value);
|
||||
writer.write("\"/>");
|
||||
writer.write("\"");
|
||||
}
|
||||
|
||||
}
|
44
src/java/davmail/exchange/ews/BaseShape.java
Normal file
44
src/java/davmail/exchange/ews/BaseShape.java
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
/**
|
||||
* Item or folder base shape.
|
||||
*/
|
||||
public final class BaseShape extends ElementOption {
|
||||
private BaseShape(String value) {
|
||||
super("t:BaseShape", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return id only.
|
||||
*/
|
||||
public static final BaseShape ID_ONLY = new BaseShape("IdOnly");
|
||||
/**
|
||||
* Return default properties.
|
||||
*/
|
||||
public static final BaseShape DEFAULT = new BaseShape("Default");
|
||||
/**
|
||||
* Return all properties, except MAPI extended properties.
|
||||
*/
|
||||
public static final BaseShape ALL_PROPERTIES = new BaseShape("AllProperties");
|
||||
}
|
30
src/java/davmail/exchange/ews/CreateFolderMethod.java
Normal file
30
src/java/davmail/exchange/ews/CreateFolderMethod.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;
|
||||
|
||||
/**
|
||||
* Create Folder method.
|
||||
*/
|
||||
public class CreateFolderMethod extends EWSMethod {
|
||||
public CreateFolderMethod(FolderId parentFolderId, Item item) {
|
||||
super("Folder", "CreateFolder");
|
||||
this.parentFolderId = parentFolderId;
|
||||
this.item = item;
|
||||
}
|
||||
}
|
30
src/java/davmail/exchange/ews/CreateItemMethod.java
Normal file
30
src/java/davmail/exchange/ews/CreateItemMethod.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;
|
||||
|
||||
/**
|
||||
* Create Item method.
|
||||
*/
|
||||
public class CreateItemMethod extends EWSMethod {
|
||||
public CreateItemMethod(FolderId parentFolderId, EWSMethod.Item item) {
|
||||
super("Folder", "CreateFolder");
|
||||
this.parentFolderId = parentFolderId;
|
||||
this.item = item;
|
||||
}
|
||||
}
|
30
src/java/davmail/exchange/ews/DeleteFolderMethod.java
Normal file
30
src/java/davmail/exchange/ews/DeleteFolderMethod.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;
|
||||
|
||||
/**
|
||||
* Delete Folder method.
|
||||
*/
|
||||
public class DeleteFolderMethod extends EWSMethod {
|
||||
public DeleteFolderMethod(FolderId folderId) {
|
||||
super("Folder", "DeleteFolder");
|
||||
this.folderId = folderId;
|
||||
this.deleteType = Disposal.HARD_DELETE;
|
||||
}
|
||||
}
|
@ -22,7 +22,7 @@ package davmail.exchange.ews;
|
||||
* Delete Item method.
|
||||
*/
|
||||
public class DeleteItemMethod extends EWSMethod {
|
||||
public DeleteItemMethod(FolderIdType folderId, ItemIdType itemId) {
|
||||
public DeleteItemMethod(FolderId folderId, ItemId itemId) {
|
||||
super("Item", "DeleteItem");
|
||||
this.folderId = folderId;
|
||||
this.itemId = itemId;
|
||||
|
35
src/java/davmail/exchange/ews/Disposal.java
Normal file
35
src/java/davmail/exchange/ews/Disposal.java
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
/**
|
||||
* Disposal.
|
||||
*/
|
||||
public class Disposal extends AttributeOption {
|
||||
private Disposal(String value) {
|
||||
super("DeleteType", value);
|
||||
}
|
||||
|
||||
public static final Disposal HARD_DELETE = new Disposal("HardDelete");
|
||||
public static final Disposal SOFT_DELETE = new Disposal("SoftDelete");
|
||||
public static final Disposal MOVE_TO_DELETED_ITEMS = new Disposal("MoveToDeletedItems");
|
||||
}
|
47
src/java/davmail/exchange/ews/DistinguishedFolderId.java
Normal file
47
src/java/davmail/exchange/ews/DistinguishedFolderId.java
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Distinguished Folder Id.
|
||||
*/
|
||||
public class DistinguishedFolderId extends FolderId {
|
||||
|
||||
private DistinguishedFolderId(String value) {
|
||||
super("t:DistinguishedFolderId", value);
|
||||
}
|
||||
|
||||
public static final DistinguishedFolderId CALENDAR = new DistinguishedFolderId("calendar");
|
||||
public static final DistinguishedFolderId CONTACTS = new DistinguishedFolderId("contacts");
|
||||
public static final DistinguishedFolderId DELETEDITEMS = new DistinguishedFolderId("deleteditems");
|
||||
public static final DistinguishedFolderId DRAFTS = new DistinguishedFolderId("drafts");
|
||||
public static final DistinguishedFolderId INBOX = new DistinguishedFolderId("inbox");
|
||||
public static final DistinguishedFolderId JOURNAL = new DistinguishedFolderId("journal");
|
||||
public static final DistinguishedFolderId NOTES = new DistinguishedFolderId("notes");
|
||||
public static final DistinguishedFolderId OUTBOX = new DistinguishedFolderId("outbox");
|
||||
public static final DistinguishedFolderId SENTITEMS = new DistinguishedFolderId("sentitems");
|
||||
public static final DistinguishedFolderId TASKS = new DistinguishedFolderId("tasks");
|
||||
public static final DistinguishedFolderId MSGFOLDERROOT = new DistinguishedFolderId("msgfolderroot");
|
||||
public static final DistinguishedFolderId PUBLICFOLDERSROOT = new DistinguishedFolderId("publicfoldersroot");
|
||||
public static final DistinguishedFolderId ROOT = new DistinguishedFolderId("root");
|
||||
public static final DistinguishedFolderId JUNKEMAIL = new DistinguishedFolderId("junkemail");
|
||||
public static final DistinguishedFolderId SEARCHFOLDERS = new DistinguishedFolderId("searchfolders");
|
||||
public static final DistinguishedFolderId VOICEMAIL = new DistinguishedFolderId("voicemail");
|
||||
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
public class DistinguishedFolderIdType extends FolderIdType {
|
||||
|
||||
private DistinguishedFolderIdType(String value) {
|
||||
super(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(Writer writer) throws IOException {
|
||||
writer.write("<t:DistinguishedFolderId Id=\"");
|
||||
writer.write(value);
|
||||
writer.write("\"/>");
|
||||
}
|
||||
|
||||
public static final DistinguishedFolderIdType calendar = new DistinguishedFolderIdType("calendar");
|
||||
public static final DistinguishedFolderIdType contacts = new DistinguishedFolderIdType("contacts");
|
||||
public static final DistinguishedFolderIdType deleteditems = new DistinguishedFolderIdType("deleteditems");
|
||||
public static final DistinguishedFolderIdType drafts = new DistinguishedFolderIdType("drafts");
|
||||
public static final DistinguishedFolderIdType inbox = new DistinguishedFolderIdType("inbox");
|
||||
public static final DistinguishedFolderIdType journal = new DistinguishedFolderIdType("journal");
|
||||
public static final DistinguishedFolderIdType notes = new DistinguishedFolderIdType("notes");
|
||||
public static final DistinguishedFolderIdType outbox = new DistinguishedFolderIdType("outbox");
|
||||
public static final DistinguishedFolderIdType sentitems = new DistinguishedFolderIdType("sentitems");
|
||||
public static final DistinguishedFolderIdType tasks = new DistinguishedFolderIdType("tasks");
|
||||
public static final DistinguishedFolderIdType msgfolderroot = new DistinguishedFolderIdType("msgfolderroot");
|
||||
public static final DistinguishedFolderIdType publicfoldersroot = new DistinguishedFolderIdType("publicfoldersroot");
|
||||
public static final DistinguishedFolderIdType root = new DistinguishedFolderIdType("root");
|
||||
public static final DistinguishedFolderIdType junkemail = new DistinguishedFolderIdType("junkemail");
|
||||
public static final DistinguishedFolderIdType searchfolders = new DistinguishedFolderIdType("searchfolders");
|
||||
public static final DistinguishedFolderIdType voicemail = new DistinguishedFolderIdType("voicemail");
|
||||
|
||||
}
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
package davmail.exchange.ews;
|
||||
|
||||
import com.wutka.dtd.DTDOutput;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.httpclient.Header;
|
||||
import org.apache.commons.httpclient.HttpConnection;
|
||||
@ -31,10 +32,7 @@ import javax.xml.stream.XMLStreamConstants;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* EWS SOAP method.
|
||||
@ -42,13 +40,14 @@ import java.util.List;
|
||||
public abstract class EWSMethod extends PostMethod {
|
||||
protected static final Logger logger = Logger.getLogger(EWSMethod.class);
|
||||
|
||||
protected FolderQueryTraversalType traversal;
|
||||
protected BaseShapeType baseShape;
|
||||
protected FolderQueryTraversal traversal;
|
||||
protected BaseShape baseShape;
|
||||
protected boolean includeMimeContent;
|
||||
protected FolderIdType folderId;
|
||||
protected FolderIdType parentFolderId;
|
||||
protected ItemIdType itemId;
|
||||
protected FolderId folderId;
|
||||
protected FolderId parentFolderId;
|
||||
protected ItemId itemId;
|
||||
protected HashSet<FieldURI> additionalProperties;
|
||||
protected Disposal deleteType;
|
||||
|
||||
protected final String itemType;
|
||||
protected final String methodName;
|
||||
@ -57,6 +56,7 @@ public abstract class EWSMethod extends PostMethod {
|
||||
protected byte[] mimeContent;
|
||||
protected List<Item> responseItems;
|
||||
protected String errorDetail;
|
||||
protected Item item;
|
||||
|
||||
/**
|
||||
* Build EWS method
|
||||
@ -99,15 +99,15 @@ public abstract class EWSMethod extends PostMethod {
|
||||
return "POST";
|
||||
}
|
||||
|
||||
protected void setBaseShape(BaseShapeType baseShapeType) {
|
||||
this.baseShape = baseShapeType;
|
||||
protected void setBaseShape(BaseShape baseShape) {
|
||||
this.baseShape = baseShape;
|
||||
}
|
||||
|
||||
protected void setFolderId(FolderIdType folderId) {
|
||||
protected void setFolderId(FolderId folderId) {
|
||||
this.folderId = folderId;
|
||||
}
|
||||
|
||||
protected void setParentFolderId(FolderIdType folderId) {
|
||||
protected void setParentFolderId(FolderId folderId) {
|
||||
this.parentFolderId = folderId;
|
||||
}
|
||||
|
||||
@ -158,9 +158,21 @@ public abstract class EWSMethod extends PostMethod {
|
||||
|
||||
protected void writeParentFolderId(Writer writer) throws IOException {
|
||||
if (parentFolderId != null) {
|
||||
writer.write("<m:ParentFolderIds>");
|
||||
writer.write("<m:ParentFolderId");if (item == null) {writer.write("s");}writer.write(">");
|
||||
parentFolderId.write(writer);
|
||||
writer.write("</m:ParentFolderIds>");
|
||||
writer.write("</m:ParentFolderId");if (item == null) {writer.write("s");}writer.write(">");
|
||||
}
|
||||
}
|
||||
|
||||
protected void writeItem(Writer writer) throws IOException {
|
||||
if (item != null) {
|
||||
writer.write("<m:");
|
||||
writer.write(itemType);
|
||||
writer.write("s>");
|
||||
item.write(writer);
|
||||
writer.write("</m:");
|
||||
writer.write(itemType);
|
||||
writer.write("s>");
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,6 +189,9 @@ public abstract class EWSMethod extends PostMethod {
|
||||
if (traversal != null) {
|
||||
traversal.write(writer);
|
||||
}
|
||||
if (deleteType != null) {
|
||||
deleteType.write(writer);
|
||||
}
|
||||
writer.write(">");
|
||||
writeSoapBody(writer);
|
||||
writer.write("</m:");
|
||||
@ -196,6 +211,7 @@ public abstract class EWSMethod extends PostMethod {
|
||||
writeItemId(writer);
|
||||
writeParentFolderId(writer);
|
||||
writeFolderId(writer);
|
||||
writeItem(writer);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -210,13 +226,37 @@ public abstract class EWSMethod extends PostMethod {
|
||||
return inputFactory;
|
||||
}
|
||||
|
||||
class Item extends HashMap<String, String> {
|
||||
public static class Item extends HashMap<String, String> {
|
||||
public String type;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "type: " + type + ' ' + super.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write XML content to writer.
|
||||
*
|
||||
* @param writer writer
|
||||
* @throws IOException on error
|
||||
*/
|
||||
public void write(Writer writer) throws IOException {
|
||||
writer.write("<t:");
|
||||
writer.write(type);
|
||||
writer.write(">");
|
||||
for (Map.Entry<String, String> mapEntry : this.entrySet()) {
|
||||
writer.write("<t:");
|
||||
writer.write(mapEntry.getKey());
|
||||
writer.write(">");
|
||||
writer.write(mapEntry.getValue());
|
||||
writer.write("</t:");
|
||||
writer.write(mapEntry.getKey());
|
||||
writer.write(">");
|
||||
}
|
||||
writer.write("</t:");
|
||||
writer.write(type);
|
||||
writer.write(">");
|
||||
}
|
||||
}
|
||||
|
||||
public List<Item> getResponseItems() {
|
||||
@ -252,12 +292,11 @@ public abstract class EWSMethod extends PostMethod {
|
||||
|
||||
protected void handleErrors(XMLStreamReader reader) throws XMLStreamException {
|
||||
String result = handleTag(reader, "ResponseCode");
|
||||
if (result != null && !"NoError".equals(result)) {
|
||||
if (errorDetail == null && result != null && !"NoError".equals(result)) {
|
||||
errorDetail = result;
|
||||
}
|
||||
result = handleTag(reader, "faultstring");
|
||||
if (result != null) {
|
||||
errorDetail = result;
|
||||
if (isStartTag(reader, "faultstring")) {
|
||||
errorDetail = reader.getElementText();
|
||||
}
|
||||
}
|
||||
|
||||
|
51
src/java/davmail/exchange/ews/ElementOption.java
Normal file
51
src/java/davmail/exchange/ews/ElementOption.java
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
/**
|
||||
* Generic element option.
|
||||
*/
|
||||
public class ElementOption extends Option {
|
||||
/**
|
||||
* Create element option.
|
||||
*
|
||||
* @param name element tag name
|
||||
* @param value element value
|
||||
*/
|
||||
protected ElementOption(String name, String value) {
|
||||
super(name, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public void write(Writer writer) throws IOException {
|
||||
writer.write('<');
|
||||
writer.write(name);
|
||||
writer.write('>');
|
||||
writer.write(value);
|
||||
writer.write("</");
|
||||
writer.write(name);
|
||||
writer.write('>');
|
||||
}
|
||||
}
|
@ -48,5 +48,7 @@ public class ExtendedFieldURI implements FieldURI {
|
||||
public static final ExtendedFieldURI PR_FLAG_STATUS = new ExtendedFieldURI("0x1090", "Integer");
|
||||
public static final ExtendedFieldURI PR_MESSAGE_FLAGS = new ExtendedFieldURI("0x0E07", "Integer");
|
||||
public static final ExtendedFieldURI PR_ACTION_FLAG = new ExtendedFieldURI("0x1081", "Integer");
|
||||
public static final ExtendedFieldURI PR_URL_COMP_NAME = new ExtendedFieldURI("0x10F3", "String");
|
||||
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ package davmail.exchange.ews;
|
||||
*/
|
||||
public class FindFolderMethod extends EWSMethod {
|
||||
|
||||
public FindFolderMethod(FolderQueryTraversalType traversal, BaseShapeType baseShape, FolderIdType parentFolderId) {
|
||||
public FindFolderMethod(FolderQueryTraversal traversal, BaseShape baseShape, FolderId parentFolderId) {
|
||||
super("Folder", "FindFolder");
|
||||
this.traversal = traversal;
|
||||
this.baseShape = baseShape;
|
||||
|
@ -18,14 +18,11 @@
|
||||
*/
|
||||
package davmail.exchange.ews;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
/**
|
||||
* EWS Find Item Method.
|
||||
*/
|
||||
public class FindItemMethod extends EWSMethod {
|
||||
public FindItemMethod(FolderQueryTraversalType traversal, BaseShapeType baseShape, FolderIdType parentFolderId) {
|
||||
public FindItemMethod(FolderQueryTraversal traversal, BaseShape baseShape, FolderId parentFolderId) {
|
||||
super("Item", "FindItem");
|
||||
this.traversal = traversal;
|
||||
this.baseShape = baseShape;
|
||||
|
54
src/java/davmail/exchange/ews/FolderId.java
Normal file
54
src/java/davmail/exchange/ews/FolderId.java
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
/**
|
||||
* Folder Id.
|
||||
*/
|
||||
public class FolderId extends Option {
|
||||
|
||||
protected FolderId(String name, String value) {
|
||||
super(name, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create FolderId option
|
||||
*
|
||||
* @param value id value
|
||||
*/
|
||||
public FolderId(String value) {
|
||||
super("t:FolderId", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public void write(Writer writer) throws IOException {
|
||||
writer.write('<');
|
||||
writer.write(name);
|
||||
writer.write(" Id=\"");
|
||||
writer.write(value);
|
||||
writer.write("\"/>");
|
||||
}
|
||||
|
||||
}
|
@ -24,10 +24,10 @@ import java.io.Writer;
|
||||
/**
|
||||
* Folder folderQueryTraversalType search mode.
|
||||
*/
|
||||
public final class FolderQueryTraversalType {
|
||||
public final class FolderQueryTraversal {
|
||||
private final String value;
|
||||
|
||||
private FolderQueryTraversalType(String value) {
|
||||
private FolderQueryTraversal(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@ -46,9 +46,9 @@ public final class FolderQueryTraversalType {
|
||||
/**
|
||||
* Search only in current folder.
|
||||
*/
|
||||
public static final FolderQueryTraversalType Shallow = new FolderQueryTraversalType("Shallow");
|
||||
public static final FolderQueryTraversal SHALLOW = new FolderQueryTraversal("Shallow");
|
||||
/**
|
||||
* Recursive search.
|
||||
*/
|
||||
public static final FolderQueryTraversalType Deep = new FolderQueryTraversalType("Deep");
|
||||
public static final FolderQueryTraversal DEEP = new FolderQueryTraversal("Deep");
|
||||
}
|
@ -23,7 +23,7 @@ package davmail.exchange.ews;
|
||||
*/
|
||||
public class GetFolderMethod extends EWSMethod {
|
||||
|
||||
public GetFolderMethod(BaseShapeType baseShape, FolderIdType folderId) {
|
||||
public GetFolderMethod(BaseShape baseShape, FolderId folderId) {
|
||||
super("Folder", "GetFolder");
|
||||
this.baseShape = baseShape;
|
||||
this.folderId = folderId;
|
||||
|
@ -22,7 +22,7 @@ package davmail.exchange.ews;
|
||||
* Get Item method.
|
||||
*/
|
||||
public class GetItemMethod extends EWSMethod {
|
||||
public GetItemMethod(BaseShapeType baseShape, ItemIdType itemId, boolean includeMimeContent) {
|
||||
public GetItemMethod(BaseShape baseShape, ItemId itemId, boolean includeMimeContent) {
|
||||
super("Item", "GetItem");
|
||||
this.baseShape = baseShape;
|
||||
this.itemId = itemId;
|
||||
|
@ -24,7 +24,7 @@ import java.io.Writer;
|
||||
/**
|
||||
* Item id.
|
||||
*/
|
||||
public class ItemIdType {
|
||||
public class ItemId {
|
||||
protected final String id;
|
||||
protected String changeKey;
|
||||
|
||||
@ -34,7 +34,7 @@ public class ItemIdType {
|
||||
* @param id item id
|
||||
* @param changeKey item change key
|
||||
*/
|
||||
public ItemIdType(String id, String changeKey) {
|
||||
public ItemId(String id, String changeKey) {
|
||||
this.id = id;
|
||||
this.changeKey = changeKey;
|
||||
}
|
||||
@ -44,7 +44,7 @@ public class ItemIdType {
|
||||
*
|
||||
* @param id item id
|
||||
*/
|
||||
public ItemIdType(String id) {
|
||||
public ItemId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
@ -22,12 +22,12 @@ import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
/**
|
||||
* Item or folder base shape.
|
||||
* MessageDisposition flag.
|
||||
*/
|
||||
public final class BaseShapeType {
|
||||
public class MessageDisposition {
|
||||
private final String value;
|
||||
|
||||
private BaseShapeType(String value) {
|
||||
private MessageDisposition(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@ -35,24 +35,15 @@ public final class BaseShapeType {
|
||||
* Write XML content to writer.
|
||||
*
|
||||
* @param writer writer
|
||||
* @throws IOException on error
|
||||
* @throws java.io.IOException on error
|
||||
*/
|
||||
public void write(Writer writer) throws IOException {
|
||||
writer.write("<t:BaseShape>");
|
||||
writer.write(" MessageDisposition=\"");
|
||||
writer.write(value);
|
||||
writer.write("</t:BaseShape>");
|
||||
writer.write("\"");
|
||||
}
|
||||
|
||||
/**
|
||||
* Return id only.
|
||||
*/
|
||||
public static final BaseShapeType IdOnly = new BaseShapeType("IdOnly");
|
||||
/**
|
||||
* Return default properties.
|
||||
*/
|
||||
public static final BaseShapeType Default = new BaseShapeType("Default");
|
||||
/**
|
||||
* Return all properties, except MAPI extended properties.
|
||||
*/
|
||||
public static final BaseShapeType AllProperties = new BaseShapeType("AllProperties");
|
||||
}
|
||||
public static final MessageDisposition SaveOnly = new MessageDisposition("SaveOnly");
|
||||
public static final MessageDisposition SendOnly = new MessageDisposition("SendOnly");
|
||||
public static final MessageDisposition SendAndSaveCopy = new MessageDisposition("SendAndSaveCopy");
|
||||
}
|
44
src/java/davmail/exchange/ews/Option.java
Normal file
44
src/java/davmail/exchange/ews/Option.java
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
/**
|
||||
* Generic option.
|
||||
*/
|
||||
public abstract class Option {
|
||||
protected final String name;
|
||||
protected final String value;
|
||||
|
||||
protected Option(String name, String value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write XML content to writer.
|
||||
*
|
||||
* @param writer writer
|
||||
* @throws IOException on error
|
||||
*/
|
||||
public abstract void write(Writer writer) throws IOException;
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user