Implementing a WebDAV client using the Apache Jackrabbit

Source: Internet
Author: User
Tags file system resource microsoft iis

WebDAV Overview

WebDAV (Web Distributed Authoring and Versioning) is an HTTP based communication protocol, an extension of HTTP that adds new methods based on the methods of, and POST of the HTTP protocol , allowing users to edit and manage files stored remotely through the client. These methods include PROPFIND, PROPPATCH, MKCOL, COPY, move, LOCK, UNLOCK and so on.

As the name suggests, WebDAV focuses on authoring (authoring) and Versioning (Versioning) capabilities, so it adds concepts and mechanisms such as document attributes, resource collections, locks, namespaces, and so on in its own protocol (RFC 2518).

Although WebDAV was originally designed to facilitate remote authoring and versioning, WebDAV is often used in contrast to network transport protocols such as FTP and SFTP, and WebDAV can be viewed as a complement and a choice for file transfer protocols. With HTTP ports in use, WebDAV can easily traverse the firewall. And because the HTTPS,WEBDAV can be used in security is not inferior to SFTP.

WebDAV has been widely used in practice. WebDAV can be found on the server side, such as Apache HTTP server and Microsoft IIS. On the client side, office automation software such as IBM Lotus and Microsoft Office can edit remote documents through WebDAV.

Introduction to JCR and Apache Jackrabbit

JCR is an abbreviation for the content Repository for Java Technology API, translated as a Java Contents Storage specification, whose specification is defined in JSR170 and JSR283, which define the JCR version 1.0 and 2.0, respectively. The goal is to simplify Java data management and to build a coding model based on content warehouses (Repository) rather than traditional databases such as RDBMS. A typical content repository should be the Content management system (CMS). JCR is an abstraction of the content warehouse because the actual content warehouse can be based on a database, possibly based on a file system or other appropriate storage mechanism, such as a WebDAV warehouse. There are also several ways to access a content warehouse, including direct access, such as an application's local repository, or as a resource (such as a container for Java EE through JNDI), or you can use HTTP or RMI for network access.

The Apache Jackrabbit is an open-source implementation of the JCR provided by the Apache Foundation. Its origins can be traced back to the 2002 Apache Jakarta Slide Project, which plans to implement JSR170-defined content warehouses. Then in 2004, the Open source implementation of JCR became a separate project and named "Jackrabbit". For the Jakarta and Slide projects, the initial Jakarta is a collection of well-known subprojects, such as Ant, Maven, JMeter, and Slide is one of the subprojects. The main content of the Slide project is the content warehouse, one of the important features is support for WebDAV, and WebDAV can be considered as an important cornerstone of the content warehouse. However, the Slide project was not updated after 2004 and was formally closed in 2007. The current support for WebDAV comes mainly from the Jackrabbit project, which implements the latest version of JCR1.0 as Jackrabbit1.6, and the latest version of JCR2.0 is Jackrabbit2.4.

Implementing a WebDAV client using Jackrabbit

Before coding, you only need to include Jackrabbit JAR files (such as Jackrabbit-standalone-2.4.3.jar) in your project and make it possible to successfully import resources for Jackrabbit library files in your code. This article takes the example of developing a WebDAV client in the Eclipse development environment to introduce a client that uses Jackrabbit to implement WebDAV. As shown in the figure, you first need to import the Jackrabbit JAR file into the new WebDAV client project.

Figure 1. Import Jackrabbit JAR file

In general, you can implement a WebDAV client in accordance with the process shown in Figure 2, first by establishing an HTTP network connection, creating a HttpClient object, then invoking the desired WebDAV method, and getting the status code and return value of the method call, and determining whether to tune it based on the status code and return value What other WebDAV methods to use or invoke.

Figure 2. Implementing a WebDAV Client

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.