if (reader.isDeleted(i)) {
continue;
}
Document d = reader.document(i);
UUID uuid = UUID.fromString(d.get(FieldNames.UUID));
if (stateMgr.hasItemState(new NodeId(uuid))) {
if (!documentUUIDs.add(uuid)) {
multipleEntries.add(uuid);
}
} else {
errors.add(new NodeDeleted(uuid));
}
}
} finally {
reader.close();
}
// create multiple entries errors
for (Iterator it = multipleEntries.iterator(); it.hasNext();) {
errors.add(new MultipleEntries((UUID) it.next()));
}
reader = index.getIndexReader();
try {
// run through documents again and check parent
for (int i = 0; i < reader.maxDoc(); i++) {
if (i > 0 && i % (reader.maxDoc() / 5) == 0) {
long progress = Math.round((100.0 * (float) i) / ((float) reader.maxDoc() * 2f));
log.info("progress: " + (progress + 50) + "%");
}
if (reader.isDeleted(i)) {
continue;
}
Document d = reader.document(i);
UUID uuid = UUID.fromString(d.get(FieldNames.UUID));
String parentUUIDString = d.get(FieldNames.PARENT);
UUID parentUUID = null;
if (parentUUIDString.length() > 0) {
parentUUID = UUID.fromString(parentUUIDString);
}
if (parentUUID == null || documentUUIDs.contains(parentUUID)) {
continue;
}
// parent is missing
NodeId parentId = new NodeId(parentUUID);
if (stateMgr.hasItemState(parentId)) {
errors.add(new MissingAncestor(uuid, parentUUID));
} else {
errors.add(new UnknownParent(uuid, parentUUID));
}