Search in sources :

Example 26 with ISVNClientAdapter

use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.

the class RepositoryResourcesManager method moveRemoteResource.

public void moveRemoteResource(ISVNRemoteResource resource, ISVNRemoteFolder destinationFolder, String destinationResourceName, String message, IProgressMonitor monitor) throws SVNException {
    IProgressMonitor progress = Policy.monitorFor(monitor);
    progress.beginTask(Policy.bind("RepositoryResourcesManager.moveRemoteResources"), // $NON-NLS-1$
    100);
    ISVNClientAdapter svnClient = null;
    try {
        svnClient = resource.getRepository().getSVNClient();
        SVNUrl destUrl = destinationFolder.getUrl().appendPath(destinationResourceName);
        svnClient.move(resource.getUrl(), destUrl, message, SVNRevision.HEAD);
        resource.getParent().refresh();
        destinationFolder.refresh();
        remoteResourceMoved(resource, destinationFolder, destinationResourceName);
    } catch (SVNClientException e) {
        throw SVNException.wrapException(e);
    } finally {
        resource.getRepository().returnSVNClient(svnClient);
        progress.done();
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 27 with ISVNClientAdapter

use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.

the class RepositoryResourcesManager method deleteRemoteResources.

/**
 * delete some remote resources Resources can be from several RemoteRepositoryLocations
 */
public void deleteRemoteResources(ISVNRemoteResource[] remoteResources, String message, IProgressMonitor monitor) throws SVNException {
    IProgressMonitor progress = Policy.monitorFor(monitor);
    progress.beginTask(Policy.bind("RepositoryResourcesManager.deleteRemoteResources"), // $NON-NLS-1$
    100 * remoteResources.length);
    // the given remote resources can come from more than a repository and so needs
    // more than one svnClient
    // we associate each repository with the corresponding resources to delete
    HashMap<ISVNRepositoryLocation, List<ISVNRemoteResource>> mapRepositories = new HashMap<ISVNRepositoryLocation, List<ISVNRemoteResource>>();
    for (ISVNRemoteResource remoteResource : remoteResources) {
        ISVNRepositoryLocation repositoryLocation = remoteResource.getRepository();
        List<ISVNRemoteResource> resources = (List<ISVNRemoteResource>) mapRepositories.get(repositoryLocation);
        if (resources == null) {
            resources = new ArrayList<ISVNRemoteResource>();
            mapRepositories.put(repositoryLocation, resources);
        }
        resources.add(remoteResource);
    }
    ISVNClientAdapter svnClient = null;
    ISVNRepositoryLocation repository = null;
    try {
        for (List<ISVNRemoteResource> resources : mapRepositories.values()) {
            repository = (resources.get(0)).getRepository();
            svnClient = repository.getSVNClient();
            SVNUrl[] urls = new SVNUrl[resources.size()];
            for (int i = 0; i < resources.size(); i++) {
                ISVNRemoteResource resource = resources.get(i);
                urls[i] = resource.getUrl();
                // refresh just says that resource needs to be updated
                // it does not update immediatly
                resource.getParent().refresh();
            }
            svnClient.remove(urls, message);
            repository.returnSVNClient(svnClient);
            svnClient = null;
            repository = null;
            for (ISVNRemoteResource resource : resources) {
                remoteResourceDeleted(resource);
            }
            progress.worked(100 * urls.length);
        }
    } catch (SVNClientException e) {
        throw SVNException.wrapException(e);
    } finally {
        if (repository != null) {
            repository.returnSVNClient(svnClient);
        }
        progress.done();
    }
}
Also used : HashMap(java.util.HashMap) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ArrayList(java.util.ArrayList) List(java.util.List) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 28 with ISVNClientAdapter

use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.

the class SVNRepositoryLocation method getRemoteFile.

/*
   * (non-Javadoc)
   * @see org.tigris.subversion.subclipse.core.ISVNRepositoryLocation#getRemoteFile(org.tigris.subversion.svnclientadapter.SVNUrl)
   */
public ISVNRemoteFile getRemoteFile(SVNUrl url) throws SVNException {
    ISVNClientAdapter svnClient = getSVNClient();
    ISVNInfo info = null;
    try {
        if (this.getRepositoryRoot().equals(url))
            return new RemoteFile(this, url, SVNRevision.HEAD);
        else
            info = svnClient.getInfo(url, SVNRevision.HEAD, SVNRevision.HEAD);
    } catch (SVNClientException e) {
        throw new SVNException("Can't get latest remote resource for " + url);
    }
    if (// no remote file
    info == null)
        // no remote file
        return null;
    else {
        return new RemoteFile(// we don't know its parent
        null, this, url, SVNRevision.HEAD, info.getLastChangedRevision(), info.getLastChangedDate(), info.getLastCommitAuthor());
    }
}
Also used : SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile) RemoteFile(org.tigris.subversion.subclipse.core.resources.RemoteFile) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 29 with ISVNClientAdapter

use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.

the class LocalFile method removeKeywords.

/* (non-Javadoc)
   * @see org.tigris.subversion.subclipse.core.ISVNLocalFile#removeKeywords(org.tigris.subversion.svnclientadapter.SVNKeywords)
   */
public void removeKeywords(SVNKeywords svnKeywords) throws SVNException {
    ISVNClientAdapter svnClient = null;
    try {
        svnClient = getRepository().getSVNClient();
        OperationManager.getInstance().beginOperation(svnClient);
        svnClient.removeKeywords(getFile(), svnKeywords);
    } catch (SVNClientException e) {
        throw SVNException.wrapException(e);
    } finally {
        getRepository().returnSVNClient(svnClient);
        OperationManager.getInstance().endOperation();
    }
}
Also used : SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 30 with ISVNClientAdapter

use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.

the class LocalResource method getPropertiesIncludingInherited.

public ISVNProperty[] getPropertiesIncludingInherited(boolean includeEmptyProperties, boolean includeClosestOnly, List<String> filterProperties) throws SVNException {
    ISVNClientAdapter svnClient = null;
    try {
        svnClient = SVNProviderPlugin.getPlugin().getSVNClient();
        SVNProviderPlugin.disableConsoleLogging();
        ISVNProperty[] properties = svnClient.getPropertiesIncludingInherited(getFile(), includeEmptyProperties, includeClosestOnly, filterProperties);
        return properties;
    } catch (SVNClientException e) {
        throw SVNException.wrapException(e);
    } finally {
        SVNProviderPlugin.enableConsoleLogging();
        SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(svnClient);
    }
}
Also used : SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ISVNProperty(org.tigris.subversion.svnclientadapter.ISVNProperty) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Aggregations

ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)108 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)67 SVNException (org.tigris.subversion.subclipse.core.SVNException)37 File (java.io.File)28 IResource (org.eclipse.core.resources.IResource)27 CoreException (org.eclipse.core.runtime.CoreException)22 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)21 TeamException (org.eclipse.team.core.TeamException)21 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)20 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)20 ISVNInfo (org.tigris.subversion.svnclientadapter.ISVNInfo)19 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)19 ArrayList (java.util.ArrayList)18 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)18 InvocationTargetException (java.lang.reflect.InvocationTargetException)15 ISVNProperty (org.tigris.subversion.svnclientadapter.ISVNProperty)13 OperationProgressNotifyListener (org.tigris.subversion.subclipse.core.client.OperationProgressNotifyListener)9 IProject (org.eclipse.core.resources.IProject)8 List (java.util.List)7 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)7