2
我試圖解析URL以獲取當前分支或中繼。解析SVNKit中的URL
public SVNConnector(String s_Url, String login, String password, String project) {
try {
url = SVNURL.parseURIEncoded(s_Url);
ISVNAuthenticationManager authManager = new BasicAuthenticationManager(login, password);
DAVRepositoryFactory.setup();
repository = SVNRepositoryFactory.create(url, null);
repository.setAuthenticationManager(authManager);
this.projectName = project;
latestRevision = repository.getLatestRevision();
} catch (SVNException svne) {
logger.error("Impossible to connect to SVN repository. s_Url: "+s_Url+" login:"+login+" password: "+password, svne);
}
}
我的網址是一樣的東西http://10.61.128.222/svn/i18ntest/trunk
或http://10.61.128.222/svn/PFT/branches/protoi18n
,我需要一種方法,我可以輸入這個網址,並會返回/trunk/
或/branches/protoi18n/
,這樣我就可以運行這個命令:
public List<OutputElement> retrieveI18nFiles() throws SVNException {
List<OutputElement> outs = new ArrayList<OutputElement>();
String path = url.getPath()+"/core/src/main/resources/fr/gefco/"+projectName+"/i18n/"; // this is not working!
latestRevision = repository.getLatestRevision();
// For some reason, type safety is not insured in SVNKit, even if generics are around for some years, now
Collection<SVNDirEntry> entries = repository.getDir(path, latestRevision, (SVNProperties)null, (Collection<SVNDirEntry>)null);
for (SVNDirEntry entry : entries) {
OutputElement out = new OutputElement();
out.setEntry(entry);
out.setOut(retrieveOutputStream(entry,path));
outs.add(out);
}
return outs;
}
url.getPath()
是返回/svn/i18ntest/trunk/
,這不是我所需要的。當然,我可以解析它以獲得我需要的位,但是我想首先知道SVNKit是否提供了已經證明的方法。
謝謝!這正是我需要的。太糟糕了SVNURLUtil是在一個「內部」包中,沒有記錄... –