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.
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.
The WebDAV extension provides several classes that applications can use in order to receive basic support for common WebDAV methods.
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.
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:
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.
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.
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.
In order to create a Multistatus response manually, perform the following steps:
- Create a new org.apache.wink.webdav.model.Multistatus instance and set its fields according to the application logic.
- 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