From: <jbo...@li...> - 2005-11-01 12:27:10
|
Author: aron.gombas Date: 2005-11-01 07:26:56 -0500 (Tue, 01 Nov 2005) New Revision: 1482 Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java Log: Caching check extended for secure repos, too Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java 2005-11-01 12:11:32 UTC (rev 1481) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java 2005-11-01 12:26:56 UTC (rev 1482) @@ -85,13 +85,41 @@ String url = key.toString(); try { - return (SVNRepositoryFactory.create(SVNURL.parseURIEncoded(url)).getLatestRevision() == previousLatestRevision); + SVNRepository repo = connect(url); + return (repo.getLatestRevision() == previousLatestRevision); } catch(SVNException ex) { log.error("Unable to get the latest revision", ex); return false; } } + + /** + * Connects to the given public or secure SVN URL. + * @return the repository after a successful connection. + */ + protected SVNRepository connect(String url) throws SVNException { + // connect to repository + SVNURL svnUrl = SVNURL.parseURIEncoded(url); + SVNRepository repo = SVNRepositoryFactory.create(svnUrl); + + // authenticate if repository is secured + String userInfo = svnUrl.getUserInfo(); + if(!StringUtils.isBlank(userInfo)) { + String strings[] = StringUtils.split(userInfo, ':'); + if(strings.length != 2) + throw new IllegalArgumentException(String.format("Invalid user info \"%s\"", userInfo)); + String userName = strings[0]; + String password = strings[1]; + if(StringUtils.isBlank(userName) || StringUtils.isBlank(password)) + throw new IllegalArgumentException(String.format("Invalid username (\"%s\") or password (\"%s\")", userName, password)); + log.debug(String.format("Signing in as \"%s\" \"%s\"...", userName, password)); + repo.setAuthenticationManager(SVNWCUtil.createDefaultAuthenticationManager(userName, password)); + } + + return repo; + } + public Object reloadData(Object key) { String url = key.toString(); List<SvnRepository> repositories = new ArrayList<SvnRepository>(); @@ -101,24 +129,8 @@ SVNRepositoryFactoryImpl.setup(); try { - // connect to repository - SVNURL svnUrl = SVNURL.parseURIEncoded(url); - SVNRepository repo = SVNRepositoryFactory.create(svnUrl); - - // authenticate if repository is secured - String userInfo = svnUrl.getUserInfo(); - if(!StringUtils.isBlank(userInfo)) { - String strings[] = StringUtils.split(userInfo, ':'); - if(strings.length != 2) - throw new IllegalArgumentException(String.format("Invalid user info \"%s\"", userInfo)); - String userName = strings[0]; - String password = strings[1]; - if(StringUtils.isBlank(userName) || StringUtils.isBlank(password)) - throw new IllegalArgumentException(String.format("Invalid username (\"%s\") or password (\"%s\")", userName, password)); - log.debug(String.format("Signing in as \"%s\" \"%s\"...", userName, password)); - - repo.setAuthenticationManager(SVNWCUtil.createDefaultAuthenticationManager(userName, password)); - } + // connect + SVNRepository repo = connect(url); // get repository info SvnRepositoryLogStats logStats = analyzeLog(repo); |