I want to delete documents for which a specific property has been set in the current version. If this property has been set all versions of that document need to be removed.
My current implementation which searches for IsCurrentVersion = TRUE and foo = 'bar'
has the problem that only the current version gets removed and not the older ones. So I assume that I need to delete the complete VersionSeries ?
Till now I use
doc.delete();
doc.save(RefreshMode.NO_REFRESH);
for each document I find. How can I retrieve all documents from the series and have them deleted too ? And is it more efficient if I add this to a batch ?
You should call the
delete()
method for the VersionSeries (http://www-304.ibm.com/support/knowledgecenter/SSNW2F_5.2.0/com.ibm.p8.ce.dev.java.doc/com/filenet/api/core/VersionSeries.html) instance,
VersionSeries vs = doc.getVersionSeries();
vs.delete();
vs.save(Refresh.NO_REFRESH);
Quote from docs
Caution: The delete and moveContent methods impact all document versions in the version series. That is, all document versions are deleted, and the content of all document versions are moved.