From 552bd0505c1ad44200c0aa3bee6fabd25e5b6a65 Mon Sep 17 00:00:00 2001 From: Mathew McBride Date: Mon, 5 Apr 2010 21:06:59 +1000 Subject: [PATCH] - Turn on multiget for calendar/task sources - Add files missing from last commit --- .../bionicmessage/groupdav/CalDAVFormatter.java | 52 +++++++++++++++++++ .../bionicmessage/groupdav/CardDAVFormatter.java | 59 ++++++++++++++++++++++ .../net/bionicmessage/groupdav/CardDAVServer.java | 41 +++++++++++++++ .../bionicmessage/groupdav/DAVReportFormatter.java | 41 +++++++++++++++ .../bionicmessage/groupdav/http/HttpReport.java | 52 +++++++++++++++++++ .../MultipleSourceICalendarObjectStore.java | 7 +++ 6 files changed, 252 insertions(+) create mode 100644 src/main/java/net/bionicmessage/groupdav/CalDAVFormatter.java create mode 100644 src/main/java/net/bionicmessage/groupdav/CardDAVFormatter.java create mode 100644 src/main/java/net/bionicmessage/groupdav/CardDAVServer.java create mode 100644 src/main/java/net/bionicmessage/groupdav/DAVReportFormatter.java create mode 100644 src/main/java/net/bionicmessage/groupdav/http/HttpReport.java diff --git a/src/main/java/net/bionicmessage/groupdav/CalDAVFormatter.java b/src/main/java/net/bionicmessage/groupdav/CalDAVFormatter.java new file mode 100644 index 0000000..9e4f98c --- /dev/null +++ b/src/main/java/net/bionicmessage/groupdav/CalDAVFormatter.java @@ -0,0 +1,52 @@ +/* + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY Mathew McBride ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of Mathew McBride. + */ +package net.bionicmessage.groupdav; + +import java.io.UnsupportedEncodingException; +import java.util.List; + +/** + * + * @author matt + */ +public class CalDAVFormatter implements DAVReportFormatter { + + public byte[] formatReport(List urlsToGet) throws UnsupportedEncodingException { + StringBuffer request = new StringBuffer(); + request.append(""); + request.append("\r\n "); + request.append("\r\n\r\n\r\n"); + request.append("\r\n"); + for (String s : urlsToGet) { + request.append(""); + request.append(s); + request.append(""); + } + request.append(""); + return request.toString().getBytes("UTF-8"); + } +} diff --git a/src/main/java/net/bionicmessage/groupdav/CardDAVFormatter.java b/src/main/java/net/bionicmessage/groupdav/CardDAVFormatter.java new file mode 100644 index 0000000..b787249 --- /dev/null +++ b/src/main/java/net/bionicmessage/groupdav/CardDAVFormatter.java @@ -0,0 +1,59 @@ +/* + * JGroupDAV + * CardDAVFormatter.java (C) 2008,2010 Mathew McBride + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY Mathew McBride ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of Mathew McBride. + */ + +package net.bionicmessage.groupdav; + +import java.io.UnsupportedEncodingException; +import java.util.List; + +/** + * + * @author matt + */ +public class CardDAVFormatter implements DAVReportFormatter { + public CardDAVFormatter() { + + } + + public byte[] formatReport(List urlsToGet) throws UnsupportedEncodingException{ + StringBuffer reportRequest = new StringBuffer(""); + reportRequest.append("\r\n"); + for (String str : urlsToGet) { + reportRequest.append(""); + reportRequest.append(str); + reportRequest.append("\r\n"); + } + reportRequest.append(""); + reportRequest.append(""); + byte[] data = reportRequest.toString().getBytes("UTF-8"); + return data; + } + +} diff --git a/src/main/java/net/bionicmessage/groupdav/CardDAVServer.java b/src/main/java/net/bionicmessage/groupdav/CardDAVServer.java new file mode 100644 index 0000000..940b9a2 --- /dev/null +++ b/src/main/java/net/bionicmessage/groupdav/CardDAVServer.java @@ -0,0 +1,41 @@ +/* + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY Mathew McBride ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of Mathew McBride. + */ + +package net.bionicmessage.groupdav; + +/** + * + * @author matt + */ +public class CardDAVServer extends GroupDAV2Server { + + public CardDAVServer() { + super(); + formatter = new CardDAVFormatter(); + } + + +} diff --git a/src/main/java/net/bionicmessage/groupdav/DAVReportFormatter.java b/src/main/java/net/bionicmessage/groupdav/DAVReportFormatter.java new file mode 100644 index 0000000..449be72 --- /dev/null +++ b/src/main/java/net/bionicmessage/groupdav/DAVReportFormatter.java @@ -0,0 +1,41 @@ +/* + * JGroupDAV + * Copyright 2010 Mathew McBride + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY Mathew McBride ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of Mathew McBride. + */ + +package net.bionicmessage.groupdav; + +import java.io.UnsupportedEncodingException; +import java.util.List; + +/** + * + * @author matt + */ +public interface DAVReportFormatter { + byte[] formatReport(List urlsToGet) throws UnsupportedEncodingException; +} diff --git a/src/main/java/net/bionicmessage/groupdav/http/HttpReport.java b/src/main/java/net/bionicmessage/groupdav/http/HttpReport.java new file mode 100644 index 0000000..deee7cf --- /dev/null +++ b/src/main/java/net/bionicmessage/groupdav/http/HttpReport.java @@ -0,0 +1,52 @@ +/* + * JGroupDAV + * Copyright 2010 Mathew McBride + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY Mathew McBride ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of Mathew McBride. + */ + +package net.bionicmessage.groupdav.http; + +import java.net.URI; +import org.apache.http.client.methods.HttpPut; + +/** + * + * @author matt + */ +public class HttpReport extends HttpPut { + + public HttpReport(URI pathURI) { + super(pathURI); + } + + + @Override + public String getMethod() { + return "REPORT"; + } + + +} diff --git a/src/main/java/net/bionicmessage/objects/MultipleSourceICalendarObjectStore.java b/src/main/java/net/bionicmessage/objects/MultipleSourceICalendarObjectStore.java index a57de86..79c2bb0 100644 --- a/src/main/java/net/bionicmessage/objects/MultipleSourceICalendarObjectStore.java +++ b/src/main/java/net/bionicmessage/objects/MultipleSourceICalendarObjectStore.java @@ -34,6 +34,7 @@ import java.util.ArrayList; import java.util.Hashtable; import java.util.List; import java.util.logging.Logger; +import net.bionicmessage.groupdav.CalDAVFormatter; import net.bionicmessage.groupdav.GroupDAVObject; import net.bionicmessage.groupdav.util.icalUtilities; import net.bionicmessage.utils.QPDecode; @@ -53,6 +54,12 @@ public class MultipleSourceICalendarObjectStore extends AbstractObjectStore { this(storedir, options, null); } + @Override + public void startSync() throws Exception { + this.server.setFormatter(new CalDAVFormatter()); + super.startSync(); + } + public MultipleSourceICalendarObjectStore(String storedir, int options, List neededCompTypes) { super(storedir, options); -- 2.11.4.GIT