Java Code Examples for org.tigris.subversion.svnclientadapter.ISVNDirEntry#getNodeKind()
The following examples show how to use
org.tigris.subversion.svnclientadapter.ISVNDirEntry#getNodeKind() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Browser.java From netbeans with Apache License 2.0 | 4 votes |
@Override public List<RepositoryPathNode.RepositoryPathEntry> listRepositoryPath(final RepositoryPathNode.RepositoryPathEntry entry, SvnProgressSupport support) throws SVNClientException { List<RepositoryPathNode.RepositoryPathEntry> ret = new ArrayList<RepositoryPathNode.RepositoryPathEntry>(); synchronized (supportList) { if(cancelled) { support.cancel(); return ret; } supportList.add(support); } try { if(entry.getSvnNodeKind().equals(SVNNodeKind.FILE)) { return ret; // nothing to do... } Subversion subversion = Subversion.getInstance(); SVNUrl svnUrl = this.repositoryRoot.getRepositoryUrl(); SvnClient client = (username != null) ? subversion.getClient(svnUrl, username, password, support) : subversion.getClient(svnUrl, support); if(support.isCanceled()) { return null; } ISVNDirEntry[] dirEntries = client.getList( entry.getRepositoryFile().getFileUrl(), entry.getRepositoryFile().getRevision(), false ); if(dirEntries == null || dirEntries.length == 0) { return ret; // nothing to do... } for (ISVNDirEntry dirEntry : dirEntries) { if(support.isCanceled()) { return null; } if( dirEntry.getNodeKind()==SVNNodeKind.DIR || // directory or (dirEntry.getNodeKind()==SVNNodeKind.FILE && // (file and show_files_allowed) ((mode & BROWSER_SHOW_FILES) == BROWSER_SHOW_FILES)) ) { RepositoryFile repositoryFile = new RepositoryFile( entry.getRepositoryFile().getRepositoryUrl(), entry.getRepositoryFile().getFileUrl().appendPath(dirEntry.getPath()), dirEntry.getLastChangedRevision()); RepositoryPathNode.RepositoryPathEntry e = new RepositoryPathNode.RepositoryPathEntry( repositoryFile, dirEntry.getNodeKind(), dirEntry.getLastChangedRevision(), dirEntry.getLastChangedDate(), dirEntry.getLastCommitAuthor()); ret.add(e); } } } catch (SVNClientException ex) { if(SvnClientExceptionHandler.isWrongURLInRevision(ex.getMessage())) { // is not a folder in the repository return null; } else { support.annotate(ex); throw ex; } } finally { synchronized (supportList) { supportList.remove(support); } } return ret; }
Example 2
Source File: SVNBasedArtifactRepository.java From carbon-commons with Apache License 2.0 | 4 votes |
private void cleanupUnversionedFiles(int tenantId, SVNUrl svnURL, File root) throws SVNClientException { TenantSVNRepositoryContext repoContext= tenantSVNRepositories.get(tenantId); if (repoContext == null ) { log.warn("TenantSVNRepositoryContext not initialized for " + tenantId); return; } ISVNClientAdapter svnClient = repoContext.getSvnClient(); DeploymentSynchronizerConfiguration conf = repoContext.getConf(); ISVNDirEntry[] entries = svnClient.getList(svnURL, SVNRevision.HEAD, false); for (ISVNDirEntry entry : entries) { String fileName = entry.getPath(); SVNNodeKind nodeType = entry.getNodeKind(); File localFile = new File(root, fileName); if (localFile.exists()) { ISVNStatus status = svnClient.getSingleStatus(localFile); if (status != null && status.getTextStatus().toInt() != UNVERSIONED) { if (localFile.isDirectory()) { // see whether there are unversioned files under this dir. Recursive String appendPath = "/" + localFile.getName(); cleanupUnversionedFiles(tenantId, svnURL.appendPath(appendPath), localFile); continue; // this is not an unversioned directory, continue } else if (localFile.isFile()) { continue; } } if (localFile.isFile() && SVNNodeKind.FILE.equals(nodeType)) { log.info("Unversioned file: " + localFile.getPath() + " will be deleted"); if (!localFile.delete()) { log.error("Unable to delete the file: " + localFile.getPath()); } } else if (localFile.isDirectory() && SVNNodeKind.DIR.equals(nodeType)) { log.info("Unversioned directory: " + localFile.getPath() + " will be deleted"); try { FileUtils.deleteDirectory(localFile); } catch (IOException e) { log.error("Error while deleting the directory: " + localFile.getPath(), e); } } } } }