WebDAV access to the OpenCms VFS

From OpenCms Wiki
Revision as of 20:40, 30 August 2010 by Jvandevelde (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
based on this message: webdav with 7RC1

For WebDAV, all you need is in CATALINA_HOME/webapps/opencms/WEB-INF/web.xml, the other servlet context should be disabled.

Here's the documentation how to use the WebDAV of OpenCms 7:

Contents

Configuring WebDAV access to OpenCms

Describes the entries made in the web.xml file of OpenCms to activate or deactivate the WebDAV protocol or to change the behavior. Additionally some hints while removing "/opencms/opencms" with Apache HTTP Server are given.

Entries in the web.xml

The access to OpenCms through WebDAV is realized with a own servlet (CmsWebdavServlet). A default configuration of this servlet is already entered in the web.xml:

 <servlet> 
   <description> 
     Creates an access to OpenCms through WebDAV. 
   </description> 
   <servlet-name>OpenCmsWebDavServlet</servlet-name> 
   <servlet-class>org.opencms.webdav.CmsWebdavServlet</servlet-class> 
     <init-param> 
       <param-name>listings</param-name> 
       <param-value>true</param-value> 
     </init-param> 
     <init-param> 
       <param-name>readonly</param-name> 
       <param-value>false</param-value> 
     </init-param> 
     <init-param> 
       <param-name>repository</param-name> 
       <param-value>org.opencms.repository.cms.CmsRepository</param-value> 
     </init-param> 
 </servlet> 

There are three parameters which allows you to configure the WebDAV access:

  1. listings: If set to true (the default), you could browse to the contents of OpenCms with a Web Browser. But this way it is not possible to edit, delete or create resources in OpenCms. Through the Web Browser it is only possible to list and view the resources.
  2. readonly: Though permissions set in OpenCms find attention in the WebDAV protocol as well, it is possible to set the access to OpenCms through WebDAV to all users to read only.
  3. repository: This parameter usually should not be changed. It defines the repository to use through the WebDAV servlet. The default value specifies that the CmsRepository should be used, which means that you see the resources in OpenCms through this servlet. As an alternative you can specify the repository "org.opencms.repository.file.CmsFileRepository" here

to access files and folders found in a defined directory of the hard drive on the server. This was made to test the WebDAV protocol with the WebDAV servlet. The complete documentation describes the use of the default repository. Attention: You have to specify some different parameters for this repository. The second entry in the web.xml file defines the servlet mapping. In other words the url where to get access to the WebDAV servlet:

 <servlet-mapping> 
   <servlet-name>OpenCmsWebDavServlet</servlet-name> 
   <url-pattern>/webdav/*</url-pattern> 
 </servlet-mapping> 

As default you will find the WebDAV access by adding "webdav" to the servlet context.

Example

If you have OpenCms installed as a web application "opencms" in your web application container (running at port 8080) you can login to the workplace with the following url: http://localhost:8080/opencms/opencms/system/login Then you will find the WebDAV at this url: http://localhost:8080/opencms/webdav/

Additional information if removing "/opencms/opencms" with Apache

HTTP Server

If you want to remove the "/opencms/opencms" from the url, you have to set up an Apache HTTP Server with an VirtualHost entry in the httpd.conf (see Alkacon Documentation). To make the WebDAV access to OpenCms work again after configuring this way, you have to insert the following lines to the VirtualHost entry in your httpd.conf:

shouldn't this be:

?

Replace the server name (127.0.0.1) and the port (8086) with the entries that are correct in your configuration.

General information for using the OpenCms WebDAV servlet

Information what you need to know to connect to the OpenCms WebDAV servlet with any client.

Which URL to use to access WebDAV

The URL you have to use to access OpenCms through WebDAV depends on your settings. The server, the port and the web application are the same as for normal use of OpenCms. Only the last part of the URL differs from accessing the OpenCms workplace. For the workplace this is alway "opencms" as defined in the web.xml. For the WebDAV access this is "webdav" which is configured in the web.xml as well. The defaults are Workplace login: http://localhost:8080/opencms/opencms/system/login

WebDAV: http://localhost:8080/opencms/webdav/

The server, the port and the name of the web application you have to replace with your server, port and web application name where OpenCms is running.

The login procedure, default site and project

The access to the WebDAV servlet is secured by HTTP Basic authentication. So you have to provide a user name and a password to login to WebDAV (and OpenCms). The user name and the password are the same as the login into the workplace.

CAVEAT: After successful login you see the resources in the site, that the (OpenCms-) user has set as the default site after login. (See Preferences -> Workplace and the settings for "Start with site"). The same procedure is used for the project that will be used. This comes from the setting "Start with project". So if you wish to use a different site or a different project, just change your preferences and re-login to WebDAV.

Alternatively, you can change the default settings in the opencms-workplace.xml config as default for all users. If you like to access all your sites via WebDAV, just replace "/sites/default" with "/" in line 761 (workplace-startupsettings > site). Then your entry point will also look more familiar, as it is similar to the superadmin view in the opencms workplace.

Limitations

WebDAV protocol:

The following methods from the WebDAV protocol (RFC 2518) are implemented:

  • OPTIONS
  • PUT
  • MKCOL
  • LOCK
  • GET
  • HEAD
  • POST
  • DELETE
  • UNLOCK
  • MOVE
  • COPY
  • PROPFIND

The method "PROPPATCH" is intended, but always returns the status "Not Implemented (501)". The Versioning Extensions to WebDAV are not yet implemented.

File and folder names:

Keep in mind that is not allowed in OpenCms to create files or folders with special characters (like space). If you try to create, copy or move a file or a folder to a name containing such characters, they will be translated according to the configuration. WebDAV clients are not refreshing the files after changing or creating. So you will see the original name you chose (with the special characters) until you make a refresh of the files. Especially while creating new folders with the WebFolders in Windows (new folders are named "New Folder", containing a space), you will face that problem.

WebDAV clients to use with OpenCms

Here you find a list with WebDAV clients to work with the OpenCms WebDAV servlet. The following clients were tested while developing the WebDAV access:

  • WebFolder from MS Windows XP (SP2)
  • Eclipse with FTP/WebDAV plugin
  • Web Browser

WebFolders on MS Windows XP (SP2)

Describes the possibilities to use MS Windows web folders to configure and use together with OpenCms WebDAV. There are two ways in MS Windows XP to create a web folder to access WebDAV servers:

  1. Open Internet Explorer and click "File->Open...". As the address (URL) use the URL to the WebDAV servlet of OpenCms (see "General Information"). Don't forget to activate the checkbox "Open as web folder". If everything was entered correctly you should now be asked for your user name and password.
  2. Open the wizard to create a new network drive and use the link at the bottom to connect to a network server. After the welcome page you will see a page where to choose a service rovider. Select "Other network resource" and proceed to the next page. Here you have to enter the URL to the WebDAV servlet of OpenCms (see "General Information"). If everything was

entered correctly you should now be asked for your user name and password. Unfortunately you can do every file operation (copy, move, delete and create), but you cannot open files on a double-click. To open a file you have to copy it to a folder on your hard drive and open it form that place.

Eclipse WebDAV plugin

Describes how to use the WebDAV plugin in Eclipse to connect to OpenCms WebDAV servlet.

Installation

  1. Open the Update Manager
  2. Search for new features to install
  3. Check "The Eclipse Project Updates"
  4. Choose "Eclipse FTP and WebDAV Support"
  5. Restart Eclipse

Attention: This plugin is not under active development!!! Also, if you are using a new Eclipse version, for example Eclipse Europe, the default update site does not include this plugin. In that case you can download it from http://update.eclipse.org/updates/3.1/.

NOTE: Eclipse versions that are newer than Europa will require you to use the update site http://update.eclipse.org/updates/3.2/.

Creating new Target Sites

Now you will find a new view "Target Management -> Site Explorer", where you have the possibility to create a new target site. While creating a new target site you will be asked for the type of the target site. Choose "WebDAV" and proceed to the next page of the wizard.

  • Server URL: the Url of the OpenCms WebDAV servlet (see "General Information")
  • User: your login name in OpenCms
  • Password: your password to login in OpenCms
  • Proxy Server URL: the Url of your Proxy Server if one exists
  • Connection Timeout (in seconds): how long should the plugin wait for an answer before giving up

Export / Import

After you have created the target site to use, you have to first import or export files to/from this target site. If you choose to import files, create a new folder, right click on it and select "Import...". As the import source you must choose "Other -> WebDAV" and proceed to the next page. There you have to select the folder where to import the files coming from the WebDAV server. On the next page of the wizard you have the possibility to create a new target site or to choose an existing one. Select the target site you created before and click "Next". Now you have the choice to import the whole site (depending on the size of the site this could take some minutes) or to import a selected folder out of the site. After that Eclipse compares the files on the WebDAV server to those already found in the folder in Eclipse and presents a list to show the differences between the local and the remote folder. Select the resources you wish to import and finish the procedure.

The export functionality works similar to the import of files.

Synchronizing

After you either exported or imported files and folders to/from the WebDAV server, you are able to synchronize these folders. This works like synchronizing with a CVS or SVN repository. Unfortunately you cannot remove folders from the synchronization view.

Known Issues

After exiting Eclipse, you may get "Unauthorized" error messages. This can be resolved by removing the site from Site Explorer and adding it back in. Another way is to have a second site set up but not synchronized. You can then remove and add this site and that seems to resolve the Unauthorized message

WebBrowser

If you only want to browse and view the files and folders inside OpenCms, you can access OpenCms through WebDAV with a web browser. Open your favorite web browser and point to url of the OpenCms WebDAV servlet (see "General Information"). Now you will be asked for a user name and a password. Use the same credentials as you want to login to the workplace. This works only if you turned on listings in the configuration (as default this is turned on). For more information about the configuration see "Configuring OpenCms WebDAV".

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox