Class BrowseCommandBuilder

java.lang.Object
sonia.scm.repository.api.BrowseCommandBuilder

public final class BrowseCommandBuilder extends Object
BrowseCommandBuilder is able to browse the files of a Repository.

Sample:

Print all paths from folder scm-core at revision 11aeec7db845:

 BrowseCommandBuilder browse = repositoryService.getBrowseCommand();
 BrowserResult result = browse.setPath("scm-core")
                              .setRevision("11aeec7db845")
                              .getBrowserResult();

 for ( FileObject fo : result ){
   System.out.println( fo.getPath() );
 }
 
Since:
1.17
  • Method Details

    • reset

      public BrowseCommandBuilder reset()
      Reset each parameter to its default value.
      Returns:
      this
    • getBrowserResult

      public BrowserResult getBrowserResult() throws IOException
      Return the files for the given parameters.
      Throws:
      IOException
    • setDisableCache

      public BrowseCommandBuilder setDisableCache(boolean disableCache)
      Disables the cache. This means that every BrowserResult is directly retrieved from the Repository. Note: Disabling the cache cost a lot of performance and could be much more slower.
      Parameters:
      disableCache - true to disable the cache
      Returns:
      this
    • setDisableLastCommit

      public BrowseCommandBuilder setDisableLastCommit(boolean disableLastCommit)
      Disabling the last commit means that every call to FileObject.getDescription() and FileObject.getLastModified() will return null, but this will also reduce the execution time.
      Parameters:
      disableLastCommit - true to disable the last commit message
      Returns:
      this
      Since:
      1.26
    • setDisablePreProcessors

      public BrowseCommandBuilder setDisablePreProcessors(boolean disablePreProcessors)
      Disable the execution of pre processors if set to true.
      Returns:
      this
    • setDisableSubRepositoryDetection

      public BrowseCommandBuilder setDisableSubRepositoryDetection(boolean disableSubRepositoryDetection)
      Enable or disable the detection of sub repositories.
      Parameters:
      disableSubRepositoryDetection - true to disable sub repository detection.
      Returns:
      this
      Since:
      1.26
    • setPath

      public BrowseCommandBuilder setPath(String path)
      Retrieve only files which are children of the given path. This path have to be a directory.
      Parameters:
      path - path of the folder
      Returns:
      this
    • setRecursive

      public BrowseCommandBuilder setRecursive(boolean recursive)
      Enable or disable recursive file object browsing. Default is disabled.
      Parameters:
      recursive - true to enable recursive browsing
      Returns:
      this
      Since:
      1.26
    • setRevision

      public BrowseCommandBuilder setRevision(String revision)
      Retrieve only files of the given revision.
      Parameters:
      revision - revision for the files
      Returns:
      this
    • setLimit

      public BrowseCommandBuilder setLimit(int limit)
      Limit the number of result files to limit entries. By default, this is set to 100. Be aware that this parameter can have severe performance implications. Reading a repository with thousands of files in one folder can generate a huge load for a longer time.
      Parameters:
      limit - The maximal number of files this request shall return (directories are not counted).
      Since:
      2.0.0
    • setOffset

      public BrowseCommandBuilder setOffset(int offset)
      Proceed the list from the given number on (zero based).
      Parameters:
      offset - The number of the file, the result should start with (zero based). All preceding files will be omitted. Directories are not counted. Therefore, directories are only listed in results without offset.
      Since:
      2.0.0
    • setCollapse

      public BrowseCommandBuilder setCollapse(boolean collapse)
      Collapse folders with only one sub-folder until a folder is empty, contains files or has more than one sub-folder and return the path to such folder as a single item.
      Parameters:
      collapse - true if folders with only one sub-folder should be collapsed, otherwise false.
      Since:
      2.31.0