Search in sources :

Example 1 with SVNClientManager

use of org.tmatesoft.svn.core.wc.SVNClientManager in project oxTrust by GluuFederation.

the class SubversionService method commitShibboleth3ConfigurationFiles.

public boolean commitShibboleth3ConfigurationFiles(GluuOrganization organization, List<SubversionFile> newSubversionFiles, List<SubversionFile> removeSubversionFiles, String svnComment) {
    // Retrieve properties and derive applianceSvnHome
    String svnUrl = appConfiguration.getSvnConfigurationStoreRoot();
    String inumFN = StringHelper.removePunctuation(appConfiguration.getApplianceInum());
    String svnPassword = appConfiguration.getSvnConfigurationStorePassword();
    String applianceSvnHomePath = String.format("%s/%s", baseSvnDir, inumFN);
    if (StringHelper.isEmpty(svnUrl) || StringHelper.isEmpty(inumFN) || StringHelper.isEmpty(svnPassword)) {
        // log.error("Failed to commit files to repository. Please check SVN related properties in gluuAppliance.properties file");
        return false;
    }
    SVNClientManager clientManager = null;
    try {
        // Decrypt password
        svnPassword = encryptionService.decrypt(svnPassword);
        // Create an instance of SVNClientManager
        log.debug("Creating an instance of SVNClientManager");
        SVNURL repositoryURL = SVNURL.parseURIEncoded(svnUrl);
        clientManager = SvnHelper.getSVNClientManager(inumFN, svnPassword);
        // Check root path exists
        boolean result = checkRootSvnPath(clientManager, repositoryURL);
        if (!result) {
            return result;
        }
        File applianceSvnHome = new File(applianceSvnHomePath);
        removeFilesFromLocalRepository(applianceSvnHome, removeSubversionFiles);
        // Copy files to temporary repository folder
        copyFilesToLocalRepository(applianceSvnHome, newSubversionFiles);
        // Add files
        log.debug("Adding files if neccessary");
        SvnHelper.addNewFiles(clientManager, applianceSvnHome);
        // Commit updates to repository
        log.debug("Commiting updates to repository");
        String message = String.format("Automatic update of Shibboleth configuration files for organization %s", organization.getDisplayName());
        message += "\n Changes List:\n" + svnComment;
        SvnHelper.commit(clientManager, applianceSvnHome, false, message);
        return true;
    } catch (Exception ex) {
    // log.error("Failed to commit files to repository", ex);
    } finally {
        if (clientManager != null) {
            clientManager.dispose();
        }
    }
    return false;
}
Also used : SVNURL(org.tmatesoft.svn.core.SVNURL) SubversionFile(org.gluu.oxtrust.model.SubversionFile) File(java.io.File) SVNClientManager(org.tmatesoft.svn.core.wc.SVNClientManager) SVNException(org.tmatesoft.svn.core.SVNException) IOException(java.io.IOException)

Example 2 with SVNClientManager

use of org.tmatesoft.svn.core.wc.SVNClientManager in project Gargoyle by callakrsos.

the class SVNList method listRemoved.

/**
	 * Not Yet Support.
	 * 아직 미구현
	 * @작성자 : KYJ
	 * @작성일 : 2017. 2. 16.
	 * @param relativePath
	 * @param startRevision
	 * @param isRecursive
	 * @return
	 * @throws SVNException
	 */
@Deprecated
public List<SVNLogEntry> listRemoved(String relativePath, long startRevision, boolean isRecursive) throws SVNException {
    SVNClientManager mgr = getSvnManager();
    Collection<SVNLogEntry> allLogs = getJavaSVNManager().getAllLogs(relativePath, startRevision);
    return Collections.emptyList();
}
Also used : SVNLogEntry(org.tmatesoft.svn.core.SVNLogEntry) SVNClientManager(org.tmatesoft.svn.core.wc.SVNClientManager)

Example 3 with SVNClientManager

use of org.tmatesoft.svn.core.wc.SVNClientManager in project Gargoyle by callakrsos.

the class SVNResource method getSvnUrlByFileSystem.

/**
	 * SVN 서버에 연결된 루트 디렉토리에 속하는 로컬 파일시스템의 파일에 해당하는 SVN서버 경로를 리턴한다.
	 *
	 * @작성자 : KYJ
	 * @작성일 : 2016. 8. 1.
	 * @return
	 * @throws Exception
	 */
public SVNURL getSvnUrlByFileSystem(File file, SVNRevision revision) throws Exception {
    SVNClientManager svnManager2 = getSvnManager();
    SVNInfo doInfo = svnManager2.getWCClient().doInfo(file, revision);
    return doInfo.getURL();
}
Also used : SVNInfo(org.tmatesoft.svn.core.wc.SVNInfo) SVNClientManager(org.tmatesoft.svn.core.wc.SVNClientManager)

