This page is the starting point for learning about the WebDAV JAX-RS extension library. The following topics are covered:
Web-based Distributed Authoring and Versioning (WebDAV) is a defined set of HTTP methods and responses to allow users to read and write documents on a web server. Most websites today use basic HTTP to allow users to easily read data using HTTP GET methods and to create and modify data using HTTP POST and PUT methods. WebDAV enhances the ability to manage, edit, and write documents by providing features to set and read document properties, lock resources, and support for collections. WebDAV defines a set of HTTP methods and request and response entity formats to form the WebDAV protocol.
The Apache Wink WebDAV JAX-RS extension library helps JAX-RS application developers build WebDAV-compliant services. It provides a JAXB data model of the WebDAV XML to help read requests and write responses, helper classes to build responses, and JAX-RS based extensions to more easily build WebDAV services.
The JAXB model is provided in the org.apache.wink.webdav.model package. Helper classes include org.apache.wink.webdav.server.WebDAVResponseBuilder, which builds appropriate WebDAV responses with various properties. In the org.apache.wink.webdav package, JAX-RS compatible @HttpMethod annotations are available for the WebDAV HTTP methods and constants for common WebDAV HTTP headers and properties. See the API documentation for more details.
If you are migrating from the WebSphere Application Server Version 7 or Version 8 Feature Pack for Web 2.0 and Mobile to WebSphere Application Server V8.5, there are a few things to consider:
Read the IBM JAX-RS documentation for more information about configuring JAX-RS. You can check the JAX-RS documentation by clicking the appropriate link:
WebSphere Application Server Version 8.5 JAX-RS Documentation.
You can use the WebDAV extension library to write JAX-RS methods and resources that can communicate using the WebDAV protocol.
Here is a sample resource method.:
@WebDAVMethod.PROPFIND @Produces(MediaType.APPLICATION_XML) public Response findProperties() throws IOException { SyndFeed feed = /* create an Apache Wink SyndFeed */; return WebDAVResponseBuilder.propfind(feed); }
The previous method responds to any HTTP PROPFIND method requests, and using the WebDAVresponseBuilder, the resource method returns a response with the feed data.
A JAXB model is provided in the org.apache.wink.webdav.model Java package to help write responses and read requests. For instance, if you want to parse a WebDAV lock request, you could use the following to read the XML:
String bodyContent = /* the XML request */ Unmarshaller unmarshaller = WebDAVModelHelper.createUnmarshaller(); Lockinfo lockinfo = WebDAVModelHelper.unmarshal(unmarshaller, new StringReader(bodyContent), Lockinfo.class, "lockinfo");
In addition, you can use a few resource classes to help you get started with creating WebDAV resources.
WebDAVResource provides an @OPTIONS method that adds the WebDAV appropriate headers.:
@Path("/myresource/") public class MyResource extends org.apache.wink.webdav.server.WebDAVResource { /* get an @OPTIONS annotated JAX-RS resource method implementation from WebDAVResource */ /* implement your own WebDAV methods */ }
WebDAVLockableResource provides a few stub methods for performing WebDAV locking and unlocking. They do not perform a real lock but provide a fake lock to satisfy compatibility with certain platforms.:
@Path("/myresource2/") public class MyResource2 extends org.apache.wink.webdav.server.WebDAVLockableResource { /* get @LOCK and @UNLOCK stub methods for compatibility */ /* implement your own WebDAV methods */ }