}
void saveAll() {
Set<Entry<String, FileEditSession>> entries = editSessions.entrySet();
Iterator<Entry<String, FileEditSession>> entryIter = entries.iterator();
final JsonArray resourceIds = new JsonArray();
while (entryIter.hasNext()) {
Entry<String, FileEditSession> entry = entryIter.next();
String resourceId = entry.getKey();
FileEditSession editSession = entry.getValue();
if (editSession.hasChanges()) {
resourceIds.addString(resourceId);
}
}
// Resolve the current paths of opened files in case they have been moved.
eb.send("tree.getCurrentPaths", new JsonObject().putArray("resourceIds", resourceIds),
new Handler<Message<JsonObject>>() {
@Override
public void handle(Message<JsonObject> event) {
JsonArray currentPaths = event.body.getArray("paths");
Iterator<Object> pathIter = currentPaths.iterator();
Iterator<Object> resourceIter = resourceIds.iterator();
if (currentPaths.size() != resourceIds.size()) {
logger.error(String.format(
"Received [%d] paths in response to a request specifying [%d] resourceIds",
currentPaths.size(), resourceIds.size()));
}
// Iterate through all the resolved paths and save the files to disk.
while (pathIter.hasNext()) {
String path = (String) pathIter.next();