hi All,
My requirement is to delete the node and its history, as both won't be
useful as per application logic.
I would like to completely delete version history for the node as it will
save us disk space and backup time.
Node childNode = parentNode.getNode("mynode"); /* node to be
completely deleted */
/* get a handle to version history before node deletion */
VersionHistory vh =
session.getWorkspace().getVersionManager().getVersionHistory(childNode.getPath());
VersionIterator vitr = vh.getAllVersions();
vitr.skip(1); /* skipping as this is "jcr:baseVersion" */
List<String> vnames = new ArrayList<String>();
childNode.remove() ;
session.save();
while (vitr.hasNext()) {
Version v = vitr.nextVersion();
String vName = v.getName();
vnames.add(vName);
}
for (String name: vnames) {
vh.removeVersion(name);
}
session.save();
Using this logic I can delete all version nodes, except the base node
"jcr:baseVersion".
Node hierarchy is root/parent/childNode. I don't have any references of
childNode from any other node in Jack rabbit tree.
Would like to know --
1. How to completely delete the version history of node, including
"jcr:baseVersion" ?
2. If it is impossible to delete them, what is the overhead (space and
references wise) of leaving then hanging?
3. As per Cedric's reply, "jcr:baseVersion" should be auto deleted. When
does the system actually delete it? During session.save() ?
How to verify it?
Pasted below is the note about auto deletion -
http://web.archiveorange.com/archive/v/L1HBQ8pa9cRvxZlPyJ1C
===================
Hi all,
As of 1.6, empty and unused VersionHistory will be automatically removed
after removal of the last Version (see
https://issues.apache.org/jira/browse/JCR-134).
This will ensure that the disk usage will not grow unnecessarily.
Regards,
Cédric
===================
Related discussion -
http://stackoverflow.com/questions/3531597/cant-remove-version-in-jackrabbit
thanks & regards,
Raj