2011-11-25 214 views
0

所以,我在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); 

我如何可以訪問存儲庫/項目信息?

感謝

回答

1

看一看的例子在"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()); 
.... 

爲子目錄(如果你想訪問)遞歸地調用它。這應該給你足夠的材料來完成整個功能。