Refine search
public void testConnection() throws SVNException { String encodedUrl = SVNEncodingUtil.autoURIEncode(addressSvn); SVNRepository repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(encodedUrl)); repository.setAuthenticationManager(authManager); repository.testConnection(); }
public SVNURL doCreateRepository(File path, String uuid, boolean enableRevisionProperties, boolean force, boolean pre14Compatible, boolean pre15Compatible, boolean pre16Compatible, boolean pre17Compatible, boolean with17Compatible) throws SVNException { return SVNRepositoryFactory.createLocalRepository(path, uuid, enableRevisionProperties, force, pre14Compatible, pre15Compatible, pre16Compatible, pre17Compatible, with17Compatible); }
public SCMRepository info() { SVNRepository repository = null; try { SVNURL url = SVNURL.parseURIEncoded(path); repository = SVNRepositoryFactory.create(url); authenticateIfNecessary(repository); SVNDirEntry firstRevision = repository.info("/", 0); SVNDirEntry lastRevision = repository.info("/", SVNRevision.HEAD.getNumber()); return new SCMRepository(this, lastRevision.getURL().getPath(), path, String.valueOf(lastRevision.getRevision()), String.valueOf(firstRevision .getRevision())); } catch (SVNException e) { throw new RuntimeException("error in getHead() for " + path, e); } finally { if (repository != null) repository.closeSession(); } }
private SVNRepository getSourceRepository() throws SVNException { if (mySourceRepository == null) { mySourceRepository = SVNRepositoryFactory.create(myRepos.getLocation()); mySourceRepository.setAuthenticationManager(myRepos.getAuthenticationManager()); mySourceRepository.setDebugLog(myRepos.getDebugLog()); mySourceRepository.setTunnelProvider(myRepos.getTunnelProvider()); mySourceRepository.setCanceller(myRepos.getCanceller()); } return mySourceRepository; }
public String getSvnRoot(String username, String password) { String repositoryRoot; try { String encodedUrl = SVNEncodingUtil.autoURIEncode(addressSvn); SVNRepository repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(encodedUrl)); ISVNAuthenticationManager svnAuthManager = SVNWCUtil.createDefaultAuthenticationManager(username, password); repository.setAuthenticationManager(svnAuthManager); repositoryRoot = repository.getRepositoryRoot(true).toString(); } catch (SVNException e) { if (log.isDebugEnabled()) { log.debug("Can't get SvnRoot for address " + addressSvn, e); } return null; } return repositoryRoot; }
protected SVNRepository getRepository(Item context, SVNURL repoURL, StandardCredentials credentials, Map<String, Credentials> additionalCredentials, ISVNSession session) throws SVNException { SVNRepository repository = SVNRepositoryFactory.create(repoURL, session); ISVNAuthenticationManager sam = createSvnAuthenticationManager( new CredentialsSVNAuthenticationProviderImpl(credentials, additionalCredentials, /* TODO */ TaskListener.NULL) ); sam = new FilterSVNAuthenticationManager(sam) { // If there's no time out, the blocking read operation may hang forever, because TCP itself // has no timeout. So always use some time out. If the underlying implementation gives us some // value (which may come from ~/.subversion), honor that, as long as it sets some timeout value. @Override public int getReadTimeout(SVNRepository repository) { int r = super.getReadTimeout(repository); if(r<=0) r = DEFAULT_TIMEOUT; return r; } }; repository.setTunnelProvider(createDefaultSVNOptions()); repository.setAuthenticationManager(sam); return repository; }
public void run() throws SVNException { SVNRevision start = getSVNAdminEnvironment().getStartRevision(); SVNRevision end = getSVNAdminEnvironment().getEndRevision(); SVNRepository repository = SVNRepositoryFactory.create(SVNURL.fromFile(getLocalRepository())); repository.setCanceller(getEnvironment()); long latestRevision = repository.getLatestRevision(); long startRev = getRevisionNumber(start, latestRevision, repository); long endRev = getRevisionNumber(end, latestRevision, repository); if (startRev < 0) { startRev = 0; endRev = latestRevision; } else if (endRev < 0) { endRev = startRev; } if (startRev > endRev) { SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR, "First revision cannot be higher than second"), SVNLogType.CLIENT); } SVNAdminClient client = getEnvironment().getClientManager().getAdminClient(); if (!getSVNAdminEnvironment().isQuiet()) { client.setEventHandler(this); } client.doVerify(getLocalRepository(), SVNRevision.create(startRev), SVNRevision.create(endRev)); }
/** * Submits the authentication info. * * This code is fairly ugly because of the way SVNKit handles credentials. */ public void postCredential(String url, final UserProvidedCredential upc, PrintWriter logWriter) throws SVNException, IOException { SVNRepository repository = null; try { // the way it works with SVNKit is that // 1) svnkit calls AuthenticationManager asking for a credential. // this is when we can see the 'realm', which identifies the user domain. // 2) DefaultSVNAuthenticationManager returns the username and password we set below // 3) if the authentication is successful, svnkit calls back acknowledgeAuthentication // (so we store the password info here) repository = SVNRepositoryFactory.create(SVNURL.parseURIDecoded(url)); repository.setTunnelProvider( createDefaultSVNOptions() ); AuthenticationManagerImpl authManager = upc.new AuthenticationManagerImpl(logWriter); authManager.setAuthenticationForced(true); repository.setAuthenticationManager(authManager); repository.testConnection(); authManager.checkIfProtocolCompleted(); } finally { if (repository != null) repository.closeSession(); } }
public void run() throws SVNException { List targets = getEnvironment().combineTargets(null, false); if (!targets.isEmpty()) { targets.remove(0); } String[] locks = (String[]) targets.toArray(new String[targets.size()]); SVNRepository repository = SVNRepositoryFactory.create(SVNURL.fromFile(getLocalRepository())); String userName = System.getProperty("user.name", "administrator"); repository.setAuthenticationManager(new BasicAuthenticationManager(userName, "")); repository.setCanceller(getEnvironment()); for (int i = 0; i < locks.length; i++) { String lockPath = locks[i]; try { SVNLock lock = repository.getLock(lockPath); if (lock == null) { getEnvironment().getOut().println("Path '" + lockPath + "' isn't locked."); continue; } Map pathToToken = new SVNHashMap(); pathToToken.put(lockPath, lock.getID()); repository.unlock(pathToToken, true, this); } catch (SVNException e) { getEnvironment().handleError(e.getErrorMessage()); } } }
SVNURL url = SVNURL.parseURIEncoded(path); repository = SVNRepositoryFactory.create(url); long endRevision = revision; Collection repositoryLog = repository.log(new String[] { "" }, null, startRevision, endRevision, true, true); } finally { if (repository != null) repository.closeSession();
public void process( @NotNull CmdLine cmdLine ) throws IOException, SVNException { cmdLine.out( SubversionMessageHandler.get( "module.list.repository.entries" ) ); String repositoryUrl = cmdLine.read( SubversionMessageHandler.get( "wich.repository.shall.be.used" ), subversionSupport.getRepositoryUrls(), null ); subversionSupport.addRepositoryUrl( repositoryUrl ); cmdLine.warning( SubversionMessageHandler.get( "listing.repository.entries" ) ); cmdLine.out( SubversionMessageHandler.get( "repository" ) ); cmdLine.success( '\t' + repositoryUrl ); SVNURL svnurl = SVNURL.parseURIDecoded( repositoryUrl ); SVNRepository repository = SVNRepositoryFactory.create( svnurl ); repository.setAuthenticationManager( subversionSupport.getAuthenticationManager() ); Collection<SVNDirEntry> dirEntry = repository.getDir( ".", repository.getLatestRevision(), null, ( Collection<?> ) null ); for ( SVNDirEntry entry : dirEntry ) { cmdLine.out( entry.getRelativePath() + "\t\t(" + entry.getKind() + ")" ); } } }
@Override public String getRepositoryId() { String repositoryUUID; try { String encodedUrl = SVNEncodingUtil.autoURIEncode(addressSvn); SVNRepository repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(encodedUrl)); ISVNAuthenticationManager svnAuthManager = SVNWCUtil.createDefaultAuthenticationManager(); repository.setAuthenticationManager(svnAuthManager); repositoryUUID = repository.getRepositoryUUID(true); } catch (SVNException e) { if (log.isDebugEnabled()) { log.debug("Can't get UUID", e); } return null; } return repositoryUUID; }
@Override public void reset() { SVNRepository repository = null; try { SVNRevision revision = SVNRevision.HEAD; SVNURL url = SVNURL.parseURIEncoded(path); repository = SVNRepositoryFactory.create(url); authenticateIfNecessary(repository); SVNClientManager ourClientManager = SVNClientManager.newInstance(null, repository.getAuthenticationManager()); SVNUpdateClient updateClient = ourClientManager.getUpdateClient(); updateClient.setIgnoreExternals(false); updateClient.doCheckout(url, new File(workingCopyPath), revision, revision, SVNDepth.INFINITY, true); } catch (Exception e) { throw new RuntimeException(e); } finally { if (repository != null) repository.closeSession(); } }
protected void doOpenConnection() throws SVNException { String url = getSubversionURL(); SVNURL repoUrl = SVNURL.parseURIDecoded(url); queryRepo = SVNRepositoryFactory.create(repoUrl); configureAuthenticationManager(queryRepo); // when URL is given like http://svn.dev.java.net/svn/abc/trunk/xyz, we need to compute // repositoryRoot=http://svn.dev.java.net/abc and rootPath=/trunk/xyz rootPath = repoUrl.getPath().substring(queryRepo.getRepositoryRoot(true).getPath().length()); if(rootPath.startsWith("/")) rootPath=rootPath.substring(1); // at least in case of file:// URL, the commit editor remembers the root path // portion and that interferes with the way we work, so re-open the repository // with the correct root. SVNURL repoRoot = queryRepo.getRepositoryRoot(true); queryRepo.setLocation(repoRoot,false); // open another one for commit commitRepo = SVNRepositoryFactory.create(repoRoot); configureAuthenticationManager(commitRepo); // prepare a commit ISVNEditor svnEditor = commitRepo.getCommitEditor("Upload by wagon-svn", new CommitMediator()); svnEditor.openRoot(-1); // if openRoot fails, Maven calls closeConnection anyway, so don't let the incorrect // editor state show through. this.editor = svnEditor; }
public static SVNRepository repository(SVNURL url, ISVNAuthenticationManager authenticationManager) throws SVNException { SVNRepository repository; repository = SVNRepositoryFactory.create(url); repository.setAuthenticationManager(authenticationManager); return repository; }
private SVNRepository getSourceRepository() throws SVNException { if (mySourceRepository == null) { mySourceRepository = SVNRepositoryFactory.create(myRepos.getLocation()); mySourceRepository.setAuthenticationManager(myRepos.getAuthenticationManager()); } return mySourceRepository; }
protected SVNRepository createRepository(SVNURL url, String uuid, boolean mayReuse) throws SVNException { SVNRepository repository = null; if (myRepositoryPool == null) { repository = SVNRepositoryFactory.create(url, null); } else { repository = myRepositoryPool.createRepository(url, mayReuse); } if (uuid != null) { String reposUUID = repository.getRepositoryUUID(true); if (!uuid.equals(reposUUID)) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_UUID_MISMATCH, "Repository UUID ''{0}'' doesn''t match expected UUID ''{1}''", new Object[] { reposUUID, uuid }); SVNErrorManager.error(err, SVNLogType.WC); } } repository.setDebugLog(getDebugLog()); repository.setCanceller(getEventDispatcher()); return repository; }
public SVNConnector build(String login, String pass) { if (repository == null) { DAVRepositoryFactory.setup(); SVNURL url; try { url = SVNURL.parseURIDecoded(SVNURI + SVNTestRepo); repository = SVNRepositoryFactory.create(url, null); } catch (SVNException e1) { e1.printStackTrace(); } } ISVNAuthenticationManager authManager = new BasicAuthenticationManager(login, pass); repository.setAuthenticationManager(authManager); return instance; }
public SVNRepository createRepository(SVNURL url, String expectedUuid, boolean mayReuse) throws SVNException { SVNRepository repository = null; if (getOperationOptionsProvider().getRepositoryPool() == null) { repository = SVNRepositoryFactory.create(url, null); repository.setAuthenticationManager(getOperationOptionsProvider().getAuthenticationManager()); } else { repository = getOperationOptionsProvider().getRepositoryPool().createRepository(url, mayReuse); } if (expectedUuid != null) { String reposUUID = repository.getRepositoryUUID(true); if (!expectedUuid.equals(reposUUID)) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_UUID_MISMATCH, "Repository UUID ''{0}'' doesn''t match expected UUID ''{1}''", new Object[] { reposUUID, expectedUuid }); SVNErrorManager.error(err, SVNLogType.WC); } } repository.setCanceller(getOperationOptionsProvider().getCanceller()); repository.setEventHandler(getOperationOptionsProvider().getEventHandler()); return repository; }