Some people requested a SubversionProvider. So there it is :-)

It is based on AbstractFileProvider and simply uses the page directory as a Subversion workspace. For page reads is fetches the latest version from the repository and for page writes it commits the page to the repository.

There is also an attachment provider. It simply keeps all attachments in a directory named after the parent page.

This is an update of the version posted earlier. It uses the latest SVNKit library (currently 1.1.0 standalone) and also comes with some performance improvements.

Installation is simple:

  1. Download the SVNKit library from TMate Software.
  2. Download subversionprovider_latest.jar from the attachments (includes source code).
  3. Put svnkit.jar, ganymed.jar and subversionprovider_latest.jar into your classpath (e.g. by copying them into /WEB-INF/lib)
  4. Add the following lines to your jspwiki.properties:
  # Tell jspwiki to use SubversionProvider for pages.
  jspwiki.pageProvider = de.treichels.jspwiki.providers.SubversionPageProvider

  # Tell jspwiki to use SubversionProvider for attachments.
  jspwiki.attachmentProvider = de.treichels.jspwiki.providers.SubversionAttachmentProvider

  # Location of the subversion repository
  # Note: SVNKit supports http, https, svn, svn+ssh, file (only FSFS repositories)
  # protocols
  jspwiki.subversionProvider.repoPath = file:///path/to/svn/JSPWiki/pages/

  # Location of the subversion workarea.
  # All files form the repoPath will be checked out into this directory
  jspwiki.fileSystemProvider.pageDir = C:\\Temp\\svnwork\\Test

  # Username and password for the repository. Default is anonymous access
  jspwiki.subversionProvider.username = admin
  jspwiki.subversionProvider.password = secret

  # Tell SubversionProvier how often to update pages and attachments from the repository. Default is 60 seconds.
  # There is a trade-off between data consistency and speed (everything comes with a price :-)).
  #
  # With a large interval performance will be better, but you may get a conflict if someone else changed the page in
  # subversion in the meantime.
  #
  # With a small interval conflicts will be less likely, but performance will be worse.
  #
  # SubversionProvider will check the subversion repository for every page access if the interval is 0. With this setting
  # you will never get conflicts, but it is also the slowest setting.
  #
  # If you are sure that the subversion respository is ONLY updated by JSPWiki you can switch off update checking
  # by setting the updateInterval to -1. This is the fastest setting but nobody should ever touch the wiki pages in
  # the repository.
  jspwiki.subversionProvider.updateInterval = 60

Have fun! Oliver

Oliver, I modified your description as it has got a bit out of date. Alexander Sinyushkin


I added a modified Version of the SubversionProvider that works with 2.4.4 of JSPWiki. The code is not tested very well. I simply extended it to be compatible with the new Interfaces (WikiEngine parameter in calls) and implemented the move methods.

Anyway, use at own risk...

--Stefan Craatz, 16-May-2006


I want to use Subversion provider with JSPWiki 2.4.53. With the subversionprovider for 2.4.4 I have the next error message: svn: Malformed network data detected in: de.treichels.jspwiki.providers.SubversionPageProvider.putPageText(), line 218 The provider for previous versions doesn't work.

I'm using svn protocol in a windows XP machine. I don't know if error is in the provider and I need to wait a stable one for this jspwiki version.

Can't you help my to know what's the matter?

--Migue, 23-Sep-2006


Oliver, Nice work on this provider, I'm using it quite a bit at work now for our documentation wiki. I have installed Stefan's update to get it running under 2.4.71 and noticed one issue so far - when showing a list of revisions for a page, it always stops at the first revision. I tracked it down to this line in the SubversionPageProvider.java:

