The WebDav client service

Hippo Repository is a WebDAV compliant server and can be approached using standard WebDAV calls.

Interface WebdavService is the main interface of the webdav client component, it defines a number of content retrieval methods using WebDAV.

For Maven: groupId=hippo, artifactId=hippo-repository-webdav-client, version=[see download page]

Configure

Create a WebdavConfig object. Either by supplying a java.util.Properties object or an InputStream on a properties file. Here is an example properties file that should work for an 'out of the box' instance of Hippo Repository:

# WebDav configuration for the Hippo Repository Java adapter
# These default values are correct for an 'out of the box' instance of Hippo Repository
#
hippo.client.username = root
hippo.client.password = password
#
hippo.client.protocol = http
hippo.client.host = localhost
hippo.client.port = 60000
hippo.client.realm = default realm
#	
hippo.client.namespace = default
hippo.client.filespath = /files/default.preview 

# Optional prefix that appears in log messages
hippo.client.loglabel = 
      
WebdavConfig webdavConfig = new WebdavConfig(new FileInputStream("webdav.properties");
      

This configuration assumes a stand-alone repository. When the repository is depoyed as a WAR inside an application container then you should also define the hippo.client.contextroot property to the context-root where the repository is deployed. The context-root will override the use of the namespace, as WAR-deployed repositories only have a single namespace to work on.

Possible values for hippo.client.protocol are 'http' and 'https'

Changing an existing WebdavConfig is done through a WebdavConfigFactory A WebdavConfig object can be written back to a properties file by using the save(OutputStream) method.

Create

Create a noncaching WebdavService using the WebdavConfig:

WebdavService webdavService = new WebdavServiceImpl(webdavConfig);
      

A caching webdavService can be created by also supplying a CachingService:

CachingService cache = ... (see cachemanager documentation)
WebdavService webdavService = new WebdavServiceImpl(webdavConfig, cache);
      

Use

The WebdavService interface is a simple flat list of methods which can be roughly divided into three groups:

(1) Low level WebDAV: These methods just execute a WebDav method and return the result in the form of a RawResponse object which has a number of methods for getting the response:as DOM tree, as SAX stream or as (prettyprinted)String.

(2) High level content retrieval: Plain WebDAV results from SEARCH, PROPFIND or FACETS calls are complex XML structures which need further processing before they are useful in a Java environment. These methods do this for you, they transform the WebDAV XML to a Java Object structure. If the WebDAV service has been configured to use caching this transformation is cached so this doesn't have any performance penalty.

  • A 'high level' SEARCH returns a DocumentCollection which holds a List of Documents. A Document contains a document metadata object with ONLY the webdav properties queried in the DASL. It can also contain a RawResponse object with the document content if the includeContent parameter is set to true.
  • A 'high level' PROPFIND returns a document metadata object with ALL the webdav properties of the document.
  • A 'high level' FACETS search returns a FacetCollection which holds a List of Facets. A Facet has a name and a List of FacetValues. Please note that the Facets method is a Hippo Repository specific extension and not part of the WebDAV standard. It has been implemented in the repository to enable faceted classification for more information about the FACETS method see the Custom Webdav Methods documentation.

(3) Write operations: PUT and PROPPATCH requests can be done for updating content(metadata), they have the HTTP response code as return value and make no use of the cache (obviously). Warning: Care must be taken when using these methods. See the WebdavService Javadoc for detailed information about the pitfalls when using these methods.

Hippo CMS version 6.04 and up supports unique document Id's, all documents created by the CMS will have a property called 'UID' with a repository-wide unique id as value. If you are on Hippo CMS v6.04 or higher you can use the fetch[Document | DocumentMetadata | Content]ById() methods. If you want to use this feature you need to explicitely enable it when constructing the WebdavService.

// The boolean parameter stands for 'documentId enabled'.
WebdavService webdavService = new WebdavServiceImpl(webdavConfig, cache, true);
Document doc = webdavService.fetchDocumentById("1234");
      

Searching the Hippo Repository is done by supplying a DASL query. Information about the DASL query syntax can be found here.