This page last changed on Oct 13, 2009 by michael.

WebDAV Extension

Apache Wink provides an extension module for supporting the WebDAV protocol. The extension contains the complete WebDAV XML model and a WebDAV response builder for easing the process of creating a WebDAV multistatus response.

Usful Information
The WebDAV extension is a single jar wink-webdav-<version>.jar, and it has no special dependencies.

WebDAV Data Model

The WebDAV extension provides a Java data model that reflects the WebDAV XMLs defined in the WebDAV RFC. All classes of the data model are located in the org.apache.wink.webdav.model package.

WebDAV Classes

The WebDAV extension provides several classes that applications can use in order to receive basic support for common WebDAV methods.

WebDAVModelHelper

The WebDAVModelHelper class provides helper methods for XML marshaling and unmarshaling of the WebDAV data model classes. It also provides helper methods for creating generic properties as DOM element classes to populate the WebDAV Prop element.

WebDAVResponseBuilder

The WebDAVResponseBuilder class is used in order to create responses to WebDAV PROPFIND requests. It takes a SyndEntry or SyndFeed as input in order to create the response.

Resource Method Definition

A resource method is defined to handle the desired WebDAV method by annotating it with one of the WebDAV method designators defined in the WebDAVMethod enum.
The supported WebDAV Http methods are as follows:

  • PROPFIND
  • PROPPATCH
  • MKCOL
  • COPY
  • MOVE
  • LOCK
  • UNLOCK.

Creating a Multistatus Response

In order to create a MULTISTATUS response to a PROPFIND request the user can use the WebDAVResponseBuilder class, or create the response manually.

Using WebDAVResponseBuilder

In order to create a multistatus response using the WebDAVResponseBuilder class, call one of the propfind() methods.

The WebDAVResponseBuilder class also enables the user to provide the properties to include in the response by extending the PropertyProvider class, overriding the setPropertyValue() method and passing the property provider instance to the response builder propfind() method.

WebDAVResponseBuilder Example

@Path("defects/{defect}")
public class DefectResource {
  @WebDAVMethod.PROPFIND
  @Consumes("application/xml")
  @Produces(application/xml")
  public Response propfindDefect(@PathParam("defect") String defected) {
    SyndFeed feed = ...
    return WebDAVResponseBuilder.propfind(feed);
  }
}

The propfindDefect() method is associated with the PROPFIND WebDAV Http method using the @WebDAVMethod.PROPFIND annotation.

When the propfindDefect() method is invoked, an instance of a org.apache.wink.common.model.synd.SyndFeed is created and passed to the WebDAVResponseBuilder.propfind() method in order to create the actual response.

Manual Creation

In order to create a Multistatus response manually, perform the following steps:

  1. Create a new org.apache.wink.webdav.model.Multistatus instance and set its fields according to the application logic.
  2. Create a new javax.ws.rs.core.Response instance, set the response code to MULTI_STATUS (207), and set its entity to be the Multistatus instance.

Return the Response instance from the resource method

Document generated by Confluence on Nov 11, 2009 06:57