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]
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
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 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);
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.
(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.