public static void main(String[] args) { ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager("admin", "john"); SVNClientManager manager = SVNClientManager.newInstance(); manager.setAuthenticationManager(authManager); SVNCommitClient commitClient = SVNClientManager.newInstance().getCommitClient(); try { SVNCommitInfo info = commitClient.doMkDir(new SVNURL[] { SVNURL.parseURIEncoded("http://192.168.3.127/repository/koux/trunk") }, "commitMessage", null, true); long newRevision = info.getNewRevision(); System.out.println(newRevision); } catch (SVNException e) { e.printStackTrace(); } }
protected SVNClientManager getClientManager(final SVNRepository repository) { // Gets the current transaction Transaction transaction = transactionService.get(); if (transaction == null) { throw new IllegalStateException("All SVN calls must be part of a SVN transaction"); } // Gets the client manager return transaction .getResource( SVNSession.class, repository.getId(), () -> { // Creates the client manager for SVN SVNClientManager clientManager = SVNClientManager.newInstance(); // Authentication (if needed) String svnUser = repository.getConfiguration().getUser(); String svnPassword = repository.getConfiguration().getPassword(); if (StringUtils.isNotBlank(svnUser) && StringUtils.isNotBlank(svnPassword)) { clientManager.setAuthenticationManager(BasicAuthenticationManager.newInstance(svnUser, svnPassword.toCharArray())); } // OK return new SVNSessionImpl(clientManager); } ) .getClientManager(); } }
SVNURL svnurl = SVNURL.parseURIDecoded(url); SVNRepository repository = SVNRepositoryFactory.create(svnurl); ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(uname, password); repository.setAuthenticationManager(authManager); SVNClientManager ourClientManager = SVNClientManager.newInstance(); ourClientManager.setAuthenticationManager(authManager); SVNUpdateClient updateClient = ourClientManager.getUpdateClient(); updateClient.setIgnoreExternals(true); long latestRevision = repository.getLatestRevision(); if (updateClient.doCheckout(svnurl, destinationDir, SVNRevision.HEAD, SVNRevision.HEAD, SVNDepth.INFINITY, allowUnversionedObstructions) == latestRevision) { ourClientManager.dispose(); }
public static void main(String[] args) { ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager("admin", "john"); SVNClientManager manager = SVNClientManager.newInstance(); manager.setAuthenticationManager(authManager); SVNCommitClient commitClient = SVNClientManager.newInstance().getCommitClient(); try { SVNCommitInfo info = commitClient.doMkDir(new SVNURL[] { SVNURL.parseURIEncoded("http://192.168.3.127/repository/koux/branches") }, "commitMessage", null, true); long newRevision = info.getNewRevision(); System.out.println(newRevision); } catch (SVNException e) { e.printStackTrace(); } }
public boolean svnMkDirs(SVNURL[] urls) { ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager("admin", "john"); SVNClientManager manager = SVNClientManager.newInstance(); manager.setAuthenticationManager(authManager); SVNCommitClient commitClient = SVNClientManager.newInstance().getCommitClient(); try { SVNCommitInfo info = commitClient.doMkDir(urls, "commitMessage", null, true); long newRevision = info.getNewRevision(); if (log.isDebugEnabled()) { if (newRevision >= 0) log.debug("commit successful: new revision = " + newRevision); else log.debug("no commits performed (commit operation returned new revision < 0)"); } System.out.println(newRevision); } catch (SVNException e) { log.error(e); return false; } return true; }
clientManager.setAuthenticationManager(authnManager); return clientManager;
private void updateClientManager() { File configDir = myConfigDir == null ? null : new File(myConfigDir); myOptions = SVNWCUtil.createDefaultOptions(configDir, true); myOptions.setConflictHandler(getConflictHandler()); myAuthenticationManager = SVNWCUtil.createDefaultAuthenticationManager(configDir, myUserName, myPassword, myOptions.isAuthStorageEnabled()); if (myPrompt != null) { myAuthenticationManager.setAuthenticationProvider(new JavaHLAuthenticationProvider(myPrompt)); } else { myAuthenticationManager.setAuthenticationProvider(null); } if (myAuthenticationManager instanceof DefaultSVNAuthenticationManager) { ((DefaultSVNAuthenticationManager)myAuthenticationManager).setRuntimeStorage(getClientCredentialsStorage()); } if (myClientManager != null) { myClientManager.dispose(); myClientManager.setAuthenticationManager(myAuthenticationManager); myClientManager.setOptions(myOptions); } }
private void updateClientManager() { File configDir = myConfigDir == null ? null : new File(myConfigDir); myOptions = SVNWCUtil.createDefaultOptions(configDir, true); myOptions.setConflictHandler(getConflictHandler()); myAuthenticationManager = SVNWCUtil.createDefaultAuthenticationManager(configDir, myUserName, myPassword, myOptions.isAuthStorageEnabled()); if (myPrompt != null) { myAuthenticationManager.setAuthenticationProvider(new JavaHLAuthenticationProvider(myPrompt)); } else { myAuthenticationManager.setAuthenticationProvider(null); } if (myAuthenticationManager instanceof DefaultSVNAuthenticationManager) { ((DefaultSVNAuthenticationManager)myAuthenticationManager).setRuntimeStorage(getClientCredentialsStorage()); } if (myClientManager != null) { myClientManager.dispose(); myClientManager.setAuthenticationManager(myAuthenticationManager); myClientManager.setOptions(myOptions); } }
private void updateClientManager() { File configDir = myConfigDir == null ? null : new File(myConfigDir); myOptions = SVNWCUtil.createDefaultOptions(configDir, true); myOptions.setConflictHandler(getConflictHandler()); myAuthenticationManager = SVNWCUtil.createDefaultAuthenticationManager(configDir, myUserName, myPassword, myOptions.isAuthStorageEnabled()); if (myPrompt != null) { myAuthenticationManager.setAuthenticationProvider(new JavaHLAuthenticationProvider(myPrompt)); } else { myAuthenticationManager.setAuthenticationProvider(null); } if (myAuthenticationManager instanceof DefaultSVNAuthenticationManager) { ((DefaultSVNAuthenticationManager)myAuthenticationManager).setRuntimeStorage(getClientCredentialsStorage()); } if (myClientManager != null) { myClientManager.dispose(); myClientManager.setAuthenticationManager(myAuthenticationManager); myClientManager.setOptions(myOptions); } }