diff --git a/src/java/davmail/exchange/ews/AttributeOption.java b/src/java/davmail/exchange/ews/AttributeOption.java index 377b5085..d168e8bf 100644 --- a/src/java/davmail/exchange/ews/AttributeOption.java +++ b/src/java/davmail/exchange/ews/AttributeOption.java @@ -24,7 +24,7 @@ import java.io.Writer; /** * Generic attribute option. */ -public abstract class AttributeOption extends Option { +public class AttributeOption extends Option { protected AttributeOption(String name, String value) { super(name, value); diff --git a/src/java/davmail/exchange/ews/EWSMethod.java b/src/java/davmail/exchange/ews/EWSMethod.java index 559c5fcf..564c9dbe 100644 --- a/src/java/davmail/exchange/ews/EWSMethod.java +++ b/src/java/davmail/exchange/ews/EWSMethod.java @@ -18,6 +18,7 @@ */ package davmail.exchange.ews; +import davmail.exchange.XMLStreamUtil; import davmail.util.StringUtil; import org.apache.commons.codec.binary.Base64; import org.apache.commons.httpclient.Header; @@ -53,6 +54,7 @@ public abstract class EWSMethod extends PostMethod { protected Set additionalProperties; protected Disposal deleteType; protected Set methodOptions; + protected ElementOption unresolvedEntry; protected Set updates; @@ -278,6 +280,11 @@ public abstract class EWSMethod extends PostMethod { } } + protected void writeUnresolvedEntry(Writer writer) throws IOException { + if (unresolvedEntry != null) { + unresolvedEntry.write(writer); + } + } protected void endChanges(Writer writer) throws IOException { //noinspection VariableNotUsedInsideIf @@ -347,6 +354,7 @@ public abstract class EWSMethod extends PostMethod { writeSavedItemFolderId(writer); writeItem(writer); writeUpdates(writer); + writeUnresolvedEntry(writer); endChanges(writer); } @@ -373,18 +381,6 @@ public abstract class EWSMethod extends PostMethod { } } - /** - * Build a new XMLInputFactory. - * - * @return XML input factory - */ - public static XMLInputFactory getXmlInputFactory() { - XMLInputFactory inputFactory = XMLInputFactory.newInstance(); - inputFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE); - inputFactory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.TRUE); - return inputFactory; - } - /** * Get Exchange server version, Exchange2010 or Exchange2007_SP1 * @return server version @@ -774,7 +770,7 @@ public abstract class EWSMethod extends PostMethod { responseItems = new ArrayList(); XMLStreamReader reader; try { - XMLInputFactory xmlInputFactory = getXmlInputFactory(); + XMLInputFactory xmlInputFactory = XMLStreamUtil.getXmlInputFactory(); reader = xmlInputFactory.createXMLStreamReader(getResponseBodyAsStream()); while (reader.hasNext()) { reader.next(); diff --git a/src/java/davmail/exchange/ews/ElementOption.java b/src/java/davmail/exchange/ews/ElementOption.java index 2d207053..c1bbf759 100644 --- a/src/java/davmail/exchange/ews/ElementOption.java +++ b/src/java/davmail/exchange/ews/ElementOption.java @@ -18,6 +18,8 @@ */ package davmail.exchange.ews; +import davmail.util.StringUtil; + import java.io.IOException; import java.io.Writer; @@ -43,7 +45,7 @@ public class ElementOption extends Option { writer.write('<'); writer.write(name); writer.write('>'); - writer.write(value); + writer.write(StringUtil.xmlEncode(value)); writer.write("'); diff --git a/src/java/davmail/exchange/ews/ResolveNamesMethod.java b/src/java/davmail/exchange/ews/ResolveNamesMethod.java new file mode 100644 index 00000000..fb9ff693 --- /dev/null +++ b/src/java/davmail/exchange/ews/ResolveNamesMethod.java @@ -0,0 +1,37 @@ +/* + * 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; + +/** + * Resolve Names method. + */ +public class ResolveNamesMethod extends EWSMethod { + protected static final AttributeOption RETURN_FULL_CONTACT_DATA = new AttributeOption("ReturnFullContactData", "true"); + /** + * Build Resolve Names method + * + * @param value search value + */ + public ResolveNamesMethod(String value) { + super("Contact", "ResolveNames"); + addMethodOption(SearchScope.ActiveDirectory); + addMethodOption(RETURN_FULL_CONTACT_DATA); + unresolvedEntry = new ElementOption("m:UnresolvedEntry", value); + } +} diff --git a/src/java/davmail/exchange/ews/SearchScope.java b/src/java/davmail/exchange/ews/SearchScope.java new file mode 100644 index 00000000..eee35d1b --- /dev/null +++ b/src/java/davmail/exchange/ews/SearchScope.java @@ -0,0 +1,33 @@ +/* + * 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; + +/** + * ResolveNames search scope. + */ +public class SearchScope extends AttributeOption { + private SearchScope(String value) { + super("SearchScope", value); + } + + public static final SearchScope ActiveDirectory = new SearchScope("ActiveDirectory"); + public static final SearchScope ActiveDirectoryContacts = new SearchScope("ActiveDirectoryContacts"); + public static final SearchScope Contacts = new SearchScope("Contacts"); + public static final SearchScope ContactsActiveDirectory = new SearchScope("ContactsActiveDirectory"); +}