If you ever wanted to swap out Jackrabbit for another JSR-170 compliant content repository (like Xythos) in Sakai 2-6-x, here is how you do it.
Special thanks to Ian Boston, Seth Theriault, Kevin Wiggen and Julian Reschke.
It's worth noting that enabling JCR in Sakai does just that and nothing more - JCR can only be used by tools that are designed to use it (this is true no matter what repository you ultimately use). OOTB, nothing in Sakai 2.6 will use the JCR. In 2.5, experimental code was written to force Resources to use JCR instead of native Sakai conventions for storing content on the file system and the database. The instructions include information on how to enable this experimental code for 2.6, but be aware that this particular approach is largely abandoned in Sakai 3.
Also be advised that this is a work in progress - there are things that we'll probably do different if we put this code into production and I welcome all suggestions.
Assuming you've already got a Sakai 2-6-x branch install set up, and that you've build and run this sakai instance already, here's what you'll need to do.
Building xythosservice
Navigate to sakai src home.
svn co https://source.sakaiproject.org/contrib/tfd/trunk/xythosservice
You'll need to change these files:
pom.xml
deploylocalrepo/redeploy-m2.sh
xythos-impl/pom.xml
xythos-impl/pack/pom.xml
Basically, you just need to make the poms all agree on their parent version (which is 2.6.0RC1-SNAPSHOT in my case), swap out some dependencies which have now moved to kernel, and update the redeploy script, as we use a slightly different xythos version.
Next, you'll need to load the xythos jars (from the xythos system) into the sakai maven repository. The necessary jars are:
/bin/xythos-jcr.jar
/wfs-7.0.50/lib/jlansrv.jar
/wfs-7.0.50/lib/hibernate2.jar
/wfs-7.0.50/lib/xssoracle.jar
/wfs-7.0.50/lib/lucene-core-2.0.0.jar
/wfs-7.0.50/lib/xssmssql.jar
/wfs-7.0.50/lib/xssdb2.jar
/wfs-7.0.50/lib/xsscore.jar
/wfs-7.0.50/lib/xss.jar
/wfs-7.0.50/lib/WorkflowCommon-6.0.7.jar
You'll need to get these jars and the xythos.properties file from the xythos machine you want to connect to.
Create a dir for all the xythos jars and xythos.properties file somewhere on the sakai file system.
Next, cd /sakai-src/xythosservice/deploylocalrepo/
./redeploy-m2.sh [xythos jars dir] [xythos jars dir]
(yes, you need to pass the dir parameter twice.)
This will load up all the xythos jars into your maven repository.
cd sakai-src
vi pom.xml
add: <module>xythosservice</module>
Now, rebuild you sakai src:
mvn clean install sakai:deploy -Dmaven.tomcat.home=/usr/local/tomcat -Dmaven.test.skip=true
xythosservice should build as part of sakai.
Modifying kernel
Now, we'll need to make changes to the kernel. In normal sakai installations, kernel is never part of your Sakai src. It gets pulled down as a dependency during build time as a zip, and stashed away in the maven repo. Then, during deploy time, the zip is exploded into the tomcat dir.
Kernel is a separate project, so it shouldn't be checked out in your sakai-src dir. It gets it's own src dir (which I will call kernel-src).
svn co https://source.sakaiproject.org/svn/kernel/tags/kernel-1.0.2 kernel
(As of this writing, kernel-1.0.3 has just been tagged. Really depends on what 2-6-x is using.)
You will need to modify the following files:
pom.xml
kernel-component/src/main/webapp/WEB-INF/components.xml
kernel-impl-experimental/content/migration/sakai-content-jcr-migration-impl/pom.xml
kernel-impl-experimental/content/migration/sakai-contentmulti-impl/pom.xml
kernel-impl-experimental/content/migration/pom.xml
kernel-impl-experimental/content/pom.xml
kernel-impl-experimental/content/jcr/pom.xml
kernel-impl-experimental/content/jcr/sakai-content-jcr-impl/pom.xml
kernel-impl-experimental/pom.xml
In components.xml:
replace <import resource="jackrabbit-components.xml" /> with <import resource="xythos-components.xml" />
replace <import resource="preloadcontent.xml" /> with <import resource="xythos-preloadcontent.xml" />
uncomment <import resource="content-jcr-components.xml" />
comment <import resource="content-components.xml" />
And you will need to add the following files:
cp sakai-src/xythosservice/xythos-impl/pack/src/webapp/WEB-INF/components.xml kernel-src/kernel-component/src/main/webapp/WEB-INF/xythos-components.xml
cp sakai-src/xythosservice/xythos-impl/pack/src/webapp/WEB-INF/preloadcontent.xml kernel-src/kernel-component/src/main/webapp/WEB-INF/xythos-preloadcontent.xml
vi kernel-src/kernel-component/src/main/webapp/WEB-INF/xythos-components.xml and change this line to include the 'xythos' part: <import resource="xythos-preloadcontent.xml" />
(jar files will still need to be added to lib afterwards)
If you look at the output from the maven build, you should see where it is stashing your overlay zip. Mine goes in: ~/.m2/repository/org/sakaiproject/kernel/deploy/kernel-assembly/1.0.2/kernel-assembly-1.0.2-tomcat-overlay.zip
rm that sucker so that you can build your new one.
cd to kernel-src and build it
Obviously, this won't include the xythosservice jar and for some reason (which I have to look into), the experimental jars aren't included either. So we will copy them in.
cd /usr/local/tomcat/components/sakai-kernel-component/WEB-INF/lib
cp sakai-src/xythosservice/xythos-impl/impl/target/sakai-xythos-impl-SNAPSHOT.jar
cp kernel-src/kernel-impl-experimental/content/jcr/sakai-content-jcr-impl/target/sakai-content-jcr-impl-1.0RC2-SNAPSHOT.jar .
cp kernel-src/kernel-impl-experimental/content/migration/sakai-content-jcr-migration-api/target/sakai-content-jcr-migration-api-1.0RC2-SNAPSHOT.jar .
cp kernel-src/kernel-impl-experimental/content/migration/sakai-content-jcr-migration-impl/target/sakai-content-jcr-migration-impl-1.0RC2-SNAPSHOT.jar .
cp kernel-src/kernel-impl-experimental/content/migration/sakai-contentmulti-impl/target/sakai-contentmulti-impl-1.0RC2-SNAPSHOT.jar .
Finally, add this to your sakai.properties:
jcr.experimental=true
defaultService@org.sakaiproject.content.api.ContentHostingService=jcr
xythosHome@org.sakaiproject.jcr.api.JCRService.repositoryBuilder=/usr/local/xythos_jars/
What you get
Files uploaded in Sakai will now be deposited in Xythos.
Also, files uploaded to the right place in Xythos will show up in Sakai.
You also now have a JCR (backed by Xythos) that you can develop Sakai tools for.
What you don't get
Pretty folders - on the Xythos side, files are stashed in a folder structure that uses Sakai's site ids, blah!
Mapping of xythos home folders to Sakai My Workspace/Dashboard Resources.
Shared metadata, as far as I can tell
Know errors
Even though this solution "works," you still get this error periodically logged:
2009-02-27 14:19:46,728 ERROR main org.sakaiproject.content.impl.BaseJCRResourceEdit - Content is being stored in memory, this is bad! ... but we will do it anyway, memory used = 12616 2009-02-27 14:19:48,012 WARN main org.sakaiproject.content.impl.BaseContentService - Edit Object not closed correctly, Cancelling /group/PortfolioAdmin/system/ 2009-02-27 14:19:48,047 ERROR main org.sakaiproject.thread_local.impl.ThreadLocalComponent - Failed to unbind Object org.sakaiproject.content.impl.BaseJCRCollectionEdit@166de66 java.lang.NullPointerException
I still have to figure out where this error is being generated so I can see if it's really as terrifying as it sounds.