SVNKit - 检查目录是否存在

问题描述:

所以,我在SVN仓库下创建了一个项目TEST,我想知道这个项目目录是否与SVNKit库存在。协议是http。SVNKit - 检查目录是否存在

我想例如...

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); 

我如何可以访问存储库/项目信息?

感谢

看一看的例子在"Printing Out a Subversion Repository Tree"。它包含以下代码:

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); 
} 

这会检查您的位置是否可以作为存储库根目录。

Collection entries = repository.getDir(path, -1 , null , (Collection) null); 
Iterator iterator = entries.iterator(); 
while (iterator.hasNext()) { 
    SVNDirEntry entry = (SVNDirEntry) iterator.next(); 
    ... 

迭代当前目录的条目。

if (entry.getKind() == SVNNodeKind.DIR) { 
    listEntries(repository, (path.equals("")) ? entry.getName() : path + "/" + entry.getName()); 
.... 

为子目录(如果你想访问)递归地调用它。这应该给你足够的材料来完成整个功能。