mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-14 03:32: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:
parent
47f2536a05
commit
d074d6094f
@ -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);
|
||||||
|
@ -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();
|
||||||
|
@ -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('>');
|
||||||
|
37
src/java/davmail/exchange/ews/ResolveNamesMethod.java
Normal file
37
src/java/davmail/exchange/ews/ResolveNamesMethod.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
33
src/java/davmail/exchange/ews/SearchScope.java
Normal file
33
src/java/davmail/exchange/ews/SearchScope.java
Normal 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");
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user