During the release on Wednesday, June 13th, 2012, the JBoss Community team has released a new feature for the Magnolia CMS - the Directory Listing paragraph. While the front-end part of the feature is well described in the above linked chapter of the Paragraph Guide, I'd like to share few details about the back-end part.

A Bit Of History

JBoss Community uses the Magnolia CMS to run the www.jboss.org and www.hibernate.org sites. Magnolia CMS is an open source Java based CMS, that runs over the JCR API. By default, it uses the Apache Jackrabbit, but after the JBoss project ModeShape sprung up, we began to play with an idea of replacing the Apache's reference implementation of the JCR API with the JBoss' one. So some 2 years ago, I've started the initial works, that resulted first into a blogpost "How To Make Magnolia CMS Shaped", and later to an official - although "experimental" - support of ModeShape in Magnolia.

Anyway, ModeShape had struggled some performance issues on big repositories back then*, so we had to abandon the idea of completely replacing the Jackrabbit with the ModeShape, and decided to use Jackrabbit and ModeShape side-by-side. The primary objective was to attach the downloads.jboss.org filesystem to Magnolia and allow the visitors to browse it on the download pages of particular projects.

Initial Conditions

The JBoss Community team uses Magnolia CMS version 4.4.x (4.4.6 at the moment), deployed into the JBoss EAP as an EAR package. This package contains the Magnolia CMS web application and a bunch of web services that provide e.g. the project navigation for project forums, documents etc. in SBS (a.k.a. community.jboss.org).

The files stored at downloads.jboss.org are served by an Apache web server from a filesystem where the total amount of data is over 320GB.

Integrating Magnolia and ModeShape

As mentioned above, we abandoned the idea of replacing the Jackrabbit completely, and decided to use both Jackrabbit and ModeShape. The first idea of putting everything together to the Magnolia's WEB-INF/lib folder led to a dead-end. The problem was, and is, that Jackrabbit is a reference implementation, and is, well, quite conservative regarding the versions of libraries it uses. ModeShape, on the other hand, is rapidly developing bleeding-edge technology, that uses as new versions as possible. So we ended up in a conflict between the Jackrabbit's version of Lucene (2.4.x) and ModeShape's one (3.x).

Thus we had to use the ModeShape repository over JNDI, so I wrote the JNDIProviderImpl class for Magnolia, and implemented a simple web application to initialize the repository and share it via JNDI. This application uses modeshape-jbossas-service to publish the ModeShape JCR engine to JNDI, as we use the JBoss EAP to run Magnolia.

A little complication occured when the testing on staging server started, because the test data we copied from the production storage contained broken symlinks, and the repository couldn't start. So I learned an useful trick how to find broken symlinks on a linux filesystem, repaired the data, and created an issue in ModeShape's JIRA. 

There has been more glitches that have shifted the expected release date, some because of my own "dexterity", others relative to the Red Hat's internal building system (we have to deploy our applications in the form of an RPM package), but finally we have achieved the goal.

How It Works

So at the moment, there is a web application that initializes ModeShape repository with a filesystem source, and places it into JNDI. It is configured to be deployed as first on the EAP start. The the EAR with Magnolia is deployed, and it loads the repository from the JNDI (besides the standard Jackrabbit-powered repositories). The Directory Listing paragraph's model class uses this repository to serve information about the files and folders.

The filesystem repository source is configured read-only (mode:updatesAllowed="false"), and there is a mode:exclusionPattern attribute set to "^[\.].*" to exclude "hidden" files and folders (whose name starts with a dot), especially the .snapshot folders.

The Future Plans

The life brings change every day, so there are already few feature requests and ideas how to improve the Directory Listing paragraph and extend the utilization of the ModeShape repository. As for the paragraph, we'd like e.g. to add the possibility of setting the default sorting, as it now supports only the standard filesystem (i.e. alphabetical) sorting that causes the latest releases to be usually displayed at the bottom of the list. And for the ModeShape repository we plan to attach e.g. the static.jboss.org filesystem to it, so we can use it more comfortably (and also move some big binaries like videos etc. out of the Magnolia's DMS).

Credits

My big thanks for helping with that projects belongs especially to Jan Haderka from the Magnolia team, Randall Hauch from the ModeShape team, and Mark Newton and the whole JBoss Community team.

 


* It was the days of ModeShape 2.4.x, and ModeShape team did a big job improving the performance with every minor release. And the new ModeShape 3.0 promises to be a giant step in that field.