NodeBuilder definitions = builder.child(INDEX_DEFINITIONS_NAME);
for (String name : definitions.getChildNodeNames()) {
NodeBuilder definition = definitions.child(name);
if (async == getBoolean(definition, ASYNC_PROPERTY_NAME)) {
String type = getString(definition, TYPE_PROPERTY_NAME);
Editor editor = null;
if (tempEditors.containsKey(type)) {
editor = tempEditors.get(type);
} else {
editor = provider.getIndexEditor(type, builder);
tempEditors.put(type, editor);
}
if (editor == null) {
// trigger reindexing when an indexer becomes available
definition.setProperty(REINDEX_PROPERTY_NAME, true);
} else if (getBoolean(definition, REINDEX_PROPERTY_NAME)) {
definition.setProperty(REINDEX_PROPERTY_NAME, false);
// as we don't know the index content node name
// beforehand, we'll remove all child nodes
for (String rm : definition.getChildNodeNames()) {
definition.removeChildNode(rm);
}
reindex.add(editor);
} else {
editors.add(VisibleEditor.wrap(editor));
}
}
}
}
// no-op when reindex is empty
CommitFailedException exception = EditorDiff.process(
VisibleEditor.wrap(CompositeEditor.compose(reindex)), MISSING_NODE, after);
if (exception != null) {
throw exception;
}
for (Editor editor : editors) {
editor.enter(before, after);
}
}