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

The following examples show how to use org.tigris.subversion.svnclientadapter.ISVNClientAdapter#cleanup() . 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: CleanupResourcesCommand.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void run(IProgressMonitor monitor) throws SVNException {
	ISVNClientAdapter svnClient = root.getRepository().getSVNClient();
    try {
        monitor.beginTask(null, 100 * resources.length);            
        OperationManager.getInstance().beginOperation(svnClient);           
        for (int i = 0; i < resources.length; i++) {
        	if (resources[i].getLocation() != null) {
             svnClient.cleanup(resources[i].getLocation().toFile());
             cleanedUpResources.add(resources[i]);
        	}
            monitor.worked(100);
        }
    } catch (SVNClientException e) {
        throw SVNException.wrapException(e);
    } finally {
		Set<IResource> refreshResources = new LinkedHashSet<IResource>();
		for (IResource resource : cleanedUpResources) {
			addToRefreshList(refreshResources, resource);
		}
		OperationManager.getInstance().endOperation(true, refreshResources);
        root.getRepository().returnSVNClient(svnClient);
        monitor.done();
    }
}
 
Example 2
Source File: SVNBasedArtifactRepository.java    From carbon-commons with Apache License 2.0 4 votes vote down vote up
public boolean commit(int tenantId, String filePath) throws DeploymentSynchronizerException {
    if (log.isDebugEnabled()) {
        log.debug("SVN committing " + filePath);
    }
    TenantSVNRepositoryContext repoContext= tenantSVNRepositories.get(tenantId);
    if (repoContext == null ) {
        log.warn("TenantSVNRepositoryContext not initialized for " + tenantId);
        return false;
    }

    ISVNClientAdapter svnClient = repoContext.getSvnClient();

    File root = new File(filePath);
    try {
        svnClient.cleanup(root);
        // need to check svn status before executing other operations on commit logic otherwise unnecessary
        // getStatus() will get called
        ISVNStatus[] checkStatus = svnClient.getStatus(root, true, false);
        if (checkStatus != null && checkStatus.length > 0) {
            svnAddFiles(tenantId, root, checkStatus);
            cleanupDeletedFiles(tenantId, root, checkStatus);

            ISVNStatus[] status = svnClient.getStatus(root, true, false);
            if (status != null && status.length > 0 && !isAllUnversioned(status)) {


                boolean var12 = true;

                for (ISVNStatus statu : status) {
                    if (statu.getTextStatus() != SVNStatusKind.IGNORED) {
                        var12 = false;
                    }
                }

                if (var12) {
                    return false;
                }


                File[] files = new File[]{root};
                svnClient.commit(files, "Commit initiated by deployment synchronizer", true);

                //Always do a svn update if you do a commit. This is just to update the working copy's
                //revision number to the latest. This fixes out-of-date working copy issues.
                if (log.isDebugEnabled()) {
                    log.debug("Updating the working copy after the commit.");
                }
                checkout(tenantId, filePath);

                return true;
            } else {
                log.debug("No changes in the local working copy");
            }
        } else {
            if (log.isDebugEnabled()) {
                log.debug("No changes in the local working copy to  commit " + filePath);
            }
        }
    } catch (SVNClientException e) {
        String message = e.getMessage();
        String pattern = System.getProperty("line.separator");
        message = message.replaceAll(pattern, " ");

        boolean isOutOfDate = message.matches(".*svn: Commit failed.* is out of date");

        if (isOutOfDate) {
            log.warn("Working copy is out of date. Forcing a svn update. Tenant: " + tenantId, e);
            boolean updated = checkout(tenantId, filePath);
            if (!updated) {
                log.error("Failed to update the working copy even though the previous commit failed due to " +
                        "out of date content.");
            }
        } else {
            handleException("Error while committing artifacts to the SVN repository", e);
        }
    }
    return false;
}