Java Code Examples for org.tigris.subversion.svnclientadapter.ISVNClientAdapter#remove()

The following examples show how to use org.tigris.subversion.svnclientadapter.ISVNClientAdapter#remove() . 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: RemoveTestHidden.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testRemoveFileTree(String folderName,
                               String fileName1,
                               String fileName2) throws Exception {
    File folder = createFolder(folderName);
    File file1 = createFile(folder, fileName1);
    File file2 = createFile(folder, fileName2);
    add(folder);
    commit(folder);
            
    assertTrue(folder.exists());
    
    ISVNClientAdapter c = getNbClient();
    c.remove(new File[] {folder}, true);

    assertFalse(folder.exists());
    assertFalse(file1.exists());
    assertFalse(file2.exists());
    assertStatus(SVNStatusKind.DELETED, folder);        
    assertStatus(SVNStatusKind.DELETED, file1);        
    assertStatus(SVNStatusKind.DELETED, file2);        
    assertNotifiedFiles(new File[] {folder, file1, file2});        
}
 
Example 2
Source File: SVNBasedArtifactRepository.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
/**
 * Find the files and directories which are in the MISSING state and schedule them
 * for svn delete
 *
 * @param root Root directory of the local working copy
 * @throws SVNClientException If an error occurs in the SVN client
 */
private void cleanupDeletedFiles(int tenantId, File root, ISVNStatus[] status) throws SVNClientException {
    TenantSVNRepositoryContext repoContext = tenantSVNRepositories.get(tenantId);
    if (repoContext == null) {
        log.warn("TenantSVNRepositoryContext not initialized for " + tenantId);
        return;
    }

    ISVNClientAdapter svnClient = repoContext.getSvnClient();
    List<File> deletableFiles = new ArrayList<File>();
    for (ISVNStatus s : status) {
        int statusCode = s.getTextStatus().toInt();
        if (statusCode == MISSING) {
            if (log.isDebugEnabled()) {
                log.debug("Scheduling the file: " + s.getPath() + " for SVN delete");

            }
            deletableFiles.add(s.getFile());
        }
    }
    
    if (deletableFiles.size() > 0) {
        svnClient.remove(deletableFiles.toArray(new File[deletableFiles.size()]), true);
    }
}
 
Example 3
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 4
Source File: RemoveTestHidden.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void testRemoveFile(String filePath) throws Exception {
    createAndCommitParentFolders(filePath);
    File file = createFile(filePath);
    add(file);
    commit(file);
            
    assertTrue(file.exists());
    
    ISVNClientAdapter c = getNbClient();
    c.remove(new File[] {file}, true);

    assertFalse(file.exists());
    assertStatus(SVNStatusKind.DELETED, file);    
    assertNotifiedFiles(new File[] {file});        
}
 
Example 5
Source File: RemoveTestHidden.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void testRemoveFolder(String folderName) throws Exception {
    File folder = createFolder(folderName);
    add(folder);
    commit(folder);
            
    assertTrue(folder.exists());
    
    ISVNClientAdapter c = getNbClient();
    c.remove(new File[] {folder}, true);

    assertFalse(folder.exists());
    assertStatus(SVNStatusKind.DELETED, folder);   
    assertNotifiedFiles(new File[] {folder});        
}
 
Example 6
Source File: RemoveOperation.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
protected void execute(IProgressMonitor monitor) throws SVNException, InterruptedException {
	ISVNClientAdapter client = null; 
	ISVNRepositoryLocation repository = null;
	ArrayList files = new ArrayList();
	for (int i = 0; i < resources.length; i++) {
		ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
		if (client == null) {
			repository = svnResource.getRepository();
		    client = repository.getSVNClient();	
		}
		files.add(svnResource.getFile());
	}
	File[] fileArray = new File[files.size()];
	files.toArray(fileArray);
	try {
		client.remove(fileArray, true);
		refresh();
	} catch (SVNClientException e) {
		throw SVNException.wrapException(e);
	}
	finally {
		if (repository != null) {
			repository.returnSVNClient(client);
		}
		monitor.done();
	}
}
 
Example 7
Source File: LocalResource.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void delete() throws SVNException {
	ISVNClientAdapter svnClient = null;
    try {
        svnClient = getRepository().getSVNClient();
        OperationManager.getInstance().beginOperation(svnClient);
        svnClient.remove(new File[] { getFile() }, true);
    } catch (SVNClientException e) {
        throw SVNException.wrapException(e); 
    } finally {
    	getRepository().returnSVNClient(svnClient);
        OperationManager.getInstance().endOperation();
    }
}
 
Example 8
Source File: SVNMoveDeleteHook.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private void deleteResource(ISVNLocalResource resource) throws SVNException {
	ISVNClientAdapter svnClient = resource.getRepository().getSVNClient();
	 try {
		svnClient.remove(new File[] { resource.getResource().getLocation().toFile() }, true);
	} catch (SVNClientException e) {
		throw new SVNException(IStatus.ERROR, TeamException.UNABLE, e.getMessage(), e);
	}
	finally {
		resource.getRepository().returnSVNClient(svnClient);
	}
}