javasvnsvnkit

How to identify a SVN path is a directory or file with SVNkit?


Say you have a specified SVN path like below, How can I know this item is a svn directory or a svn file. thanks.

http://cvs-server.test.com:8001/svn/test

Updated

            SVNURL svnUrl = SVNURL.parseURIEncoded(url);
            SVNRepository repos = SVNRepositoryFactory.create(svnUrl);
            ISVNAuthenticationManager authManager = 
            SVNWCUtil.createDefaultAuthenticationManager("user1","123");

            repos.setAuthenticationManager(authManager);

            SVNNodeKind nodeKind = repos.checkPath(url, repos.getLatestRevision());

Why did I get none even the url is a file ? I am sure this url exist in SVN. ORZ... There are many bugs with SVNkit .


Solution

  • Try something like this:

    String url = "http://cvs-server.test.com:8001/svn/test";
    SVNURL svnUrl = SVNURL.parseURIEncoded(url);
    SVNRepository repos = SVNRepositoryFactory.create(svnUrl);
    ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(DEFAULT_USER, DEFAULT_PASS);
    repos.setAuthenticationManager(authManager); 
    SVNNodeKind nodeKind = repos.checkPath("", repos.getLatestRevision());
    

    nodeKind will be one of FILE, DIR or NONE.