Not able to get jcr:content of rootVersion node

365 views Asked by At

I have created a node and created 2 versions of it using VersionManager checkout and checkin feature. I am adding/setting xyz files contents in jcr:content property.

version::jcr:rootVersion
hasNode:jcr_content :false
version::1.0
hasNode:jcr_content :true
version::1.1
hasNode:jcr_content :true

But when I am trying to get all versions data using below code, I am not able to get jcr:content property of jcr:rootVersion node. I am able to to fetch files contents using jcr:content property of version 1.0 and 1.1

if (node.isNodeType(NodeType.MIX_VERSIONABLE)) {
    final VersionHistory versionHistory = session.getWorkspace().getVersionManager().getVersionHistory(node.getPath());
    final VersionIterator itr = versionHistory.getAllVersions();
    while (itr.hasNext()) {
        final Version v = itr.nextVersion();
        final Node frozenNode = v.getFrozenNode();
        log.info("version::" + v.getName());
        log.info("hasNode:jcr_content :" + frozenNode.hasNode(Property.JCR_CONTENT));
    }
}

How I can get files content from rootversion node, why jcr:content property is not available for root version in jcr version history.

1

There are 1 answers

6
Julian Reschke On

See https://docs.adobe.com/content/docs/en/spec/jcr/2.0/3_Repository_Model.html#3.13.5.2%20Root%20Version:

3.13.5.2 Root Version

Each version history has a root version, which is a null version that stores no state; it simply serves as the eventual predecessor of all subsequent versions.

The root version is accessed through VersionHistory.getRootVersion (see 15.1.1.1 Root Version). Under full versioning it is also represented as an nt:version child node of the nt:versionHistory node, called jcr:rootVersion.