Example 4 with SVNClientManager

use of org.tmatesoft.svn.core.wc.SVNClientManager in project sonarqube by SonarSource.

the class SvnBlameCommand method blame.

@Override
public void blame(final BlameInput input, final BlameOutput output) {
    FileSystem fs = input.fileSystem();
    LOG.debug("Working directory: " + fs.baseDir().getAbsolutePath());
    SVNClientManager clientManager = null;
    try {
        clientManager = newSvnClientManager(configuration);
        for (InputFile inputFile : input.filesToBlame()) {
            blame(clientManager, inputFile, output);
        }
    } finally {
        if (clientManager != null) {
            try {
                clientManager.dispose();
            } catch (Exception e) {
                LOG.warn("Unable to dispose SVN ClientManager", e);
            }
        }
    }
}
Also used : FileSystem(org.sonar.api.batch.fs.FileSystem) SVNClientManager(org.tmatesoft.svn.core.wc.SVNClientManager) SVNException(org.tmatesoft.svn.core.SVNException) SVNAuthenticationException(org.tmatesoft.svn.core.SVNAuthenticationException) InputFile(org.sonar.api.batch.fs.InputFile)

Example 5 with SVNClientManager

use of org.tmatesoft.svn.core.wc.SVNClientManager in project sonarqube by SonarSource.

the class SvnScmProvider method branchChangedLines.

@CheckForNull
@Override
public Map<Path, Set<Integer>> branchChangedLines(String targetBranchName, Path rootBaseDir, Set<Path> changedFiles) {
    SVNClientManager clientManager = null;
    try {
        clientManager = newSvnClientManager(configuration);
        // find reference revision number: the copy point
        SVNLogClient svnLogClient = clientManager.getLogClient();
        long[] revisionCounter = { 0 };
        svnLogClient.doLog(new File[] { rootBaseDir.toFile() }, null, null, null, true, true, 0, svnLogEntry -> revisionCounter[0] = svnLogEntry.getRevision());
        long startRev = revisionCounter[0];
        SVNDiffClient svnDiffClient = clientManager.getDiffClient();
        File path = rootBaseDir.toFile();
        ChangedLinesComputer computer = newChangedLinesComputer(rootBaseDir, changedFiles);
        svnDiffClient.doDiff(path, SVNRevision.create(startRev), path, SVNRevision.WORKING, SVNDepth.INFINITY, false, computer.receiver(), null);
        return computer.changedLines();
    } catch (Exception e) {
        LOG.warn("Failed to get changed lines from Subversion", e);
    } finally {
        if (clientManager != null) {
            try {
                clientManager.dispose();
            } catch (Exception e) {
                LOG.warn("Unable to dispose SVN ClientManager", e);
            }
        }
    }
    return null;
}
Also used : SVNDiffClient(org.tmatesoft.svn.core.wc.SVNDiffClient) File(java.io.File) SVNClientManager(org.tmatesoft.svn.core.wc.SVNClientManager) SVNLogClient(org.tmatesoft.svn.core.wc.SVNLogClient) URISyntaxException(java.net.URISyntaxException) MalformedURLException(java.net.MalformedURLException) SVNException(org.tmatesoft.svn.core.SVNException) CheckForNull(javax.annotation.CheckForNull)

Aggregations

SVNClientManager (org.tmatesoft.svn.core.wc.SVNClientManager)13 File (java.io.File)7 SVNLogClient (org.tmatesoft.svn.core.wc.SVNLogClient)5 SVNRevision (org.tmatesoft.svn.core.wc.SVNRevision)4 ZipFile (java.util.zip.ZipFile)3 Test (org.junit.Test)3 InputFile (org.sonar.api.batch.fs.InputFile)3 SVNException (org.tmatesoft.svn.core.SVNException)3 SVNURL (org.tmatesoft.svn.core.SVNURL)3 SVNInfo (org.tmatesoft.svn.core.wc.SVNInfo)3 IOException (java.io.IOException)2 MalformedURLException (java.net.MalformedURLException)2 URISyntaxException (java.net.URISyntaxException)2 CheckForNull (javax.annotation.CheckForNull)2 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)2 BlameOutput (org.sonar.api.batch.scm.BlameCommand.BlameOutput)2 SVNDepth (org.tmatesoft.svn.core.SVNDepth)2 ISVNOptions (org.tmatesoft.svn.core.wc.ISVNOptions)2 SVNStatus (org.tmatesoft.svn.core.wc.SVNStatus)2 SVNStatusClient (org.tmatesoft.svn.core.wc.SVNStatusClient)2