- Turn on multiget for calendar/task sources
[jgroupdav.git] / src / main / java / net / bionicmessage / groupdav / CardDAVFormatter.java
blobb787249be37bdfe6f2c0fd421732cd56f94d1adb
1 /*
2 * JGroupDAV
3 * CardDAVFormatter.java (C) 2008,2010 Mathew McBride
4 *
5 * Redistribution and use in source and binary forms, with or without modification, are
6 * permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice, this list of
9 * conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 * of conditions and the following disclaimer in the documentation and/or other materials
13 * provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY Mathew McBride ``AS IS'' AND ANY EXPRESS OR IMPLIED
16 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 * The views and conclusions contained in the software and documentation are those of the
26 * authors and should not be interpreted as representing official policies, either expressed
27 * or implied, of Mathew McBride.
30 package net.bionicmessage.groupdav;
32 import java.io.UnsupportedEncodingException;
33 import java.util.List;
35 /**
37 * @author matt
39 public class CardDAVFormatter implements DAVReportFormatter {
40 public CardDAVFormatter() {
44 public byte[] formatReport(List<String> urlsToGet) throws UnsupportedEncodingException{
45 StringBuffer reportRequest = new StringBuffer("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
46 reportRequest.append("<C:addressbook-multiget xmlns:D=\"DAV:\"");
47 reportRequest.append(" xmlns:C=\"urn:ietf:params:xml:ns:carddav\">\r\n");
48 for (String str : urlsToGet) {
49 reportRequest.append("<D:href>");
50 reportRequest.append(str);
51 reportRequest.append("</D:href>\r\n");
53 reportRequest.append("<D:prop><D:getetag/><C:address-data/></D:prop>");
54 reportRequest.append("</C:addressbook-multiget>");
55 byte[] data = reportRequest.toString().getBytes("UTF-8");
56 return data;