org.tigris.subversion.svnclientadapter.ISVNDirEntry Java Examples

The following examples show how to use org.tigris.subversion.svnclientadapter.ISVNDirEntry. 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: AbstractCommandTestCase.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected void assertEntryArrays(ISVNDirEntry[] listedArray, ISVNDirEntry[] refArray) {
    assertEquals(listedArray.length, refArray.length);
    Map<String, ISVNDirEntry> entriesMap = new HashMap<String, ISVNDirEntry>();
    for (ISVNDirEntry e : listedArray) {
        entriesMap.put(e.getPath(), e);
    }
    ISVNDirEntry entry;
    for (int i = 0; i < refArray.length; i++) {
        entry = entriesMap.get(refArray[i].getPath());

        assertNotNull(entry);
        assertEquals(refArray[i].getPath(), entry.getPath());
        assertEquals(refArray[i].getHasProps(), entry.getHasProps());
        assertEquals(refArray[i].getLastChangedRevision(), entry.getLastChangedRevision());
        assertEquals(refArray[i].getLastCommitAuthor(), entry.getLastCommitAuthor());
        assertEquals(refArray[i].getNodeKind(), entry.getNodeKind());
        assertEquals(refArray[i].getSize(), entry.getSize());
        assertEquals(refArray[i].getLastChangedDate().toString(), entry.getLastChangedDate().toString());
    }
}
 
Example #2
Source File: ListTestHidden.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testListFiles() throws Exception {                        
    File file1 = createFile("file1");
    File file2 = createFile("file2");
    File file3 = createFile("file3");
            
    add(file1);                       
    add(file2);                       
    add(file3);                       
    commit(getWC());
                            
    ISVNDirEntry[] entries1 = getNbClient().getList(getTestUrl().appendPath(getWC().getName()), SVNRevision.HEAD, false);        
    assertEquals(3, entries1.length);
    ISVNDirEntry[] entries2 = getFullWorkingClient().getList(getTestUrl().appendPath(getWC().getName()), SVNRevision.HEAD, false);
    
    assertEntryArrays(entries1, entries2);
}
 
Example #3
Source File: ListTestHidden.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testListFilesRecursively() throws Exception {                        
    File folder = createFolder("file1");
    File file1 = createFile(folder, "file1");
    File file2 = createFile(folder, "file2");
    File file3 = createFile(folder, "file3");
            
    add(folder);                       
    add(file1);                       
    add(file2);                       
    add(file3);                       
    commit(getWC());
                    
    ISVNDirEntry[] entries1 = getNbClient().getList(getTestUrl().appendPath(getWC().getName()), SVNRevision.HEAD, true);        
    assertEquals(4, entries1.length);
    ISVNDirEntry[] entries2 = getFullWorkingClient().getList(getTestUrl().appendPath(getWC().getName()), SVNRevision.HEAD, true);
    
    assertEntryArrays(entries1, entries2);
}
 
Example #4
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public ISVNDirEntry getDirEntry(File path, SVNRevision revision)
		throws SVNClientException {

	// list give the DirEntrys of the elements of a directory or the
	// DirEntry
	// of a file
	ISVNDirEntry[] entries = getList(path.getParentFile(), revision, false);
	String expectedPath = path.getName();
	for (int i = 0; i < entries.length; i++) {
		if (entries[i].getPath().equals(expectedPath)) {
			return entries[i];
		}
	}
	return null; // not found
}
 
Example #5
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public ISVNDirEntry getDirEntry(SVNUrl url, SVNRevision revision)
		throws SVNClientException {

	// list give the DirEntrys of the elements of a directory or the
	// DirEntry
	// of a file
	ISVNDirEntry[] entries = getList(url.getParent(), revision, false);
	String expectedPath = url.getLastPathSegment();
	for (int i = 0; i < entries.length; i++) {
		if (entries[i].getPath().equals(expectedPath)) {
			return entries[i];
		}
	}
	return null; // not found
}
 
Example #6
Source File: InteceptorTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void cleanUpRepo() throws SVNClientException {
    ISVNClientAdapter client = getClient();
    ISVNDirEntry[] entries = client.getList(repoUrl, SVNRevision.HEAD, false);
    SVNUrl[] urls = new SVNUrl[entries.length];
    for (int i = 0; i < entries.length; i++) {
        urls[i] = repoUrl.appendPath(entries[i].getPath());            
    }        
    client.remove(urls, "cleanup");
}
 
