// iterate over all node bundles in the db
while (rs.next()) {
NodeId id;
if (getStorageModel() == SM_BINARY_KEYS) {
id = new NodeId(new UUID(rs.getBytes(1)));
} else {
id = new NodeId(new UUID(rs.getLong(1), rs.getLong(2)));
}
// issuing 2nd statement to circumvent issue JCR-1474
ResultSet bRs = null;
byte[] data = null;
try {
Statement bSmt = connectionManager.executeStmt(bundleSelectSQL, getKey(id.getUUID()));
bRs = bSmt.getResultSet();
if (!bRs.next()) {
throw new SQLException("bundle cannot be retrieved?");
}
Blob blob = bRs.getBlob(1);
data = getBytes(blob);
} finally {
closeResultSet(bRs);
}
try {
// parse and check bundle
// checkBundle will log any problems itself
DataInputStream din = new DataInputStream(new ByteArrayInputStream(data));
if (binding.checkBundle(din)) {
// reset stream for readBundle()
din = new DataInputStream(new ByteArrayInputStream(data));
NodePropBundle bundle = binding.readBundle(din, id);
checkBundleConsistency(id, bundle, fix, modifications);
} else {
log.error("invalid bundle '" + id + "', see previous BundleBinding error log entry");
}
} catch (Exception e) {
log.error("Error in bundle " + id + ": " + e);
}
count++;
if (count % 1000 == 0) {
log.info(name + ": checked " + count + "/" + total + " bundles...");
}
}
} catch (Exception e) {
log.error("Error loading bundle", e);
} finally {
closeResultSet(rs);
total = count;
}
} else {
// check only given uuids, handle recursive flag
// 1) convert uuid array to modifiable list
// 2) for each uuid do
// a) load node bundle
// b) check bundle, store any bundle-to-be-modified in collection
// c) if recursive, add child uuids to list of uuids
List<UUID> uuidList = new ArrayList<UUID>(uuids.length);
// convert uuid string array to list of UUID objects
for (int i = 0; i < uuids.length; i++) {
try {
uuidList.add(new UUID(uuids[i]));
} catch (IllegalArgumentException e) {
log.error("Invalid uuid for consistency check, skipping: '" + uuids[i] + "': " + e);
}
}
// iterate over UUIDs (including ones that are newly added inside the loop!)
for (int i = 0; i < uuidList.size(); i++) {
final UUID uuid = (UUID) uuidList.get(i);
try {
// load the node from the database
NodeId id = new NodeId(uuid);
NodePropBundle bundle = loadBundle(id, true);