1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-13 19:22:22 -05:00

EWS: implement ResolveNames method

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1303 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-07-27 19:26:54 +00:00
parent 47f2536a05
commit d074d6094f
5 changed files with 83 additions and 15 deletions

View File

@ -24,7 +24,7 @@ import java.io.Writer;
/** /**
* Generic attribute option. * Generic attribute option.
*/ */
public abstract class AttributeOption extends Option { public class AttributeOption extends Option {
protected AttributeOption(String name, String value) { protected AttributeOption(String name, String value) {
super(name, value); super(name, value);

View File

@ -18,6 +18,7 @@
*/ */
package davmail.exchange.ews; package davmail.exchange.ews;
import davmail.exchange.XMLStreamUtil;
import davmail.util.StringUtil; import davmail.util.StringUtil;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Base64;
import org.apache.commons.httpclient.Header; import org.apache.commons.httpclient.Header;
@ -53,6 +54,7 @@ public abstract class EWSMethod extends PostMethod {
protected Set<FieldURI> additionalProperties; protected Set<FieldURI> additionalProperties;
protected Disposal deleteType; protected Disposal deleteType;
protected Set<AttributeOption> methodOptions; protected Set<AttributeOption> methodOptions;
protected ElementOption unresolvedEntry;
protected Set<FieldUpdate> updates; protected Set<FieldUpdate> 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 { protected void endChanges(Writer writer) throws IOException {
//noinspection VariableNotUsedInsideIf //noinspection VariableNotUsedInsideIf
@ -347,6 +354,7 @@ public abstract class EWSMethod extends PostMethod {
writeSavedItemFolderId(writer); writeSavedItemFolderId(writer);
writeItem(writer); writeItem(writer);
writeUpdates(writer); writeUpdates(writer);
writeUnresolvedEntry(writer);
endChanges(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 * Get Exchange server version, Exchange2010 or Exchange2007_SP1
* @return server version * @return server version
@ -774,7 +770,7 @@ public abstract class EWSMethod extends PostMethod {
responseItems = new ArrayList<Item>(); responseItems = new ArrayList<Item>();
XMLStreamReader reader; XMLStreamReader reader;
try { try {
XMLInputFactory xmlInputFactory = getXmlInputFactory(); XMLInputFactory xmlInputFactory = XMLStreamUtil.getXmlInputFactory();
reader = xmlInputFactory.createXMLStreamReader(getResponseBodyAsStream()); reader = xmlInputFactory.createXMLStreamReader(getResponseBodyAsStream());
while (reader.hasNext()) { while (reader.hasNext()) {
reader.next(); reader.next();

View File

@ -18,6 +18,8 @@
*/ */
package davmail.exchange.ews; package davmail.exchange.ews;
import davmail.util.StringUtil;
import java.io.IOException; import java.io.IOException;
import java.io.Writer; import java.io.Writer;
@ -43,7 +45,7 @@ public class ElementOption extends Option {
writer.write('<'); writer.write('<');
writer.write(name); writer.write(name);
writer.write('>'); writer.write('>');
writer.write(value); writer.write(StringUtil.xmlEncode(value));
writer.write("</"); writer.write("</");
writer.write(name); writer.write(name);
writer.write('>'); writer.write('>');

View File

@ -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);
}
}

View File

@ -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");
}