1 Reply Latest reply on Apr 10, 2014 2:42 AM by Horia Chiorean

    How do I get to jcr:data from the root version?  It does not exist when using VersionHistory.getRootVersion().

    Ross Woolf Newbie

      I have a content node that is versioned. I store binary documents here.  Using VersionHistory I can retrieve any of the versions except the root version.  I am using ModeShape 3.7.1.

       

      To get at the subsequent versions I can do the following.

      VersionManager vm = session.getWorkspace().getVersionManager();

      String strNodePath = getFileNode().getNode("jcr:content").getPath();

      VersionHistory vh = vm.getVersionHistory(strNodePath);

      Version version =vh.getVersionByLabel(label);

      Node content = version.getFrozenNode();

      Property property = content.getProperty("jcr:data");

      Binary binary = property.getValue().getBinary();

       

      This all works.

       

      However if I try:

      VersionManager vm = session.getWorkspace().getVersionManager();

      String strNodePath = getFileNode().getNode("jcr:content").getPath();

      VersionHistory vh = vm.getVersionHistory(strNodePath);

      Version version =vh.getRootVersion();

      Node content = version.getFrozenNode();

      Property property = content.getProperty("jcr:data");

      Binary binary = property.getValue().getBinary();

       

      I get the exception: "No item exists at path jcr:data relative to /jcr:system/jcr:versionStorage..."

       

      When I inspect the frozen node via eclipse I see that it contains no jcr:data content

      /jcr:system/jcr:versionStorage/db/24/ce/db24cec72066b21dbd5fa66dd07ab676b4f5aec1/jcr:rootVersion/jcr:frozenNode {jcr:primaryType=nt:frozenNode, jcr:frozenPrimaryType=nt:resource, jcr:frozenMixinTypes=[mix:versionable], jcr:frozenUuid=24a4600b-6401-481b-a36c-8a39faa275f3, jcr:uuid=e03bade317f1e7fe6cafa1-c128-4fda-9e77-a2643e5d2dfb}

       

      Whereas the ones that work do in fact have the jcr:data within the frozon node.

      /jcr:system/jcr:versionStorage/db/24/ce/db24cec72066b21dbd5fa66dd07ab676b4f5aec1/1.12/jcr:frozenNode {jcr:primaryType=nt:frozenNode, jcr:data=**binary-value-not-shown**, jcr:frozenPrimaryType=nt:resource, jcr:frozenMixinTypes=[mix:versionable], jcr:lastModified=2014-04-08T16:47:15.076-06:00, jcr:frozenUuid=24a4600b-6401-481b-a36c-8a39faa275f3, jcr:lastModifiedBy=<anonymous>, jcr:uuid=e03bade317f1e773c4b7cf-aa0d-4153-9870-747907f04458, jcr:mimeType=application/pdf}

       

      I have played around with the code but I can't find any way to get at the original binary data to retrieve it.  Can anyone point me in the right direction to be able to retrieve the binary of my root version?