Chapter 38. Nuxeo WebDAV interface

Table of Contents

38.1. WebDAV clients
38.1.1. Path vs displayName
38.1.2. Filesystem resource vs Nuxeo DocumentModel artifact
38.1.3. MS Web Folder client
38.2. Fooling WebDAV clients
38.2.1. Available hacks
38.2.2. Configuring Nuxeo WebDAV connector for each client.
38.3. Nuxeo EP WebDAV implementation
38.3.1. Nuxeo EP WebDAV-specific features
38.3.2. Known limitations
38.4. Using the Nuxeo WebDAV connector
38.4.1. Installing the WebDAV connector
38.4.2. Connecting a client to Nuxeo WebDAV connector

The nuxeo-platform-webdav-server module provides a WebDAV interface on top of Nuxeo services.

38.1. WebDAV clients

There are several WebDAV clients available. Each of them has its specific behavior, and also some limitations.

38.1.1. Path vs displayName

In WebDAV specification each accessible resource must have a name (part of the URL) and can have a displayName (defines how the resource should be displayed to the user). Unfortunately, most WebDAV client don't use the displayName property even if they ask the server to send it. Because of this limitations, most client use the last part of the URL as display name (with all limitations due to URL encoding). In addition of the display problem, this has side effect on other features like renaming. When trying to rename a resource (for example after creating a new Collection/Folder), most clients will send a move operation (change the path) instead of sending a propatch on displayName.

Inside Nuxeo 5, the path (id) and the display name (title) are clearly separated:

  • id/path is generated from the title but is not equal: non standard characters are escaped and length is limited to avoid having too long URLs.

    Foe example, a folder with title "New Folder" will have "new-folder" as a name.

  • The name has to be unique within a given container, but 2 documents can have the same title.

38.1.2. Filesystem resource vs Nuxeo DocumentModel artifact

Inside WebDAV, each container is a collection. Most WebDAV client consider that a collection is not a document, but a simple folder. This limitation is important because Nuxeo supports folderish documents, and document types that can contain several files. Because of that, depending on the document types we may want to map, a Nuxeo document could be seen as a collection or as a resource. Unfortunately, since all clients consider collections as simple folders, this is not very useful.

38.1.3. MS Web Folder client

One of the most popular WebDAV client are Web Folders that are included inside Windows OS. Unfortunately depending on the version of Windows (including service pack) and also on the version of MSOffice the webdav client will be implemented in a different way with different bugs and behavior. Web Folders are not the worse WebDAV client, but they are definitely the less predictable...

For a complete bug listing of Web Folders depending on version please see http://www.greenbytes.de/tech/webdav/webdavfaq.html, http://www.greenbytes.de/tech/webdav/webfolder-client-list.html, http://www.greenbytes.de/tech/webdav/webdav-redirector-list.html

38.2. Fooling WebDAV clients

Because of the path vs name problem, the Nuxeo 5 WebDAV connector introduce some hacks to force some webdav client displaying the correct names.

This hacks can be activated of not depending on the User-Agent header provided by each client.

38.2.1. Available hacks

  • Virtual path for lief resources (ie: non collections)

    Because most client uses the last part of the URL to get the displayName, a simple hack to have resources displayed correctly is to have a specific URL for them.

    By default a resource with URL http://nxServer/nuxeo/dav/default/default-domain/workspaces/my-workspace-1/file-1 will be displayed as "file-1". But if file-1 contains a file named "MyFile.doc", when using a virtual URL like http://nxServer/nuxeo/dav/default/default-domain/workspaces/my-workspace-1/file-1/WebFolder_FileName/MyFile.doc, then the display will be correct.

  • Use filename as resource name

    The resource URL will be http://nxServer/nuxeo/dav/default/default-domain/workspaces/my-workspace-1/file-1/MyFile.doc. This is very much like the previous hack, but this is harder to resolve on the server side, because there may be several file resources containing MyFile.doc in the same container.

  • Use fake get parameters for collections names

    Getting the good displayName for collection resources is a little bit harder, previous hacks won't work.

    In some webdav client, the url parsing is so weak, that we can use URLs like : http://nxServer/nuxeo/dav/default/default-domain/workspaces/my-workspace-1?displayName=/My%20Workspace%201 to have the collection correctly displayed as "My Workspace 1". Although this hack does not work with most clients, it works with most Web Folders version.

38.2.2. Configuring Nuxeo WebDAV connector for each client.

