SVNKitによるバージョンライブラリのツリーのエクスポート
6927 ワード
public List searchByTree(String userName,String passwd,String SVNServerUrl,String dirUrl){
// storeManager , 。
SVNURL repositoryUrl=null;
SVNRepository repository=null;
SVNRepositoryFactoryImpl.setup();
try {
repositoryUrl=SVNURL.parseURIEncoded(SVNServerUrl);
repository=SVNRepositoryFactory.create(repositoryUrl);
ISVNAuthenticationManager authenticationManager=SVNWCUtil.createDefaultAuthenticationManager(userName, passwd);
repository.setAuthenticationManager(authenticationManager);
result.clear();
FileNode rootNode=new FileNode("root", SVNServerUrl, 0, "", 0, null, null);
listTree(repository, dirUrl,rootNode);
result.add(rootNode);
} catch (Exception e) {
// TODO: handle exception
}
return result;
}
public void listTree(SVNRepository repository,String dirUrl,FileNode node){
String currentPath="";
List list=new ArrayList();
Collection root;
try {
String finalPath[]=dirUrl.split("/");
for(int i=3;i<finalPath.length;i++){
currentPath+=finalPath[i]+"/";
}
System.out.println("****************: "+currentPath);
root=repository.getDir(currentPath, -1, null, (Collection)null);
Iterator iterator=root.iterator();
while (iterator.hasNext()) {
SVNDirEntry entry=(SVNDirEntry)iterator.next();
if (entry.getKind()==SVNNodeKind.DIR) {
FileNode subDirNode=new FileNode(entry.getName(), entry.getURL().toString(),entry.getRevision(),entry.getAuthor(),entry.getSize(), entry.getDate(), null);
System.out.println("********"+entry.getURL());
listTree(repository, entry.getURL().toString(), subDirNode);
list.add(subDirNode);
} else {
FileNode subnode=new FileNode(entry.getName(), entry.getURL().toString(),entry.getRevision(),entry.getAuthor(),entry.getSize(), entry.getDate(), null);
list.add(subnode);
}
}
} catch (SVNException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
node.setChildren(list);
}
以上のコードは,バージョンライブラリ内のものをリストにまとめる操作を実現している.最後に返されるresultはリストです.
呼び出すときは次のようになります.
ModelDeveloper developer=new ModelDeveloper();
List ddList=developer.searchByTree("test", "test", "svn://localhost/", ""); // “‘ , , 。 "svn://localhost/aa/b" , aa/b 。
treeViewer.setInput(ddList);