}
}
protected void checkRebuildHasRun(boolean firstRun) throws Exception {
Connection conn = null;
ConnectionPool cpm = SQLUtility.getConnectionPool(getConfig());
try {
conn = cpm.getReadWriteConnection();
long mostRecentRebuildDate = SQLUtility.getMostRecentRebuild(conn);
if (firstRun && mostRecentRebuildDate == -1) {
// if first run and rebuildStatus has NO ROWS, create one
SQLUtility.recordSuccessfulRebuild(conn, System.currentTimeMillis());
} else {
// otherwise, verify that the most recent rebuild was successful
boolean rebuildFinished =
SQLUtility.getRebuildStatus(conn, mostRecentRebuildDate);
if (!rebuildFinished) {
throw new ServerInitializationException(
"The SQL Rebuild attempted on "
+ new Date(mostRecentRebuildDate).toGMTString()
+ " did not finish successfully, which may compromise"
+ " the repo. Please re-run the SQL rebuild.");
}
}
} finally {
if (conn != null) cpm.free(conn);
}
}