From 3f79bba60852d488be7b1efb87aaeac0df304898 Mon Sep 17 00:00:00 2001 From: mguessan Date: Tue, 23 Apr 2013 08:31:19 +0000 Subject: [PATCH] EWS: implement SortOrder git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2092 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- src/java/davmail/exchange/ews/EWSMethod.java | 16 +++++++ src/java/davmail/exchange/ews/FieldOrder.java | 45 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 src/java/davmail/exchange/ews/FieldOrder.java diff --git a/src/java/davmail/exchange/ews/EWSMethod.java b/src/java/davmail/exchange/ews/EWSMethod.java index c35bd7c0..4bf5aefe 100644 --- a/src/java/davmail/exchange/ews/EWSMethod.java +++ b/src/java/davmail/exchange/ews/EWSMethod.java @@ -82,6 +82,7 @@ public abstract class EWSMethod extends PostMethod { protected Item item; protected SearchExpression searchExpression; + protected FieldOrder fieldOrder; protected String serverVersion; protected String timezoneContext; @@ -163,6 +164,10 @@ public abstract class EWSMethod extends PostMethod { this.searchExpression = searchExpression; } + protected void setFieldOrder(FieldOrder fieldOrder) { + this.fieldOrder = fieldOrder; + } + protected void writeShape(Writer writer) throws IOException { if (baseShape != null) { writer.write(""); + StringBuilder buffer = new StringBuilder(); + fieldOrder.appendTo(buffer); + writer.write(buffer.toString()); + writer.write(""); + } + } + protected void startChanges(Writer writer) throws IOException { //noinspection VariableNotUsedInsideIf if (updates != null) { @@ -371,6 +386,7 @@ public abstract class EWSMethod extends PostMethod { writeShape(writer); writeIndexedPageItemView(writer); writeRestriction(writer); + writeSortOrder(writer); writeParentFolderId(writer); writeToFolderId(writer); writeItemId(writer); diff --git a/src/java/davmail/exchange/ews/FieldOrder.java b/src/java/davmail/exchange/ews/FieldOrder.java new file mode 100644 index 00000000..7d4518dd --- /dev/null +++ b/src/java/davmail/exchange/ews/FieldOrder.java @@ -0,0 +1,45 @@ +/* + * DavMail POP/IMAP/SMTP/CalDav/LDAP Exchange Gateway + * Copyright (C) 2013 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; + +/** + * Sort order. + */ +public class FieldOrder { + protected enum Order { + Descending, Ascending + } + protected Order order; + protected FieldURI fieldURI; + + public FieldOrder(FieldURI fieldURI, Order order) { + this.fieldURI = fieldURI; + this.order = order; + } + /** + * Append sort order to buffer. + * + * @param buffer search buffer + */ + void appendTo(StringBuilder buffer) { + buffer.append(""); + fieldURI.appendTo(buffer); + buffer.append(""); + } +}