Examples of SVNClientManager

  • org.tmatesoft.svn.core.wc.SVNClientManager
    ault options and authentication drivers to use SVNClientManager clientManager = SVNClientManager.newInstance(); ... //2.provided options and default authentication drivers to use ISVNOptions myOptions; ... SVNClientManager clientManager = SVNClientManager.newInstance(myOptions); ... //3.provided options and authentication drivers to use ISVNOptions myOptions; ISVNAuthenticationManager myAuthManager; ... SVNClientManager clientManager = SVNClientManager.newInstance(myOptions, myAuthManager); ... //4.provided options driver and user's credentials to make //a default authentication driver use them ISVNOptions myOptions; ... SVNClientManager clientManager = SVNClientManager.newInstance(myOptions, "name", "passw");
    Having instantiated an SVNClientManager in one of these ways, all the SVN*Client objects it will provide you will share those drivers, so you don't need to code much to provide the same drivers to each SVN*Client instance by yourself.
  • With SVNClientManager you don't need to create and keep your SVN*Client objects by youself - SVNClientManager will do all the work for you, so this will certainly bring down your efforts on coding and your code will be clearer and more flexible. All you need is to create an SVNClientManager instance.
  • Actually every SVN*Client object is instantiated only at the moment of the first call to an appropriate SVNClientManager's get method:
     SVNClientManager clientManager; ... //an update client will be created only at that moment when you  //first call this method for getting your update client, but if you //have already called it once before, then the method will return //that update client object instantiated in previous... so, it's //quite cheap, you see..  SVNUpdateClient updateClient = clientManager.getUpdateClient();

  • You can provide a single event handler that will be used by all SVN*Client objects provided by SVNClientManager:
     import org.tmatesoft.svn.core.wc.ISVNEventHandler; ... ISVNEventHandler commonEventHandler; SVNClientManager clientManager = SVNClientManager.newInstance(); ... //will be used by all SVN*Client objects //obtained from your client manager clientManager.setEventHandler(commonEventHandler); 
  • @version 1.3 @author TMate Software Ltd. @since 1.2 @see ISVNEventHandler @see Examples

  • Examples of org.tmatesoft.svn.core.wc.SVNClientManager

        project.setScm(subversionSCM);
        assertBuildStatusSuccess(project.scheduleBuild2(0));

        // Create a status client and get the working copy format.
        SVNClientManager testWCVerseion = SVNClientManager.newInstance(null, "testWCVerseion", null);
        File path = new File(project.getWorkspace().getRemote());
        return testWCVerseion.getStatusClient().doStatus(path,
                true).getWorkingCopyFormat();
      }
    View Full Code Here

    Examples of org.tmatesoft.svn.core.wc.SVNClientManager

            for (ModuleLocation l : scm.getLocations(env, build)) {
                ISVNAuthenticationProvider authProvider =
                        CredentialsSVNAuthenticationProviderImpl
                                .createAuthenticationProvider(build.getParent(), scm, l);
                final SVNClientManager manager = SubversionSCM.createClientManager(authProvider).getCore();
                try {
                    SVNLogClient svnlc = manager.getLogClient();
                    PathContext context = getUrlForPath(workspace.child(l.getLocalDir()), authProvider);
                    context.moduleWorkspacePath = l.getLocalDir();
                    changelogFileCreated |= buildModule(context, svnlc, logHandler);
                } finally {
                    manager.dispose();
                }
            }
            ISVNAuthenticationProvider authProvider =
                    CredentialsSVNAuthenticationProviderImpl
                            .createAuthenticationProvider(build.getParent(), scm, null);
            final SVNClientManager manager = SubversionSCM.createClientManager(authProvider).getCore();
            try {
                SVNLogClient svnlc = manager.getLogClient();
                for(SubversionSCM.External ext : externals) {
                    PathContext context = getUrlForPath(workspace.child(ext.path), authProvider);
                    context.moduleWorkspacePath = ext.path;
                    changelogFileCreated |= buildModule(context, svnlc, logHandler);
                }
            } finally {
                manager.dispose();
            }

            if(changelogFileCreated) {
                logHandler.endDocument();
            }
    View Full Code Here

    Examples of org.tmatesoft.svn.core.wc.SVNClientManager

        SVNRevision svnRevision = SVNRevision.HEAD;
        if (revision != null && -1L != revision) {
          svnRevision = SVNRevision.create(revision);
        }
        final List<FileEntry> fileEntries = newArrayList();
        SVNClientManager svnClientManager = getSVNClientManager();
        try {
          svnClientManager.getLogClient().doList(SVNURL.fromFile(getUserRepoDirectory(user)).appendPath(path, true),
              svnRevision, svnRevision, true, recursive, new ISVNDirEntryHandler() {
            @Override
            public void handleDirEntry(SVNDirEntry dirEntry) throws SVNException {

              FileEntry script = new FileEntry();
    View Full Code Here

    Examples of org.tmatesoft.svn.core.wc.SVNClientManager

       * @param user user
       * @return found {@link FileEntry}s
       */
      public List<FileEntry> findAll(final User user) {
        final List<FileEntry> scripts = newArrayList();
        SVNClientManager svnClientManager = getSVNClientManager();
        try {
          svnClientManager.getLogClient().doList(SVNURL.fromFile(getUserRepoDirectory(user)), SVNRevision.HEAD,
              SVNRevision.HEAD, false, true, new ISVNDirEntryHandler() {
            @Override
            public void handleDirEntry(SVNDirEntry dirEntry) throws SVNException {
              FileEntry script = new FileEntry();
              String relativePath = dirEntry.getRelativePath();
    View Full Code Here

    Examples of org.tmatesoft.svn.core.wc.SVNClientManager

       * @param revision revision of the file
       * @return found {@link FileEntry}, null if not found
       */
      public FileEntry findOne(User user, String path, SVNRevision revision) {
        final FileEntry script = new FileEntry();
        SVNClientManager svnClientManager = null;
        ByteArrayOutputStream outputStream = null;
        try {
          svnClientManager = getSVNClientManager();

          SVNURL userRepoUrl = SVNURL.fromFile(getUserRepoDirectory(user));
          if (userRepoUrl == null) {
            return null;
          }
          SVNRepository repo = svnClientManager.createRepository(userRepoUrl, true);
          SVNNodeKind nodeKind = repo.checkPath(path, -1);
          if (nodeKind == SVNNodeKind.NONE) {
            return null;
          }
          outputStream = new ByteArrayOutputStream();
    View Full Code Here

    Examples of org.tmatesoft.svn.core.wc.SVNClientManager

       * @param fileEntry fileEntry to be saved
       * @param encoding  file encoding with which fileEntry is saved. It is meaningful
       *                  only FileEntry is editable.
       */
      public void save(User user, FileEntry fileEntry, String encoding) {
        SVNClientManager svnClientManager = null;
        ISVNEditor editor = null;
        String checksum = null;
        InputStream bais = null;
        try {
          svnClientManager = getSVNClientManager();
          SVNRepository repo = svnClientManager.createRepository(SVNURL.fromFile(getUserRepoDirectory(user)), true);
          SVNDirEntry dirEntry = repo.info(fileEntry.getPath(), -1);

          // Add base paths
          String fullPath = "";
          // Check.. first
    View Full Code Here

    Examples of org.tmatesoft.svn.core.wc.SVNClientManager

       *
       * @param user  user
       * @param paths paths of file entries.
       */
      public void delete(User user, List<String> paths) {
        SVNClientManager svnClientManager = null;
        ISVNEditor editor = null;
        try {
          svnClientManager = getSVNClientManager();
          SVNRepository repo = svnClientManager.createRepository(SVNURL.fromFile(getUserRepoDirectory(user)), true);

          editor = repo.getCommitEditor("delete", null, true, null);
          editor.openRoot(-1);
          for (String each : paths) {
            editor.deleteEntry(each, -1);
    View Full Code Here

    Examples of org.tmatesoft.svn.core.wc.SVNClientManager

       * @param user user
       * @param path path in user repo
       * @return true if exists.
       */
      public boolean hasOne(User user, String path) {
        SVNClientManager svnClientManager = null;
        try {
          svnClientManager = getSVNClientManager();
          SVNURL userRepoUrl = SVNURL.fromFile(getUserRepoDirectory(user));
          SVNRepository repo = svnClientManager.createRepository(userRepoUrl, true);
          SVNNodeKind nodeKind = repo.checkPath(path, -1);
          return (nodeKind != SVNNodeKind.NONE);
        } catch (Exception e) {
          LOG.error("Error while fetching files from SVN", e);
          throw processException("Error while checking file existence from SVN", e);
    View Full Code Here

    Examples of org.tmatesoft.svn.core.wc.SVNClientManager

       * @param user      user
       * @param path      path of {@link FileEntry}
       * @param toPathDir file dir path to write.
       */
      public void writeContentTo(User user, String path, File toPathDir) {
        SVNClientManager svnClientManager = null;
        FileOutputStream fileOutputStream = null;
        try {
          svnClientManager = getSVNClientManager();

          SVNURL userRepoUrl = SVNURL.fromFile(getUserRepoDirectory(user));
          SVNRepository repo = svnClientManager.createRepository(userRepoUrl, true);
          SVNNodeKind nodeKind = repo.checkPath(path, -1);
          // If it's DIR, it does not work.
          if (nodeKind == SVNNodeKind.NONE || nodeKind == SVNNodeKind.DIR) {
            throw processException("It's not possible to write directory. nodeKind is " + nodeKind);
          }
    View Full Code Here

    Examples of org.tmatesoft.svn.core.wc.SVNClientManager

        workDir.mkdirs();
            File baseDirectory = workDir;
            File reposRoot = new File(baseDirectory, "tempRepository");
            File wcRoot = new File(workDir, "working_copy");
           
            SVNClientManager clientManager = SVNClientManager.newInstance();       
            SVNAdminClient adminClient = clientManager.getAdminClient();
            SVNDiffClient diffClient = clientManager.getDiffClient();    
            DefaultSVNOptions options = (DefaultSVNOptions) diffClient.getOptions();
            options.setConflictHandler(new ConflictResolverHandler());
            SVNCommitClient commitClient = clientManager.getCommitClient();
           
            boolean fileRepo = true;
           
            String url = "svn://192.168.56.101/project6";
            final SVNURL reposURL = (fileRepo? SVNURL.fromFile(reposRoot) : SVNURL.parseURIEncoded(url)),
          demoURL = reposURL.appendPath("demo", false);       
            if (fileRepo)
              adminClient.doCreateRepository(reposRoot, null, true, true, false, false);
            else
            {
              SubversionSubmitter.setUpSVNKit();
              //SVNRepository repository = SVNRepositoryFactory.create(reposURL);
              ISVNAuthenticationManager m = SVNWCUtil.createDefaultAuthenticationManager("harry", "secret");
             //repository.setAuthenticationManager(m);
             clientManager.setAuthenticationManager(m);
            }
            logger.info("Repo URL = "+ reposURL);
            repos =  SVNRepositoryFactory.create(reposURL);
           
            SVNCommitInfo info;       
            String msg;

            msg = "Import of oldDMO tree";
            info = clientManager.getCommitClient( ).doImport( oldDemoTree , demoURL , msg , true);
            logger.info("Imported oldDemo tree: "+ info);
            //final long revOldDemo = info.getNewRevision();
               
            msg= "Copy demo to custom";
            SVNCopyClient copyClient = clientManager.getCopyClient();
            SVNURL customURL = reposURL.appendPath("custom", true);
            SVNCopySource copySource = new SVNCopySource(SVNRevision.UNDEFINED, SVNRevision.HEAD, demoURL);
            info = copyClient.doCopy(new SVNCopySource[] { copySource }, customURL, false, false, true,
                    msg, null);
            final long revAfterCopyToCustom = info.getNewRevision();
            logger.info(msg + ": " + info);
                   
            File  demoDir = new File(wcRoot, "demo"),
              customDir = new File(wcRoot, "custom");
           
            SVNUpdateClient updateClient = clientManager.getUpdateClient();
            updateClient.doCheckout(reposURL, wcRoot, SVNRevision.UNDEFINED, SVNRevision.HEAD, SVNDepth.INFINITY,
                    false);
            logger.info("Checked out working copy to " + wcRoot);
           
            overwriteTree(newDemoTree, demoDir);
    /*       
            for (File f: dirsCreated)
              clientManager.getWCClient( ).doAdd( f, false , false , false , false );
            for (File f: filesCreated)
              clientManager.getWCClient( ).doAdd( f, false , false , false , false );
    */
            msg = "Commit of newDMO (in demo tree)";
            info = commitClient.doCommit(new File[] { wcRoot }, false, msg, null, null, false,
                                  false, SVNDepth.INFINITY);       
            //final long revNewDMO = info.getNewRevision();
    /*
            diffClient.doDiffStatus(reposURL, SVNRevision.create(revOldDemo), reposURL, SVNRevision.create(revNewDMO),
                true, true, new ISVNDiffStatusHandler() {       
              public void handleDiffStatus(SVNDiffStatus arg0) throws SVNException {
                if (arg0.getURL().toString().endsWith(".pcode"))
                {
                  logger.info("Diff in NewDMO-OldDMO: " + arg0.getURL());

                   logger.info("path = " + arg0.getPath());
                      SVNProperties properties = SVNProperties.wrap(new HashMap());
                      if (repos.checkPath("/" + arg0.getPath(), revOldDemo) == SVNNodeKind.FILE
                          && repos.checkPath("/" + arg0.getPath(), revNewDMO) == SVNNodeKind.FILE)
                      {
                    deltaOldDMONewDMO.add(arg0.getURL());
                        repos.getFile( "/" + arg0.getPath(), revOldDemo, properties, null);
                        String oldCheckSum = properties.getStringValue(SVNProperty.CHECKSUM);
                        repos.getFile("/" +arg0.getPath(), revNewDMO, properties, null);
                        String newCheckSum = properties.getStringValue(SVNProperty.CHECKSUM);
                        logger.info("Checksums: " + oldCheckSum + " " + newCheckSum);
                      }
                }
              }
            });
    */
            logger.info(msg + ":" + info);

            dirsCreated.clear(); filesCreated.clear();
            overwriteTree(oldDevTree, customDir);
    /*
            msg = "Commit of old DEV";
            info = commitClient.doCommit(new File[] { wcRoot }, false, msg, null, null, false,
                                  false, SVNDepth.INFINITY);         
            logger.info(msg + ":" + info);
            long revOldDEV = info.getNewRevision();
            diffClient.doDiffStatus(reposURL, SVNRevision.create(revNewDMO), reposURL, SVNRevision.create(revOldDEV),
                true, true, new ISVNDiffStatusHandler() {       
              public void handleDiffStatus(SVNDiffStatus arg0) throws SVNException {
                if (arg0.getURL().toString().endsWith(".pcode"))
                {
                  logger.fine("Diff in DEV-oldDMO: " + arg0.getURL());
                  deltaOldDMODev.add(arg0.getURL());
                }
              }
            });
    */
            updateClient = clientManager.getUpdateClient();
            updateClient.doCheckout(reposURL, wcRoot, SVNRevision.UNDEFINED, SVNRevision.HEAD, SVNDepth.INFINITY,
                    false);
            logger.info("Checked out working copy to " + wcRoot);       
           
            File targetOfMerge = (mergeToDMO? demoDir: customDir);
    View Full Code Here
    TOP
    Copyright © 2018 www.massapi.com. All rights reserved.
    All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.