JBoss.orgCommunity Documentation

Chapter 16. Subversion Connector

This connector provides read and write access to the directories and folders within a Subversion repository, providing that content in the form of nt:file and nt:folder nodes. This source considers a workspace name to be the path to the directory on the repository's root directory location that represents the root of that workspace (e.g., "trunk" or "branches"). New workspaces can be created, as long as the names represent valid existing directories within the SVN repository.

The SVNRepositorySource class provides a number of JavaBean properties that control its behavior:

Table 16.1. SVNRepositorySource properties

PropertyDescription
cachePolicyOptional property that, if used, defines the cache policy to use for caching information in the repository. When not used, this source will not define a specific duration for caching information.
creatingWorkspaceAllowedOptional property that defines whether clients can create additional workspaces. The default value is "true".
defaultWorkspaceNameOptional property that, if used, specifies the name of the workspace to use when no workspace name is specified in an operation. Each workspace name is treated as a path relative to the SVN repository being exposed (e.g., a workspace name of "trunk" will map to the URL "http://acme.com/repo/trunk" if the repository root URL is "http://acme.com/repo/").
nameThe name of the repository source, which is used by the RepositoryService when obtaining a RepositoryConnection by name.
password The password that should be used to establish a connection to the repository. This is not required if the URL represents an anonymous SVN repository address.
predefinedWorkspaceNamesOptional property that, if used, defines names of the workspaces that are predefined and need not be created before being used. Each workspace name is treated as a path relative to the SVN repository being exposed (e.g., a workspace name of "trunk" will map to the URL "http://acme.com/repo/trunk" if the repository root URL is "http://acme.com/repo/"). This can be coupled with a "false" value for the "creatingWorkspaceAllowed" property to allow only the use of predefined workspaces.
repositoryRootURL Required property that should be set with the URL to the Subversion repository.
retryLimitOptional property that, if used, defines the number of times that any single operation on a RepositoryConnection to this source should be retried following a communication failure. The default value is '0'.
username The username that should be used to establish a connection to the repository.

One way to configure the Subversion connector is to create JcrConfiguration instance with a repository source that uses the SVNRepositorySource class. For example:



JcrConfiguration config = ...
config.repositorySource("SVN Store")
      .usingClass(SVNRepositorySource.class)
      .setDescription("The ModeShape SVN repository (anonymous access)")
      .setProperty("repositoryRootUrl", "http://anonsvn.jboss.org/repos/modeshape");
      .setProperty("defaultWorkspaceName", "trunk");
      .setProperty("predefinedWorkspaceNames", new String[] {"trunk });
 

Another way to configure the Subversion connector is to create JcrConfiguration instance and load an XML configuration file that contains a repository source that uses the SVNRepositorySource class. For example a file named configRepository.xml can be created with these contents:



<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns:mode="http://www.modeshape.org/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0">
    <!-- 
    Define the sources for the content.  These sources are directly accessible using the 
    ModeShape-specific Graph API.  In fact, this is how the ModeShape JCR implementation works.  You 
    can think of these as being similar to JDBC DataSource objects, except that they expose 
    graph content via the Graph API instead of records via SQL or JDBC. 
    -->
    <mode:sources jcr:primaryType="nt:unstructured">
        <!-- 
        The 'SVN Store' repository is an Subversion source with one workspace (although others could 
        be defined).
        -->
        <mode:source jcr:name="SVN Store" 
                    mode:classname="org.modeshape.graph.connector.svn.SVNRepositorySource" 
                    mode:description="The ModeShape SVN repository (anonymous access)"
                    mode:repositoryRootUrl="http://anonsvn.jboss.org/repos/modeshape"
                    mode:defaultWorkspaceName="trunk"
                    mode:predefinedWorkspaceNames="trunk"
                    mode:defaultWorkspaceName="default"/>    
    </mode:sources>
    
    <!-- MIME type detectors and JCR repositories would be defined below --> 
</configuration>
 

The configuration can then be loaded from Java like this:



JcrConfiguration config = new JcrConfiguration().loadFrom("/configRepository.xml");