use of org.tmatesoft.svn.core.wc.admin.ISVNAdminEventHandler in project mycore by MyCoRe-Org.
the class MCRVersioningMetadataStore method verify.
/**
* Checks to local SVN repository for errors
* @throws MCRPersistenceException if 'svn verify' fails
*/
public void verify() throws MCRPersistenceException {
String replURLStr = repURL.toString();
if (!repURL.getProtocol().equals("file")) {
LOGGER.warn("Cannot verify non local SVN repository '{}'.", replURLStr);
return;
}
try {
SVNRepository repository = getRepository();
long latestRevision = repository.getLatestRevision();
if (latestRevision == 0) {
LOGGER.warn("Cannot verify SVN repository '{}' with no revisions.", replURLStr);
}
ISVNAuthenticationManager authenticationManager = repository.getAuthenticationManager();
SVNAdminClient adminClient = new SVNAdminClient(authenticationManager, null);
File repositoryRoot = new File(URI.create(replURLStr));
adminClient.setEventHandler(new ISVNAdminEventHandler() {
// if more than batchSize revisions print progress
int batchSize = 100;
@Override
public void checkCancelled() throws SVNCancelException {
}
@Override
public void handleEvent(SVNEvent event, double progress) throws SVNException {
}
@Override
public void handleAdminEvent(SVNAdminEvent event, double progress) throws SVNException {
if (event.getMessage() != null) {
if (event.getRevision() % batchSize != 0 || event.getRevision() == 0) {
LOGGER.debug(event::getMessage);
} else {
LOGGER.info("{} ({}% done)", event.getMessage(), (int) (event.getRevision() * 100.0 / latestRevision));
}
}
}
});
adminClient.doVerify(repositoryRoot);
LOGGER.info("Verified SVN repository '{}'.", replURLStr);
} catch (Exception e) {
throw new MCRPersistenceException("SVN repository contains errors and could not be verified: " + replURLStr, e);
}
}
Aggregations