Re: Strange getChildResources() behaviour
David King <[email protected]> Sun, 25 Mar 2007 20:27:37 -0700
| Newsgroups | gmane.comp.jakarta.slide.user |
|---|---|
| Message-ID | <[email protected]> |
I've just verified this against https://svn.apache.org/repos/asf/,
which means that it's not the server causing the problem
-- David
On 25 Mar 2007, at 20:23, David King wrote:
> I have a small program which tries to list an entire collection
> tree by recursion (it's a smaller part of a larger program). In
> theory this should be pretty easy. The tree looks like this (where
> a trailing slash denotes a collection):
>
> dir/1/
> dir/1/2
> dir/3/
> dir/3/4/
> dir/5
> dir/6
>
> However, when I try to do getChildResources() on "dir", instead of
> getting back {1,3,5,6}, instead I get back {dir,5,6}. That is,
> getChildResources() returns the original resource, and any files
> (but not collections) within the collection. Slide is the only
> library that seems to do this, so I'm inclined to believe that it's
> a bug (either in Slide or the server), but I'm hoping that I'm just
> doing something wrong. I'm doing this from Slide 2.1, talking to a
> Xythos 6.0 server (www.xythosondemand.com, but I've tried another
> Xythos server as well).
>
> Here's the actual code:
>
> import java.io.File;
> import java.io.IOException;
> import java.util.Enumeration;
> import org.apache.commons.httpclient.HttpException;
> import org.apache.commons.httpclient.HttpURL;
> import org.apache.commons.httpclient.HttpsURL;
> import org.apache.commons.httpclient.URIException;
> import org.apache.webdav.lib.WebdavResource;
> import org.apache.webdav.lib.WebdavResources;
>
> public class Davsync {
> private static final String URL="https://server/path/to/
> collection/";
> private static final String source="/local/path";
> private static final String user="username";
> private static final String password = "password";
>
> public static void main(String[] args) throws URIException,
> IOException {
> HttpsURL hrl=new HttpsURL(URL);
> hrl.setUserinfo(user, password);
>
> syncUp(hrl, new File(source));
> }
>
> private static void syncUp(HttpURL hu, File localFile) throws
> HttpException, IOException {
> syncUp(
> new WebdavResource(hu).getChildResources(),
> localFile);
> }
>
> private static void syncUp(WebdavResources wrs, File localfile)
> throws IOException {
> Enumeration wr=wrs.getResources();
> while(wr.hasMoreElements()) {
> WebdavResource r=(WebdavResource)wr.nextElement();
>
> if(r.isCollection()) {
> System.out.println("Dire:" + r.toString());
> // syncUp(r.listWebdavResources(),localfile);
> } else {
> System.out.println("File:" + r.toString());
> }
> }
> }
> }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]