You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-dev@jackrabbit.apache.org by Vivek Kamble <vi...@gmail.com> on 2019/01/10 11:46:54 UTC
Node versioning, Custom attribute lost on versioning
Hi team,
Question is regarding versioning of node,
Step 1) If a Custom node which is of type mix:versionable and with custom
properties is added as child of root node. using
Node node=rootNode.addNode(name, type);
node.addMixin("mix:versionable");
setFolderNodeAttributes(cutomMetadataObj, node, type); api.
Step 2 ) and if second version is created and saved on same node but with
Different attributes for eg. below
final VersionManager versionManager =
session.getWorkspace().getVersionManager();
Node node = RootNode.getNode(name);
versionManager.checkout(node.getPath());
setCustomNodeAttributes(newMetadataObj,
node, type);
session.save();
versionManager.checkin(node.getPath());
Now Version hsitory object gives me two version
1) jcr:rootVersion
2) First Version naming 1.0
This version 1.0, has currenlty updated Custom attributes, and root version
doesnt have any custom attributes.
So for first commit or 0the version of node, which was created in step 1,
custom attributes are lost(In DB they are present), but through
VersionManager api i'm not able to read the 0th commit attributes.
Im using following code for iterating over versions
final VersionHistory versionHistory =
versionManager.getVersionHistory(node.getPath());
final VersionIterator versionItrator = versionHistory.getAllVersions();
while(versionItrator.hasNext()){
final Version version = versionItrator.nextVersion();
final Node idNode = version.getFrozenNode();
if (idNode.hasProperty("<Custom Property>")){ // For JCR:rootVersion its
not present and for version 1.0 it printing latest checkedin property
//Print It
}
}
Thanks In advanced,
Re: Node versioning, Custom attribute lost on versioning
Posted by Vivek Kamble <vi...@gmail.com>.
Hi team,
Question is regarding versioning of node,
Step 1) If a Custom node which is of type mix:versionable and with custom
properties is added as child of root node. using
Node node=rootNode.addNode(name, type);
node.addMixin("mix:versionable");
setCustomNodeAttributes(cutomMetadataObj, node, type);
Step 2 ) and if second version is created and saved on same node but with
Different attributes for eg. below
final VersionManager versionManager =
session.getWorkspace().getVersionManager();
Node node = RootNode.getNode(name);
versionManager.checkout(node.getPath());
setCustomNodeAttributes(newMetadataObj,
node, type);
session.save();
versionManager.checkin(node.getPath());
Now Version hsitory object gives me two version
1) jcr:rootVersion
2) First Version naming 1.0
This version 1.0, has currenlty updated Custom attributes, and root version
doesnt have any custom attributes.
So for first commit or 0the version of node, which was created in step 1,
custom attributes are lost(In DB they are present), but through
VersionManager api i'm not able to read the 0th commit attributes.
Im using following code for iterating over versions
final VersionHistory versionHistory =
versionManager.getVersionHistory(node.getPath());
final VersionIterator versionItrator = versionHistory.getAllVersions();
while(versionItrator.hasNext()){
final Version version = versionItrator.nextVersion();
final Node idNode = version.getFrozenNode();
if (idNode.hasProperty("<Custom Property>")){ // For JCR:rootVersion its
not present and for version 1.0 it printing latest checkedin property
//Print It
}
}
Thanks In advanced
On Thu, Jan 10, 2019, 5:16 PM Vivek Kamble <vivekk360@gmail.com wrote:
> Hi team,
>
>
>
> Question is regarding versioning of node,
>
>
>
> Step 1) If a Custom node which is of type mix:versionable and with custom
> properties is added as child of root node. using
>
> Node node=rootNode.addNode(name, type);
>
> node.addMixin("mix:versionable");
>
> setFolderNodeAttributes(cutomMetadataObj, node, type); api.
>
>
>
> Step 2 ) and if second version is created and saved on same node but with
> Different attributes for eg. below
>
>
>
> final VersionManager versionManager =
> session.getWorkspace().getVersionManager();
>
> Node node = RootNode.getNode(name);
>
> versionManager.checkout(node.getPath());
>
> setCustomNodeAttributes(newMetadataObj,
> node, type);
>
> session.save();
>
> versionManager.checkin(node.getPath());
>
>
>
> Now Version hsitory object gives me two version
>
> 1) jcr:rootVersion
>
> 2) First Version naming 1.0
>
>
>
> This version 1.0, has currenlty updated Custom attributes, and root
> version doesnt have any custom attributes.
>
> So for first commit or 0the version of node, which was created in step 1,
> custom attributes are lost(In DB they are present), but through
> VersionManager api i'm not able to read the 0th commit attributes.
>
>
>
> Im using following code for iterating over versions
>
>
>
> final VersionHistory versionHistory =
> versionManager.getVersionHistory(node.getPath());
>
> final VersionIterator versionItrator = versionHistory.getAllVersions();
>
> while(versionItrator.hasNext()){
>
> final Version version = versionItrator.nextVersion();
>
> final Node idNode = version.getFrozenNode();
>
> if (idNode.hasProperty("<Custom Property>")){ // For JCR:rootVersion its
> not present and for version 1.0 it printing latest checkedin property
>
> //Print It
>
> }
>
> }
>
>
>
> Thanks In advanced,
>
>
>
>