// TODO: post-process deletes so that child deletes are subsumed by parent deletes.
}
// Notify the edit session verticle of the changes.
JsonObject message = new JsonObject();
JsonArray messageDelete = new JsonArray();
JsonArray messageModify = new JsonArray();
message.putArray("delete", messageDelete);
message.putArray("modify", messageModify);
// Broadcast a tree mutation to all clients.
WorkspaceTreeUpdateBroadcastImpl broadcast = WorkspaceTreeUpdateBroadcastImpl.make();
for (NodeInfoExt node : adds) {
System.out.println("add: " + pathString(node));
// Edit session doesn't care.
// Broadcast to clients.
MutationImpl mutation =
MutationImpl.make().setMutationType(Mutation.Type.ADD).setNewPath(pathString(node));
/*
* Do not strip the node; in the case of a newly scanned directory (e.g. recursive copy), its
* children to not get their own mutations, it's just a single tree.
*/
mutation.setNewNodeInfo((TreeNodeInfoImpl) node);
broadcast.getMutations().add(mutation);
}
for (NodeInfoExt node : removes) {
System.out.println("del: " + pathString(node));
// Edit session wants deletes.
messageDelete.addString(node.getFileEditSessionKey());
// Broadcast to clients.
MutationImpl mutation =
MutationImpl.make().setMutationType(Mutation.Type.DELETE).setOldPath(pathString(node));
broadcast.getMutations().add(mutation);
}
for (ExpectedMove move : completedMoves) {
System.out.println("mov: " + pathString(move.oldNode) + " to: " + pathString(move.newNode));
// Edit session doesn't care.
// Broadcast to clients.
MutationImpl mutation = MutationImpl.make()
.setMutationType(Mutation.Type.MOVE).setNewPath(pathString(move.newNode))
.setOldPath(pathString(move.oldNode));
// Strip the node; the client should already have the children.
mutation.setNewNodeInfo(stripChildren(move.newNode));
broadcast.getMutations().add(mutation);
}
for (NodeInfoExt node : modifies) {
System.out.println("mod: " + pathString(node));
// Edit session wants modifies.
messageModify.addString(node.getFileEditSessionKey());
// No broadcast, edit session will handle.
}
vertx.eventBus().send("documents.fileSystemEvents", message);
if (treeDirty) {
broadcast.setNewTreeVersion(Long.toString(treeVersion));