}
// If we are deleting the last version of a document, remove it
// from the index. If we may be deleting the latest version of
// the document, force the new latest version to be re-indexed.
ICollection versions = null;
try {
versions = getCurrentVersion(chronicleId);
if (versions != null && versions.next()) {
ITime lastModify = versions.getTime("r_modify_date");
if (lastModify.getDate().before(deleteDate.getDate())) {
// We may have deleted the latest version, so refeed the
// current latest version.
dctmSysobjectDocument = new DctmSysobjectDocument(
traversalManager, session,
versions.getString("r_object_id"), chronicleId,
lastModify, SpiConstants.ActionType.ADD, checkpoint);
logger.fine("Creation of a new dctmSysobjectDocument to "
+ "resubmit newest version of deleted item: "
+ chronicleId);
} else {
// Skip this doc.
logger.fine("Skipping delete of old version: " + chronicleId);
continue;
}
} else {
// No more versions of the document remain.
// Delete the document from the index.
dctmSysobjectDocument = new DctmSysobjectDocument(
traversalManager, session,
collectionToDel.getString("audited_obj_id"), chronicleId,
deleteDate, SpiConstants.ActionType.DELETE, checkpoint);
logger.fine("Creation of a new dctmSysobjectDocument to delete: "
+ chronicleId);
}
} finally {
if (versions != null) {
versions.close();
}
}
// Handled this version in this batch.
deletedIds.add(chronicleId);
retDoc = dctmSysobjectDocument;