You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by Tobias Bocanegra <tr...@adobe.com> on 2011/10/02 01:08:02 UTC
Re: Jackrabbit 2.2.8 Retrieval of JCR:data node from VersionHistory
( not available)
but you're iterating over the properties of the frozen node of the
version, which corresponds to the nt:file.
i think if you change the code to:
Node n = version.getFrozenNode().getNode("jcr:content");
you should get the desired result.
regards, toby
On Fri, Sep 30, 2011 at 5:04 PM, yacur <ya...@yahoo.com> wrote:
> I am trying to retrieved the diff versions for jcr:data node that represented
> by the resNode in the code below. But when going through the versions, the
> jcr:data property is not available. Can someone please inform me why?
>
> So after this snippet:
> Node root = s.getRootNode();
> Node timcard = root.addNode("ntfolder" , JcrConstants.NT_FOLDER );
> Node fileNode = timcard.addNode("123" , JcrConstants.NT_FILE );
> Node resNode = fileNode.addNode(JcrConstants.JCR_CONTENT,
> JcrConstants.NT_RESOURCE);
> fileNode.addMixin(JcrConstants.MIX_VERSIONABLE);
>
> Binary binary = new BinaryImpl( is );
>
> resNode.setProperty("jcr:data", "hello" );
> s.save();
> VersionManager vm = s.getWorkspace().getVersionManager();
> for(int i=0; i<3; i++) {
> vm.checkout("/ntfolder/123");
> resNode.setProperty("jcr:data", binary );
> s.save();
> vm.checkin("/ntfolder/123");
> }
> s.save();
> VersionHistory history = vm.getVersionHistory("/ntfolder/123");
> for (VersionIterator it = history.getAllVersions(); it.hasNext();)
> {
> Version version = (Version) it.next();
> System.out.println("getting version " + version.getName());
>
> Node n = version.getFrozenNode();
> PropertyIterator pi = n.getProperties();
> while ( pi.hasNext() ) {
> Property p = pi.nextProperty();
> System.out.println( "Prop name " + p.getName() );
> }
> }
>
> the property jcr:data never shows up:
>
> All versions except the base have:
> Prop name jcr:frozenUuid
> Prop name jcr:uuid
> Prop name jcr:createdBy
> Prop name jcr:frozenPrimaryType
> Prop name jcr:created
> Prop name jcr:frozenMixinTypes
> Prop name jcr:primaryType
>
>
> --
> View this message in context: http://jackrabbit.510166.n4.nabble.com/Jackrabbit-2-2-8-Retrieval-of-JCR-data-node-from-VersionHistory-not-available-tp3860061p3860061.html
> Sent from the Jackrabbit - Dev mailing list archive at Nabble.com.
>
Re: Jackrabbit 2.2.8 Retrieval of JCR:data node from VersionHistory (
not available)
Posted by Tobias Bocanegra <tr...@apache.org>.
but the jcr:data should be on the jcr:content.
regards, toby
On Wed, Dec 4, 2013 at 1:19 AM, mpankaj <mp...@yahoo.com> wrote:
> I have tried what was suggesed to get jcr:data, but I still get path not
> found error. Is there a solution. I will truly appreciate if you have any
> idea.
>
>
>
> --
> View this message in context: http://jackrabbit.510166.n4.nabble.com/Jackrabbit-2-2-8-Retrieval-of-JCR-data-node-from-VersionHistory-not-available-tp3860061p4660016.html
> Sent from the Jackrabbit - Dev mailing list archive at Nabble.com.
Re: Jackrabbit 2.2.8 Retrieval of JCR:data node from VersionHistory
( not available)
Posted by mpankaj <mp...@yahoo.com>.
The reason jcr:data is not found is becuase the root version does not have
it. So while going through the loop of all versions, skip the first node.
VersionManager versionMgr = session.getWorkspace().getVersionManager();
VersionHistory history = versionMgr.getVersionHistory(path to
jcr:content);
VersionIterator ito = history.getAllVersions();
while (ito.hasNext()) {
Version v = ito.nextVersion();
String version = v.getName();
if (version.startsWith("jcr:"))
{
continue; // skip root version
}
Node frozenNode = v.getFrozenNode();
// now you can see jcr:data property
}
--
View this message in context: http://jackrabbit.510166.n4.nabble.com/Jackrabbit-2-2-8-Retrieval-of-JCR-data-node-from-VersionHistory-not-available-tp3860061p4660024.html
Sent from the Jackrabbit - Dev mailing list archive at Nabble.com.
Re: Jackrabbit 2.2.8 Retrieval of JCR:data node from VersionHistory
( not available)
Posted by mpankaj <mp...@yahoo.com>.
I have tried what was suggesed to get jcr:data, but I still get path not
found error. Is there a solution. I will truly appreciate if you have any
idea.
--
View this message in context: http://jackrabbit.510166.n4.nabble.com/Jackrabbit-2-2-8-Retrieval-of-JCR-data-node-from-VersionHistory-not-available-tp3860061p4660016.html
Sent from the Jackrabbit - Dev mailing list archive at Nabble.com.
Re: Jackrabbit 2.2.8 Retrieval of JCR:data node from VersionHistory
( not available)
Posted by yacur <ya...@yahoo.com>.
Thanks Toby.
Now I see the light.
--
View this message in context: http://jackrabbit.510166.n4.nabble.com/Jackrabbit-2-2-8-Retrieval-of-JCR-data-node-from-VersionHistory-not-available-tp3860061p3866308.html
Sent from the Jackrabbit - Dev mailing list archive at Nabble.com.