commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stewart-c, Theresa" <Theresa.Stewar...@airliquide.com>
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
webdav.

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
VFS.

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
functionality.

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 VFSJFileChooser.java 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 addition....to help the project in some small way for having VFS
available).
     (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 ConnectionDialog.java 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
"webdav://BASFLA:BASFLA@http://altacsdev.am.corp.airliquide.com/webdav-t
est/:80".

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

if ( uri.startsWith("webdav://") ) {
    // In the webdavclient4j example, the code reads --
    // WebdavFileObject resource =
(WebdavFileObject)fsManager.resolveFile(
    // "webdav://foo.bar/webdav/resource.txt");
    // Now with this uri, I do not fail:
    //String absoluteUri = credentials.getHostname();
    String absoluteUri = m_hostname;
    fo = VFSUtils.resolveFileObject(absoluteUri, uri, m_username,
         m_password);
    //WebdavFileObject resource =
(WebdavFileObject)VFSUtils.resolveFileObject(uri, m_username,
m_password);
}
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);
    	
        try
        {
        	WebdavFileSystemConfigBuilder builder =
(WebdavFileSystemConfigBuilder)
getFileSystemManager().getFileSystemConfigBuilder("webdav");
            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,
Theresa

-----Original Message-----
From: Martin Gainty [mailto:mgainty@hotmail.com] 
Sent: Tuesday, April 27, 2010 1:17 PM
To: user@commons.apache.org
Subject: RE: [VFS] Trying To Use WebDAV


Guten Tag

on which container will you be implementing?

Martin 
______________________________________________ 
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
uebernehmen.






> Subject: [VFS] Trying To Use WebDAV
> Date: Tue, 27 Apr 2010 11:49:35 -0700
> From: Theresa.Stewart-c@airliquide.com
> To: user@commons.apache.org
> 
> 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 =
> 
>  
>
(WebdavFileSystemConfigBuilder)manager.getFileSystemConfigBuilder("webda
> 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 = credentialsBuilder.build();
> 
> 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.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:
ON:WL:en-US:WM_HMP:042010_2

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message