| By Harry Klein | Article Rating: |
|
| July 19, 2006 07:15 PM EDT | Reads: |
34,607 |
Using JavaSVN
The JavaSVN Open Source library is
used in several projects for interaction with Subversion. Projects that
use JavaSVN include Subclipse, SmartSVN, and Atlassian JIRA. JavaSVN is
a pure Java Subversion client library.
In the following example I use JavaSVN to access the Subversion repository from a ColdFusion application. It achieves a very simple task: It reads the latest revision from a file in the repository called "test.htm."
The JavaSVN library must be accessible to ColdFusion so I copied javasvn.jar to the Directory "C:\CFusionMX7\wwwroot\WEB-INF\lib\."
Example: getLatestRevision
First we have to initialize the library:
<!--- initialize the library to work with a repository for DAV (over http and https) --->
<cfset CreateObject
("java", "org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory").setup()>
The configuration part is easy; we define the URL to the repository, the user credentials, and the file path:
<!--- configuration --->
<cfset sRepUrl = "http://rocket/svn/projects/trunk">
<cfset sUser = "">
<cfset sPasswd = "">
<cfset sFilePath = "test.htm">
<cfset oSVNURL = CreateObject("java", "org.tmatesoft.svn.core.SVNURL").parseURIEncoded(sRepUrl)>
Next we create a repository driver object and authenticate the user:
<!--- create an SVNRepository driver object --->
<cfset oSVNRepository = CreateObject("java",
"org.tmatesoft.svn.core.io.SVNRepositoryFactory").create(oSVNURL.parseURIEncoded(sRepUrl))>
<cfset oAuthManager = CreateObject("java",
"org.tmatesoft.svn.core.wc.SVNWCUtil").createDefaultAuthenticationManager(sUser, sPasswd)>
<cfset oSVNRepository.setAuthenticationManager(oAuthManager)>
Finally we get the file using the method getFile() and dump the latest revision number for this file:
<cfset oSvnFileprops = CreateObject("java", "java.util.HashMap")>
<cfset oBaos = CreateObject("java", "java.io.ByteArrayOutputStream")>
<cfset oSVNRepository.getFile(sFilePath, JavaCast('long', -1), oSvnFileprops, oBaos)>
<cfset latestRevision = oSVNRepository.getLatestRevision()>
<cfdump var="#latestRevision#">
Please consult the JavaSVN documentation, it contains several other excellent Java samples.
Conclusion
The switch from CVS to Subversion was
quite easy because of the excellent tools and documentation available.
I hope that this article contains some useful information for
developers wanting to switch from CVS or some other version control
system to Subversion. Maybe it will help to convince your boss that
Subversion is the right choice for your team.
Resources
- Subversion Project http://subversion.tigris.org/
- Subclipse Plug-in http://subclipse.tigris.org/
- Tortoise Client http://tortoisesvn.tigris.org/
- SVNImport, Subversive Plug-in www.polarion.org and http://polarion.org/projects.php
- Mere-Moments Guide to installing a Subversion server on Windows http://excastle.com/blog/archive/2005/05/31/ 1048.aspx1ClickInstallerhttp://svn1clicksetup.tigris.org/
- Version Control with Subversion http://svnbook.red-bean.com/
- Pragmatic Version Control Using Subversion (Mike Mason)
Published July 19, 2006 Reads 34,607
Copyright © 2006 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Harry Klein
Harry Klein is cofounder and CTO at CONTENS Software GmbH, a leading supplier of enterprise content management software. He is a Certified Advanced ColdFusion developer and Microsoft MSCE.
![]() |
Mark Bickford 07/20/06 09:00:52 AM EDT | |||
In the section on IDE integration, I would have been interested in knowing about any experiences with integrating Subversion with the Source Control functionality in CF Studio (IIRC, Homesite didn't do Source Control directly.) |
||||
![]() |
CFDJ News Desk 07/19/06 07:32:56 PM EDT | |||
This article describes the differences between CVS and Subversion and explains how to install Subversion and migrate an existing CVS repository. It also describes how to configure Subversion in a Windows environment, explains a basic Subversion project structure, and introduces the main Subversion clients. Finally, it shows ways to use Subversion with Ant and how to get connected to the repository via JavaSVN and ColdFusion. |
||||
![]() |
CFDJ News Desk 06/07/06 05:08:37 PM EDT | |||
This article describes the differences between CVS and Subversion and explains how to install Subversion and migrate an existing CVS repository. It also describes how to configure Subversion in a Windows environment, explains a basic Subversion project structure, and introduces the main Subversion clients. Finally, it shows ways to use Subversion with Ant and how to get connected to the repository via JavaSVN and ColdFusion. |
||||
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- Adobe May Cooperate with Apple to Transplant Flash Player to iPhone
- Adobe Flex Developer Earns $100K in New York City
- Adobe LiveCycle Enterprise Suite 2 for Cloud Computing
- Adobe Betas Target RIAs and Cloud Computing
- Adobe Cans Another 9% of its Workforce
- Moyea DVD4Web Converter V2.0 Converts DVD to FLV Fast and Synchronously with Watermarks
- Adobe Fiddles with its Web Apps
- Adobe & Salesforce Cut Cloud Deal
- Hosting.com Launches ColdFusion 9 in the Cloud
- The Real Time Infrastructure Ultimatum
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Eval JavaScript in a Global Context
- Fig Leaf Software to Exhibit at Government IT Conference & Expo
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- Is Microsoft as Free as Open Source?
- Adobe Reader Sued
- The Planet Named “Bronze Sponsor” of Cloud Computing Expo
- Microsoft Expression Web Has Got Game
- Adobe Flex Developer Earns $100K in New York City
- Adobe May Cooperate with Apple to Transplant Flash Player to iPhone
- Bruce Chizen Joins Voyager Capital as Venture Partner
- My Top Seven Wishes From Adobe MAX 2009
- The Next Programming Models, RIAs and Composite Applications
- Where Are RIA Technologies Headed in 2008?
- Constructing an Application with Flash Forms from the Ground Up
- AJAX World RIA Conference & Expo Kicks Off in New York City
- CFEclipse: The Developer's IDE, Eclipse For ColdFusion
- Personal Branding Checklist
- Adobe Flex 2: Advanced DataGrid
- Has the Technology Bounceback Begun?
- Building a Zip Code Proximity Search with ColdFusion
- i-Technology Viewpoint: We Need Not More Frameworks, But Better Programmers
- The Asynchronous CFML Gateway
- Web Services Using ColdFusion and Apache CXF






























