Reputation: 61
So, I've created a project TEST under an SVN repository and I want to know if this project directory exists with SVNKit library. Protocol is http.
I tried for example...
private String urlSviluppo = "http://myrepo/SVILUPPO";
DAVRepositoryFactory.setup();
SVNURL url = SVNURL.parseURIDecoded(urlSviluppo);
ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager("user", "pwd");
DAVRepository repositorySviluppo = (DAVRepository)DAVRepositoryFactory.create(url, null);
repositorySviluppo.setAuthenticationManager(authManager);
DefaultSVNOptions options = SVNWCUtil.createDefaultOptions(true);
SVNClientManager clientManager = SVNClientManager.newInstance(options, "user", "pwd");
clientManager.createRepository(url, true);
how can I access repository/project info ?
thanks
Upvotes: 1
Views: 5993
Reputation: 15525
Have a look at the example at "Printing Out a Subversion Repository Tree". It contains the following code:
SVNNodeKind nodeKind = repository.checkPath( "" , -1 );
if ( nodeKind == SVNNodeKind.NONE ) {
System.err.println( "There is no entry at '" + url + "'." );
System.exit( 1 );
} else if ( nodeKind == SVNNodeKind.FILE ) {
System.err.println( "The entry at '" + url + "' is a file while a directory was expected." );
System.exit( 1 );
}
That checks if your location is ok as a repository root.
Collection entries = repository.getDir( path, -1 , null , (Collection) null );
Iterator iterator = entries.iterator( );
while ( iterator.hasNext( ) ) {
SVNDirEntry entry = ( SVNDirEntry ) iterator.next( );
...
Iterate over the entries of the current dir.
if ( entry.getKind() == SVNNodeKind.DIR ) {
listEntries( repository, ( path.equals( "" ) ) ? entry.getName( ) : path + "/" + entry.getName( ) );
....
Call it recursively for sub-dirs (if you want to visit). This should give you enough material to do the whole function.
Upvotes: 1