Class SVNAdminClient

  • All Implemented Interfaces:
    ISVNCanceller, ISVNEventHandler

    public class SVNAdminClient
    extends SVNAdminBasicClient
    The SVNAdminClient class provides methods that brings repository-side functionality and repository synchronizing features.

    Repository administrative methods are analogues of the corresponding commands of the native Subversion 'svnadmin' utility, while repository synchronizing methods are the ones for the 'svnsync' utility.

    Here's a list of the SVNAdminClient's methods matched against corresponing commands of the Subversion svnsync and svnadmin command-line utilities:

    SVNKit Subversion
    doInitialize()'svnsync initialize'
    doSynchronize()'svnsync synchronize'
    doInfo()'svnsync info'
    doCopyRevisionProperties()'svnsync copy-revprops'
    doDump()'svnadmin dump'
    doListTransactions()'svnadmin lstxns'
    doLoad()'svnadmin load'
    doRemoveTransactions()'svnadmin rmtxns'
    doVerify()'svnadmin verify'
    doPack()'svnadmin pack'
    Since:
    1.2
    Version:
    1.3
    • Constructor Detail

      • SVNAdminClient

        public SVNAdminClient​(ISVNAuthenticationManager authManager,
                              ISVNOptions options)
        Creates a new admin client.
        Parameters:
        authManager - an auth manager
        options - an options driver
      • SVNAdminClient

        public SVNAdminClient​(ISVNRepositoryPool repositoryPool,
                              ISVNOptions options)
        Creates a new admin client.
        Parameters:
        repositoryPool - a repository pool
        options - an options driver
    • Method Detail

      • setReplayHandler

        public void setReplayHandler​(ISVNLogEntryHandler handler)
        Sets a replication handler that will receive a log entry object per each replayed revision.

        Log entries dispatched to the handler may not contain changed paths and committed log message until this features are implemented in future releases.

        Parameters:
        handler - a replay handler
      • setEventHandler

        public void setEventHandler​(ISVNEventHandler handler)
        Sets an event handler for this object. ISVNAdminEventHandler should be provided to SVNAdminClent via this method also. But it does not mean that you can have two handler set, only one handler can be used at a time.
        Overrides:
        setEventHandler in class SVNAdminBasicClient
        Parameters:
        handler - an event handler
      • doCreateRepository

        public SVNURL doCreateRepository​(java.io.File path,
                                         java.lang.String uuid,
                                         boolean enableRevisionProperties,
                                         boolean force)
                                  throws SVNException
        Creates an FSFS-type repository. This implementation uses SVNRepositoryFactory.createLocalRepository(File, String, boolean, boolean)}.

        If uuid is null a new uuid will be generated, otherwise the specified will be used.

        If enableRevisionProperties is true, an empty pre-revprop-change hook will be placed into the repository /hooks subdir. This enables changes to revision properties of the newly created repository.

        If force is true and path already exists, deletes that path and creates a repository in its place.

        Parameters:
        path - a repository root dir path
        uuid - a repository uuid
        enableRevisionProperties - enables/disables changes to revision properties
        force - forces operation to run
        Returns:
        a local URL (file:///) of a newly created repository
        Throws:
        SVNException
        Since:
        1.1.0
        See Also:
        doCreateRepository(File, String, boolean, boolean, boolean)
      • doCreateRepository

        public SVNURL doCreateRepository​(java.io.File path,
                                         java.lang.String uuid,
                                         boolean enableRevisionProperties,
                                         boolean force,
                                         boolean pre14Compatible)
                                  throws SVNException
        Creates an FSFS-type repository. This implementation uses SVNRepositoryFactory.createLocalRepository(File, String, boolean, boolean)}.

        If uuid is null a new uuid will be generated, otherwise the specified will be used.

        If enableRevisionProperties is true, an empty pre-revprop-change hook will be placed into the repository /hooks subdir. This enables changes to revision properties of the newly created repository.

        If force is true and path already exists, deletes that path and creates a repository in its place.

        Set pre14Compatible to true if you want a new repository to be compatible with pre-1.4 servers.

        Parameters:
        path - a repository root dir path
        uuid - a repository uuid
        enableRevisionProperties - enables/disables changes to revision properties
        force - forces operation to run
        pre14Compatible - true to create a repository with pre-1.4 format
        Returns:
        a local URL (file:///) of a newly created repository
        Throws:
        SVNException
        Since:
        1.1.1
      • doCreateRepository

        public SVNURL doCreateRepository​(java.io.File path,
                                         java.lang.String uuid,
                                         boolean enableRevisionProperties,
                                         boolean force,
                                         boolean pre14Compatible,
                                         boolean pre15Compatible,
                                         boolean pre16Compatible)
                                  throws SVNException
        Creates an FSFS-type repository. This implementation uses SVNRepositoryFactory.createLocalRepository(File, String, boolean, boolean)}.

        If uuid is null a new uuid will be generated, otherwise the specified will be used.

        If enableRevisionProperties is true, an empty pre-revprop-change hook will be placed into the repository /hooks subdir. This enables changes to revision properties of the newly created repository.

        If force is true and path already exists, deletes that path and creates a repository in its place.

        Set pre14Compatible to true if you want a new repository to be compatible with pre-1.4 servers, pre15Compatible - with pre-1.5 servers and pre16Compatible - with pre-1.6 servers.

        There must be only one option (either pre14Compatible or pre15Compatible or pre16Compatible) set to true at a time.

        Parameters:
        path - a repository root dir path
        uuid - a repository uuid
        enableRevisionProperties - enables/disables changes to revision properties
        force - forces operation to run
        pre14Compatible - true to create a repository with pre-1.4 format
        pre15Compatible - true to create a repository with pre-1.5 format
        pre16Compatible - true to create a repository with pre-1.6 format
        Returns:
        a local URL (file:///) of a newly created repository
        Throws:
        SVNException
        Since:
        1.3, SVN 1.5.0
      • doCreateRepository

        public SVNURL doCreateRepository​(java.io.File path,
                                         java.lang.String uuid,
                                         boolean enableRevisionProperties,
                                         boolean force,
                                         boolean pre14Compatible,
                                         boolean pre15Compatible,
                                         boolean pre16Compatible,
                                         boolean pre17Compatible,
                                         boolean with17Compatible)
                                  throws SVNException
        Throws:
        SVNException
      • doCreateRepository

        public SVNURL doCreateRepository​(java.io.File path,
                                         java.lang.String uuid,
                                         boolean enableRevisionProperties,
                                         boolean force,
                                         boolean pre14Compatible,
                                         boolean pre15Compatible)
                                  throws SVNException
        Creates an FSFS-type repository. This implementation uses SVNRepositoryFactory.createLocalRepository(File, String, boolean, boolean)}.

        If uuid is null a new uuid will be generated, otherwise the specified will be used.

        If enableRevisionProperties is true, an empty pre-revprop-change hook will be placed into the repository /hooks subdir. This enables changes to revision properties of the newly created repository.

        If force is true and path already exists, deletes that path and creates a repository in its place.

        Set pre14Compatible to true if you want a new repository to be compatible with pre-1.4 servers, pre15Compatible - with pre-1.5 servers.

        There must be only one option (either pre14Compatible or pre15Compatible) set to true at a time.

        Parameters:
        path - a repository root dir path
        uuid - a repository uuid
        enableRevisionProperties - enables/disables changes to revision properties
        force - forces operation to run
        pre14Compatible - true to create a repository with pre-1.4 format
        pre15Compatible - true to create a repository with pre-1.5 format
        Returns:
        a local URL (file:///) of a newly created repository
        Throws:
        SVNException
        Since:
        1.2, SVN 1.5.0
      • doCopyRevisionProperties

        public void doCopyRevisionProperties​(SVNURL toURL,
                                             long startRevision,
                                             long endRevision)
                                      throws SVNException
        Copies revision properties from the source repository starting at startRevision and up to endRevision to corresponding revisions of the destination repository represented by toURL.

        This method is equivalent to the command 'copy-revprops' of the native Subversion svnsync utility. Note that the destination repository given as toURL must be synchronized with a source repository. Please, see doInitialize(SVNURL, SVNURL)} how to initialize such a synchronization.

        If the caller has provided an event handler, the handler will receive an SVNAdminEvent with the SVNAdminEventAction.REVISION_PROPERTIES_COPIED action when the properties get copied.

        Parameters:
        toURL - a url to the destination repository which must be synchronized with another repository
        startRevision - start revision
        endRevision - end revision
        Throws:
        SVNException - in the following cases:
        • exception with SVNErrorCode.IO_ERROR error code - if any of revisions between startRevision and endRevision inclusively was not synchronized yet
        Since:
        1.2.0, new in Subversion 1.5.0
      • doInitialize

        public void doInitialize​(SVNURL fromURL,
                                 SVNURL toURL)
                          throws SVNException
        Initializes synchronization between source and target repositories.

        This method is equivalent to the command 'initialize' ('init') of the native Subversion svnsync utility. Initialization places information of a source repository to a destination one (setting special revision properties in revision 0) as well as copies all revision props from revision 0 of the source repository to revision 0 of the destination one.

        Parameters:
        fromURL - a source repository url
        toURL - a destination repository url
        Throws:
        SVNException - in the following cases:
        Since:
        1.1, new in Subversion 1.4
      • doInfo

        public SVNSyncInfo doInfo​(SVNURL toURL)
                           throws SVNException
        Returns information about the synchronization repository located at toURL.
        Parameters:
        toURL - destination repository url
        Returns:
        synchronization information
        Throws:
        SVNException
        Since:
        1.3, SVN 1.6
      • doPack

        public void doPack​(java.io.File repositoryRoot)
                    throws SVNException
        Compacts a repository into a more efficient storage model.

        Compacting does not occur if there are no full shards. Also compacting does not work on pre-1.6 repositories.

        Parameters:
        repositoryRoot - root of the repository to pack
        Throws:
        SVNException
        Since:
        1.3, SVN 1.6
      • doCompleteSynchronize

        public void doCompleteSynchronize​(SVNURL fromURL,
                                          SVNURL toURL)
                                   throws SVNException
        Completely synchronizes two repositories.

        This method initializes the destination repository and then copies all revision changes (including revision properties) from the given source repository to the destination one. First it tries to use synchronization features similar to the native Subversion 'svnsync' capabilities. But if a server does not support replay functionality, SVNKit uses its own repository replication feature (see SVNRepositoryReplicator})

        Parameters:
        fromURL - a url of a repository to copy from
        toURL - a destination repository url
        Throws:
        SVNException
        Since:
        1.1
      • doSynchronize

        public void doSynchronize​(SVNURL toURL)
                           throws SVNException
        Synchronizes the repository at the given url.

        Synchronization means copying revision changes and revision properties from the source repository (that the destination one is synchronized with) to the destination one starting at the last merged revision. This method is equivalent to the command 'synchronize' ('sync') of the native Subversion svnsync utility.

        Parameters:
        toURL - a destination repository url
        Throws:
        SVNException
        Since:
        1.1, new in Subversion 1.4
      • doListLocks

        public void doListLocks​(java.io.File repositoryRoot)
                         throws SVNException
        Walks through the repository tree found under repositoryRoot and reports all found locks via calls to the caller's ISVNAdminEventHandler handler implementation.

        On each locked path found this method dispatches an SVNAdminEventAction.LOCK_LISTED event to the caller's handler providing the lock information.

        Parameters:
        repositoryRoot - repository root location
        Throws:
        SVNException
        Since:
        1.2.0, SVN 1.5.0
      • doVerify

        public void doVerify​(java.io.File repositoryRoot)
                      throws SVNException
        Verifies the data stored in the repository. This method uses the dump implementation (non incremental, beginning with revision 0, ending at the latest one) passing a dummy output stream to it. This allows to check the integrity of the repository data.

        This is identical to doVerify(repositoryRoot, SVNRevision.create(0), SVNRevision.HEAD).

        Parameters:
        repositoryRoot - a repository root directory path
        Throws:
        SVNException - verification failed - a repository may be corrupted
        Since:
        1.1.1
      • doVerify

        public void doVerify​(java.io.File repositoryRoot,
                             SVNRevision startRevision,
                             SVNRevision endRevision)
                      throws SVNException
        Verifies repository contents found under repositoryRoot starting at startRevision and up to endRevision. This method uses the dump implementation (non incremental) passing a dummy output stream to it. This allows to check the integrity of the repository data.

        If startRevision is invalid, it defaults to 0. If endRevision is invalid, it defaults to the HEAD revision.

        Parameters:
        repositoryRoot - a repository root directory path
        startRevision - revision to start verification at
        endRevision - revision to stop verification at
        Throws:
        SVNException - verification failed - a repository may be corrupted
        Since:
        1.2.0, SVN 1.5.0
      • doDump

        public void doDump​(java.io.File repositoryRoot,
                           java.io.OutputStream dumpStream,
                           SVNRevision startRevision,
                           SVNRevision endRevision,
                           boolean isIncremental,
                           boolean useDeltas)
                    throws SVNException
        Dumps contents of the repository to the provided output stream in a 'dumpfile' portable format.

        On each revision dumped this method fires an SVNAdminEvent with action set to SVNAdminEventAction.REVISION_DUMPED to the registered ISVNAdminEventHandler (if any). To register your ISVNAdminEventHandler pass it to setEventHandler(ISVNEventHandler). For this operation the following information can be retrieved out of SVNAdminEvent:

        Parameters:
        repositoryRoot - a repository root directory path
        dumpStream - an output stream to write dumped contents to
        startRevision - the first revision to start dumping from
        endRevision - the last revision to end dumping at
        isIncremental - if true then the first revision dumped will be a diff against the previous revision; otherwise the first revision is a fulltext.
        useDeltas - if true deltas will be written instead of fulltexts
        Throws:
        SVNException
        Since:
        1.1.1
      • doLoad

        public void doLoad​(java.io.File repositoryRoot,
                           java.io.InputStream dumpStream,
                           boolean usePreCommitHook,
                           boolean usePostCommitHook,
                           SVNUUIDAction uuidAction,
                           java.lang.String parentDir)
                    throws SVNException
        Reads the provided dump stream committing new revisions to a repository.

        On each revision loaded this method fires an SVNAdminEvent with action set to SVNAdminEventAction.REVISION_LOADED to the registered ISVNAdminEventHandler (if any). To register your ISVNAdminEventHandler pass it to setEventHandler(ISVNEventHandler). For this operation the following information can be retrieved out of SVNAdminEvent:

        Parameters:
        repositoryRoot - the root directory path of the repository where new revisions will be committed
        dumpStream - stream with dumped contents of a repository
        usePreCommitHook - if true then calls a pre-commit hook before committing
        usePostCommitHook - if true then calls a post-commit hook after committing
        uuidAction - one of the three possible ways to treat uuids
        parentDir - if not null then loads at this directory in the repository
        Throws:
        SVNException
        Since:
        1.1.1
      • doRecover

        public void doRecover​(java.io.File repositoryRoot)
                       throws SVNException
        Recovers the repository found under repositoryRoot. This method can recover only FSFS type repositories and is identical to the 'svnadmin recover' command.

        If the caller has provided an event handler, the handler will receive an SVNAdminEvent with the SVNAdminEventAction.RECOVERY_STARTED action before the recovery starts.

        Parameters:
        repositoryRoot - repository root location
        Throws:
        SVNException
        Since:
        1.2.0, SVN 1.5.0
      • doUpgrade

        public void doUpgrade​(java.io.File repositoryRoot)
                       throws SVNException
        Upgrades the repository located at repositoryRoot to the latest supported schema version. This method is identical to the 'svnadmin upgrade' command.

        This functionality is provided as a convenience for repository administrators who wish to make use of new Subversion functionality without having to undertake a potentially costly full repository dump and load operation. As such, the upgrade performs only the minimum amount of work needed to accomplish this while still maintaining the integrity of the repository. It does not guarantee the most optimized repository state as a dump and subsequent load would.

        If the caller has provided an event handler, the handler will receive an SVNAdminEvent with the SVNAdminEventAction.UPGRADE action before the upgrade starts.

        Parameters:
        repositoryRoot - repository root location
        Throws:
        SVNException
        Since:
        1.2.0, SVN 1.5.0
      • doSetUUID

        public void doSetUUID​(java.io.File repositoryRoot,
                              java.lang.String uuid)
                       throws SVNException
        Resets the repository UUID with the provided uuid for the repository located at repositoryRoot. This method is identical to the 'svnadmin setuuid' command.

        If no uuid is specified, then SVNKit will generate a new one and will use it to reset the original UUID.

        Parameters:
        repositoryRoot - repository root location
        uuid - new UUID to set
        Throws:
        SVNException - exception with SVNErrorCode.BAD_UUID error code - if the uuid is malformed
        Since:
        1.2.0, SVN 1.5.0
      • doHotCopy

        public void doHotCopy​(java.io.File srcRepositoryRoot,
                              java.io.File newRepositoryRoot)
                       throws SVNException
        Makes a hot copy of a repository located at srcRepositoryRoot to one located at newRepositoryRoot. This method is identical to the 'svnadmin hotcopy' command.
        Parameters:
        srcRepositoryRoot - repository to copy data from
        newRepositoryRoot - repository to copy data to
        Throws:
        SVNException
        Since:
        1.2.0, SVN 1.5.0
      • getYoungestRevision

        public long getYoungestRevision​(java.io.File repositoryRoot)
                                 throws SVNException
        Returns the HEAD revision of the repository located at repositoryRoot.

        Identical to the 'svnlook youngest' svn command.

        Parameters:
        repositoryRoot - repository root location
        Returns:
        the last revision
        Throws:
        SVNException
        Since:
        1.2.0
      • handlePropertesCopied

        protected void handlePropertesCopied​(boolean foundSyncProps,
                                             long revision)
                                      throws SVNException
        Throws:
        SVNException
      • handleNormalizedProperties

        protected void handleNormalizedProperties​(int normalizedRevPropsCount,
                                                  int normalizedNodePropsCount)
                                           throws SVNException
        Throws:
        SVNException
      • dump

        private void dump​(FSFS fsfs,
                          java.io.OutputStream dumpStream,
                          long start,
                          long end,
                          boolean isIncremental,
                          boolean useDeltas)
                   throws SVNException
        Throws:
        SVNException
      • writeRevisionRecord

        private void writeRevisionRecord​(java.io.OutputStream dumpStream,
                                         FSFS fsfs,
                                         long revision)
                                  throws SVNException
        Throws:
        SVNException
      • writeDumpData

        private void writeDumpData​(java.io.OutputStream out,
                                   java.lang.String data)
                            throws SVNException
        Throws:
        SVNException
      • createLoadHandler

        private DefaultLoadHandler createLoadHandler​(FSFS fsfs,
                                                     boolean usePreCommitHook,
                                                     boolean usePostCommitHook,
                                                     SVNUUIDAction uuidAction,
                                                     java.lang.String parentDir)
      • getDumpFilterHandler

        private DefaultDumpFilterHandler getDumpFilterHandler​(java.io.OutputStream os,
                                                              boolean exclude,
                                                              boolean renumberRevisions,
                                                              boolean dropEmptyRevisions,
                                                              boolean preserveRevisionProperties,
                                                              java.util.Collection prefixes,
                                                              boolean skipMissingMergeSources)
      • getDumpEditor

        private SVNDumpEditor getDumpEditor​(FSFS fsfs,
                                            FSRoot root,
                                            long toRevision,
                                            long oldestDumpedRevision,
                                            java.lang.String rootPath,
                                            java.io.OutputStream dumpStream,
                                            boolean useDeltas,
                                            boolean isVerify)
      • normalizeString

        public static java.lang.String normalizeString​(java.lang.String string)
                                                throws SVNException
        Throws:
        SVNException