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

The following examples show how to use org.tigris.subversion.svnclientadapter.ISVNClientAdapter#mkdir() . 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: TestKit.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static void svnimport(File repoDir, File wc) throws SVNClientException, MalformedURLException {
    ISVNClientAdapter client = getClient();
    String url = TestUtilities.formatFileURL(repoDir);
    SVNUrl repoUrl = new SVNUrl(url);
    client.mkdir(repoUrl.appendPath(wc.getName()), "msg");        
    client.checkout(repoUrl.appendPath(wc.getName()), wc, SVNRevision.HEAD, true);        
    File[] files = wc.listFiles();
    if(files != null) {
        for (File file : files) {
            if(!isMetadata(file)) {
                client.addFile(file);
            }                
        }
        client.commit(new File[] {wc}, "commit", true);                    
    }
    Subversion.getInstance().versionedFilesChanged();
}
 
Example 2
Source File: AbstractSvnTestCase.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected void svnimportWC() throws SVNClientException {
    ISVNClientAdapter client = getFullWorkingClient();
    SVNUrl url = getTestUrl().appendPath(wc.getName());
    try {
        client.mkdir(url, true, "msg");
    } catch (SVNClientException ex) {
    }
    client.checkout(url, wc, SVNRevision.HEAD, true);        
    File[] files = wc.listFiles();
    if(files != null) {
        for (File file : files) {
            if(!isMetadata(file)) {
                client.addFile(file);
            }
        }
        client.commit(new File[] {wc}, "commit", true);                    
    }        
}
 
Example 3
Source File: AbstractSvnTestCase.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected void importFile(File folder) throws SVNClientException {
    ISVNClientAdapter client = getFullWorkingClient();
    SVNUrl url = getTestUrl().appendPath(folder.getName());        
    client.mkdir(url, true, "msg");
    client.checkout(url, folder, SVNRevision.HEAD, true);        
    File[] files = folder.listFiles();
    if(files != null) {
        for (File file : files) {
            if(!isMetadata(file)) {
                if (file.isDirectory()) {
                    client.addDirectory(file, true);
                } else {
                    client.addFile(file);
                }
            }
        }
        client.commit(new File[] {folder}, "commit", true);                    
    }        
}
 
Example 4
Source File: SvnFileSystemTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void repoinit() throws IOException {
    try {
        File repoDir = getRepoDir();
        File wc = getWorkDir();            
        if (!repoDir.exists()) {
            repoDir.mkdirs();                
            String[] cmd = {"svnadmin", "create", repoDir.getAbsolutePath()};
            Process p = Runtime.getRuntime().exec(cmd);
            p.waitFor();                
        }            
        
        ISVNClientAdapter client = getClient(getRepoUrl());
        SVNUrl url = getRepoUrl().appendPath(getWorkDir().getName());
        client.mkdir(url, "mkdir");
        client.checkout(url, wc, SVNRevision.HEAD, true);
    } catch (Exception ex) {
        throw new IOException(ex.getMessage());
    } 
}
 
Example 5
Source File: ImportTestHidden.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testImportFolder() throws Exception {                                        
    File folder = createFolder("folder");
            
    assertTrue(folder.exists());
    
    ISVNClientAdapter c = getNbClient();
    SVNUrl url = getTestUrl().appendPath(getName()); 
    c.mkdir(url, "mrkvadir");        
    url = url.appendPath(folder.getName());
    c.mkdir(url, "mrkvadir");        
    c.doImport(folder, url, "imprd", false);

    assertTrue(folder.exists());
    assertStatus(SVNStatusKind.UNVERSIONED, folder);
    
    ISVNInfo info = getInfo(url);
    assertNotNull(info);        
    assertEquals(url.toString(), TestUtilities.decode(info.getUrl()).toString());
    assertNotifiedFiles(new File[] {});        // XXX empty also in svnCA - why?! - no output from cli
}
 
Example 6
Source File: RemoteFolder.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void createRemoteFolder(String folderName, String message, IProgressMonitor monitor) throws SVNException {
        IProgressMonitor progress = Policy.monitorFor(monitor);
        progress.beginTask(Policy.bind("RemoteFolder.createRemoteFolder"), 100); //$NON-NLS-1$
        ISVNClientAdapter svnClient = null;
        try {
            svnClient = getRepository().getSVNClient();
            svnClient.mkdir( getUrl().appendPath(folderName), message);
            refresh();
            SVNProviderPlugin.getPlugin().getRepositoryResourcesManager().remoteResourceCreated(this, folderName);
        } catch (SVNClientException e) {
            throw SVNException.wrapException(e);
        } finally {
//        	getRepository().returnSVNClient(svnClient);
            progress.done();
        }
    }
 
Example 7
Source File: TestKit.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static void mkdirs(File repoDir, String folder) throws SVNClientException, MalformedURLException {
    ISVNClientAdapter client = getClient();
    String url = TestUtilities.formatFileURL(repoDir);
    SVNUrl repoUrl = new SVNUrl(url);
    repoUrl = repoUrl.appendPath(folder);
    client.mkdir(repoUrl, true, "creating folder " + folder);
}
 
Example 8
Source File: MkdirTestHidden.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void testMkdirUrl(String urlLastPathSegment) throws Exception {
                    
    ISVNClientAdapter c = getNbClient();        
    SVNUrl url = getRepoUrl().appendPath(urlLastPathSegment);
    c.mkdir(url, "trkvadir");

    ISVNInfo info = getInfo(url);
    assertNotNull(info);        
    assertEquals(url.toString(), TestUtilities.decode(info.getUrl()).toString());
    assertNotifiedFiles(new File[] {});        
}
 
