mirror of
https://github.com/moparisthebest/davmail
synced 2025-01-09 04:38:02 -05:00
Caldav: implement full contact folder dump at /users/<email>/contacts/
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1970 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
3c2a5ec9cb
commit
599c0de815
@ -297,7 +297,18 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
String folderPath = request.getFolderPath();
|
String folderPath = request.getFolderPath();
|
||||||
ExchangeSession.Folder folder = session.getFolder(folderPath);
|
ExchangeSession.Folder folder = session.getFolder(folderPath);
|
||||||
if (folder.isContact()) {
|
if (folder.isContact()) {
|
||||||
sendHttpResponse(HttpStatus.SC_OK, buildEtagHeader(folder.etag), "text/vcard", (byte[]) null, true);
|
List<ExchangeSession.Contact> contacts = session.getAllContacts(folderPath);
|
||||||
|
ChunkedResponse response = new ChunkedResponse(HttpStatus.SC_OK, "text/vcard;charset=UTF-8");
|
||||||
|
|
||||||
|
for (ExchangeSession.Contact contact : contacts) {
|
||||||
|
String contactBody = contact.getBody();
|
||||||
|
if (contactBody != null) {
|
||||||
|
response.append(contactBody);
|
||||||
|
response.append("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
response.close();
|
||||||
|
|
||||||
} else if (folder.isCalendar() || folder.isTask()) {
|
} else if (folder.isCalendar() || folder.isTask()) {
|
||||||
List<ExchangeSession.Event> events = session.getAllEvents(folderPath);
|
List<ExchangeSession.Event> events = session.getAllEvents(folderPath);
|
||||||
ChunkedResponse response = new ChunkedResponse(HttpStatus.SC_OK, "text/calendar;charset=UTF-8");
|
ChunkedResponse response = new ChunkedResponse(HttpStatus.SC_OK, "text/calendar;charset=UTF-8");
|
||||||
|
@ -2556,7 +2556,7 @@ public abstract class ExchangeSession {
|
|||||||
* @throws IOException on error
|
* @throws IOException on error
|
||||||
*/
|
*/
|
||||||
public List<ExchangeSession.Contact> getAllContacts(String folderPath) throws IOException {
|
public List<ExchangeSession.Contact> getAllContacts(String folderPath) throws IOException {
|
||||||
return searchContacts(folderPath, getItemProperties(), isEqualTo("outlookmessageclass", "IPM.Contact"), 0);
|
return searchContacts(folderPath, ExchangeSession.CONTACT_ATTRIBUTES, isEqualTo("outlookmessageclass", "IPM.Contact"), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ import org.apache.commons.httpclient.*;
|
|||||||
import org.apache.commons.httpclient.auth.AuthScope;
|
import org.apache.commons.httpclient.auth.AuthScope;
|
||||||
import org.apache.commons.httpclient.methods.GetMethod;
|
import org.apache.commons.httpclient.methods.GetMethod;
|
||||||
import org.apache.commons.httpclient.methods.RequestEntity;
|
import org.apache.commons.httpclient.methods.RequestEntity;
|
||||||
|
import org.apache.commons.httpclient.params.HttpMethodParams;
|
||||||
import org.apache.commons.httpclient.util.URIUtil;
|
import org.apache.commons.httpclient.util.URIUtil;
|
||||||
import org.apache.jackrabbit.webdav.DavException;
|
import org.apache.jackrabbit.webdav.DavException;
|
||||||
import org.apache.jackrabbit.webdav.MultiStatus;
|
import org.apache.jackrabbit.webdav.MultiStatus;
|
||||||
@ -135,13 +136,19 @@ public class TestCaldav extends AbstractDavMailTestCase {
|
|||||||
assertEquals(HttpStatus.SC_OK, method.getStatusCode());
|
assertEquals(HttpStatus.SC_OK, method.getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPropfindCalendar() throws IOException {
|
public void testGetContacts() throws IOException {
|
||||||
//Settings.setLoggingLevel("httpclient.wire", Level.DEBUG);
|
GetMethod method = new GetMethod("/users/" + session.getEmail() + "/contacts/");
|
||||||
PropFindMethod method = new PropFindMethod("/users/" + session.getAlias() + "/calendar/", null, 1);
|
|
||||||
httpClient.executeMethod(method);
|
httpClient.executeMethod(method);
|
||||||
assertEquals(HttpStatus.SC_OK, method.getStatusCode());
|
assertEquals(HttpStatus.SC_OK, method.getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testPropfindCalendar() throws IOException {
|
||||||
|
Settings.setLoggingLevel("httpclient.wire", Level.DEBUG);
|
||||||
|
PropFindMethod method = new PropFindMethod("/users/" + session.getEmail() + "/calendar/", null, 1);
|
||||||
|
httpClient.executeMethod(method);
|
||||||
|
assertEquals(HttpStatus.SC_MULTI_STATUS, method.getStatusCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testGetOtherUserCalendar() throws IOException {
|
public void testGetOtherUserCalendar() throws IOException {
|
||||||
Settings.setLoggingLevel("httpclient.wire", Level.DEBUG);
|
Settings.setLoggingLevel("httpclient.wire", Level.DEBUG);
|
||||||
@ -372,4 +379,15 @@ public class TestCaldav extends AbstractDavMailTestCase {
|
|||||||
method.getResponseBodyAsMultiStatus();
|
method.getResponseBodyAsMultiStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testPropfindAddressBook() throws IOException, DavException {
|
||||||
|
DavPropertyNameSet davPropertyNameSet = new DavPropertyNameSet();
|
||||||
|
//davPropertyNameSet.add(DavPropertyName.create("getctag", Namespace.getNamespace("http://calendarserver.org/ns/")));
|
||||||
|
davPropertyNameSet.add(DavPropertyName.create("getetag", Namespace.getNamespace("DAV:")));
|
||||||
|
PropFindMethod method = new PropFindMethod("/users/" + session.getEmail()+"/addressbook/", davPropertyNameSet, 1);
|
||||||
|
httpClient.getParams().setParameter(HttpMethodParams.USER_AGENT, "Address%20Book/883 CFNetwork/454.12.4 Darwin/10.8.0 (i386) (MacBookPro3%2C1)");
|
||||||
|
httpClient.executeMethod(method);
|
||||||
|
assertEquals(HttpStatus.SC_MULTI_STATUS, method.getStatusCode());
|
||||||
|
method.getResponseBodyAsMultiStatus();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user