/**
* @return whether we are waiting for unacked or queued doc ops
*/
public boolean notifyForDocuments(Callback callback, int... documentIds) {
RemoverManager remover = new RemoverManager();
JsonIntegerMap<Integer> remainingAcksByDocumentId = JsonCollections.createIntegerMap();
for (int i = 0; i < documentIds.length; i++) {
int documentId = documentIds[i];
if (!DocumentMetadata.isLinkedToFile(documentManager.getDocumentById(documentId))) {
// Ignore unlinked files
continue;
}
DocumentCollaborationController documentCollaborationController =
collaborationManager.getDocumentCollaborationController(documentId);
Preconditions.checkNotNull(documentCollaborationController,
"Could not find collaboration controller document ID [" + documentId + "]");
FileConcurrencyController fileConcurrencyController =
documentCollaborationController.getFileConcurrencyController();
int remainingAcks = computeRemainingAcks(fileConcurrencyController);
if (remainingAcks > 0) {
remainingAcksByDocumentId.put(documentId, remainingAcks);
remover.track(
fileConcurrencyController.getDocOpListenerRegistrar().add(callback.docOpListener));
}
}
callback.initialize(remover, remainingAcksByDocumentId);