Example 9
Source File: MkdirTestHidden.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void testMkdirFile(String folderName) throws Exception {
                    
    File folder = new File(getWC(), folderName);
    
    ISVNClientAdapter c = getNbClient();                
    c.mkdir(folder);       

    ISVNInfo info = getInfo(folder);
    assertNotNull(info);        
    assertStatus(SVNStatusKind.ADDED, folder);
    assertNotifiedFiles(new File[] {folder});        
}
 
Example 10
Source File: MkdirTestHidden.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void testMkdirUrlParents(String... urlPathSegments) throws Exception {
    ISVNClientAdapter c = getNbClient();        
    SVNUrl url = getRepoUrl();
    for (String pathSegment : urlPathSegments) {
        url = url.appendPath(pathSegment);
    }
    c.mkdir(url, true, "trkvadir");       

    ISVNInfo info = getInfo(url);
    assertNotNull(info);        
    assertEquals(url.toString(), TestUtilities.decode(info.getUrl()).toString());
    assertNotifiedFiles(new File[] {});        
}
 
Example 11
Source File: ImportTestHidden.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testImportFolderNonRecursivelly() throws Exception {                                        
    File folder = createFolder("folder");
    File folder1 = createFolder(folder, "folder1");
    File file = createFile(folder1, "file");
            
    assertTrue(folder.exists());
    assertTrue(folder1.exists());
    assertTrue(file.exists());
    
    ISVNClientAdapter c = getNbClient();
    SVNUrl url = getTestUrl().appendPath(getName());
    c.mkdir(url, "mrkvadir");        
    url = url.appendPath(folder.getName());
    c.mkdir(url, "mrkvadir");        
    c.doImport(folder, url, "imprd", false);

    assertTrue(folder.exists());
    assertTrue(folder1.exists());
    assertTrue(file.exists());
    assertStatus(SVNStatusKind.UNVERSIONED, folder);
    assertStatus(SVNStatusKind.UNVERSIONED, folder1);
    assertStatus(SVNStatusKind.UNVERSIONED, file);
    
    ISVNInfo info = getInfo(url);
    assertNotNull(info);        
    assertEquals(url.toString(), TestUtilities.decode(info.getUrl()).toString());
    
    SVNClientException ex = null;
    try {
        info = getInfo(url.appendPath(folder1.getName()));
    } catch (SVNClientException e) {
        ex = e;
    }
    assertNotNull(ex);
    assertNotifiedFiles(new File[] {});        // XXX empty also in svnCA - why?! - no output from cli
}
 
Example 12
Source File: ImportTestHidden.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testImportFolderRecursivelly() throws Exception {                                        
    File folder = createFolder("folder");
    File folder1 = createFolder(folder, "folder1");
    File file = createFile(folder1, "file");
            
    assertTrue(folder.exists());
    assertTrue(folder1.exists());
    assertTrue(file.exists());
    
    ISVNClientAdapter c = getNbClient();
    SVNUrl url = getTestUrl().appendPath(getName());
    c.mkdir(url, "mrkvadir");        
    url = url.appendPath(folder.getName());
    c.doImport(folder, url, "imprd", true);

    assertTrue(folder.exists());
    assertTrue(folder1.exists());
    assertTrue(file.exists());
    assertStatus(SVNStatusKind.UNVERSIONED, folder);
    assertStatus(SVNStatusKind.UNVERSIONED, folder1);
    assertStatus(SVNStatusKind.UNVERSIONED, file);
    
    ISVNInfo info = getInfo(url);
    assertNotNull(info);        
    assertEquals(url.toString(), TestUtilities.decode(info.getUrl()).toString());
    
    url = url.appendPath(folder1.getName());
    info = getInfo(url);
    assertNotNull(info);        
    assertEquals(url.toString(), TestUtilities.decode(info.getUrl()).toString());
    
    url = url.appendPath(file.getName());
    info = getInfo(url);        
    assertNotNull(info);        
    assertEquals(url.toString(), TestUtilities.decode(info.getUrl()).toString());
    assertNotifiedFiles(new File[] {folder1, file}); 
}
 
Example 13
Source File: SVNBasedArtifactRepository.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
/**
 * Check whether the specified directory exists in the remote SVN repository. If the
 * directory does not exist, attempt to create it.
 *
 * @throws DeploymentSynchronizerException If an error occurs while creating the directory
 */
private void checkRemoteDirectory(int tenantId) throws DeploymentSynchronizerException {
    TenantSVNRepositoryContext repoContext= tenantSVNRepositories.get(tenantId);
    if (repoContext == null ) {
        log.warn("TenantSVNRepositoryContext not initialized for " + tenantId);
        return;
    }

    SVNUrl svnUrl = repoContext.getSvnUrl();
    ISVNClientAdapter svnClient = repoContext.getSvnClient();

    try {

        ISVNInfo info = svnClient.getInfo(svnUrl);
        if (info != null && log.isDebugEnabled()) {
            log.debug("Remote directory: " + svnUrl + " exists");
        }
    } catch (SVNClientException ex) {
        if (log.isDebugEnabled()) {
            log.debug("Error while retrieving information from the directory: " + svnUrl, ex);
            log.debug("Attempting to create the directory: " + svnUrl);
        }

        try {
            svnClient.mkdir(svnUrl, true, "Directory creation by deployment synchronizer");
        } catch (SVNClientException e) {
            handleException("Error while attempting to create the directory: " + svnUrl, e);
        }
    }
}