1
0
mirror of https://github.com/moparisthebest/davmail synced 2025-01-07 11:48:02 -05:00

EWS: fixes from audit

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1166 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-07-11 00:13:28 +00:00
parent 72e57df57a
commit dcf3232161
34 changed files with 246 additions and 107 deletions

View File

@ -30,11 +30,13 @@ public abstract class AttributeOption extends Option {
super(name, value); super(name, value);
} }
/**
* @inheritDoc
*/
public void appendTo(StringBuilder buffer) { public void appendTo(StringBuilder buffer) {
buffer.append(' ').append(name).append("=\"").append(value).append('"'); buffer.append(' ').append(name).append("=\"").append(value).append('"');
} }
/** /**
* @inheritDoc * @inheritDoc
*/ */

View File

@ -18,9 +18,6 @@
*/ */
package davmail.exchange.ews; package davmail.exchange.ews;
import java.io.IOException;
import java.io.Writer;
/** /**
* Item or folder base shape. * Item or folder base shape.
*/ */

View File

@ -22,7 +22,7 @@ package davmail.exchange.ews;
* Contains comparison mode. * Contains comparison mode.
*/ */
public class ContainmentComparison extends AttributeOption { public class ContainmentComparison extends AttributeOption {
private ContainmentComparison(String value) { private ContainmentComparison(String value) {
super("ContainmentComparison", value); super("ContainmentComparison", value);
} }

View File

@ -34,7 +34,9 @@ public class ContainmentMode extends AttributeOption {
* Starts with. * Starts with.
*/ */
public static final ContainmentMode Prefixed = new ContainmentMode("Prefixed"); public static final ContainmentMode Prefixed = new ContainmentMode("Prefixed");
/**
* Contains
*/
public static final ContainmentMode Substring = new ContainmentMode("Substring"); public static final ContainmentMode Substring = new ContainmentMode("Substring");
public static final ContainmentMode PrefixOnWords = new ContainmentMode("PrefixOnWords"); public static final ContainmentMode PrefixOnWords = new ContainmentMode("PrefixOnWords");
public static final ContainmentMode ExactPhrase = new ContainmentMode("ExactPhrase"); public static final ContainmentMode ExactPhrase = new ContainmentMode("ExactPhrase");

View File

@ -22,6 +22,12 @@ package davmail.exchange.ews;
* Copy item to another folder. * Copy item to another folder.
*/ */
public class CopyItemMethod extends EWSMethod { public class CopyItemMethod extends EWSMethod {
/**
* Copy item method.
*
* @param itemId item id
* @param toFolderId target folder id
*/
public CopyItemMethod(ItemId itemId, FolderId toFolderId) { public CopyItemMethod(ItemId itemId, FolderId toFolderId) {
super("Item", "CopyItem"); super("Item", "CopyItem");
this.itemId = itemId; this.itemId = itemId;

View File

@ -22,6 +22,12 @@ package davmail.exchange.ews;
* Create Folder method. * Create Folder method.
*/ */
public class CreateFolderMethod extends EWSMethod { public class CreateFolderMethod extends EWSMethod {
/**
* Update folder method.
*
* @param parentFolderId parent folder id
* @param item folder item
*/
public CreateFolderMethod(FolderId parentFolderId, Item item) { public CreateFolderMethod(FolderId parentFolderId, Item item) {
super("Folder", "CreateFolder"); super("Folder", "CreateFolder");
this.parentFolderId = parentFolderId; this.parentFolderId = parentFolderId;

View File

@ -22,6 +22,13 @@ package davmail.exchange.ews;
* Create Item method. * Create Item method.
*/ */
public class CreateItemMethod extends EWSMethod { public class CreateItemMethod extends EWSMethod {
/**
* Create exchange item.
*
* @param messageDisposition save or send option
* @param savedItemFolderId saved item folder id
* @param item item content
*/
public CreateItemMethod(MessageDisposition messageDisposition, FolderId savedItemFolderId, EWSMethod.Item item) { public CreateItemMethod(MessageDisposition messageDisposition, FolderId savedItemFolderId, EWSMethod.Item item) {
super("Item", "CreateItem"); super("Item", "CreateItem");
this.savedItemFolderId = savedItemFolderId; this.savedItemFolderId = savedItemFolderId;
@ -29,6 +36,14 @@ public class CreateItemMethod extends EWSMethod {
addMethodOption(messageDisposition); addMethodOption(messageDisposition);
} }
/**
* Create exchange item.
*
* @param messageDisposition save or send option
* @param sendMeetingInvitations send invitation option
* @param savedItemFolderId saved item folder id
* @param item item content
*/
public CreateItemMethod(MessageDisposition messageDisposition, SendMeetingInvitations sendMeetingInvitations, FolderId savedItemFolderId, EWSMethod.Item item) { public CreateItemMethod(MessageDisposition messageDisposition, SendMeetingInvitations sendMeetingInvitations, FolderId savedItemFolderId, EWSMethod.Item item) {
super("Item", "CreateItem"); super("Item", "CreateItem");
this.savedItemFolderId = savedItemFolderId; this.savedItemFolderId = savedItemFolderId;
@ -36,5 +51,5 @@ public class CreateItemMethod extends EWSMethod {
addMethodOption(messageDisposition); addMethodOption(messageDisposition);
addMethodOption(sendMeetingInvitations); addMethodOption(sendMeetingInvitations);
} }
} }

View File

@ -22,6 +22,11 @@ package davmail.exchange.ews;
* Delete Folder method. * Delete Folder method.
*/ */
public class DeleteFolderMethod extends EWSMethod { public class DeleteFolderMethod extends EWSMethod {
/**
* Delete folder method.
*
* @param folderId folder id
*/
public DeleteFolderMethod(FolderId folderId) { public DeleteFolderMethod(FolderId folderId) {
super("Folder", "DeleteFolder"); super("Folder", "DeleteFolder");
this.folderId = folderId; this.folderId = folderId;

View File

@ -22,6 +22,12 @@ package davmail.exchange.ews;
* Delete Item method. * Delete Item method.
*/ */
public class DeleteItemMethod extends EWSMethod { public class DeleteItemMethod extends EWSMethod {
/**
* Delete item method.
*
* @param itemId item id
* @param deleteType delete mode
*/
public DeleteItemMethod(ItemId itemId, DeleteType deleteType) { public DeleteItemMethod(ItemId itemId, DeleteType deleteType) {
super("Item", "DeleteItem"); super("Item", "DeleteItem");
addMethodOption(deleteType); addMethodOption(deleteType);

View File

@ -18,9 +18,6 @@
*/ */
package davmail.exchange.ews; package davmail.exchange.ews;
import java.io.IOException;
import java.io.Writer;
/** /**
* Disposal. * Disposal.
*/ */

View File

@ -66,6 +66,9 @@ public abstract class EWSMethod extends PostMethod {
/** /**
* Build EWS method * Build EWS method
*
* @param itemType item type
* @param methodName method name
*/ */
public EWSMethod(String itemType, String methodName) { public EWSMethod(String itemType, String methodName) {
super("/ews/exchange.asmx"); super("/ews/exchange.asmx");
@ -226,6 +229,7 @@ public abstract class EWSMethod extends PostMethod {
} }
protected void startChanges(Writer writer) throws IOException { protected void startChanges(Writer writer) throws IOException {
//noinspection VariableNotUsedInsideIf
if (updates != null) { if (updates != null) {
writer.write("<m:"); writer.write("<m:");
writer.write(itemType); writer.write(itemType);
@ -248,6 +252,7 @@ public abstract class EWSMethod extends PostMethod {
protected void endChanges(Writer writer) throws IOException { protected void endChanges(Writer writer) throws IOException {
//noinspection VariableNotUsedInsideIf
if (updates != null) { if (updates != null) {
writer.write("</t:"); writer.write("</t:");
writer.write(itemType); writer.write(itemType);
@ -322,7 +327,13 @@ public abstract class EWSMethod extends PostMethod {
return inputFactory; return inputFactory;
} }
/**
* Item
*/
public static class Item extends HashMap<String, String> { public static class Item extends HashMap<String, String> {
/**
* Item type.
*/
public String type; public String type;
protected byte[] mimeContent; protected byte[] mimeContent;
protected Set<FieldUpdate> fieldUpdates; protected Set<FieldUpdate> fieldUpdates;
@ -366,10 +377,21 @@ public abstract class EWSMethod extends PostMethod {
writer.write(">"); writer.write(">");
} }
/**
* Field updates.
*
* @param fieldUpdates field updates
*/
public void setFieldUpdates(Set<FieldUpdate> fieldUpdates) { public void setFieldUpdates(Set<FieldUpdate> fieldUpdates) {
this.fieldUpdates = fieldUpdates; this.fieldUpdates = fieldUpdates;
} }
/**
* Get property value as int
*
* @param key property response name
* @return property value
*/
public int getInt(String key) { public int getInt(String key) {
int result = 0; int result = 0;
String value = get(key); String value = get(key);
@ -379,6 +401,12 @@ public abstract class EWSMethod extends PostMethod {
return result; return result;
} }
/**
* Get property value as long
*
* @param key property response name
* @return property value
*/
public long getLong(String key) { public long getLong(String key) {
long result = 0; long result = 0;
String value = get(key); String value = get(key);
@ -389,6 +417,12 @@ public abstract class EWSMethod extends PostMethod {
} }
/**
* Get property value as boolean
*
* @param key property response name
* @return property value
*/
public boolean getBoolean(String key) { public boolean getBoolean(String key) {
boolean result = false; boolean result = false;
String value = get(key); String value = get(key);
@ -400,17 +434,34 @@ public abstract class EWSMethod extends PostMethod {
} }
/**
* Check method success.
*
* @throws EWSException on error
*/
public void checkSuccess() throws EWSException { public void checkSuccess() throws EWSException {
if (errorDetail != null) { if (errorDetail != null) {
throw new EWSException(errorDetail + "\n request: " + new String(generateSoapEnvelope())); throw new EWSException(errorDetail + "\n request: " + new String(generateSoapEnvelope()));
} }
} }
/**
* Get response items.
*
* @return response items
* @throws EWSException on error
*/
public List<Item> getResponseItems() throws EWSException { public List<Item> getResponseItems() throws EWSException {
checkSuccess(); checkSuccess();
return responseItems; return responseItems;
} }
/**
* Get single response item.
*
* @return response item
* @throws EWSException on error
*/
public Item getResponseItem() throws EWSException { public Item getResponseItem() throws EWSException {
checkSuccess(); checkSuccess();
if (responseItems != null && responseItems.size() == 1) { if (responseItems != null && responseItems.size() == 1) {
@ -420,6 +471,12 @@ public abstract class EWSMethod extends PostMethod {
} }
} }
/**
* Get response mime content.
*
* @return mime content
* @throws EWSException on error
*/
public byte[] getMimeContent() throws EWSException { public byte[] getMimeContent() throws EWSException {
checkSuccess(); checkSuccess();
Item responseItem = getResponseItem(); Item responseItem = getResponseItem();
@ -509,13 +566,13 @@ public abstract class EWSMethod extends PostMethod {
reader.next(); reader.next();
if (reader.getEventType() == XMLStreamConstants.START_ELEMENT) { if (reader.getEventType() == XMLStreamConstants.START_ELEMENT) {
String tagLocalName = reader.getLocalName(); String tagLocalName = reader.getLocalName();
if (tagLocalName.equals("ExtendedFieldURI")) { if ("ExtendedFieldURI".equals(tagLocalName)) {
propertyTag = getAttributeValue(reader, "PropertyTag"); propertyTag = getAttributeValue(reader, "PropertyTag");
// property name is in PropertyId with DistinguishedPropertySetId // property name is in PropertyId with DistinguishedPropertySetId
if (propertyTag == null) { if (propertyTag == null) {
propertyTag = getAttributeValue(reader, "PropertyId"); propertyTag = getAttributeValue(reader, "PropertyId");
} }
} else if (tagLocalName.equals("Value")) { } else if ("Value".equals(tagLocalName)) {
propertyValue = reader.getElementText(); propertyValue = reader.getElementText();
} }
} }
@ -555,7 +612,7 @@ public abstract class EWSMethod extends PostMethod {
Header contentTypeHeader = getResponseHeader("Content-Type"); Header contentTypeHeader = getResponseHeader("Content-Type");
if (contentTypeHeader != null && "text/xml; charset=utf-8".equals(contentTypeHeader.getValue())) { if (contentTypeHeader != null && "text/xml; charset=utf-8".equals(contentTypeHeader.getValue())) {
responseItems = new ArrayList<Item>(); responseItems = new ArrayList<Item>();
XMLStreamReader reader = null; XMLStreamReader reader;
try { try {
XMLInputFactory xmlInputFactory = getXmlInputFactory(); XMLInputFactory xmlInputFactory = getXmlInputFactory();
reader = xmlInputFactory.createXMLStreamReader(getResponseBodyAsStream()); reader = xmlInputFactory.createXMLStreamReader(getResponseBodyAsStream());

View File

@ -40,27 +40,42 @@ public class ExtendedFieldURI implements FieldURI {
protected int propertyId; protected int propertyId;
protected PropertyType propertyType; protected PropertyType propertyType;
/**
* Create extended field uri.
*
* @param intPropertyTag property tag as int
* @param propertyType property type
*/
public ExtendedFieldURI(int intPropertyTag, PropertyType propertyType) { public ExtendedFieldURI(int intPropertyTag, PropertyType propertyType) {
this.propertyTag = "0x" + Integer.toHexString(intPropertyTag); this.propertyTag = "0x" + Integer.toHexString(intPropertyTag);
this.propertyType = propertyType; this.propertyType = propertyType;
} }
/**
* Create extended field uri.
*
* @param distinguishedPropertySetId distinguished property set id
* @param propertyId property id
* @param propertyType property type
*/
public ExtendedFieldURI(DistinguishedPropertySetType distinguishedPropertySetId, int propertyId, PropertyType propertyType) { public ExtendedFieldURI(DistinguishedPropertySetType distinguishedPropertySetId, int propertyId, PropertyType propertyType) {
this.distinguishedPropertySetId = distinguishedPropertySetId; this.distinguishedPropertySetId = distinguishedPropertySetId;
this.propertyId = propertyId; this.propertyId = propertyId;
this.propertyType = propertyType; this.propertyType = propertyType;
} }
/**
* Create extended field uri.
*
* @param distinguishedPropertySetId distinguished property set id
* @param propertyName property name
*/
public ExtendedFieldURI(DistinguishedPropertySetType distinguishedPropertySetId, String propertyName) { public ExtendedFieldURI(DistinguishedPropertySetType distinguishedPropertySetId, String propertyName) {
this.distinguishedPropertySetId = distinguishedPropertySetId; this.distinguishedPropertySetId = distinguishedPropertySetId;
this.propertyName = propertyName; this.propertyName = propertyName;
this.propertyType = PropertyType.String; this.propertyType = PropertyType.String;
} }
public String getPropertyTag() {
return propertyTag;
}
public void appendTo(StringBuilder buffer) { public void appendTo(StringBuilder buffer) {
buffer.append("<t:ExtendedFieldURI "); buffer.append("<t:ExtendedFieldURI ");
if (propertyTag != null) { if (propertyTag != null) {
@ -104,6 +119,11 @@ public class ExtendedFieldURI implements FieldURI {
} }
} }
/**
* Field name in EWS response.
*
* @return field name in response
*/
public String getResponseName() { public String getResponseName() {
if (propertyTag != null) { if (propertyTag != null) {
return propertyTag; return propertyTag;

View File

@ -27,6 +27,9 @@ import java.util.Map;
public class Field { public class Field {
protected static final Map<String, FieldURI> FIELD_MAP = new HashMap<String, FieldURI>(); protected static final Map<String, FieldURI> FIELD_MAP = new HashMap<String, FieldURI>();
private Field() {
}
static { static {
// items // items
FIELD_MAP.put("etag", new ExtendedFieldURI(0x3008, ExtendedFieldURI.PropertyType.SystemTime)); FIELD_MAP.put("etag", new ExtendedFieldURI(0x3008, ExtendedFieldURI.PropertyType.SystemTime));
@ -37,7 +40,7 @@ public class Field {
FIELD_MAP.put("permanenturl", new ExtendedFieldURI(0x670E, ExtendedFieldURI.PropertyType.String)); //PR_FLAT_URL_NAME FIELD_MAP.put("permanenturl", new ExtendedFieldURI(0x670E, ExtendedFieldURI.PropertyType.String)); //PR_FLAT_URL_NAME
FIELD_MAP.put("instancetype", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.PublicStrings, "urn:schemas:calendar:instancetype")); FIELD_MAP.put("instancetype", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.PublicStrings, "urn:schemas:calendar:instancetype"));
FIELD_MAP.put("mimeContent", new UnindexedFieldURI("item:MimeContent")); FIELD_MAP.put("mimeContent", new UnindexedFieldURI("item:MimeContent"));
// use PR_RECORD_KEY as unique key // use PR_RECORD_KEY as unique key
FIELD_MAP.put("uid", new ExtendedFieldURI(0x0FF9, ExtendedFieldURI.PropertyType.Binary)); FIELD_MAP.put("uid", new ExtendedFieldURI(0x0FF9, ExtendedFieldURI.PropertyType.Binary));
@ -68,7 +71,7 @@ public class Field {
FIELD_MAP.put("homepostaladdress", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.Address, 0x801A, ExtendedFieldURI.PropertyType.String)); FIELD_MAP.put("homepostaladdress", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.Address, 0x801A, ExtendedFieldURI.PropertyType.String));
FIELD_MAP.put("otherpostaladdress", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.Address, 0x801C, ExtendedFieldURI.PropertyType.String)); FIELD_MAP.put("otherpostaladdress", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.Address, 0x801C, ExtendedFieldURI.PropertyType.String));
FIELD_MAP.put("mailingaddressid", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.Address,0x8022, ExtendedFieldURI.PropertyType.String )); FIELD_MAP.put("mailingaddressid", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.Address, 0x8022, ExtendedFieldURI.PropertyType.String));
FIELD_MAP.put("workaddress", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.Address, 0x801B, ExtendedFieldURI.PropertyType.String)); FIELD_MAP.put("workaddress", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.Address, 0x801B, ExtendedFieldURI.PropertyType.String));
FIELD_MAP.put("alternaterecipient", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.PublicStrings, "urn:schemas:contacts:alternaterecipient")); FIELD_MAP.put("alternaterecipient", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.PublicStrings, "urn:schemas:contacts:alternaterecipient"));

View File

@ -25,13 +25,17 @@ public interface FieldURI {
/** /**
* Append field to buffer * Append field to buffer
*
* @param buffer current buffer * @param buffer current buffer
*/ */
public void appendTo(StringBuilder buffer); public void appendTo(StringBuilder buffer);
/** /**
* Append updated field value to buffer * Append updated field value to buffer
* @param buffer current buffer *
* @param buffer current buffer
* @param itemType item type
* @param value field value
*/ */
public void appendValue(StringBuilder buffer, String itemType, String value); public void appendValue(StringBuilder buffer, String itemType, String value);

View File

@ -28,13 +28,27 @@ public class FieldUpdate {
FieldURI fieldURI; FieldURI fieldURI;
String value; String value;
/**
* Create field update with value.
*
* @param fieldURI target field
* @param value field value
*/
public FieldUpdate(FieldURI fieldURI, String value) { public FieldUpdate(FieldURI fieldURI, String value) {
this.fieldURI = fieldURI; this.fieldURI = fieldURI;
this.value = value; this.value = value;
} }
/**
* Write field to request writer.
*
* @param itemType item type
* @param writer request writer
* @throws IOException on error
*/
public void write(String itemType, Writer writer) throws IOException { public void write(String itemType, Writer writer) throws IOException {
String action; String action;
//noinspection VariableNotUsedInsideIf
if (value == null) { if (value == null) {
action = "Delete"; action = "Delete";
} else { } else {

View File

@ -28,9 +28,9 @@ public class FindFolderMethod extends EWSMethod {
/** /**
* Find Exchange Folder. * Find Exchange Folder.
* *
* @param traversal traversal type * @param traversal traversal type
* @param baseShape base shape * @param baseShape base shape
* @param parentFolderId parent folder id * @param parentFolderId parent folder id
* @param additionalProperties folder properties * @param additionalProperties folder properties
*/ */
public FindFolderMethod(FolderQueryTraversal traversal, BaseShape baseShape, FolderId parentFolderId, Set<FieldURI> additionalProperties) { public FindFolderMethod(FolderQueryTraversal traversal, BaseShape baseShape, FolderId parentFolderId, Set<FieldURI> additionalProperties) {
@ -44,11 +44,11 @@ public class FindFolderMethod extends EWSMethod {
/** /**
* Find Exchange Folder. * Find Exchange Folder.
* *
* @param traversal traversal type * @param traversal traversal type
* @param baseShape base shape * @param baseShape base shape
* @param parentFolderId parent folder id * @param parentFolderId parent folder id
* @param additionalProperties folder properties * @param additionalProperties folder properties
* @param searchExpression search expression * @param searchExpression search expression
*/ */
public FindFolderMethod(FolderQueryTraversal traversal, BaseShape baseShape, FolderId parentFolderId, public FindFolderMethod(FolderQueryTraversal traversal, BaseShape baseShape, FolderId parentFolderId,
Set<FieldURI> additionalProperties, SearchExpression searchExpression) { Set<FieldURI> additionalProperties, SearchExpression searchExpression) {

View File

@ -22,6 +22,13 @@ package davmail.exchange.ews;
* EWS Find Item Method. * EWS Find Item Method.
*/ */
public class FindItemMethod extends EWSMethod { public class FindItemMethod extends EWSMethod {
/**
* Find item method.
*
* @param traversal folder traversal mode
* @param baseShape base item shape
* @param parentFolderId parent folder id
*/
public FindItemMethod(FolderQueryTraversal traversal, BaseShape baseShape, FolderId parentFolderId) { public FindItemMethod(FolderQueryTraversal traversal, BaseShape baseShape, FolderId parentFolderId) {
super("Item", "FindItem"); super("Item", "FindItem");
this.traversal = traversal; this.traversal = traversal;

View File

@ -27,15 +27,23 @@ import java.io.Writer;
public class FolderId extends Option { public class FolderId extends Option {
protected String changeKey; protected String changeKey;
/**
* Create FolderId with specified tag name.
*
* @param name field tag name
* @param value id value
* @param changeKey folder change key
*/
protected FolderId(String name, String value, String changeKey) { protected FolderId(String name, String value, String changeKey) {
super(name, value); super(name, value);
this.changeKey = changeKey; this.changeKey = changeKey;
} }
/** /**
* Create FolderId option * Create FolderId
* *
* @param value id value * @param value id value
* @param changeKey folder change key
*/ */
public FolderId(String value, String changeKey) { public FolderId(String value, String changeKey) {
super("t:FolderId", value); super("t:FolderId", value);
@ -48,7 +56,7 @@ public class FolderId extends Option {
* @param item response item * @param item response item
*/ */
public FolderId(EWSMethod.Item item) { public FolderId(EWSMethod.Item item) {
this(item.get("FolderId"),item.get("ChangeKey")); this(item.get("FolderId"), item.get("ChangeKey"));
} }

View File

@ -18,9 +18,6 @@
*/ */
package davmail.exchange.ews; package davmail.exchange.ews;
import java.io.IOException;
import java.io.Writer;
/** /**
* Folder folderQueryTraversalType search mode. * Folder folderQueryTraversalType search mode.
*/ */

View File

@ -25,6 +25,13 @@ import java.util.Set;
*/ */
public class GetFolderMethod extends EWSMethod { public class GetFolderMethod extends EWSMethod {
/**
* Get folder method.
*
* @param baseShape base requested shape
* @param folderId folder id
* @param additionalProperties additional requested properties
*/
public GetFolderMethod(BaseShape baseShape, FolderId folderId, Set<FieldURI> additionalProperties) { public GetFolderMethod(BaseShape baseShape, FolderId folderId, Set<FieldURI> additionalProperties) {
super("Folder", "GetFolder"); super("Folder", "GetFolder");
this.baseShape = baseShape; this.baseShape = baseShape;

View File

@ -22,6 +22,13 @@ package davmail.exchange.ews;
* Get Item method. * Get Item method.
*/ */
public class GetItemMethod extends EWSMethod { public class GetItemMethod extends EWSMethod {
/**
* Get item method.
*
* @param baseShape base requested shape
* @param itemId item id
* @param includeMimeContent return mime content
*/
public GetItemMethod(BaseShape baseShape, ItemId itemId, boolean includeMimeContent) { public GetItemMethod(BaseShape baseShape, ItemId itemId, boolean includeMimeContent) {
super("Item", "GetItem"); super("Item", "GetItem");
this.baseShape = baseShape; this.baseShape = baseShape;

View File

@ -25,6 +25,11 @@ public class IndexedFieldURI implements FieldURI {
protected String fieldURI; protected String fieldURI;
protected String fieldIndex; protected String fieldIndex;
/**
* Create indexed field uri.
* @param fieldURI base field uri
* @param fieldIndex field name
*/
public IndexedFieldURI(String fieldURI, String fieldIndex) { public IndexedFieldURI(String fieldURI, String fieldIndex) {
this.fieldURI = fieldURI; this.fieldURI = fieldURI;
this.fieldIndex = fieldIndex; this.fieldIndex = fieldIndex;

View File

@ -22,7 +22,12 @@ package davmail.exchange.ews;
* Internet Message Header Field. * Internet Message Header Field.
*/ */
public class InternetMessageHeaderFieldURI extends IndexedFieldURI { public class InternetMessageHeaderFieldURI extends IndexedFieldURI {
public InternetMessageHeaderFieldURI(String fieldIndex) { /**
super("item:InternetMessageHeader", fieldIndex); * Create header field for field name.
*
* @param fieldName header field name
*/
public InternetMessageHeaderFieldURI(String fieldName) {
super("item:InternetMessageHeader", fieldName);
} }
} }

View File

@ -49,20 +49,11 @@ public class ItemId {
this.changeKey = item.get("ChangeKey"); this.changeKey = item.get("ChangeKey");
} }
/**
* Create Item id.
*
* @param id item id
*/
public ItemId(String id) {
this.id = id;
}
/** /**
* Write item id as XML. * Write item id as XML.
* *
* @param writer * @param writer request writer
* @throws IOException * @throws IOException on error
*/ */
public void write(Writer writer) throws IOException { public void write(Writer writer) throws IOException {
writer.write("<t:ItemId Id=\""); writer.write("<t:ItemId Id=\"");

View File

@ -18,9 +18,6 @@
*/ */
package davmail.exchange.ews; package davmail.exchange.ews;
import java.io.IOException;
import java.io.Writer;
/** /**
* MessageDisposition flag. * MessageDisposition flag.
*/ */

View File

@ -22,6 +22,12 @@ package davmail.exchange.ews;
* Create Folder method. * Create Folder method.
*/ */
public class MoveFolderMethod extends EWSMethod { public class MoveFolderMethod extends EWSMethod {
/**
* Move folder to target folder.
*
* @param folderId folder id
* @param toFolderId target folder id
*/
public MoveFolderMethod(FolderId folderId, FolderId toFolderId) { public MoveFolderMethod(FolderId folderId, FolderId toFolderId) {
super("Folder", "MoveFolder"); super("Folder", "MoveFolder");
this.folderId = folderId; this.folderId = folderId;

View File

@ -22,6 +22,12 @@ package davmail.exchange.ews;
* Move Item method. * Move Item method.
*/ */
public class MoveItemMethod extends EWSMethod { public class MoveItemMethod extends EWSMethod {
/**
* Move item to target folder.
*
* @param itemId item id
* @param toFolderId target folder id
*/
public MoveItemMethod(ItemId itemId, FolderId toFolderId) { public MoveItemMethod(ItemId itemId, FolderId toFolderId) {
super("Item", "MoveItem"); super("Item", "MoveItem");
this.itemId = itemId; this.itemId = itemId;

View File

@ -1,49 +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;
/**
* Boolean search expression
*/
public class MultipleOperandBooleanExpression implements SearchExpression {
public enum Operator {
And, Or, Not
}
private SearchExpression[] searchExpressions;
private Operator operator;
public MultipleOperandBooleanExpression(Operator operator, SearchExpression... searchExpressions) {
this.searchExpressions = searchExpressions;
this.operator = operator;
}
public void appendTo(StringBuilder buffer) {
buffer.append("<t:").append(operator.toString()).append('>');
for (SearchExpression searchExpression : searchExpressions) {
searchExpression.appendTo(buffer);
}
buffer.append("</t:").append(operator.toString()).append('>');
}
}

View File

@ -22,10 +22,10 @@ package davmail.exchange.ews;
* Item update option. * Item update option.
*/ */
public class SendMeetingInvitations extends AttributeOption { public class SendMeetingInvitations extends AttributeOption {
private SendMeetingInvitations(String value) { private SendMeetingInvitations(String value) {
super("SendMeetingInvitations", value); super("SendMeetingInvitations", value);
} }
public static final SendMeetingInvitations SendToNone = new SendMeetingInvitations("SendToNone"); public static final SendMeetingInvitations SendToNone = new SendMeetingInvitations("SendToNone");
public static final SendMeetingInvitations SendOnlyToAll = new SendMeetingInvitations("SendOnlyToAll"); public static final SendMeetingInvitations SendOnlyToAll = new SendMeetingInvitations("SendOnlyToAll");
public static final SendMeetingInvitations SendToAllAndSaveCopy = new SendMeetingInvitations("SendToAllAndSaveCopy"); public static final SendMeetingInvitations SendToAllAndSaveCopy = new SendMeetingInvitations("SendToAllAndSaveCopy");

View File

@ -22,10 +22,10 @@ package davmail.exchange.ews;
* Item update option. * Item update option.
*/ */
public class SendMeetingInvitationsOrCancellations extends AttributeOption { public class SendMeetingInvitationsOrCancellations extends AttributeOption {
private SendMeetingInvitationsOrCancellations(String value) { private SendMeetingInvitationsOrCancellations(String value) {
super("SendMeetingInvitationsOrCancellations", value); super("SendMeetingInvitationsOrCancellations", value);
} }
public static final SendMeetingInvitationsOrCancellations SendToNone = new SendMeetingInvitationsOrCancellations("SendToNone"); public static final SendMeetingInvitationsOrCancellations SendToNone = new SendMeetingInvitationsOrCancellations("SendToNone");
public static final SendMeetingInvitationsOrCancellations SendOnlyToAll = new SendMeetingInvitationsOrCancellations("SendOnlyToAll"); public static final SendMeetingInvitationsOrCancellations SendOnlyToAll = new SendMeetingInvitationsOrCancellations("SendOnlyToAll");
public static final SendMeetingInvitationsOrCancellations SendToAllAndSaveCopy = new SendMeetingInvitationsOrCancellations("SendToAllAndSaveCopy"); public static final SendMeetingInvitationsOrCancellations SendToAllAndSaveCopy = new SendMeetingInvitationsOrCancellations("SendToAllAndSaveCopy");

View File

@ -20,9 +20,6 @@ package davmail.exchange.ews;
import davmail.util.StringUtil; import davmail.util.StringUtil;
import java.io.IOException;
import java.io.Writer;
/** /**
* Two operand expression. * Two operand expression.
*/ */

View File

@ -25,13 +25,18 @@ public class UnindexedFieldURI implements FieldURI {
protected final String fieldURI; protected final String fieldURI;
protected final String fieldName; protected final String fieldName;
/**
* Create unindexed field URI.
*
* @param fieldURI field name
*/
public UnindexedFieldURI(String fieldURI) { public UnindexedFieldURI(String fieldURI) {
this.fieldURI = fieldURI; this.fieldURI = fieldURI;
int colonIndex = fieldURI.indexOf(':'); int colonIndex = fieldURI.indexOf(':');
if (colonIndex < 0) { if (colonIndex < 0) {
fieldName = fieldURI; fieldName = fieldURI;
} else { } else {
fieldName = fieldURI.substring(colonIndex+1); fieldName = fieldURI.substring(colonIndex + 1);
} }
} }

View File

@ -24,6 +24,12 @@ import java.util.Set;
* Update Folder method. * Update Folder method.
*/ */
public class UpdateFolderMethod extends EWSMethod { public class UpdateFolderMethod extends EWSMethod {
/**
* Update folder options.
*
* @param folderId folder id
* @param updates folder properties updates
*/
public UpdateFolderMethod(FolderId folderId, Set<FieldUpdate> updates) { public UpdateFolderMethod(FolderId folderId, Set<FieldUpdate> updates) {
super("Folder", "UpdateFolder"); super("Folder", "UpdateFolder");
this.folderId = folderId; this.folderId = folderId;

View File

@ -21,9 +21,19 @@ package davmail.exchange.ews;
import java.util.Set; import java.util.Set;
/** /**
* Uµpdate Item method. * Update Item method.
*/ */
public class UpdateItemMethod extends EWSMethod { public class UpdateItemMethod extends EWSMethod {
/**
* Update exchange item.
*
* @param messageDisposition save or send option
* @param conflictResolution overwrite option
* @param sendMeetingInvitationsOrCancellations
* send invitations option
* @param itemId item id with change key
* @param updates field updates
*/
public UpdateItemMethod(MessageDisposition messageDisposition, ConflictResolution conflictResolution, public UpdateItemMethod(MessageDisposition messageDisposition, ConflictResolution conflictResolution,
SendMeetingInvitationsOrCancellations sendMeetingInvitationsOrCancellations, SendMeetingInvitationsOrCancellations sendMeetingInvitationsOrCancellations,
ItemId itemId, Set<FieldUpdate> updates) { ItemId itemId, Set<FieldUpdate> updates) {