clientManager.getLogClient().doLog(new File[] { file }, SVNRevision.create(0), SVNRevision.HEAD, false, false, Long.MAX_VALUE,
...

It seems that the HEAD parameter seems to be interpreted in a different way to what I expect. Changing it to UNDEFINED causes all revisions to be returned.

Also, using revision 0 as the start will cause an error in the new JavaSVN 1.1.0beta5 release. It complains if the file was not present in revision 0. The way to resolve this was to also use the UNDEFINED revision.

Finally, setting the limit to 0 apparently is a better way of not imposing a limit, rather than using Long.MAX_VALUE. It's not documented but I came across it in the mailing lists.

Here is what I use (and also in SUbversionAttachmentProvider.java):

clientManager.getLogClient().doLog(new File[] { file }, SVNRevision.UNDEFINED, SVNRevision.UNDEFINED, false, false, 0,
...

--DavidChandler, 11-Nov-2006


I encountered errors with the modification date when using the weblog plugin to display entries stored in Subversion. I tracked it down to the following line of code in AbstractSubversionProvider.java:

clientManager.getLogClient().doLog(new File[] { file }, rev, rev, false, false, 1, new SVNLogEntryHandler() {
...

The rev object is created for version "1", as for blog entries jspwiki attempts to display the create date as the modification date (for ordering / sorting, I suppose...). As both startRevision and endRevision parameters are set to version 1, the page modification date will not be found (as it is unlikely that the blog entry existed in revision 1). Anyway to correct the problem, modify the endRevision parameter as in the following code:

clientManager.getLogClient().doLog(new File[] { file }, rev, SVNRevision.HEAD, false, false, 1, new SVNLogEntryHandler() {
...

Using HEAD as the endRevision will allow the log client to find the earliest valid revision so that the modification date can be correctly displayed.

-pvs, 12.27.2006


We added some contributions to SubversionProvider. Now it's possible to keep wiki data in sync with a Subversion repository through the svn+ssh:// scheme using special keys in your jspwiki.properties file:

  # Location of the subversion repository
  # Note: SVNKit supports http, https, svn, svn+ssh, file (only FSFS repositories)
  # protocols
  jspwiki.subversionProvider.repoPath =  svn+ssh://host/path/to/svn/repos

  # ssh server login
  # if an ssh tunnel is successfully established, a Subversion repository  
  # located on this server is accessed just like on a local machine
  jspwiki.subversionProvider.sshUser = username
  
  # path to the private key 
  # this file is kept on the same server that JSPWiki runs on 
  jspwiki.subversionProvider.sshKey = /path/to/ssh_private_key

  # passphrase to the private key
  # optional
  jspwiki.subversionProvider.sshKey.passphrase = password

  # port to connect to
  # if not set, port 22 is used
  jspwiki.subversionProvider.sshPort = 22

Also your change notes will be used as commit log messages. Commit author names are names of page modifiers. This feature is available in subversionprovider_latest.jar. Installation notes remain the same as listed above.

02.07.2007

Alexander Sinyushkin


de.treichels.jspwiki.providers.AbstractSubversionProvider  - Can't conntect to Subversion repository!
org.tmatesoft.svn.core.SVNException: svn: PROPFIND of '/svn/elisa/jspwiki': 405 Method Not Allowed (http://elisa)
        at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:43)
I have just spent quite some time finding the reason for this error.

I had moved the subversion repository to another machine and had changed jspwiki.subversionProvider.repoPath

but it seems this is not enough, somehow the path is stored in jspwiki.fileSystemProvider.pageDir, too.

After I had deleted everything from jspwiki.fileSystemProvider.pageDir, jspwiki worked again and the error message went away.

http://www.nabble.com/forum/ViewPost.jtp?post=1408966&framed=y

--Jürgen Weber, 14-Feb-2007


Has anybody gotten SubversionProvider to work with JSPWiki v.2.4.91? I keep getting errors:

 Unable to load and setup properties from jspwiki.properties. Failed to start managers: null
--Jeff Dahl, 16-Feb-2007

Am I right that the page history doesn't show the repository logmessages?

Using subversionprovider_latest.jar with above patches from pvs and David applied (on JSPWiki 2.4.87 and svn 1.4.2)

Thanks

FrankF, 04-Apr-2007


Is this possible --> Idea Subversion Provider Should Go Into Core?

--Dran Dane, 06-May-2007


Hi,

I have a Use Case where I want to use JSPWiki to use Subversion as the data store. But, the important part of requirement is that the location of the SVN repository is not pre-defined and needs to be configured dynamically.

If there a way that I can set these properties through Wiki context (at runtime) and still use the Subversion connector?

Cheers k.

--Kapil Viren Ahuja, 22-Aug-2007


Uploaded version 3 of subversionprovider_latest.jar

Merged changes made by -DavidChandler, 11-Nov-2006 and -pvs, 12.27.2006 in subversionprovider_latest.jar

Fixed missing author information for first version 'This page was created on 25-Feb-2008 11:50 by unknown

--Fai, 26-02-2008


Uploaded version 4 of subversionprovider_latest.jar

SubversionProvider#getPageText(final String page, final int version) doesn't throw a ProviderException anymore when a certain (revi)/(ver)sion cannot be found.

It returns null as specified in the WikiPageProvider#getPageText(String, int)

--Fai, 29-02-2008

Add new attachment

In order to upload a new attachment to this page, please use the following box to find the file, then click on “Upload”.

List of attachments

Kind Attachment Name Size Version Date Modified Author Change note
jar
subversionprovider.jar 27.2 kB 2 02-Oct-2005 20:06 OliverTreichel
jar
subversionproviderFor2_4_4.jar 29.4 kB 1 16-May-2006 08:47 212.202.227.220
jar
subversionprovider_latest.jar 33.0 kB 4 29-Feb-2008 16:32 145.221.24.6
jar
subversionprovider_with_svnkit... 27.2 kB 1 18-Jan-2007 18:00 alexander
« This page (revision-37) was last changed on 29-Feb-2008 16:38 by 145.221.24.6 [RSS]