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

The following examples show how to use org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getContent() . 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: CatTestHidden.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void testCatFilePrevRev(String path) throws Exception {
    createAndCommitParentFolders(path);
    File file = createFile(path);
    write(file, 1);
    add(file);
    commit(file);

    File prevRevisionCopy = new File(file.getParentFile(), "prevRevisionCopy");
    FileUtils.copyFile(file, prevRevisionCopy);

    ISVNClientAdapter c = getNbClient();        
    SVNRevision prevrev = getRevision(file);
    write(file, 2);        
    commit(file);
    
    InputStream is1 = c.getContent(file, prevrev);
    InputStream is2 = new FileInputStream(prevRevisionCopy);
    
    assertInputStreams(is2, is1);
}
 
Example 2
Source File: CatTestHidden.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void testCatURLPrevRev(String path) throws Exception {
    File file = createFile(path);
    write(file, 1);
    add(file);
    commit(file);

    File prevRevisionCopy = new File(file.getParentFile(), "prevRevisionCopy");
    FileUtils.copyFile(file, prevRevisionCopy);

    ISVNClientAdapter c = getNbClient();        
    SVNRevision prevrev = getRevision(file);
    write(file, 2);        
    commit(file);
    
    InputStream is1 = c.getContent(getFileUrl(file), prevrev);
    InputStream is2 = new FileInputStream(prevRevisionCopy);
    
    assertInputStreams(is2, is1);
}
 
Example 3
Source File: CatTestHidden.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void testCatURL(String path) throws Exception {
    createAndCommitParentFolders(path);
    File file = createFile(path);
    write(file, 1);
    add(file);
    commit(file);
    
    ISVNClientAdapter c = getNbClient();        
    InputStream is1 = c.getContent(getFileUrl(file), SVNRevision.HEAD);
    InputStream is2 = new FileInputStream(file);
    
    assertInputStreams(is2, is1);
}
 
Example 4
Source File: BaseResourceStorage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public InputStream getContents() throws CoreException {
	ISVNClientAdapter svnClient = baseResource.getRepository().getSVNClient();
	try {
		return svnClient.getContent(baseResource.getFile(), baseResource.getRevision());
	} catch (SVNClientException e) {
		throw new CoreException(new Status(IStatus.ERROR, SVNProviderPlugin.ID, 0, "Failed in BaseFile.getContents()", e)); //$NON-NLS-1$);
	}
	finally {
		baseResource.getRepository().returnSVNClient(svnClient);
	}
}
 
Example 5
Source File: SVNWorkspaceRoot.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * get the project name for the remote folder. The name is either the name of the
 * remote folder or the name in .project if this file exists.
 * @param folder
 * @param monitor
 * @return
 */
public static String getProjectName(ISVNRemoteFolder folder,IProgressMonitor monitor) throws Exception {
    ISVNClientAdapter client = folder.getRepository().getSVNClient();
    try {
        client.getNotificationHandler().disableLog();
        String result = folder.getName();

        InputStream is = client.getContent(folder.getUrl().appendPath(".project"), SVNRevision.HEAD);
        DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        org.w3c.dom.Document doc = db.parse(is);
        is.close();
        NodeList nl = doc.getDocumentElement().getChildNodes();
        for (int j = 0; j < nl.getLength(); ++j) {
            Node child = nl.item(j);
            if (child instanceof Element && "name".equals(child.getNodeName())) {
                Node grandChild = child.getFirstChild();
                if (grandChild instanceof Text) result = ((Text)grandChild).getData();
            }
        }

        return result;
    } catch (Exception e) {
        throw e;
    } finally {
    	if (client != null) {
         client.getNotificationHandler().enableLog();
         folder.getRepository().returnSVNClient(client);
    	}
    }
}
 
Example 6
Source File: RemoteFile.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void fetchContents(IProgressMonitor aMonitor) throws TeamException {
	IProgressMonitor monitor = Policy.monitorFor(aMonitor);
	monitor.beginTask(Policy.bind("RemoteFile.getContents"), 100);//$NON-NLS-1$
	ISVNClientAdapter svnClient = null;
	try {
		svnClient = repository.getSVNClient();
		InputStream inputStream = null;
		try {
			
			if (pegRevision != null) {
				try {
					inputStream = svnClient.getContent(url, revision, pegRevision);
				}
				catch (SVNClientException e1) {}
			}
			if (inputStream == null) {
				inputStream = svnClient.getContent(url, getRevision(), getRevision());
			}
			super.setContents(inputStream, monitor);
			cached = true;
		} catch (SVNClientException e) {
			throw new TeamException("Failed in RemoteFile.getContents()", e);
		}
	} finally {
		repository.returnSVNClient(svnClient);
		monitor.done();
	}
}