while (retDoc == null) {
if (isOpen(collectionToAdd) && collectionToAdd.next()) {
logger.fine("Looking through the collection of documents to add");
String objId = "";
ITime modifyDate = null;
try {
objId = collectionToAdd.getString("r_object_id");
modifyDate = collectionToAdd.getTime("r_modify_date");
logger.fine("r_object_id is " + objId + " modifyDate is "
+ modifyDate.getDate());
} catch (RepositoryException e) {
logger.severe("impossible to get the r_object_id of the document");
return null;
}
checkpoint.setInsertCheckpoint(modifyDate.getDate(), objId);
dctmSysobjectDocument = new DctmSysobjectDocument(traversalManager,
session, objId, collectionToAdd.getString("i_chronicle_id"),
modifyDate, SpiConstants.ActionType.ADD, checkpoint);
logger.fine("Creation of a new dctmSysobjectDocument to add");
retDoc = dctmSysobjectDocument;
} else if (isOpen(collectionToDel) && collectionToDel.next()) {
logger.fine("Looking through the collection of documents to remove");
String eventId = "";
ITime deleteDate = null;
try {
eventId = collectionToDel.getString("r_object_id");
deleteDate = collectionToDel.getTime("time_stamp_utc");
logger.fine("delete event r_object_id is " + eventId
+ " deleteDate is " + deleteDate.getDate());
} catch (RepositoryException e) {
logger.warning("impossible to get the r_object_id of the delete event");
return null;
}
checkpoint.setDeleteCheckpoint(deleteDate.getDate(), eventId);
String chronicleId = collectionToDel.getString("chronicle_id");
// Deleting multiple versions can post multiple dm_destroy and
// dm_prune events with the same chronicle_id. We only want to
// send a single delete request to the GSA.
if (deletedIds.contains(chronicleId)) {
logger.fine("Skipping redundant delete of version: " + chronicleId);
continue; // Already deleted this chronicle_id in this batch.
}
// 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,