Fork me on GitHub

DefaultJcrCommentPersistenceManager

Introduction

The default implementation of CommentPersistenceManager, DefaultJcrCommentPersistenceManager, stores comment data in JCR repository in a specific node tree, similarly to how Hippo Workflow logging data or HST Form data is stored.

Comment Data Node Types

DefaultJcrCommentPersistenceManager uses the following node types:

<'mix'='http://www.jcp.org/jcr/mix/1.0'>
<'nt'='http://www.jcp.org/jcr/nt/1.0'>
<'doccommenting'='http://forge.onehippo.org/doccommenting/nt/1.0'>

[doccommenting:commentdata] > nt:base
  - doccommenting:subjectid (string)
  - doccommenting:author (string)
  - doccommenting:created (date)
  - doccommenting:lastModified (date)
  - doccommenting:content (string)
  - * (string)
  - * (string) multiple
  - * (boolean)
  - * (boolean) multiple
  - * (long)
  - * (long) multiple
  - * (double)
  - * (double) multiple
  - * (date)
  - * (date) multiple

[doccommenting:commentdatacontainer] > nt:base
  + * (doccommenting:commentdata)
  + * (doccommenting:commentdatacontainer)
          

doccommenting:commentdatacontainer type is used for folder nodes (which are randomly created and selected for scalability) and doccommenting:commentdata is used for each comment data node.

Please note that a doccommenting:commentdata has basic properties:

  • doccommenting:subjectid: used for the related document handle node identifier of the comment data
  • doccommenting:author: used for the author name of the comment data
  • doccommenting:created: used for the creation datetime of the comment data
  • doccommenting:lastModified: used for the last modified datetime of the comment data
  • doccommenting:content: used for the text content of the comment data

In addition, for more extensibility/customizability, a doccommenting:commentdata node allows to store any ad hoc single-valued or multi-valued properties in different types (string, boolean, long, double and date).

You can find an example which takes advantage of this here:

https://github.com/bloomreach-forge/document-commenting/tree/master/demo/cms/src/main/java/org/onehippo/forge/document/commenting/demo/cms/

Document Commenting Data Node Structure

One of the easiest way to look up the comment data is to use the Repository Servlet (/cms/repository). So, you can execute query like the following example to search comment data:

Query in Repository Servlet

It will show all the values of the default properties together in the result view.

You can also browse the data by the path in CMS Console like the following. CMS Console will show all the properties (not just the basic properties but also any custom/extended properties if you have any).

View in CMS Console

As you can see, it creates 26 folders from 'a' to 'z' in 4 levels initially and stores a comment node after selecting a fourth-level folder randomly. This way, it can store a lot of data in a more performant and scalable way.