Example #7
Source File: AbstractSvnTestCase.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected void cleanUpRepo() throws SVNClientException, IOException, InterruptedException {
    ISVNClientAdapter client = getFullWorkingClient();
    ISVNDirEntry[] entries = client.getList(repoUrl, SVNRevision.HEAD, false);
    SVNUrl[] urls = new SVNUrl[entries.length];
    for (int i = 0; i < entries.length; i++) {
        urls[i] = repoUrl.appendPath(entries[i].getPath());            
    }        
    cliRemove(urls);
}
 
Example #8
Source File: SvnClientJavaHl.java    From MergeProcessor with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public List<String> listDirectories(URL url) throws SvnClientException {
	try {
		final ISVNDirEntry[] list = client.getList(toSVNUrl(url), SVNRevision.HEAD, false);
		return Arrays.stream(list) //
				.filter(entry -> entry.getNodeKind() == SVNNodeKind.DIR) // only directories
				.map(ISVNDirEntry::getPath) // get path of entry
				.collect(Collectors.toList());
	} catch (MalformedURLException | SVNClientException e) {
		throw new SvnClientException(e);
	}
}
 
Example #9
Source File: ListTestHidden.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void testListNoFile() throws Exception {                                
    ISVNClientAdapter c = getNbClient();
    ISVNDirEntry[] entries1 = c.getList(getTestUrl().appendPath(getWC().getName()), SVNRevision.HEAD, false);
                    
    assertEquals(0, entries1.length);
}
 
Example #10
Source File: SVNBasedArtifactRepository.java    From carbon-commons with Apache License 2.0 4 votes vote down vote up
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);
                }
            }
        }
    }
}
 
Example #11
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public ISVNDirEntry[] getList(File path, SVNRevision revision,
		SVNRevision pegRevision, boolean recurse) throws SVNClientException {
	String target = fileToSVNPath(path, false);
	return list(target, revision, pegRevision, recurse);
}
 
Example #12
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public ISVNDirEntry[] getList(File path, SVNRevision revision,
		boolean recurse) throws SVNClientException {
	String target = fileToSVNPath(path, false);
	return list(target, revision, SVNRevision.HEAD, recurse);
}
 
Example #13
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public ISVNDirEntry[] getList(SVNUrl url, SVNRevision revision,
		SVNRevision pegRevision, boolean recurse) throws SVNClientException {
	String target = url.toString();
	return list(target, revision, pegRevision, recurse);
}
 
Example #14
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public ISVNDirEntry[] getList(SVNUrl url, SVNRevision revision,
		boolean recurse) throws SVNClientException {
	String target = url.toString();
	return list(target, revision, SVNRevision.HEAD, recurse);
}
 
Example #15
Source File: JhlDirEntryWithLock.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public ISVNDirEntry getDirEntry() {
	return dirEntry;
}
 
Example #16
Source File: AbstractSvnTestCase.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected ISVNDirEntry[] list(SVNUrl url) throws SVNClientException {
    return getFullWorkingClient().getList(url, SVNRevision.HEAD, false);
}
 
Example #17
Source File: Browser.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@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 #18
Source File: CommandlineClient.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public ISVNDirEntry[] getList(File arg0, SVNRevision arg1, SVNRevision arg2, boolean arg3) throws SVNClientException {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
Example #19
Source File: CommandlineClient.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public ISVNDirEntry[] getList(SVNUrl arg0, SVNRevision arg1, SVNRevision arg2, boolean arg3) throws SVNClientException {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
Example #20
Source File: CommandlineClient.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public ISVNDirEntry[] getList(File arg0, SVNRevision arg1, boolean arg2) throws SVNClientException {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
Example #21
Source File: CommandlineClient.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public ISVNDirEntry getDirEntry(File arg0, SVNRevision arg1) throws SVNClientException {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
Example #22
Source File: CommandlineClient.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public ISVNDirEntry getDirEntry(SVNUrl arg0, SVNRevision arg1) throws SVNClientException {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
Example #23
Source File: CommandlineClient.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public ISVNDirEntry[] getList(SVNUrl url, SVNRevision revision, boolean recursivelly) throws SVNClientException {
    ListCommand cmd = new ListCommand(url, revision, recursivelly);
    exec(cmd);
    return cmd.getEntries();
}
 
Example #24
Source File: ListCommand.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public ISVNDirEntry[] getEntryAttributes() {            
    return entries != null ? entries.toArray(new ISVNDirEntry[entries.size()]) : new ISVNDirEntry[] {} ;
}