The Nuxeo WebDAV connector enables you to configure for each WebDAV clients:

  • The hacks you want to enable

  • If you want full or relative URLs

  • If your client needs MS specific DAV Headers (required for some versions of Web Folders)

Configuration can be contributed using a simple Extension Point.

<?xml version="1.0"?>
<component name="org.nuxeo.ecm.platform.webdav.config.defaultContrib">

  <extension target="org.nuxeo.ecm.platform.webdav.config.WebDavConfigurationService" point="DavClientConfiguration">
    <documentation>
      Configuration for MS Web Folders (both versions) and WebDrive.
    </documentation>
    <davClientConfiguration name="MSWebFolders" enabled="true">
      <needGetParameterForCollectionNamming>true</needGetParameterForCollectionNamming>
      <needVirtualPathForLief>false</needVirtualPathForLief>
      <useFileNameAsRessourceName>true</useFileNameAsRessourceName>
      <needFullURLs>true</needFullURLs>
      <needMSDavHeader>true</needMSDavHeader>
      <userAgentPatterns>
        <pattern>Microsoft-WebDAV</pattern>
        <pattern>Microsoft Data Access Internet Publishing Provider</pattern>
      </userAgentPatterns>
    </davClientConfiguration>
   ...

As you can see, each configuration set is attached to one or more User-Agent substring. Unfortunately, Web Folders clients do not send information about their version, even if it would be very helpful.

38.3. Nuxeo EP WebDAV implementation

38.3.1. Nuxeo EP WebDAV-specific features

Because of the limitations explained earlier, the Nuxeo EP WebDAV implementation provides some features to be able to work with existing WebDAV clients.

38.3.1.1. VirtualPath management

When URLs hack are activated, the clients will be able to display the resources with their displayName (title) instead of the name. But some of them will be fooled enough to use this displayName in URLs to do propfind or move calls. Because of that, the server must be able to resolve URLs that are constitued partially of path and partially of displayNames like: http://nxServer/nuxeo/dav/default/default-domain/workspaces/My%20Workspace%201.

The Nuxeo EP WebDAV connector implements a custom URL resolver that is able to resolve these URLs. In also maintains a cache of these virtual URLs to speed up resolution (and also make it more consistent is case of name collisions).

38.3.1.2. WebDAV resource adapters

Displaying your Nuxeo documents as simple files (that's what will do most WebDAV client) can be very restrictive.

The Nuxeo WebDAV connector uses DocumentModel adapters to define how a Nuxeo Document must be mapped to a WebDAV resources. This adapter defines:

  • How the display name of your resource will be generated.

    Simple document title or filename of the main file field...

    The default built-in behavior will be to return the filename for each document that has the file schema and otherwise return the title.

  • How your DocumentModel will respond to a GET request.

    The default built-in behavior will be to return:

    • a folder listing as HTML for each folderish resource

    • the binary file for Documents that uses the file schema

    • the XML export for other non folderish resources

New DavAdapters can be contributed to define specific WebDAV mapping for your document types. For that, the Nuxeo WebDAV connector provides an extension point to let you register a new class implementingorg.nuxeo.ecm.platform.webdav.adapters.DavResourceAdapter and associate it to a document type.

<extension target="org.nuxeo.ecm.platform.webdav.config.WebDavConfigurationService"
      point="DavAdapter">

  <davAdapter name="NoteDavAdapter" enabled="true">
    <typeName>Note</typeName>
    class>org.nuxeo.ecm.platform.webdav.adapters.NoteDavResourceAdapter</class>
  </davAdapter>
</extension>

38.3.2. Known limitations

Locking management is restricted to exclusive write locks, exactly as in Nuxeo Core.

Propset is for now not implemented as none of the used WebDAV client seems to use this method.

WebDAV versioning extension are not implemented.

38.4. Using the Nuxeo WebDAV connector

38.4.1. Installing the WebDAV connector

The Nuxeo WebDAV Connector is an optional additional component for Nuxeo EP.

In order to install the WebDAV features, you need to download the WebDAV Connector jar (or build it from source), copy the jar in nuxeo.ear/system and restart your server.

The WebDAV connector works for both 5.1 and 5.2 versions of Nuxeo EP, you just need to download the associated version or build it using the right POM file.

38.4.2. Connecting a client to Nuxeo WebDAV connector

The WebDAV URL for the default domain is http://$NuxeoServer/nuxeo/dav/default/default-domain.

In order to use MS Web Folders, you just need to go to "My Network Places" and choose "Add a new Network place". You can then enter the Nuxeo WebDAV URL and login/password.