diff --git a/src/java/davmail/exchange/ews/EWSMethod.java b/src/java/davmail/exchange/ews/EWSMethod.java index deedcde9..c53ee44f 100644 --- a/src/java/davmail/exchange/ews/EWSMethod.java +++ b/src/java/davmail/exchange/ews/EWSMethod.java @@ -58,6 +58,9 @@ public abstract class EWSMethod extends PostMethod { protected String errorDetail; protected Item item; + protected SearchExpression searchExpression; + + /** * Build EWS method */ @@ -118,6 +121,10 @@ public abstract class EWSMethod extends PostMethod { additionalProperties.add(additionalProperty); } + protected void setSearchExpression(SearchExpression searchExpression) { + this.searchExpression = searchExpression; + } + protected void writeShape(Writer writer) throws IOException { if (baseShape != null) { writer.write(""); + writer.write(""); parentFolderId.write(writer); - writer.write(""); + writer.write(""); } } @@ -176,6 +191,14 @@ public abstract class EWSMethod extends PostMethod { } } + protected void writeRestriction(Writer writer) throws IOException { + if (searchExpression != null) { + writer.write(""); + searchExpression.write(writer); + writer.write(""); + } + } + protected byte[] generateSoapEnvelope() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { @@ -208,6 +231,7 @@ public abstract class EWSMethod extends PostMethod { protected void writeSoapBody(Writer writer) throws IOException { writeShape(writer); + writeRestriction(writer); writeItemId(writer); writeParentFolderId(writer); writeFolderId(writer); diff --git a/src/java/davmail/exchange/ews/SearchExpression.java b/src/java/davmail/exchange/ews/SearchExpression.java new file mode 100644 index 00000000..cb92531f --- /dev/null +++ b/src/java/davmail/exchange/ews/SearchExpression.java @@ -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; + +/** + * EWS Search Expression. + */ +public abstract class SearchExpression { + /** + * Write XML content to writer. + * + * @param writer writer + * @throws IOException on error + */ + public abstract void write(Writer writer) throws IOException; +} diff --git a/src/java/davmail/exchange/ews/TwoOperandExpression.java b/src/java/davmail/exchange/ews/TwoOperandExpression.java new file mode 100644 index 00000000..69d5fd65 --- /dev/null +++ b/src/java/davmail/exchange/ews/TwoOperandExpression.java @@ -0,0 +1,65 @@ +/* + * 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; + +/** + * Two operand expression. + */ +public class TwoOperandExpression extends SearchExpression { + protected enum Operator { + IsEqualTo, IsNotEqualTo, IsGreaterThan, IsGreaterThanOrEqualTo, IsLessThan, IsLessThanOrEqualTo + } + + protected Operator operator; + protected FieldURI fieldURI; + protected String value; + + /** + * Create two operand expression. + * + * @param operator operator + * @param fieldURI field operand + * @param value value operand + */ + public TwoOperandExpression(Operator operator, FieldURI fieldURI, String value) { + this.operator = operator; + this.fieldURI = fieldURI; + this.value = value; + } + + @Override + public void write(Writer writer) throws IOException { + writer.write(""); + fieldURI.write(writer); + + writer.write(""); + + writer.write(""); + } + +}