commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stewart-c, Theresa" <>
Subject RE: [VFS] Trying To Use WebDAV
Date Wed, 28 Apr 2010 12:43:20 GMT
Good Morning, Martin.

And thank you for trying to help me.

By container, do you mean "which web server will I be using?"  If that
is the question (and pardon my ignorance of what you mean by container),
it is a MS Windows IIS Server.

I have already written a test mini-application that used jackrabbit (I
implemented, from examples, a find() (uses HttpClient, sets
NTCredentials for username and password, uses DavMethod
(PropFindMethod), and successfully lists files and folders.  Likewise, I
did the same for a read() and a write(), so I know that I can
successfully connect to the server with the jackrabbit version of

What I then needed to do was modify an existing Applet's UI that already
had an open dialog (the standard open dialog, which presents the local
files) to allow users of the Applet to list, read, write and create
directories on a remote Web server within the Applet itself.  I realized
that this involved uses Accessories, so a search has led me here, to

I am currently running the demo, with the hopes of eventually just
"plugging in" the UI for handling the open and the save/save as

I saw from using the demo that sftp is already included, and eventually
got to the point where I could connect to one of our ftp sites (although
it does not open a file that I select, and I wonder "why?").  I then
became hopeful that all I needed to do was put in webdav in order to at
least be able to connect to our webdav server and list files.

What I have done so far is:

(1)  Modified the static block of code within to:
     (a)  Create a log4j logger so I could put debug messages within the
source (if this is something useful to VFS, I would like to contribute
this help the project in some small way for having VFS
     (b)  Added a Webdav File Provider as follows:
               WebdavFileProvider webDavFP = new WebdavFileProvider();
               // Register the webdav provider with the manager.
               sfs.addProvider(Protocol.WEBDAV.getName(), webDavFP);
(2)  Modified in actionPerformed() to handle the
webdav connection (as leaving the code "as is" would give me the
following error:
LOG4J - local/ftp failed due to:  Invalid absolute URI

The modification looks like this (and placed after the UI fields have
been obtained and the "String uri = credentials.toFileObjectURL();"

if ( uri.startsWith("webdav://") ) {
    // In the webdavclient4j example, the code reads --
    // WebdavFileObject resource =
    // "webdav://");
    // Now with this uri, I do not fail:
    //String absoluteUri = credentials.getHostname();
    String absoluteUri = m_hostname;
    fo = VFSUtils.resolveFileObject(absoluteUri, uri, m_username,
    //WebdavFileObject resource =
(WebdavFileObject)VFSUtils.resolveFileObject(uri, m_username,
else {
     fo = VFSUtils.resolveFileObject(uri);

As you can see, I have confusion as to (1) when to use WebdavFileObject
(and, if I do use it, how that impacts using the rest of the VFS
software), (2) which Uri to use (when I use the one from
credentials.toFileObjectURL(), I get "LOG4J - WebDAV failed due to:
null" error) and (when I use the absolute URI which is the same as the
host name, I get the same error).

(3)  Created a new resolveFileObject so I could pass in the
username/password credentials, and then eventually added the absolute
URI as opposed to the filePath (with the embedded webdav:// notation):

public static FileObject resolveFileObject(String uri, String filePath,
String userName, char[] password)
  	String pw = new String(password);
        	WebdavFileSystemConfigBuilder builder =
            StaticUserAuthenticator auth = new
StaticUserAuthenticator(null, userName, pw);
            opts = new FileSystemOptions();
            // Cannot do this, as builder does not have a setRootURI.
            //builder.setRootURI(opts, uri);
            builder.setProxyAuthenticator(opts, auth);
            builder.setProxyHost(opts, filePath);
            //return getFileSystemManager().resolveFile(filePath, opts);
            return getFileSystemManager().resolveFile(uri, opts);
        catch (FileSystemException ex)
        	VFSJFileChooserConstants.VFS_LOGGER.debug("LOG4J -
WebDAV failed due to:  " + ex.getMessage());
            return null;
        catch (Exception ex)
        	VFSJFileChooserConstants.VFS_LOGGER.debug("LOG4J -
WebDAV failed due to:  " + ex.getMessage());
        	return null;

So this is why I asked the original question.....there has to be a way
to connect the uri to the WebdavFileSstemConfigBuilder so it knows how
to access the remote webdav server.

I apologize for the length of the reply, as I was trying to explain as
best as I know how.

Thank you,

-----Original Message-----
From: Martin Gainty [] 
Sent: Tuesday, April 27, 2010 1:17 PM
Subject: RE: [VFS] Trying To Use WebDAV

Guten Tag

on which container will you be implementing?

Verzicht und Vertraulichkeitanmerkung
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede
unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig.
Diese Nachricht dient lediglich dem Austausch von Informationen und
entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten
Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt

> Subject: [VFS] Trying To Use WebDAV
> Date: Tue, 27 Apr 2010 11:49:35 -0700
> From:
> To:
> Hi,
> I was trying to use the following solution in order to obtain a
> FileObject using the WebDAV protocol (posted earlier on a thread):
>         WebdavFileSystemConfigBuilder builder =
> v");
>         final String uri = System.getProperty(TEST_URI);
>         FileSystemOptions opts = new FileSystemOptions();
>         builder.setRootURI(opts, uri);
>         return manager.resolveFile(uri, opts);
> and found out that builder.setRootURI(opts,uri); is not a choice on
> builder (not supported for the API I have).  Is there an alternative?
> Is the TEST_URI the one constructed from:
> Credentials credentials =;
> String uri = credentials.toFileObjectURL();
> Finally, how can the username and password be set?
> Thanks,
> Theresa
Hotmail is redefining busy with tools for the New Busy. Get more from
your inbox.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message