All Downloads are FREE. Search and download functionalities are using the official Maven repository.

eu.cedarsoft.devtools.modules.ListRepositoryEntries Maven / Gradle / Ivy

The newest version!
package eu.cedarsoft.devtools.modules;

import com.google.inject.Inject;
import eu.cedarsoft.devtools.Module;
import eu.cedarsoft.devtools.SubversionMessageHandler;
import eu.cedarsoft.devtools.SubversionSupport;
import eu.cedarsoft.utils.CmdLine;
import org.jetbrains.annotations.NotNull;
import org.tmatesoft.svn.core.SVNDirEntry;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.internal.wc.DefaultSVNAuthenticationManager;
import org.tmatesoft.svn.core.auth.BasicAuthenticationManager;
import org.tmatesoft.svn.core.io.SVNRepository;
import org.tmatesoft.svn.core.io.SVNRepositoryFactory;

import java.io.IOException;
import java.util.Collection;

/**
 * Lists the repository entry
 */
public class ListRepositoryEntries implements Module {
  @NotNull
  private final SubversionSupport subversionSupport;

  @Inject
  public ListRepositoryEntries( @NotNull SubversionSupport subversionSupport ) {
    this.subversionSupport = subversionSupport;
  }

  @NotNull
  public String getDescription() {
    return SubversionMessageHandler.get( "module.list.repository.entries" );
  }

  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 dirEntry = repository.getDir( ".", repository.getLatestRevision(), null, ( Collection ) null );

    for ( SVNDirEntry entry : dirEntry ) {
      cmdLine.out( entry.getRelativePath() + "\t\t(" + entry.getKind() + ")" );
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy