[jboss-svn-commits] JBoss Portal SVN: r5387 - in branches/JBoss_Portal_Branch_2_4: . build cms cms/src/main/org/jboss/portal/cms/hibernate/state cms/src/main/org/jboss/portal/cms/impl/jcr cms/src/main/org/jboss/portal/cms/impl/jcr/command cms/src/main/org/jboss/portal/test/cms cms/src/main/org/jboss/portal/test/cms/clustering cms/src/main/org/jboss/portal/test/cms/commands cms/src/resources/hibernate cms/src/resources/test cms/src/resources/test/cms cms/src/resources/test/cms/clustering cms/src/resources/test/cms/clustering/sar cms/src/resources/test/cms/clustering/sar/META-INF cms/src/resources/test/cms/clustering/sar/conf cms/src/resources/test/cms/clustering/sar/conf/hibernate cms/src/resources/test/cms/clustering/sar/conf/hibernate/cms cms/src/resources/test/cms/clustering/test-cms-clustering-war cms/src/resources/test/cms/clustering/test-cms-clustering-war/WEB-INF cms/src/resources/test/jcr core core/src/resources/portal-cms-sar/META-INF core/src/resources/portal-cms-sar/conf/hib! ernate/cms portlet test tools/etc/buildfragments

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Oct 10 02:13:45 EDT 2006


Author: sohil.shah at jboss.com
Date: 2006-10-10 02:13:26 -0400 (Tue, 10 Oct 2006)
New Revision: 5387

Added:
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/Base.java
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/JBossCachePersistenceManager.java
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/PortalCMSCacheLoader.java
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/Tools.java
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/impl/jcr/command/FileUpdateAndVersionCommand.java
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/clustering/
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/clustering/CMSTestSuite.java
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/clustering/FileModSequenceBuilder.java
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/AbstractCommandTestCase.java
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileArchiveUpload.java
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileCopy.java
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileCreate.java
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileCreateFailed.java
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileDelete.java
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileGet.java
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileGetList.java
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileGetVersion.java
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileUpdate.java
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFolderCopy.java
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFolderCreate.java
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFolderDelete.java
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFolderGet.java
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFolderUpdate.java
   branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/
   branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/
   branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/sar/
   branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/sar/META-INF/
   branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/sar/META-INF/jboss-service.xml
   branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/sar/conf/
   branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/sar/conf/hibernate/
   branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/sar/conf/hibernate/cms/
   branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/sar/conf/hibernate/cms/domain.hbm.xml
   branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/sar/conf/hibernate/cms/hibernate.cfg.xml
   branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/test-cms-clustering-war/
   branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/test-cms-clustering-war/WEB-INF/
   branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/test-cms-clustering-war/WEB-INF/jboss-portlet.xml
   branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/test-cms-clustering-war/WEB-INF/portlet.xml
   branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/test-cms-clustering-war/WEB-INF/web.xml
   branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/log4j.xml
   branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/pm-cache.xml
Removed:
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileCommands.java
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFolderCommands.java
Modified:
   branches/JBoss_Portal_Branch_2_4/
   branches/JBoss_Portal_Branch_2_4/build/build-thirdparty.xml
   branches/JBoss_Portal_Branch_2_4/cms/
   branches/JBoss_Portal_Branch_2_4/cms/build.xml
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/HibernatePersistenceManager.java
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/VersionNode.java
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/VersionProp.java
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/VersionRefs.java
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/WSPNode.java
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/WSPProp.java
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/WSPRefs.java
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ContentGetVersionsCommand.java
   branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/AbstractCMSTestCase.java
   branches/JBoss_Portal_Branch_2_4/cms/src/resources/hibernate/domain.hbm.xml
   branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/jcr/repository.xml
   branches/JBoss_Portal_Branch_2_4/core/build.xml
   branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-cms-sar/META-INF/jboss-service.xml
   branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-cms-sar/conf/hibernate/cms/domain.hbm.xml
   branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-cms-sar/conf/hibernate/cms/hibernate.cfg.xml
   branches/JBoss_Portal_Branch_2_4/portlet/
   branches/JBoss_Portal_Branch_2_4/portlet/build.xml
   branches/JBoss_Portal_Branch_2_4/test/
   branches/JBoss_Portal_Branch_2_4/tools/etc/buildfragments/modules.ent
Log:
cms clustering backport from trunk


Property changes on: branches/JBoss_Portal_Branch_2_4
___________________________________________________________________
Name: svn:ignore
   + *.classpath
*.project
eclipseBin
thirdparty


Modified: branches/JBoss_Portal_Branch_2_4/build/build-thirdparty.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/build/build-thirdparty.xml	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/build/build-thirdparty.xml	2006-10-10 06:13:26 UTC (rev 5387)
@@ -82,7 +82,7 @@
       <componentref name="jbossas/core-libs" version="4.0.4.GA"/>
       <componentref name="jboss/aop" version="1.5.0.GA"/>     
       <componentref name="jboss/backport-concurrent" version="2.1.0.GA"/>
-      <componentref name="jboss/cache" version="1.3.0.SP2"/>
+      <componentref name="jboss/cache" version="1.4.0.SP1"/>
       <componentref name="jboss/jbossretro-rt" version="1.0.0.GA"/>
       <componentref name="jboss/jbossws14" version="1.0.0.GA"/>
       <componentref name="jboss/jbossxb" version="1.0.0.CR4"/>


Property changes on: branches/JBoss_Portal_Branch_2_4/cms
___________________________________________________________________
Name: svn:ignore
   - output
bin
bin

   + output
bin
bin
*.log


Modified: branches/JBoss_Portal_Branch_2_4/cms/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/build.xml	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/build.xml	2006-10-10 06:13:26 UTC (rev 5387)
@@ -1,12 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE project [
-      <!ENTITY libraries  SYSTEM "../thirdparty/libraries.ent">
-      <!ENTITY buildmagic SYSTEM "../tools/etc/buildfragments/buildmagic.ent">
-      <!ENTITY tools      SYSTEM "../tools/etc/buildfragments/tools.ent">
-      <!ENTITY modules    SYSTEM "../tools/etc/buildfragments/modules.ent">
-      <!ENTITY defaults   SYSTEM "../tools/etc/buildfragments/defaults.ent">
-      <!ENTITY targets    SYSTEM "../tools/etc/buildfragments/targets.ent">
-      ]>
+   <!ENTITY libraries  SYSTEM "../thirdparty/libraries.ent">
+   <!ENTITY buildmagic SYSTEM "../tools/etc/buildfragments/buildmagic.ent">
+   <!ENTITY tools      SYSTEM "../tools/etc/buildfragments/tools.ent">  
+   <!ENTITY modules    SYSTEM "../tools/etc/buildfragments/modules.ent">
+   <!ENTITY defaults   SYSTEM "../tools/etc/buildfragments/defaults.ent">
+   <!ENTITY targets    SYSTEM "../tools/etc/buildfragments/targets.ent">
+   ]>
 
 <!-- $Id$ -->
 
@@ -65,28 +65,32 @@
       <!-- Configure thirdparty libraries -->
       &libraries;
       <path id="library.classpath">
-         <path refid="apache.logging.classpath"/>
+      	 <path refid="apache.logging.classpath"/>
+	     <path refid="apache.xerces.classpath"/>
+	     <path refid="apache.log4j.classpath"/>
+	     <path refid="apache.collections.classpath"/>
+	     <path refid="apache.lucene.classpath"/>
          <path refid="jboss.jbossxb.classpath"/>
-         <path refid="jboss.cache.classpath"/>
-         <path refid="apache.xerces.classpath"/>
+         <path refid="jboss.cache.classpath"/>         
          <path refid="oswego.concurrent.classpath"/>
          <path refid="jboss.microcontainer.classpath"/>
          <path refid="hibernate.hibernate.classpath"/>
          <path refid="ehcache.ehcache.classpath"/>
-         <path refid="jbossas/core.libs.classpath"/>
-         <path refid="apache.log4j.classpath"/>
-         <path refid="jakarta.io.classpath"/>
-         <path refid="apache.collections.classpath"/>
-         <path refid="apache.lucene.classpath"/>
+         <path refid="jbossas/core.libs.classpath"/>         
+         <path refid="jakarta.io.classpath"/>         
          <path refid="junit.junit.classpath"/>
          <path refid="jackrabbit.jackrabbit.classpath"/>
          <path refid="slf4j.slf4j.classpath"/>
          <path refid="sun.jaf.classpath"/>
          <path refid="xdoclet.xdoclet.classpath"/>
          <path refid="jcr.jcr.classpath"/>
+	     <!-- cms optimization integration -->
+	     <path refid="jgroups.jgroups.classpath"/>
+		 <path refid="sun.servlet.classpath"/>
       </path>
+      
+      
 
-
       <path id="javac.classpath">
          <pathelement location="${build.classes}"/>
       </path>
@@ -97,9 +101,12 @@
       <call target="configure-modules"/>
       <path id="dependentmodule.classpath">
          <path refid="jboss.portal-server.classpath"/>
-         <path refid="jboss.portal-common.classpath"/>
+         <path refid="jboss.portal-common.classpath"/>		 
          <path refid="jboss.portal-jems.classpath"/>
-         <path refid="jboss.portal-test.classpath"/>
+         <path refid="jboss.portal-test.classpath"/>	
+	     <!-- clustered testcases related -->
+	     <path refid="jboss.portal-portlet.classpath"/>
+		 <path refid="jboss.portlet-api.classpath"/>
       </path>
 
 
@@ -160,22 +167,94 @@
          <fileset dir="${jcr.jcr.root}/lib" includes="jcr-1.0.jar"/>
          <fileset dir="${apache.collections.root}/lib" includes="commons-collections.jar"/>
          <fileset dir="${apache.lucene.root}/lib" includes="lucene.jar"/>
-         <fileset dir="${jackrabbit.jackrabbit.lib}" includes="jackrabbit-core-1.0.jar"/>
-         <fileset dir="${slf4j.slf4j.lib}" includes="slf4j-log4j12.jar"/>
+	
+	  	<!-- cms optimization integration -->
+	    <fileset dir="${jackrabbit.jackrabbit.lib}" includes="jackrabbit-core-1.0.jar"/>	    
+	  	<fileset dir="${jboss.cache.lib}" includes="jboss-cache.jar"/>
+	  	<fileset dir="${jgroups.jgroups.lib}" includes="jgroups.jar"/>		 
+	     
+	
+         <fileset dir="${slf4j.slf4j.lib}" includes="slf4j-log4j12.jar"/>   
       </jar>
-
+		
       <copy todir="${build.resources}/test/jcr/">
          <fileset dir="${source.bin}" includes="ziptest.zip"/>
          <fileset dir="${source.bin}" includes="headerpage.html"/>
          <fileset dir="${source.bin}" includes="headerpage_good.html"/>
       </copy>
    </target>
+	
+	<!-- 
+				generates artifacts used for tests, requires output to be previously run
+	-->
+	<target name="package-tests" depends="init,output">		 
+	
+		 <jar jarfile="${build.lib}/test-cms-cluster.sar" manifest="${build.etc}/portal-cms-lib-sar.mf">
+		         <fileset dir="${build.resources}/portal-cms-sar"/>
+		         <fileset dir="${build.lib}" includes="portal-cms-lib.jar"/>
+		         <fileset dir="${jcr.jcr.root}/lib" includes="jcr-1.0.jar"/>
+		         <fileset dir="${apache.collections.root}/lib" includes="commons-collections.jar"/>
+		         <fileset dir="${apache.lucene.root}/lib" includes="lucene.jar"/>
+			
+				<!-- cms optimization integration -->
+		    	<fileset dir="${jackrabbit.jackrabbit.lib}" includes="jackrabbit-core-1.0.jar"/>	    
+		  		<fileset dir="${jboss.cache.lib}" includes="jboss-cache.jar"/>
+		  		<fileset dir="${jgroups.jgroups.lib}" includes="jgroups.jar"/>		 
+			     
+			
+		        <fileset dir="${slf4j.slf4j.lib}" includes="slf4j-log4j12.jar"/>   
+		
+		        <!-- add the jboss-service.xml and hibernate configuration -->
+	   			<fileset dir="${build.resources}/test/cms/clustering/sar"/>   
+	   			<fileset dir="${jboss.portal-core.lib}" includes="portal-core-lib.jar"/>			
+	   	   		<fileset dir="${jboss.portal-common.lib}" includes="portal-common-lib.jar"/>
+	   			<fileset dir="${jboss.portal-jems.lib}" includes="portal-jems-lib.jar"/>   						
+	   			<fileset dir="${jboss.portal-server.lib}" includes="portal-server-lib.jar"/>
+	   			<fileset dir="${jboss.portal-portlet.lib}" includes="portal-portlet-testframework-lib.jar"/>
+		  </jar>
+		 <jar jarfile="${build.lib}/test-cms-cluster.war">
+	         <fileset dir="${build.resources}/test/cms/clustering/test-cms-clustering-war"/>
+			 <fileset dir="${build.classes}" includes="org/jboss/portal/test/cms/clustering/**"/>			 
+	      </jar>
+	</target>
+	
+	<target name="deploy-tests"
+	           description="Deploy."
+	           depends="package-tests">		  
+	
+	<!-- 
+			  		upgrage the jbosscache/groups of the HA instances for the puropse of testing
+			  		
+			  		TODO: This is fine for this iteration. Eventually we need to integrate these libraries
+			    	for bundling in the thirdparty mechanism. This will follow in the next iteration
+			   -->
+	      	  <copy file="${jboss.cache.lib}/jboss-cache.jar" todir="${jboss.home}/server/ports-01/lib" overwrite="true"/>
+	      	  <copy file="${jgroups.jgroups.lib}/jgroups.jar" todir="${jboss.home}/server/ports-01/lib" overwrite="true"/>
+			  <copy file="${jboss.cache.lib}/jboss-cache.jar" todir="${jboss.home}/server/ports-02/lib" overwrite="true"/>
+		      <copy file="${jgroups.jgroups.lib}/jgroups.jar" todir="${jboss.home}/server/ports-02/lib" overwrite="true"/>
+	
+	      <!-- install test sars needed for the testsuite framework -->
+		  <copy file="${jboss.portal-portlet.lib}/test.sar" todir="${jboss.home}/server/ports-01/deploy"/>
+	      <copy file="${jboss.portal-portlet.lib}/test.sar" todir="${jboss.home}/server/ports-02/deploy"/>
+		  <copy file="${jboss.portal-test.lib}/portal-test.sar" todir="${jboss.home}/server/ports-01/deploy"/>
+		  <copy file="${jboss.portal-test.lib}/portal-test.sar" todir="${jboss.home}/server/ports-02/deploy"/>
+	
+	      <copy file="${build.lib}/test-cms-cluster.sar" todir="${jboss.home}/server/ports-01/deploy"/>
+		  <copy file="${build.lib}/test-cms-cluster.sar" todir="${jboss.home}/server/ports-02/deploy"/>
+	</target>
+	
+	<target name="undeploy-tests"
+		           description="UnDeploy." depends="init">
+	
+		      <!-- install test sars needed for the testsuite framework -->
+			  <delete file="${jboss.home}/server/ports-01/deploy/test.sar"/>
+		      <delete file="${jboss.home}/server/ports-02/deploy/test.sar"/>
+			  <delete file="${jboss.home}/server/ports-01/deploy/portal-test.sar"/>
+			  <delete file="${jboss.home}/server/ports-02/deploy/portal-test.sar"/>		
+		      <delete file="${jboss.home}/server/ports-01/deploy/test-cms-cluster.sar"/>
+			  <delete file="${jboss.home}/server/ports-02/deploy/test-cms-cluster.sar"/>
+	</target>
 
-   <!-- generates artifacts used for tests, requires output to be previously run
-         -->
-   <target name="package-tests" depends="init">
-   </target>
-
    <!-- ================================================================== -->
    <!-- Cleaning                                                           -->
    <!-- ================================================================== -->
@@ -207,17 +286,91 @@
    <!-- ================================================================== -->
    <!-- Test.                                                              -->
    <!-- ================================================================== -->
-
+   <target name="clustered-tests" depends="init">
+	      <execute-tests>
+      	     <x-sysproperty>
+      	            <sysproperty key="test.root" value="${build.lib}"/>
+      	            <sysproperty key="test.uri" value="/test/redirect/"/>
+      	     </x-sysproperty>
+	         <x-test>				
+				<test todir="${test.reports}" name="org.jboss.portal.test.cms.clustering.CMSTestSuite"/> 		        
+	         </x-test>
+	         <x-classpath>
+	            <path refid="apache.logging.classpath"/>
+	            <path refid="jboss.jbossxb.classpath"/>
+	            <path refid="jboss.cache.classpath"/>
+	            <path refid="apache.xerces.classpath"/>
+	            <path refid="oswego.concurrent.classpath"/>
+	            <path refid="jboss.microcontainer.classpath"/>
+	            <path refid="hibernate.hibernate.classpath"/>
+	            <path refid="ehcache.ehcache.classpath"/>
+	            <path refid="jbossas/core.libs.classpath"/>
+	            <path refid="apache.log4j.classpath"/>
+	            <path refid="jakarta.io.classpath"/>
+	            <path refid="apache.collections.classpath"/>
+	            <path refid="apache.lucene.classpath"/>
+	            <path refid="junit.junit.classpath"/>            
+	            <path refid="slf4j.slf4j.classpath"/>
+	            <path refid="sun.jaf.classpath"/>
+	            <path refid="xdoclet.xdoclet.classpath"/>
+	            <path refid="jcr.jcr.classpath"/>
+	            <path refid="dom4j.dom4j.classpath"/>
+	            <path refid="antlr.antlr.classpath"/>
+	            <path refid="asm.asm.classpath"/>
+	            <path refid="cglib.cglib.classpath"/>
+	            <path refid="hsqldb.hsqldb.classpath"/>
+	            <path refid="jboss.portal-common.classpath"/>
+	            <path refid="jboss.portal-test.classpath"/>
+	            <path refid="jboss.portal-server.classpath"/>
+	            <path refid="jboss.portal-jems.classpath"/>
+	            <pathelement location="${build.lib}/portal-cms-lib.jar"/>
+	            <pathelement location="${build.resources}/portal-cms-sar"/>
+	            <pathelement location="${build.resources}/test"/>
+	            <pathelement location="${build.resources}/hibernate"/>
+	            <pathelement location="${jboss.portal-test.root}/etc"/>
+		        <!-- jbosscachepersistence manager integration -->
+				<path refid="jackrabbit.jackrabbit.classpath"/>
+		        <path refid="jboss.cache.classpath"/>
+				<path refid="jgroups.jgroups.classpath"/>
+	            <!-- for clustering related -->
+				<pathelement location="${source.java}"/>
+	            <pathelement location="${build.classes}"/>
+	            <pathelement location="${build.resources}"/>
+	            <path refid="library.classpath"/>
+	            <path refid="dependentmodule.classpath"/>
+				<path refid="jboss.remoting.classpath"/>
+				<path refid="apache.httpclient.classpath"/>
+				<path refid="jboss.serialization.classpath"/>
+				<path refid="apache.codec.classpath"/>
+	         </x-classpath>
+	      </execute-tests>
+   </target>
    <target name="tests" depends="init">
       <execute-tests>
-         <x-test>
-            <test todir="${test.reports}" name="org.jboss.portal.test.cms.JackrabbitTestCase"/>
-            <test todir="${test.reports}" name="org.jboss.portal.test.cms.TestRepositoryBootStrap"/>
-            <test todir="${test.reports}" name="org.jboss.portal.test.cms.TestRepositoryUtil"/>
-            <test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFileCommands"/>
-            <test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFolderCommands"/>
-            <test todir="${test.reports}" name="org.jboss.portal.test.cms.TestRegEx"/>
-            <!--test todir="${test.reports}" name="org.jboss.portal.test.cms.TestAll"/-->
+         <x-test>	
+			<!-- general cms setup related tests -->
+	        <test todir="${test.reports}" name="org.jboss.portal.test.cms.JackrabbitTestCase"/>
+	        <test todir="${test.reports}" name="org.jboss.portal.test.cms.TestRepositoryBootStrap"/>
+			<test todir="${test.reports}" name="org.jboss.portal.test.cms.TestRegEx"/>
+			<test todir="${test.reports}" name="org.jboss.portal.test.cms.TestRepositoryUtil"/>
+	
+	        <!-- cms file command tests -->      		
+      		<test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFileCreate"/>
+      		<test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFileUpdate"/>
+      		<test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFileArchiveUpload"/>			
+			<test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFileGet"/>			
+			<test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFileGetVersion"/>
+			<test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFileGetList"/>
+			<test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFileCopy"/>			
+			<test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFileCreateFailed"/>
+			<test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFileDelete"/>			
+	
+	        <!-- cms folder command tests -->
+			<test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFolderCopy"/>            
+			<test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFolderCreate"/>            
+            <test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFolderDelete"/>            			
+			<test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFolderGet"/>            			
+			<test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFolderUpdate"/> 		        
          </x-test>
          <x-classpath>
             <path refid="apache.logging.classpath"/>
@@ -233,8 +386,7 @@
             <path refid="jakarta.io.classpath"/>
             <path refid="apache.collections.classpath"/>
             <path refid="apache.lucene.classpath"/>
-            <path refid="junit.junit.classpath"/>
-            <path refid="jackrabbit.jackrabbit.classpath"/>
+            <path refid="junit.junit.classpath"/>            
             <path refid="slf4j.slf4j.classpath"/>
             <path refid="sun.jaf.classpath"/>
             <path refid="xdoclet.xdoclet.classpath"/>
@@ -253,6 +405,10 @@
             <pathelement location="${build.resources}/test"/>
             <pathelement location="${build.resources}/hibernate"/>
             <pathelement location="${jboss.portal-test.root}/etc"/>
+	        <!-- jbosscachepersistence manager integration -->
+			<path refid="jackrabbit.jackrabbit.classpath"/>
+			<path refid="jboss.cache.classpath"/>
+			<path refid="jgroups.jgroups.classpath"/>
          </x-classpath>
       </execute-tests>
    </target>

Added: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/Base.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/Base.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/Base.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -0,0 +1,85 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.cms.hibernate.state;
+
+import java.io.Serializable;
+
+/*
+ * Created on Aug 31, 2006
+ *
+ * @author <a href="mailto:sohil.shah at jboss.com">Sohil Shah</a>
+ */
+public abstract class Base implements Serializable 
+{
+    /**
+     * 
+     */
+    private boolean persistCacheItem = true; //true by default...all items when placed in cache must be persisted to database by cacheloader by default
+    private Integer key = null;
+    
+    /**
+     * 
+     *
+     */
+    public Base()
+    {
+        
+    }
+    
+    //------cacheItem Persistence related methods------------------------------------------------------------------------------------------------------
+    /**
+     * 
+     *
+     */
+    public void disableCacheItemPersistence()
+    {
+        this.persistCacheItem = false;
+    }
+    
+    /**
+     * 
+     *
+     */
+    public boolean isPersistCacheItem()
+    {
+        return this.persistCacheItem;
+    }
+    
+    /**
+     * 
+     *
+     */
+    public void resetCacheItemPersistence()
+    {
+        this.persistCacheItem = true;
+    }
+    //-----------data access related methods-------------------------------------------------------------------------------------------------------------
+    public Integer getKey()
+    {
+       return key;
+    }
+
+    public void setKey(Integer key)
+    {
+       this.key = key;
+    }
+}

Modified: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/HibernatePersistenceManager.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/HibernatePersistenceManager.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/HibernatePersistenceManager.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -58,7 +58,7 @@
 import org.hibernate.SessionFactory;
 import org.hibernate.Transaction;
 import org.jboss.portal.cms.hibernate.HibernateStoreConstants;
-import org.jboss.portal.cms.util.HibernateUtil;
+//import org.jboss.portal.cms.util.HibernateUtil;
 import org.jboss.portal.common.util.Tools;
 import org.jboss.portal.jems.hibernate.CacheableBlobUserType;
 import org.jboss.portal.jems.hibernate.ByteArrayBlob;
@@ -155,7 +155,9 @@
          throw new IllegalStateException("already initialized");
       }
 
-      hibernateSessionFactory = HibernateUtil.getSessionFactory(jndiName);
+      //hibernateSessionFactory = HibernateUtil.getSessionFactory(jndiName);
+      org.jboss.portal.cms.hibernate.state.Tools.init(jndiName);
+      hibernateSessionFactory = org.jboss.portal.cms.hibernate.state.Tools.getSessionFactory();
 
       nodeBinValSelect = "from " + schemaObjectPrefix + "BinVal where BINVAL_ID = ?";
 
@@ -388,8 +390,12 @@
          List rs = session.createQuery(nodeStateSelectData).setString(0, id.toString()).list();
 
          Iterator iter = rs.iterator();
-         java.sql.Blob blob = (java.sql.Blob) iter.next();
-         in = blob.getBinaryStream();
+         
+         //java.sql.Blob blob = (java.sql.Blob) iter.next();
+         //in = blob.getBinaryStream();
+         byte[] data = (byte[])iter.next();
+         in = new java.io.ByteArrayInputStream(data);
+         
          NodeState state = createNew(id);
          Serializer.deserialize(state, in);
          Tools.safeClose(in);
@@ -428,8 +434,13 @@
       {
          List rs = session.createQuery(propertyStateSelectData).setCacheable(true).setString(0, id.toString()).list();
          Iterator iter = rs.iterator();
-         java.sql.Blob blob = (java.sql.Blob) iter.next();
-         in = blob.getBinaryStream();
+         
+         //java.sql.Blob blob = (java.sql.Blob) iter.next();
+         //in = blob.getBinaryStream();
+         byte[] data = (byte[])iter.next();
+         in = new java.io.ByteArrayInputStream(data);
+         
+         
          PropertyState state = createNew(id);
          Serializer.deserialize(state, in, blobStore);
          Tools.safeClose(in);
@@ -474,8 +485,9 @@
          {
             throw new NoSuchItemStateException(targetId.toString());
          }
-         java.sql.Blob blob = (java.sql.Blob) iter.next();
-         in = blob.getBinaryStream();
+         byte[] data = (byte[]) iter.next();         
+         in = new java.io.ByteArrayInputStream(data);
+         
          NodeReferences refs = new NodeReferences(targetId);
          Serializer.deserialize(refs, in);
          Tools.safeClose(in);
@@ -515,13 +527,13 @@
          Serializer.serialize(state, out);
          if (schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.versionPrefix))
          {
-            VersionNode versionNode = new VersionNode(state.getId().toString(), createBlob(out.toByteArray()));
+            VersionNode versionNode = new VersionNode(state.getId().toString(),out.toByteArray());
             session.save(versionNode);
          }
          else if (schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.wspPrefix))
          {
 
-            WSPNode wspNode = new WSPNode(state.getId().toString(), createBlob(out.toByteArray()));
+            WSPNode wspNode = new WSPNode(state.getId().toString(),out.toByteArray());
             session.save(wspNode);
          }
       }
@@ -568,14 +580,14 @@
          if (schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.versionPrefix))
          {
 
-            VersionRefs versionRefs = new VersionRefs(refs.getTargetId().toString(), createBlob(out
-                  .toByteArray()));
+            VersionRefs versionRefs = new VersionRefs(refs.getTargetId().toString(),out
+                  .toByteArray());
             session.save(versionRefs);
          }
          else if (schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.wspPrefix))
          {
 
-            WSPRefs wspRefs = new WSPRefs(refs.getTargetId().toString(), createBlob(out.toByteArray()));
+            WSPRefs wspRefs = new WSPRefs(refs.getTargetId().toString(),out.toByteArray());
             session.save(wspRefs);
          }
       }
@@ -625,12 +637,12 @@
 
          if (schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.versionPrefix))
          {
-            VersionProp versionProp = new VersionProp(state.getId().toString(), createBlob(out.toByteArray()));
+            VersionProp versionProp = new VersionProp(state.getId().toString(),out.toByteArray());
             session.save(versionProp);
          }
          else if (schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.wspPrefix))
          {
-            WSPProp wspProp = new WSPProp(state.getId().toString(), createBlob(out.toByteArray()));
+            WSPProp wspProp = new WSPProp(state.getId().toString(),out.toByteArray());
             session.save(wspProp);
          }
       }
@@ -678,7 +690,7 @@
             {
                throw new Exception("No such Node: " + state.getId());
             }
-            versionNode.setData(createBlob(out.toByteArray()));
+            versionNode.setData(out.toByteArray());
          }
          else if (schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.wspPrefix))
          {
@@ -688,7 +700,7 @@
             {
                throw new Exception("No such Node: " + state.getId());
             }
-            wspNode.setData(createBlob(out.toByteArray()));
+            wspNode.setData(out.toByteArray());
          }
       }
       catch (Exception e)
@@ -735,7 +747,7 @@
             {
                throw new Exception("No such Property: " + state.getId());
             }
-            versionProp.setData(createBlob(out.toByteArray()));
+            versionProp.setData(out.toByteArray());
          }
          else if (schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.wspPrefix))
          {
@@ -745,7 +757,7 @@
             {
                throw new Exception("No such Property: " + state.getId());
             }
-            wspProp.setData(createBlob(out.toByteArray()));
+            wspProp.setData(out.toByteArray());
          }
       }
       catch (Exception e)
@@ -875,8 +887,14 @@
       try
       {
          Query query = session.createQuery(nodeReferenceSelect).setCacheable(true).setString(0,
-               refs.getTargetId().toString());
-         Object result = query.uniqueResult();
+               refs.getTargetId().toString());                  
+         
+         List list = query.list();
+         if(list == null)
+         {
+             return;
+         }
+         Object result = list.iterator().next();
          if (result != null)
          {
             session.delete(result);

Added: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/JBossCachePersistenceManager.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/JBossCachePersistenceManager.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/JBossCachePersistenceManager.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -0,0 +1,1494 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.cms.hibernate.state;
+
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.InputStream;
+import java.io.ByteArrayInputStream;
+import java.sql.Blob;
+import java.sql.SQLException;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.jcr.PropertyType;
+import javax.management.MBeanServer;
+
+import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.core.PropertyId;
+import org.apache.jackrabbit.core.fs.FileSystem;
+import org.apache.jackrabbit.core.fs.local.LocalFileSystem;
+import org.apache.jackrabbit.core.state.ChangeLog;
+import org.apache.jackrabbit.core.state.ItemState;
+import org.apache.jackrabbit.core.state.ItemStateException;
+import org.apache.jackrabbit.core.state.NoSuchItemStateException;
+import org.apache.jackrabbit.core.state.NodeReferences;
+import org.apache.jackrabbit.core.state.NodeReferencesId;
+import org.apache.jackrabbit.core.state.NodeState;
+import org.apache.jackrabbit.core.state.PMContext;
+import org.apache.jackrabbit.core.state.PersistenceManager;
+import org.apache.jackrabbit.core.state.PropertyState;
+import org.apache.jackrabbit.core.state.util.BLOBStore;
+import org.apache.jackrabbit.core.state.util.FileSystemBLOBStore;
+import org.apache.jackrabbit.core.state.util.Serializer;
+import org.apache.jackrabbit.core.value.BLOBFileValue;
+import org.apache.jackrabbit.core.value.InternalValue;
+import org.apache.log4j.Logger;
+
+import org.jboss.portal.cms.hibernate.HibernateStoreConstants;
+
+import org.jboss.cache.PropertyConfigurator;
+import org.jboss.cache.TreeCache;
+import org.jboss.cache.TreeCacheMBean;
+import org.jboss.cache.CacheException;
+import org.jboss.mx.util.MBeanProxyExt;
+import org.jboss.mx.util.MBeanServerLocator;
+
+import org.hibernate.Hibernate;
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+
+/*
+ * Created on Aug 28, 2006
+ *
+ * @author <a href="mailto:sohil.shah at jboss.com">Sohil Shah</a>
+ */
+public class JBossCachePersistenceManager implements PersistenceManager 
+{
+    /**
+     * Logger instance
+     */
+    private static Logger log = Logger.getLogger(JBossCachePersistenceManager.class);
+
+    protected static final String SCHEMA_OBJECT_PREFIX_VARIABLE = "${schemaObjectPrefix}";
+
+    protected boolean initialized = false;
+
+    protected String jndiName = null;
+
+    protected String schemaObjectPrefix = null;
+
+    protected boolean externalBLOBs = false;
+
+    // initial size of buffer used to serialize objects
+    protected static final int INITIAL_BUFFER_SIZE = 1024;
+    
+
+    // shared statements for BLOB management
+    // (if <code>externalBLOBs==false</code>)
+    protected String blobSelect = null;
+
+    protected String blobSelectData = null;
+
+    protected String blobSelectExist = null;
+
+    protected String nodeBinValSelect = null;
+
+    /**
+     * file system where BLOB data is stored
+     * (if <code>externalBLOBs==true</code>)
+     */
+    protected FileSystem blobFS = null;
+
+    /**
+     * BLOBStore that manages BLOB data in the file system
+     * (if <code>externalBLOBs==true</code>)
+     */
+    protected BLOBStore blobStore = null;
+
+    /**
+     * 
+     */
+    private static TreeCacheMBean pmCache = null;
+    private static boolean preloaded = false;
+    
+    /**
+     * Creates a new <code>SimpleDbPersistenceManager</code> instance.
+     */
+    public JBossCachePersistenceManager()
+    {
+       schemaObjectPrefix = "";
+       externalBLOBs = true;
+       initialized = false;
+    }
+    
+    //------------------------------------------------------------------------------------------------------------------------------------------------
+    public String getJNDIName()
+    {
+       return jndiName;
+    }
+
+    public void setJNDIName(String JNDIName)
+    {
+       this.jndiName = JNDIName;
+    }
+
+    public String getSchemaObjectPrefix()
+    {
+       return schemaObjectPrefix;
+    }
+
+    public void setSchemaObjectPrefix(String schemaObjectPrefix)
+    {
+       this.schemaObjectPrefix = schemaObjectPrefix;//.toUpperCase();
+    }
+
+    public boolean isExternalBLOBs()
+    {
+       return externalBLOBs;
+    }
+
+    public void setExternalBLOBs(boolean externalBLOBs)
+    {
+       this.externalBLOBs = externalBLOBs;
+    }
+
+    public void setExternalBLOBs(String externalBLOBs)
+    {
+       this.externalBLOBs = Boolean.valueOf(externalBLOBs).booleanValue();
+    }
+    
+    
+    /* 
+     * 
+     */
+    public void init(PMContext context) throws Exception 
+    {
+        if (initialized)
+        {
+           throw new IllegalStateException("already initialized");
+        }     
+
+        nodeBinValSelect = "from " + schemaObjectPrefix + "BinVal where BINVAL_ID = ?";
+
+        if (externalBLOBs)
+        {
+           /**
+            * store BLOBs in local file system in a sub directory
+            * of the workspace home directory
+            */
+           LocalFileSystem blobFS = new LocalFileSystem();
+           blobFS.setRoot(new File(context.getHomeDir(), "blobs"));
+           blobFS.init();
+           this.blobFS = blobFS;
+           blobStore = new FileSystemBLOBStore(blobFS);
+        }
+        else
+        {
+           /**
+            * store BLOBs in db
+            */
+           blobStore = new DbBLOBStore();
+
+           blobSelect = "from " + schemaObjectPrefix + "BinVal where BINVAL_ID = ?";
+           blobSelectData = "select data from " + schemaObjectPrefix + "BinVal where BINVAL_ID = ?";
+           blobSelectExist = "select 1 from " + schemaObjectPrefix + "BinVal where BINVAL_ID = ?";
+        }
+
+        initialized = true;
+        
+        try
+        { 
+           Tools.init(this.jndiName);           
+	       if(JBossCachePersistenceManager.pmCache == null)
+	       {
+	           try
+	           {	               
+	               MBeanServer server=MBeanServerLocator.locateJBoss();
+	               JBossCachePersistenceManager.pmCache = (TreeCacheMBean)MBeanProxyExt.create(TreeCacheMBean.class,"cms.pm.cache:service=TreeCache",server);	               
+	           }
+	           catch(Exception e)
+	           {
+	               JBossCachePersistenceManager.pmCache = null;
+	           }
+	           
+	           //try to load from specified configuration if any
+	           //if nothing found in the environment...chances are running in a non-managed environment
+	           if(JBossCachePersistenceManager.pmCache == null)
+	           {
+	               InputStream is = null;
+	               try
+	               {
+		                JBossCachePersistenceManager.pmCache = new TreeCache();
+					    
+					    //configure the cache
+					    PropertyConfigurator configurator = new PropertyConfigurator();
+					    is = JBossCachePersistenceManager.class.getClassLoader().getResourceAsStream("pm-cache.xml");
+					    configurator.configure(JBossCachePersistenceManager.pmCache,is);
+					    			    
+					    JBossCachePersistenceManager.pmCache.createService();
+					    JBossCachePersistenceManager.pmCache.startService();
+	               }
+	               finally
+	               {
+	                   if(is != null)
+	                   {
+	                       is.close();
+	                   }
+	               }
+	           }
+	       }
+	       
+	       //pre-load the cache with property nodes
+	       if(!JBossCachePersistenceManager.preloaded)
+	       {
+	           JBossCachePersistenceManager.loadProperties();	           
+	           log.info("-------------------------------------------------");
+	           log.info("JBossCachePersistenceManager is fully loaded.....");
+	           log.info("-------------------------------------------------");
+	       }
+        }
+        catch(Exception e)
+        {
+            throw new RuntimeException(e);
+        }
+    }  
+        
+    /**
+     * 
+     *
+     */
+    private static synchronized void loadProperties() throws Exception
+    {
+        if(JBossCachePersistenceManager.preloaded)
+        {
+            return;
+        }
+        
+        log.info("Pre-loading the PersistenceManager Cache in the background (started).......");        
+        
+        CacheLoader wspProp = new CacheLoader(CacheLoader.wspProp,PortalCMSCacheLoader.WSP_PROP_NODE);
+        Thread wspPropLoader = new Thread(wspProp);
+        CacheLoader versionProp = new CacheLoader(CacheLoader.versionProp,PortalCMSCacheLoader.VERSION_PROP_NODE);
+        Thread versionPropLoader = new Thread(versionProp);
+        CacheLoader wspNode = new CacheLoader(CacheLoader.wspNode,PortalCMSCacheLoader.WSP_NODE_NODE);
+        Thread wspNodeLoader = new Thread(wspNode);
+        CacheLoader versionNode = new CacheLoader(CacheLoader.versionNode,PortalCMSCacheLoader.VERSION_NODE_NODE);
+        Thread versionNodeLoader = new Thread(versionNode);
+        CacheLoader wspRef = new CacheLoader(CacheLoader.wspRef,PortalCMSCacheLoader.WSP_REF_NODE);
+        Thread wspRefLoader = new Thread(wspRef);
+        CacheLoader versionRef = new CacheLoader(CacheLoader.versionRef,PortalCMSCacheLoader.VERSION_REF_NODE);
+        Thread versionRefLoader = new Thread(versionRef);
+        
+        wspPropLoader.start();
+        versionPropLoader.start();
+        wspNodeLoader.start();
+        versionNodeLoader.start();
+        wspRefLoader.start();
+        versionRefLoader.start();
+        
+        //hang out here till the cache loader threads have pre-loaded the busy nodes
+        //of the CMS...don't allow the usage of CMS till this operation is completed.
+        while(
+                !wspProp.done	||
+                !versionProp.done ||
+                !wspNode.done ||
+                !versionNode.done ||
+                !wspRef.done ||
+                !versionRef.done
+        )
+        {
+            Thread.currentThread().sleep((long)2000);
+        }
+        
+        JBossCachePersistenceManager.preloaded = true;                
+    }
+    
+    private static class CacheLoader implements Runnable
+    {
+        /**
+         * 
+         */
+        private static final String wspProp = "from org.jboss.portal.cms.hibernate.state.WSPProp";
+        private static final String versionProp = "from org.jboss.portal.cms.hibernate.state.VersionProp";
+        private static final String wspNode = "from org.jboss.portal.cms.hibernate.state.WSPNode";
+        private static final String versionNode = "from org.jboss.portal.cms.hibernate.state.VersionNode";
+        private static final String wspRef = "from org.jboss.portal.cms.hibernate.state.WSPRefs";
+        private static final String versionRef = "from org.jboss.portal.cms.hibernate.state.VersionRefs";
+        
+        
+        /**
+         * 
+         */
+        private String nodeQuery = null;
+        private String nodePrefix = null;
+        private boolean done = false;
+        
+        private CacheLoader(String nodeQuery,String nodePrefix)
+        {
+           this.nodeQuery = nodeQuery;
+           this.nodePrefix = nodePrefix;
+        }
+                        
+        public void run()
+        {                                    
+            Session session = null;
+            try
+            {
+                session = Tools.getOpenSession();  
+                List rs = session.createQuery(this.nodeQuery).list();                                
+                if(rs != null)
+                {
+    	            for(Iterator itr=rs.iterator();itr.hasNext();)
+    	            {
+    	                Base cour = (Base)itr.next();
+    	                cour.disableCacheItemPersistence();
+    	                
+    	                if(cour instanceof WSPProp)
+    	                {    	                    
+    	                    String node = this.nodePrefix + "/" + PortalCMSCacheLoader.parseNodeName(((WSPProp)cour).getPropId());    	                    
+    	                    pmCache.put(node,((WSPProp)cour).getPropId(),cour);
+    	                }
+    	                else if(cour instanceof VersionProp)
+    	                {    	                    
+    	                    String node = this.nodePrefix + "/" + PortalCMSCacheLoader.parseNodeName(((VersionProp)cour).getPropId());
+    	                    pmCache.put(node,((VersionProp)cour).getPropId(),cour);
+    	                }
+    	                else if(cour instanceof WSPNode)
+    	                {    	                    
+    	                    String node = this.nodePrefix + "/" + PortalCMSCacheLoader.parseNodeName(((WSPNode)cour).getNodeId());
+    	                    pmCache.put(node,((WSPNode)cour).getNodeId(),cour);
+    	                }
+    	                else if(cour instanceof VersionNode)
+    	                {    	                    
+    	                    String node = this.nodePrefix + "/" + PortalCMSCacheLoader.parseNodeName(((VersionNode)cour).getNodeId());
+    	                    pmCache.put(node,((VersionNode)cour).getNodeId(),cour);
+    	                }
+    	                else if(cour instanceof WSPRefs)
+    	                {    	                    
+    	                    String node = this.nodePrefix + "/" + PortalCMSCacheLoader.parseNodeName(((WSPRefs)cour).getRefId());
+    	                    pmCache.put(node,((WSPRefs)cour).getRefId(),cour);
+    	                }
+    	                else if(cour instanceof VersionRefs)
+    	                {    	                    
+    	                    String node = this.nodePrefix + "/" + PortalCMSCacheLoader.parseNodeName(((VersionRefs)cour).getRefId());
+    	                    pmCache.put(node,((VersionRefs)cour).getRefId(),cour);
+    	                }
+    	            }
+                }                                
+                log.info("Pre-loading the PersistenceManager Cache for"+this.nodePrefix+" (finished).......");
+            }
+            catch(CacheException ce)
+            {
+                throw new RuntimeException(ce);
+            }
+            finally
+            {
+                Tools.closeSession(session);
+                this.done = true;
+            }
+        }
+    }
+    
+    //----------actions for node entities-------------------------------------------------------------------------------------------------------------
+    /* 
+     * 
+     */
+    public boolean exists(NodeId node) throws ItemStateException 
+    {
+        try
+        {
+	        boolean exists = false;
+	        String nodeId = node.toString();
+	        if(this.schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.wspPrefix))
+	        {
+	            Object o = this.pmCache.get(PortalCMSCacheLoader.WSP_NODE_NODE+"/"+PortalCMSCacheLoader.parseNodeName(nodeId),nodeId);
+	            if(o != null)
+	            {
+	                if(o instanceof WSPNode)
+	                {
+	                    exists = true;
+	                }
+	            }
+	            else
+	            {
+	                this.pmCache.put(PortalCMSCacheLoader.WSP_NODE_NODE+"/"+PortalCMSCacheLoader.parseNodeName(nodeId),nodeId,new Boolean(false));
+	            }
+	        }
+	        else if(this.schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.versionPrefix))
+	        {
+	            Object o = this.pmCache.get(PortalCMSCacheLoader.VERSION_NODE_NODE+"/"+PortalCMSCacheLoader.parseNodeName(nodeId),nodeId);
+	            if(o != null)
+	            {
+	                if(o instanceof VersionNode)
+	                {
+	                    exists = true;
+	                }
+	            }
+	            else
+	            {
+	                this.pmCache.put(PortalCMSCacheLoader.VERSION_NODE_NODE+"/"+PortalCMSCacheLoader.parseNodeName(nodeId),nodeId,new Boolean(false));
+	            }
+	        }
+	        return exists;
+        }
+        catch(CacheException ce)
+        {
+            throw new RuntimeException(ce);
+        }
+    }
+    
+    /* 
+     * 
+     */
+    public NodeState load(NodeId node) throws NoSuchItemStateException,ItemStateException 
+    {
+        try
+        {
+	        NodeState nodeState = null;
+	        String nodeId = node.toString();
+	        
+	        //get the nodeData
+	        byte[] nodeData = null;
+	        if(this.schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.wspPrefix))
+	        {
+	            Object o = this.pmCache.get(PortalCMSCacheLoader.WSP_NODE_NODE+"/"+PortalCMSCacheLoader.parseNodeName(nodeId),nodeId);
+	            nodeData = ((WSPNode)o).getData();
+	        }
+	        else if(this.schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.versionPrefix))
+	        {
+	            Object o = this.pmCache.get(PortalCMSCacheLoader.VERSION_NODE_NODE+"/"+PortalCMSCacheLoader.parseNodeName(nodeId),nodeId);
+	            nodeData = ((VersionNode)o).getData();
+	        }
+	        
+	        //parse propertyData into propertyState
+	        if(nodeData!=null)
+	        {
+	            Session session = null;
+	            Transaction tx = null;
+	            boolean success = false;
+	            try
+	            {
+	                session = Tools.getOpenSession();
+	                tx = session.beginTransaction();
+	                              
+	                InputStream in = new ByteArrayInputStream(nodeData);
+	                
+	                //setup the propertyState
+	                nodeState = createNew(node);
+	                Serializer.deserialize(nodeState,in);
+	                org.jboss.portal.common.util.Tools.safeClose(in);
+	                
+	                tx.commit();
+	                success = true;
+	            }
+	            catch(Exception e)
+	            {
+	                if (e instanceof NoSuchItemStateException)
+	                {
+	                   throw (NoSuchItemStateException) e;
+	                }
+	                String msg = "failed to read node state from cache: " + node.toString();
+	                log.error(msg, e);
+	                throw new ItemStateException(msg, e);
+	            }
+	            finally
+	            {
+	                if(!success)
+	                {
+	                    tx.rollback();
+	                }
+	                Tools.closeSession(session);
+	            }
+	        }	        
+	        
+	        return nodeState;
+        }
+        catch(CacheException ce)
+        {
+            throw new RuntimeException(ce);
+        }
+    }
+    
+    /**
+     * 
+     *
+     */
+    private void store(NodeState state) throws ItemStateException
+    {
+       if (!initialized)
+       {
+          throw new IllegalStateException("not initialized");
+       }
+
+       ByteArrayOutputStream out = new ByteArrayOutputStream(INITIAL_BUFFER_SIZE);
+       try
+       {
+          Serializer.serialize(state, out);
+          if (schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.versionPrefix))
+          {
+             VersionNode versionNode = new VersionNode(state.getId().toString(), out.toByteArray());
+             
+             //place this in the cache
+             versionNode.resetCacheItemPersistence();
+             String cacheNode = PortalCMSCacheLoader.VERSION_NODE_NODE + "/" + PortalCMSCacheLoader.parseNodeName(versionNode.getNodeId());
+             pmCache.put(cacheNode,versionNode.getNodeId(),versionNode);
+          }
+          else if (schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.wspPrefix))
+          {
+
+             WSPNode wspNode = new WSPNode(state.getId().toString(), out.toByteArray());
+             
+             //place this in the cache
+             wspNode.resetCacheItemPersistence();
+             String cacheNode = PortalCMSCacheLoader.WSP_NODE_NODE + "/" + PortalCMSCacheLoader.parseNodeName(wspNode.getNodeId());
+             pmCache.put(cacheNode,wspNode.getNodeId(),wspNode);
+          }
+       }
+       catch (Exception e)
+       {
+          String msg = "failed to write node state: " + state.getId();
+          log.error(msg, e);
+          throw new ItemStateException(msg, e);
+       }
+       finally
+       {
+          try
+          {
+             out.close();
+          }
+          catch (Exception e)
+          {
+             e.printStackTrace();
+          }
+       }
+    }
+    
+    /**
+     * 
+     *
+     */
+    private void update(NodeState state) throws ItemStateException
+    {
+       if (!initialized)
+       {
+          throw new IllegalStateException("not initialized");
+       }
+
+       ByteArrayOutputStream out = new ByteArrayOutputStream(INITIAL_BUFFER_SIZE);
+       try
+       {
+          Serializer.serialize(state, out);
+          String id = state.getId().toString();
+          String cacheNodeName = PortalCMSCacheLoader.parseNodeName(id);
+          if (schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.versionPrefix))
+          {
+             VersionNode versionNode = (VersionNode)pmCache.get(PortalCMSCacheLoader.VERSION_NODE_NODE+"/"+cacheNodeName,id);
+             if (versionNode == null)
+             {
+                throw new Exception("No such Node: " + state.getId());
+             }
+             versionNode.setData(out.toByteArray());
+             versionNode.resetCacheItemPersistence();
+             pmCache.put(PortalCMSCacheLoader.VERSION_NODE_NODE+"/"+cacheNodeName,id,versionNode);
+          }
+          else if (schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.wspPrefix))
+          {
+             WSPNode wspNode = (WSPNode)pmCache.get(PortalCMSCacheLoader.WSP_NODE_NODE+"/"+cacheNodeName,id);
+             if (wspNode == null)
+             {
+                throw new Exception("No such Node: " + state.getId());
+             }
+             wspNode.setData(out.toByteArray());
+             wspNode.resetCacheItemPersistence();
+             pmCache.put(PortalCMSCacheLoader.WSP_NODE_NODE+"/"+cacheNodeName,id,wspNode);
+          }
+       }
+       catch (Exception e)
+       {
+          String msg = "failed to write node state: " + state.getId();
+          log.error(msg, e);
+          throw new ItemStateException(msg, e);
+       }
+       finally
+       {
+          try
+          {
+             out.close();
+          }
+          catch (Exception e)
+          {
+             e.printStackTrace();
+          }
+       }
+    }
+    
+    /**
+     * This is called by store(Changelog) this should not be called anywhere else
+     */
+    private void destroy(NodeState state) throws ItemStateException
+    {
+       if (!initialized)
+       {
+          throw new IllegalStateException("not initialized");
+       }
+
+       String id = state.getId().toString();
+       String cacheNodeName = PortalCMSCacheLoader.parseNodeName(id);
+       try
+       {
+           if (schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.versionPrefix))
+           {
+               pmCache.remove(PortalCMSCacheLoader.VERSION_NODE_NODE+"/"+cacheNodeName,id);
+           }
+           else if(schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.wspPrefix))
+           {
+               pmCache.remove(PortalCMSCacheLoader.WSP_NODE_NODE+"/"+cacheNodeName,id);
+           }
+       }
+       catch (Exception e)
+       {
+          String msg = "failed to delete node state: " + state.getId();
+          log.error(msg, e);
+          throw new ItemStateException(msg, e);
+       }
+    }
+    
+    //----------actions for property entities-------------------------------------------------------------------------------------------------------------    
+    /* 
+     * 
+     */
+    public boolean exists(PropertyId property) throws ItemStateException 
+    {
+        try
+        {
+	        boolean exists = false;
+	        String propId = property.toString();
+	        if(this.schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.wspPrefix))
+	        {
+	            Object o = this.pmCache.get(PortalCMSCacheLoader.WSP_PROP_NODE+"/"+PortalCMSCacheLoader.parseNodeName(propId),propId);
+	            if(o != null)
+	            {
+	                if(o instanceof WSPProp)
+	                {
+	                    exists = true;
+	                }
+	            }
+	            else
+	            {
+	                this.pmCache.put(PortalCMSCacheLoader.WSP_PROP_NODE+"/"+PortalCMSCacheLoader.parseNodeName(propId),propId,new Boolean(false));
+	            }
+	        }
+	        else if(this.schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.versionPrefix))
+	        {
+	            Object o = this.pmCache.get(PortalCMSCacheLoader.VERSION_PROP_NODE+"/"+PortalCMSCacheLoader.parseNodeName(propId),propId);
+	            if(o != null)
+	            {
+	                if(o instanceof VersionProp)
+	                {
+	                    exists = true;
+	                }
+	            }
+	            else
+	            {
+	                this.pmCache.put(PortalCMSCacheLoader.VERSION_PROP_NODE+"/"+PortalCMSCacheLoader.parseNodeName(propId),propId,new Boolean(false));
+	            }
+	        }
+	        return exists;
+        }
+        catch(CacheException ce)
+        {
+            throw new RuntimeException(ce);
+        }
+    }
+
+    /* 
+     * 
+     */
+    public PropertyState load(PropertyId property) throws NoSuchItemStateException,ItemStateException 
+    {
+        try
+        {
+	        PropertyState propertyState = null;
+	        String propId = property.toString();
+	        
+	        //get the propertyData
+	        byte[] propertyData = null;
+	        if(this.schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.wspPrefix))
+	        {
+	            Object o = this.pmCache.get(PortalCMSCacheLoader.WSP_PROP_NODE+"/"+PortalCMSCacheLoader.parseNodeName(propId),propId);	
+	            propertyData = ((WSPProp)o).getData();
+	        }
+	        else if(this.schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.versionPrefix))
+	        {
+	            Object o = this.pmCache.get(PortalCMSCacheLoader.VERSION_PROP_NODE+"/"+PortalCMSCacheLoader.parseNodeName(propId),propId);
+	            propertyData = ((VersionProp)o).getData();
+	        }
+	        
+	        //parse propertyData into propertyState
+	        if(propertyData!=null)
+	        {
+	            Session session = null;
+	            Transaction tx = null;
+	            boolean success = false;
+	            try
+	            {
+	                session = Tools.getOpenSession();
+	                tx = session.beginTransaction();
+	                              
+	                InputStream in = new ByteArrayInputStream(propertyData);
+	                
+	                //setup the propertyState
+	                propertyState = createNew(property);
+	                Serializer.deserialize(propertyState,in,blobStore);
+	                org.jboss.portal.common.util.Tools.safeClose(in);
+	                
+	                tx.commit();
+	                success = true;
+	            }
+	            catch(Exception e)
+	            {
+	                if (e instanceof NoSuchItemStateException)
+	                {
+	                   throw (NoSuchItemStateException) e;
+	                }
+	                String msg = "failed to read property state from cache: " + property.toString();
+	                log.error(msg, e);
+	                throw new ItemStateException(msg, e);
+	            }
+	            finally
+	            {
+	                if(!success)
+	                {
+	                    tx.rollback();
+	                }
+	                Tools.closeSession(session);
+	            }
+	        }	        
+	        
+	        return propertyState;
+        }
+        catch(CacheException ce)
+        {
+            throw new RuntimeException(ce);
+        }
+    }
+            
+    /**
+     * 
+     */
+    private void store(PropertyState state) throws ItemStateException
+    {
+       if (!initialized)
+       {
+          throw new IllegalStateException("not initialized");
+       }
+
+       ByteArrayOutputStream out = new ByteArrayOutputStream(INITIAL_BUFFER_SIZE);
+       try
+       {
+          Serializer.serialize(state,out,blobStore);
+          if (schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.versionPrefix))
+          {
+             VersionProp versionProp = new VersionProp(state.getId().toString(), out.toByteArray());
+             
+             //place this in the cache
+             versionProp.resetCacheItemPersistence();
+             String cacheNode = PortalCMSCacheLoader.VERSION_PROP_NODE + "/" + PortalCMSCacheLoader.parseNodeName(versionProp.getPropId());
+             pmCache.put(cacheNode,versionProp.getPropId(),versionProp);
+          }
+          else if (schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.wspPrefix))
+          {
+
+             WSPProp wspProp = new WSPProp(state.getId().toString(), out.toByteArray());
+             
+             //place this in the cache
+             wspProp.resetCacheItemPersistence();
+             String cacheNode = PortalCMSCacheLoader.WSP_PROP_NODE + "/" + PortalCMSCacheLoader.parseNodeName(wspProp.getPropId());
+             pmCache.put(cacheNode,wspProp.getPropId(),wspProp);
+          }
+       }
+       catch (Exception e)
+       {
+          String msg = "failed to write property state: " + state.getId();
+          log.error(msg, e);
+          throw new ItemStateException(msg, e);
+       }
+       finally
+       {
+          try
+          {
+             out.close();
+          }
+          catch (Exception e)
+          {
+             e.printStackTrace();
+          }
+       }
+    }
+    
+    /**
+     * 
+     *
+     */
+    private void update(PropertyState state) throws ItemStateException
+    {
+        if (!initialized)
+        {
+           throw new IllegalStateException("not initialized");
+        }
+
+        ByteArrayOutputStream out = new ByteArrayOutputStream(INITIAL_BUFFER_SIZE);
+        try
+        {
+           Serializer.serialize(state, out, blobStore);
+           String id = state.getId().toString();
+           String cacheNodeName = PortalCMSCacheLoader.parseNodeName(id);
+           if (schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.versionPrefix))
+           {
+              VersionProp versionProp = (VersionProp)pmCache.get(PortalCMSCacheLoader.VERSION_PROP_NODE+"/"+cacheNodeName,id);
+              if (versionProp == null)
+              {
+                 throw new Exception("No such Property: " + state.getId());
+              }
+              versionProp.setData(out.toByteArray());
+              versionProp.resetCacheItemPersistence();
+              pmCache.put(PortalCMSCacheLoader.VERSION_PROP_NODE+"/"+cacheNodeName,id,versionProp);
+           }
+           else if (schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.wspPrefix))
+           {
+              WSPProp wspProp = (WSPProp)pmCache.get(PortalCMSCacheLoader.WSP_PROP_NODE+"/"+cacheNodeName,id);
+              if (wspProp == null)
+              {
+                 throw new Exception("No such Property: " + state.getId());
+              }
+              wspProp.setData(out.toByteArray());
+              wspProp.resetCacheItemPersistence();
+              pmCache.put(PortalCMSCacheLoader.WSP_PROP_NODE+"/"+cacheNodeName,id,wspProp);
+           }
+        }
+        catch (Exception e)
+        {
+           String msg = "failed to write property state: " + state.getId();
+           log.error(msg, e);
+           throw new ItemStateException(msg, e);
+        }
+        finally
+        {
+           try
+           {
+              out.close();
+           }
+           catch (Exception e)
+           {
+              e.printStackTrace();
+           }
+        }
+    }
+
+    /**
+     * This is called by store(Changelog) this should not be called anywhere else
+     */
+    private void destroy(PropertyState state) throws ItemStateException
+    {
+       if (!initialized)
+       {
+          throw new IllegalStateException("not initialized");
+       }
+
+       // make sure binary values (BLOBs) are properly removed
+       InternalValue[] values = state.getValues();
+       if (values != null)
+       {
+          for (int i = 0; i < values.length; i++)
+          {
+             InternalValue val = values[i];
+             if (val != null)
+             {
+                if (val.getType() == PropertyType.BINARY)
+                {
+                   BLOBFileValue blobVal = (BLOBFileValue) val.internalValue();
+                   // delete internal resource representation of BLOB value
+                   blobVal.delete(true);
+                   // also remove from BLOBStore
+                   String blobId = blobStore.createId((PropertyId) state.getId(), i);
+                   try
+                   {
+                      blobStore.remove(blobId);
+                   }
+                   catch (Exception e)
+                   {
+                      log.warn("failed to remove from BLOBStore: " + blobId, e);
+                   }
+                }
+             }
+          }
+       }
+
+       //remove the property node
+       String id = state.getId().toString();
+       String cacheNodeName = PortalCMSCacheLoader.parseNodeName(id);
+       try
+       {
+           if (schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.versionPrefix))
+           {
+               pmCache.remove(PortalCMSCacheLoader.VERSION_PROP_NODE+"/"+cacheNodeName,id);
+           }
+           else if(schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.wspPrefix))
+           {
+               pmCache.remove(PortalCMSCacheLoader.WSP_PROP_NODE+"/"+cacheNodeName,id);
+           }
+       }
+       catch (Exception e)
+       {
+          String msg = "failed to delete property state: " + state.getId();
+          log.error(msg, e);
+          throw new ItemStateException(msg, e);
+       }
+    }
+    //----------actions for nodereferences entities-------------------------------------------------------------------------------------------------------------
+    /**
+    *
+    */
+   public boolean exists(NodeReferencesId targetId) throws ItemStateException
+   {
+       try
+       {
+	        boolean exists = false;
+	        String nodeId = targetId.toString();
+	        if(this.schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.wspPrefix))
+	        {
+	            Object o = this.pmCache.get(PortalCMSCacheLoader.WSP_REF_NODE+"/"+PortalCMSCacheLoader.parseNodeName(nodeId),nodeId);
+	            if(o != null)
+	            {
+	                if(o instanceof WSPRefs)
+	                {
+	                    exists = true;
+	                }
+	            }
+	            else
+	            {
+	                this.pmCache.put(PortalCMSCacheLoader.WSP_REF_NODE+"/"+PortalCMSCacheLoader.parseNodeName(nodeId),nodeId,new Boolean(false));
+	            }
+	        }
+	        else if(this.schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.versionPrefix))
+	        {
+	            Object o = this.pmCache.get(PortalCMSCacheLoader.VERSION_REF_NODE+"/"+PortalCMSCacheLoader.parseNodeName(nodeId),nodeId);
+	            if(o != null)
+	            {
+	                if(o instanceof VersionRefs)
+	                {
+	                    exists = true;
+	                }
+	            }
+	            else
+	            {
+	                this.pmCache.put(PortalCMSCacheLoader.VERSION_REF_NODE+"/"+PortalCMSCacheLoader.parseNodeName(nodeId),nodeId,new Boolean(false));
+	            }
+	        }
+	        return exists;
+       }
+       catch(CacheException ce)
+       {
+           throw new RuntimeException(ce);
+       }
+   }
+    
+    /**
+    *
+    */
+   public NodeReferences load(NodeReferencesId targetId) throws NoSuchItemStateException, ItemStateException
+   {
+       try
+       {
+	        NodeReferences refs = null;
+	        String nodeId = targetId.toString();
+	        
+	        //get the nodeData
+	        byte[] nodeData = null;
+	        if(this.schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.wspPrefix))
+	        {
+	            Object o = this.pmCache.get(PortalCMSCacheLoader.WSP_REF_NODE+"/"+PortalCMSCacheLoader.parseNodeName(nodeId),nodeId);
+	            if(o == null || !(o instanceof Base))
+	            {
+	                throw new NoSuchItemStateException(targetId.toString()); 
+	            }
+	            nodeData = ((WSPRefs)o).getData();
+	        }
+	        else if(this.schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.versionPrefix))
+	        {
+	            Object o = this.pmCache.get(PortalCMSCacheLoader.VERSION_REF_NODE+"/"+PortalCMSCacheLoader.parseNodeName(nodeId),nodeId);
+	            if(o == null || !(o instanceof Base))
+	            {
+	                throw new NoSuchItemStateException(targetId.toString()); 
+	            }
+	            nodeData = ((VersionRefs)o).getData();
+	        }
+	        
+	        //parse propertyData into propertyState
+	        if(nodeData!=null)
+	        {
+	            Session session = null;
+	            Transaction tx = null;
+	            boolean success = false;
+	            try
+	            {
+	                session = Tools.getOpenSession();
+	                tx = session.beginTransaction();
+	                              
+	                InputStream in = new ByteArrayInputStream(nodeData);
+	                
+	                //setup the propertyState
+	                refs = new NodeReferences(targetId);
+	                Serializer.deserialize(refs,in);
+	                org.jboss.portal.common.util.Tools.safeClose(in);
+	                
+	                tx.commit();
+	                success = true;
+	            }
+	            catch(Exception e)
+	            {
+	                if (e instanceof NoSuchItemStateException)
+	                {
+	                   throw (NoSuchItemStateException) e;
+	                }
+	                String msg = "failed to read reference from cache: " + targetId.toString();
+	                log.error(msg, e);
+	                throw new ItemStateException(msg, e);
+	            }
+	            finally
+	            {
+	                if(!success)
+	                {
+	                    tx.rollback();
+	                }
+	                Tools.closeSession(session);
+	            }
+	        }	        
+	        
+	        return refs;
+       }
+       catch(CacheException ce)
+       {
+           throw new RuntimeException(ce);
+       }
+   }
+   
+   /**
+    * 
+    *
+    */
+   private void store(NodeReferences refs) throws ItemStateException
+   {
+       if (!initialized)
+       {
+          throw new IllegalStateException("not initialized");
+       }
+
+       ByteArrayOutputStream out = new ByteArrayOutputStream(INITIAL_BUFFER_SIZE);
+       try
+       {
+          Serializer.serialize(refs,out);
+          if (schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.versionPrefix))
+          {
+             VersionRefs versionRefs = new VersionRefs(refs.getId().toString(), out.toByteArray());
+             
+             //place this in the cache
+             versionRefs.resetCacheItemPersistence();
+             String cacheNode = PortalCMSCacheLoader.VERSION_REF_NODE + "/" + PortalCMSCacheLoader.parseNodeName(versionRefs.getRefId());
+             pmCache.put(cacheNode,versionRefs.getRefId(),versionRefs);
+          }
+          else if (schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.wspPrefix))
+          {
+
+             WSPRefs wspRefs = new WSPRefs(refs.getId().toString(), out.toByteArray());
+             
+             //place this in the cache
+             wspRefs.resetCacheItemPersistence();
+             String cacheNode = PortalCMSCacheLoader.WSP_REF_NODE + "/" + PortalCMSCacheLoader.parseNodeName(wspRefs.getRefId());
+             pmCache.put(cacheNode,wspRefs.getRefId(),wspRefs);
+          }
+       }
+       catch (Exception e)
+       {
+          String msg = "failed to write reference state: " + refs.getId();
+          log.error(msg, e);
+          throw new ItemStateException(msg, e);
+       }
+       finally
+       {
+          try
+          {
+             out.close();
+          }
+          catch (Exception e)
+          {
+             e.printStackTrace();
+          }
+       }
+   }
+   
+   /**
+    *
+    */
+   private void destroy(NodeReferences refs) throws ItemStateException
+   {
+       if (!initialized)
+       {
+          throw new IllegalStateException("not initialized");
+       }
+
+       String id = refs.getId().toString();
+       String cacheNodeName = PortalCMSCacheLoader.parseNodeName(id);
+       try
+       {
+           if (schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.versionPrefix))
+           {
+               pmCache.remove(PortalCMSCacheLoader.VERSION_REF_NODE+"/"+cacheNodeName,id);
+           }
+           else if(schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.wspPrefix))
+           {
+               pmCache.remove(PortalCMSCacheLoader.WSP_REF_NODE+"/"+cacheNodeName,id);
+           }
+       }
+       catch (Exception e)
+       {
+          String msg = "failed to delete reference state: " + refs.getId();
+          log.error(msg, e);
+          throw new ItemStateException(msg, e);
+       }
+   }          
+    //----------------------------------------------------------------------------------------------------------------------------------------
+    /**
+    *
+    */
+   public void close() throws Exception
+   {
+      if (!initialized)
+      {
+         throw new IllegalStateException("not initialized");
+      }
+
+      try
+      {
+         if (externalBLOBs)
+         {
+            //close BLOB file system
+            blobFS.close();
+            blobFS = null;
+         }
+         blobStore = null;
+      }
+      finally
+      {
+         initialized = false;
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public NodeState createNew(NodeId id)
+   {
+      return new NodeState(id, null, null, NodeState.STATUS_NEW, false);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public PropertyState createNew(PropertyId id)
+   {
+      return new PropertyState(id, PropertyState.STATUS_NEW, false);
+   }
+   
+    /**
+     * 
+     */
+    public void store(ChangeLog changeLog) throws ItemStateException
+    {
+       Session session = null;
+       Transaction tx = null;
+       try
+       {
+          session = Tools.getOpenSession();
+          tx = session.beginTransaction();
+          storeHB(changeLog);
+          tx.commit();
+       }
+       catch (ItemStateException e)
+       {
+          tx.rollback();
+          throw e;
+       }
+       finally
+       {
+          Tools.closeSession(session);            
+       }
+    }
+    
+    private Blob createBlob(byte[] bytes)
+    {
+       return Hibernate.createBlob(bytes);
+       //return new ByteArrayBlob(bytes);
+    }
+
+    public void storeHB(ChangeLog changeLog) throws ItemStateException
+    {
+       Iterator iter = changeLog.deletedStates();
+       while (iter.hasNext())
+       {
+          ItemState state = (ItemState) iter.next();
+          if (state.isNode())
+          {
+             destroy((NodeState) state);
+          }
+          else
+          {
+             destroy((PropertyState) state);
+          }
+       }
+       iter = changeLog.addedStates();
+       while (iter.hasNext())
+       {
+          ItemState state = (ItemState) iter.next();
+          if (state.isNode())
+          {
+             store((NodeState) state);
+          }
+          else
+          {
+             store((PropertyState) state);
+          }
+       }
+       iter = changeLog.modifiedStates();
+       while (iter.hasNext())
+       {
+          ItemState state = (ItemState) iter.next();
+          if (state.isNode())
+          {
+             update((NodeState) state);
+          }
+          else
+          {
+             update((PropertyState) state);
+          }
+       }
+       iter = changeLog.modifiedRefs();
+       while (iter.hasNext())
+       {
+          NodeReferences refs = (NodeReferences) iter.next();
+          if (refs.hasReferences())
+          {
+             store(refs);
+          }
+          else
+          {
+             if (exists(refs.getId()))
+             {
+                destroy(refs);
+             }
+          }
+       }
+    }
+
+    /**
+     *
+     */
+    protected boolean exists(String blobid) throws ItemStateException
+    {
+       return exists(blobSelectExist, blobid);
+    }
+    
+    /**
+     * 
+     *
+     */
+    private boolean exists(String query, String id) throws ItemStateException
+    {
+       if (!initialized)
+       {
+          throw new IllegalStateException("not initialized");
+       }
+
+       Session session = Tools.getOpenSession();
+       try
+       {
+          List rs = session.createQuery(query).setCacheable(true).setString(0, id).list();
+          Iterator iter = rs.iterator();
+          return iter.hasNext();
+       }
+       catch (Exception e)
+       {
+          String msg = "failed to check existence of node state: " + id;
+          log.error(msg, e);
+          throw new ItemStateException(msg, e);
+       }
+       finally
+       {
+          Tools.closeSession(session);
+       }
+
+    }
+    //-------------------------------------------------< misc. helper methods >
+    protected void logException(String message, SQLException se)
+    {
+       if (message != null)
+       {
+          log.error(message);
+       }
+       log.error("    reason: " + se.getMessage());
+       log.error("state/code: " + se.getSQLState() + "/" + se.getErrorCode());
+       log.debug("      dump:", se);
+    }
+    //--------------------------------------------------------< inner classes >
+    class DbBLOBStore implements BLOBStore
+    {
+
+       /**
+        *
+        */
+       public String createId(PropertyId id, int index)
+       {
+          // the blobId is a simple string concatenation of id plus index
+          StringBuffer sb = new StringBuffer();
+          sb.append(id.toString());
+          sb.append('[');
+          sb.append(index);
+          sb.append(']');
+          return sb.toString();
+       }
+
+       /**
+        *
+        */
+       public InputStream get(String blobId) throws Exception
+       {
+          Session session = Tools.getCurrentSession();
+          try
+          {
+             List rs = session.createQuery(blobSelectData).setCacheable(true).setString(0, blobId).list();
+             Iterator iter = rs.iterator();
+             java.sql.Blob blob = (java.sql.Blob) iter.next();
+             InputStream is = blob.getBinaryStream();
+             return is;
+          }
+          catch (Exception e)
+          {
+             if (e instanceof NoSuchItemStateException)
+             {
+                throw (NoSuchItemStateException) e;
+             }
+             String msg = "failed to read binary data: " + blobId;
+             log.error(msg, e);
+             throw new ItemStateException(msg, e);
+          }
+       }
+
+       /**
+        *
+        */
+       public void put(String blobId, InputStream in, long size) throws Exception
+       {
+          boolean update = exists(blobId);
+
+          Session session = Tools.getCurrentSession();
+
+          if (update)
+          {
+             try
+             {
+
+                Query query = session.createQuery(blobSelect).setCacheable(true);
+                if (schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.versionPrefix))
+                {
+                   query.setString(0, blobId);
+                   VersionBinVal versionNode = (VersionBinVal) query.uniqueResult();
+                   if (versionNode == null)
+                   {
+                      throw new Exception("No such Node: " + blobId);
+                   }
+                   versionNode.setId(blobId);
+                   versionNode.setData(Hibernate.createBlob(in));
+                }
+                else if (schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.wspPrefix))
+                {
+                   query.setString(0, blobId);
+                   WSPBinVal wspNode = (WSPBinVal) query.uniqueResult();
+                   if (wspNode == null)
+                   {
+                      throw new Exception("No such Node: " + blobId);
+                   }
+                   wspNode.setId(blobId);
+                   wspNode.setData(Hibernate.createBlob(in));
+                }
+             }
+             catch (Exception e)
+             {
+                String msg = "failed to write node state: " + blobId;
+                log.error(msg, e);
+                throw new ItemStateException(msg, e);
+             }
+          }
+          else
+          // insert
+          {
+             try
+             {
+
+                if (schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.versionPrefix))
+                {
+                   VersionBinVal versionNode = new VersionBinVal(blobId, Hibernate.createBlob(in));
+                   session.save(versionNode);
+                }
+                else if (schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.wspPrefix))
+                {
+                   WSPBinVal wspNode = new WSPBinVal(blobId, Hibernate.createBlob(in));
+                   session.save(wspNode);
+                }
+             }
+             catch (Exception e)
+             {
+                String msg = "failed to write node state: " + blobId;
+                log.error(msg, e);
+                throw new ItemStateException(msg, e);
+             }
+          }
+       }
+
+       /**
+        *
+        */
+       //      public synchronized boolean remove(String blobId) throws Exception
+       public boolean remove(String blobId) throws Exception
+       {
+          Session session = Tools.getCurrentSession();
+          try
+          {
+             Query query = session.createQuery(nodeBinValSelect).setCacheable(true).setString(0, blobId);
+             Object result = query.uniqueResult();
+             if (result != null)
+             {
+                session.delete(result);
+             }
+             return true;
+          }
+          catch (Exception e)
+          {
+             String msg = "failed to delete binval: " + blobId;
+             log.error(msg, e);
+             throw new ItemStateException(msg, e);
+          }
+       }
+    }        
+}

Added: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/PortalCMSCacheLoader.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/PortalCMSCacheLoader.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/PortalCMSCacheLoader.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -0,0 +1,845 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.cms.hibernate.state;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Collections;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.TreeCache;
+import org.jboss.cache.loader.CacheLoader;
+import org.jboss.cache.Modification;
+
+import org.jboss.portal.cms.hibernate.state.Base;
+import org.jboss.portal.cms.hibernate.state.WSPProp;
+import org.jboss.portal.cms.hibernate.state.VersionProp;
+import org.jboss.portal.cms.hibernate.state.WSPNode;
+import org.jboss.portal.cms.hibernate.state.VersionNode;
+
+import org.apache.log4j.Logger;
+import org.hibernate.Session;
+
+
+/*
+ * Created on Aug 29, 2006
+ *
+ * @author <a href="mailto:sohil.shah at jboss.com">Sohil Shah</a>
+ */
+public class PortalCMSCacheLoader implements CacheLoader 
+{
+    /**
+     * Logger instance
+     */
+    private static Logger log = Logger.getLogger(PortalCMSCacheLoader.class);
+    
+    /**
+     * 
+     */
+    private static final String loadWSPProps = "from org.jboss.portal.cms.hibernate.state.WSPProp";
+    private static final String loadWSPPropChildren = "select property.propId from org.jboss.portal.cms.hibernate.state.WSPProp property";
+    private static final String loadWSPProp = "from org.jboss.portal.cms.hibernate.state.WSPProp property where property.propId=?";
+    private static final String loadVersionProps = "from org.jboss.portal.cms.hibernate.state.VersionProp";  
+    private static final String loadVersionPropChildren = "select property.propId from org.jboss.portal.cms.hibernate.state.VersionProp property";
+    private static final String loadVersionProp = "from org.jboss.portal.cms.hibernate.state.VersionProp property where property.propId=?";
+    
+    /**
+     * 
+     */
+    private static final String loadWSPNodes = "from org.jboss.portal.cms.hibernate.state.WSPNode";
+    private static final String loadWSPNodeChildren = "select node.nodeId from org.jboss.portal.cms.hibernate.state.WSPNode node";
+    private static final String loadWSPNode = "from org.jboss.portal.cms.hibernate.state.WSPNode node where node.nodeId=?";
+    private static final String loadVersionNodes = "from org.jboss.portal.cms.hibernate.state.VersionNode";
+    private static final String loadVersionNodeChildren = "select node.nodeId from org.jboss.portal.cms.hibernate.state.VersionNode node";
+    private static final String loadVersionNode = "from org.jboss.portal.cms.hibernate.state.VersionNode node where node.nodeId=?";
+    
+    /**
+     * 
+     */
+    private static final String loadWSPRefs = "from org.jboss.portal.cms.hibernate.state.WSPRefs";
+    private static final String loadWSPRefsChildren = "select ref.refId from org.jboss.portal.cms.hibernate.state.WSPRefs ref";
+    private static final String loadWSPRef = "from org.jboss.portal.cms.hibernate.state.WSPRefs ref where ref.refId=?";
+    private static final String loadVersionRefs = "from org.jboss.portal.cms.hibernate.state.VersionRefs";
+    private static final String loadVersionRefsChildren = "select ref.refId from org.jboss.portal.cms.hibernate.state.VersionRefs ref";
+    private static final String loadVersionRef = "from org.jboss.portal.cms.hibernate.state.VersionRefs ref where ref.refId=?";
+    
+    
+    /**
+     * 
+     */
+    public static final String WSP_PROP_NODE = "/wsp_prop";
+    public static final String VERSION_PROP_NODE = "/version_prop";
+    public static final String WSP_NODE_NODE = "/wsp_node";
+    public static final String VERSION_NODE_NODE = "/version_node";
+    public static final String WSP_REF_NODE = "/wsp_ref";
+    public static final String VERSION_REF_NODE = "/version_ref";
+    
+    /**
+     * map of propertyId-nodeName map
+     */
+    private static Map nodeNames = Collections.synchronizedMap(new HashMap());
+    
+    /**
+     * 
+     */
+    private TreeCache cache = null;
+    
+    
+    /**
+     * 
+     */
+    public void setConfig(Properties properties) 
+    {
+    }
+
+    /**
+     * 
+     */
+    public void setCache(TreeCache cache) 
+    {
+        this.cache = cache;                
+    }
+
+    /**
+     * 
+     */
+    public Set getChildrenNames(Fqn fqn) throws Exception 
+    {
+        Set children = null;
+        
+        if(fqn.toString().equals("/"))
+        {
+            children = new HashSet();
+            children.add(WSP_PROP_NODE.substring(1));
+            children.add(VERSION_PROP_NODE.substring(1));
+            children.add(WSP_NODE_NODE.substring(1));
+            children.add(VERSION_NODE_NODE.substring(1));
+        }
+        else if(fqn.toString().equals(WSP_PROP_NODE))
+        {
+            children = this.getChildrenNames(loadWSPPropChildren);
+        }
+        else if(fqn.toString().equals(VERSION_PROP_NODE))
+        {
+            children = this.getChildrenNames(loadVersionPropChildren);
+        }
+        else if(fqn.toString().equals(WSP_NODE_NODE))
+        {
+            children = this.getChildrenNames(loadWSPNodeChildren);
+        }
+        else if(fqn.toString().equals(VERSION_NODE_NODE))
+        {
+            children = this.getChildrenNames(loadVersionNodeChildren);
+        }
+        else if(fqn.toString().equals(WSP_REF_NODE))
+        {
+            children = this.getChildrenNames(loadWSPRefsChildren);
+        }
+        else if(fqn.toString().equals(VERSION_REF_NODE))
+        {
+            children = this.getChildrenNames(loadVersionRefsChildren);
+        }
+        
+        if(children!=null)
+        {
+            children = Collections.unmodifiableSet(children);
+        }
+        
+        return children;
+    }
+    
+    /**
+     * 
+     */
+    public boolean exists(Fqn fqn) throws Exception 
+    {
+        boolean exists = false;
+        
+        //node calculation
+        String node = fqn.toString();
+        String nodeName = "";
+        int lastIndex = node.lastIndexOf('/');
+        if(lastIndex>0)
+        {
+            nodeName = node.substring(lastIndex+1);
+        }
+        String query = null;
+        
+        if(
+                node.equals("/") 
+        )
+        {
+            exists = true;
+            return exists;
+        }
+        else if(node.startsWith(WSP_PROP_NODE))
+        {
+            query = loadWSPProp;
+        }
+        else if(node.startsWith(VERSION_PROP_NODE))
+        {
+            query = loadVersionProp;
+        }
+        else if(node.startsWith(WSP_NODE_NODE))
+        {
+            query = loadWSPNode;
+        }
+        else if(node.startsWith(VERSION_NODE_NODE))
+        {
+            query = loadVersionNode;
+        }
+        else if(node.startsWith(WSP_REF_NODE))
+        {
+            query = loadWSPRef;
+        }
+        else if(node.startsWith(VERSION_REF_NODE))
+        {
+            query = loadVersionRef;
+        }
+        
+        if(query!=null && query.trim().length()>0)
+        {
+	        String id = PortalCMSCacheLoader.lookupNodeId(nodeName); 
+	        if(id!=null && id.trim().length()>0)
+	        {
+	            Object nodeValue = this.loadNode(query,id);
+	            if(nodeValue!=null)
+	            {
+	                exists = true;
+	            }	            
+	        }
+        }
+        
+        return exists;
+    }
+
+    /**
+     * 
+     */
+    public Map get(Fqn fqn) throws Exception 
+    {
+        Map map = null;
+        
+        //node calculation
+        String node = fqn.toString();
+        String nodeName = "";
+        int lastIndex = node.lastIndexOf('/');
+        if(lastIndex>0)
+        {
+            nodeName = node.substring(lastIndex+1);
+        }
+        String query = null;
+                
+        if(node.startsWith(WSP_PROP_NODE))
+        {
+            query = loadWSPProp;
+        }
+        else if(node.startsWith(VERSION_PROP_NODE))
+        {   
+            query = loadVersionProp;
+        }
+        else if(node.startsWith(WSP_NODE_NODE))
+        {          
+            query = loadWSPNode;
+        }
+        else if(node.startsWith(VERSION_NODE_NODE))
+        {          
+            query = loadVersionNode;
+        }
+        else if(node.startsWith(WSP_REF_NODE))
+        {          
+            query = loadWSPRef;
+        }
+        else if(node.startsWith(VERSION_REF_NODE))
+        {          
+            query = loadVersionRef;
+        }
+        
+        if(query != null && query.trim().length()>0)
+        {
+            String id = PortalCMSCacheLoader.lookupNodeId(nodeName);
+            if(id !=null && id.trim().length()>0)
+            {
+	            Object nodeValue = this.loadNode(query,id);
+	            if(nodeValue!=null)
+	            {
+	                map = new HashMap();
+	                map.put(id,nodeValue);
+	            }	            
+            }
+        }
+        
+        return map;
+    }
+
+    /**
+     * semantically, if the fqn node does not exist, the entire node needs to be created..
+     * In this cacheLoader's case, the node not existing in the database is not an option.
+     * that scenario never happens
+     * 
+     * returns the oldValue if its found or a new value is created
+     */
+    public Object put(Fqn fqn,Object key,Object value) throws Exception 
+    {
+        Object oldValue = null;
+        String node = fqn.toString();
+        
+        if(node.startsWith(WSP_PROP_NODE) && value instanceof WSPProp)
+        {
+            if(((Base)value).isPersistCacheItem())
+            {
+                oldValue = this.saveWSPPropNodeEntry((WSPProp)value);
+            }
+            ((Base)value).resetCacheItemPersistence();
+        }
+        else if(node.startsWith(VERSION_PROP_NODE) && value instanceof VersionProp)
+        {
+            if(((Base)value).isPersistCacheItem())
+            {
+                oldValue = this.saveVersionPropNodeEntry((VersionProp)value);
+            }
+            ((Base)value).resetCacheItemPersistence();
+        }
+        else if(node.startsWith(WSP_NODE_NODE) && value instanceof WSPNode)
+        {
+            if(((Base)value).isPersistCacheItem())
+            {
+                oldValue = this.saveWSPNodeNodeEntry((WSPNode)value);
+            }
+            ((Base)value).resetCacheItemPersistence();
+        }
+        else if(node.startsWith(VERSION_NODE_NODE) && value instanceof VersionNode)
+        {
+            if(((Base)value).isPersistCacheItem())
+            {
+                oldValue = this.saveVersionNodeNodeEntry((VersionNode)value);
+            }
+            ((Base)value).resetCacheItemPersistence();
+        }
+        else if(node.startsWith(WSP_REF_NODE) && value instanceof WSPRefs)
+        {
+            if(((Base)value).isPersistCacheItem())
+            {
+                oldValue = this.saveWSPRefNodeEntry((WSPRefs)value);
+            }
+            ((Base)value).resetCacheItemPersistence();
+        }
+        else if(node.startsWith(VERSION_REF_NODE) && value instanceof VersionRefs)
+        {
+            if(((Base)value).isPersistCacheItem())
+            {
+                oldValue = this.saveVersionRefNodeEntry((VersionRefs)value);
+            }
+            ((Base)value).resetCacheItemPersistence();
+        }
+        
+        return oldValue;
+    }
+
+    /**
+     * 
+     */
+    public void put(Fqn fqn,Map attributes) throws Exception 
+    {
+        if(attributes!=null)
+        {
+            Set keys = attributes.keySet();
+            for(Iterator itr=keys.iterator();itr.hasNext();)
+            {
+                Object key = itr.next();
+                Object value = attributes.get(key);
+                this.put(fqn,key,value);
+            }
+        }
+    }
+
+    /**
+     * 
+     */
+    public void put(List modifications) throws Exception 
+    {
+        if(modifications!=null)
+        {
+            for(int i = 0; i < modifications.size(); ++i)
+            {
+               Modification m = (Modification) modifications.get(i);
+               switch(m.getType())
+               {
+                  case Modification.PUT_DATA:
+                     put(m.getFqn(),m.getData());
+                     break;
+                  case Modification.PUT_DATA_ERASE:
+                     put(m.getFqn(), m.getData());
+                     break;
+                  case Modification.PUT_KEY_VALUE:
+                     put(m.getFqn(),m.getKey(),m.getValue());
+                     break;
+                  case Modification.REMOVE_DATA:
+                     removeData(m.getFqn());
+                     break;
+                  case Modification.REMOVE_KEY_VALUE:
+                     remove(m.getFqn(),m.getKey());
+                     break;
+                  case Modification.REMOVE_NODE:
+                     remove(m.getFqn());
+                     break;
+                  default:
+                     throw new IllegalStateException("Unexpected modification code: " + m.getType());
+               }
+            }
+        }
+    }
+
+    /**
+     * 
+     */
+    public Object remove(Fqn fqn, Object key) throws Exception 
+    {
+        Object removedValue = null;
+        String node = fqn.toString();
+        String id = (String)key;
+        String query = null;
+        
+        
+        if(node.startsWith(WSP_PROP_NODE))
+        {
+            query = loadWSPProp;
+        }
+        else if(node.startsWith(VERSION_PROP_NODE))
+        {   
+            query = loadVersionProp;
+        }
+        else if(node.startsWith(WSP_NODE_NODE))
+        {          
+            query = loadWSPNode;
+        }
+        else if(node.startsWith(VERSION_NODE_NODE))
+        {          
+            query = loadVersionNode;
+        }
+        else if(node.startsWith(WSP_REF_NODE))
+        {          
+            query = loadWSPRef;
+        }
+        else if(node.startsWith(VERSION_REF_NODE))
+        {          
+            query = loadVersionRef;
+        }
+        
+        if(query != null && query.trim().length()>0)
+        {
+            removedValue = this.delete(query,id);
+        }
+        
+        return removedValue;
+    }
+
+    /**
+     * 
+     */
+    public void remove(Fqn fqn) throws Exception 
+    {
+        //just for safety this is not implemented.
+        //the cache should not be used for this kind of stuff
+        
+        //the admin tool is suited for that
+    }
+
+    /**
+     * 
+     */
+    public void removeData(Fqn fqn) throws Exception 
+    {
+        //just for safety this is not implemented.
+        //the cache should not be used for this kind of stuff
+        
+        //the admin tool is suited for that
+    }
+    //------------cache unit of work transaction-management--------------------------------------------------------------------------------------------------------------------    
+    /**
+     * 
+     */
+    public void prepare(Object tx,List modifications,boolean one_phase) throws Exception 
+    {                
+        this.put(modifications);
+    }
+
+    /**
+     * 
+     */
+    public void commit(Object tx) throws Exception 
+    {                                             
+    }
+
+    /**
+     * 
+     */
+    public void rollback(Object tx) 
+    {                               
+    }
+    //--------------------------------------------------------------------------------------------------------------------------------------------------------
+    /**
+     * 
+     */
+    public byte[] loadEntireState() throws Exception 
+    {
+        //loading the entire cms into a byteBuffer and sending it over the network to a remote cache
+        //is not feasible for this loader
+        //plus, all distributed caches/cache loaders will be loading/saving data to the same database
+        //so the content is in sync across all the caches in the cluster
+        return null;
+    }
+
+    /**
+     * 
+     */
+    public void storeEntireState(byte[] arg0) throws Exception 
+    {
+        //no need for this since all the distributed caches/cacheloaders will be loading/saving data to the same
+        //database
+    }
+    //------Service lifecycle implementation---------------------------------------------------------------------------------------------------------------------
+    /**
+     * 
+     */
+    public void create() throws Exception 
+    {
+    }
+
+    /**
+     * 
+     */
+    public void start() throws Exception 
+    { 
+        log.debug("------------------------------------------------------");
+        log.debug("PersistenceManager Cache successfully started.....(ClusterName="+this.cache.getClusterName()+")");
+        log.debug("------------------------------------------------------");
+    }
+
+    /**
+     * 
+     */
+    public void stop() 
+    {
+        this.cache = null;
+    }
+
+    /**
+     * 
+     */
+    public void destroy() 
+    {
+    }
+    //------internal implementation-----------------------------------------------------------------------------------------------------------------------                    
+    /**
+     * 
+     *
+     */
+    private Object saveWSPPropNodeEntry(WSPProp wspProp) throws Exception
+    {
+        Object oldValue = null;
+        
+        oldValue = this.loadManagedNode(loadWSPProp,wspProp.getPropId());
+        if(oldValue!=null)
+        {
+            Integer id = ((WSPProp)oldValue).getKey();
+            wspProp.setKey(id);
+        }
+        else
+        {
+            wspProp.setKey(null);
+        }
+        this.save(wspProp);
+        
+        return oldValue;
+    }
+        
+    /**
+     * 
+     *
+     */
+    private Object saveVersionPropNodeEntry(VersionProp versionProp) throws Exception
+    {
+        Object oldValue = null;
+        
+        oldValue = this.loadManagedNode(loadVersionProp,versionProp.getPropId());
+        if(oldValue!=null)
+        {
+            Integer id = ((VersionProp)oldValue).getKey();
+            versionProp.setKey(id);
+        }
+        else
+        {
+            versionProp.setKey(null);
+        }
+        this.save(versionProp);
+        
+        return oldValue;
+    }
+    
+    /**
+     * 
+     *
+     */
+    private Object saveWSPNodeNodeEntry(WSPNode wspNode) throws Exception
+    {
+        Object oldValue = null;
+        
+        oldValue = this.loadManagedNode(loadWSPNode,wspNode.getNodeId());
+        if(oldValue!=null)
+        {
+            Integer id = ((WSPNode)oldValue).getKey();
+            wspNode.setKey(id);
+        }
+        else
+        {
+            wspNode.setKey(null);
+        }
+        this.save(wspNode);
+        
+        return oldValue;
+    }
+    
+    /**
+     * 
+     *
+     */
+    private Object saveVersionNodeNodeEntry(VersionNode versionNode) throws Exception
+    {
+        Object oldValue = null;
+        
+        oldValue = this.loadManagedNode(loadVersionNode,versionNode.getNodeId());
+        if(oldValue!=null)
+        {
+            Integer id = ((VersionNode)oldValue).getKey();
+            versionNode.setKey(id);
+        }
+        else
+        {
+            versionNode.setKey(null);
+        }
+        this.save(versionNode);
+        
+        return oldValue;
+    }
+    
+    /**
+     * 
+     *
+     */
+    private Object saveWSPRefNodeEntry(WSPRefs wspRef) throws Exception
+    {
+        Object oldValue = null;
+        
+        oldValue = this.loadManagedNode(loadWSPRef,wspRef.getRefId());
+        if(oldValue!=null)
+        {
+            Integer id = ((WSPRefs)oldValue).getKey();
+            wspRef.setKey(id);
+        }
+        else
+        {
+            wspRef.setKey(null);
+        }
+        this.save(wspRef);
+        
+        return oldValue;
+    }
+    
+    /**
+     * 
+     *
+     */
+    private Object saveVersionRefNodeEntry(VersionRefs versionRef) throws Exception
+    {
+        Object oldValue = null;
+        
+        oldValue = this.loadManagedNode(loadVersionRef,versionRef.getRefId());
+        if(oldValue!=null)
+        {
+            Integer id = ((VersionRefs)oldValue).getKey();
+            versionRef.setKey(id);
+        }
+        else
+        {
+            versionRef.setKey(null);
+        }
+        this.save(versionRef);
+        
+        return oldValue;
+    }
+    //-----------------------------------------------------------------------------------------------------------------------------------------------------
+    /**
+     * 
+     *
+     */
+    private Set getChildrenNames(String query) throws Exception
+    {
+        Set children = null;
+        Session session = null;
+        try
+        {
+            session = Tools.getOpenSession();
+            
+            List rs = session.createQuery(query).list();
+            for(Iterator itr=rs.iterator();itr.hasNext();)
+            {
+                String id = (String)itr.next();   
+                if(children==null)
+                {
+                    children = new HashSet();
+                }
+                children.add(PortalCMSCacheLoader.parseNodeName(id));
+            }
+        }
+        finally
+        {
+            Tools.closeSession(session);
+        }
+        return children;
+    }
+    
+    /**
+     * 
+     *
+     */
+    private Object loadNode(String query,String id) throws Exception
+    {
+        Object node = null;
+        Session session = null;
+        try
+        {
+            session = Tools.getOpenSession();
+            
+            //node = session.createQuery(query).setString(0,id).uniqueResult();
+            List rs = session.createQuery(query).setString(0,id).list();
+            if(rs !=null && !rs.isEmpty())
+            {
+                node = rs.iterator().next();
+            }
+        }
+        finally
+        {
+            Tools.closeSession(session);
+        }
+        return node;
+    }
+    
+    /**
+     * 
+     *
+     */
+    private Object loadManagedNode(String query,String id) throws Exception
+    {
+        Object node = null;
+        
+        Session session = Tools.getCurrentSession();        
+        //node = session.createQuery(query).setString(0,id).uniqueResult();
+        List rs = session.createQuery(query).setString(0,id).list();
+        if(rs !=null && !rs.isEmpty())
+        {
+            node = rs.iterator().next();
+        }
+                
+        return node;
+    }
+    
+    /**
+     * 
+     */
+    private void save(Object object) throws Exception
+    {
+        Session session = Tools.getCurrentSession();
+        if(((Base)object).getKey() != null)
+        {
+            session.merge(object);
+        }
+        else
+        {
+            session.save(object);
+        }
+    }
+    
+    /**
+     * 
+     *
+     */
+    private Object delete(String loadQuery,String id) throws Exception
+    {
+        Object removedValue = null;
+        removedValue = this.loadManagedNode(loadQuery,id);
+        if(removedValue!=null)
+        {
+            Session session = Tools.getCurrentSession();            
+            session.delete(removedValue);            
+        }
+        return removedValue;
+    }
+    //---------------nodeName related methods-------------------------------------------------------------------------------------------------------------
+    /**
+     * 
+     *
+     */
+    public static String parseNodeName(String id)
+    {
+        String node = (String)PortalCMSCacheLoader.nodeNames.get(id);
+        
+        if(node == null)
+        {
+            node = id.replace('/','_');
+            node = node.replace(':','_');
+            node = node.replace('{','_');
+            node = node.replace('}','_');
+            PortalCMSCacheLoader.nodeNames.put(id,node);
+        }
+        
+        return node;
+    }
+    
+    /**
+     * 
+     *
+     */
+    private static String lookupNodeId(String nodeName)
+    {
+       String id = null;
+       
+       Object[] keys = PortalCMSCacheLoader.nodeNames.keySet().toArray();
+       for(int i=0;i<keys.length;i++)
+       {
+           String key = (String)keys[i];
+           String value = (String)PortalCMSCacheLoader.nodeNames.get(key);
+           if(value.equals(nodeName))
+           {
+               id = key;
+               break;
+           }
+       }
+       
+       return id;
+    }
+}

Added: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/Tools.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/Tools.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/Tools.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -0,0 +1,199 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.cms.hibernate.state;
+
+import javax.naming.InitialContext;
+
+import org.apache.log4j.Logger;
+
+import org.hibernate.cfg.Configuration;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Query;
+import org.hibernate.HibernateException;
+import org.hibernate.metadata.ClassMetadata;
+import org.hibernate.tool.hbm2ddl.SchemaExport;
+import org.hibernate.Transaction;
+
+/*
+ * Created on Aug 29, 2006
+ * 
+ * A Tool for performing some Hibernate related utilities. This is designed to work in both managed as well as non-managed environments
+ *
+ * @author <a href="mailto:sohil.shah at jboss.com">Sohil Shah</a>
+ */
+public class Tools 
+{
+	private static final Logger log = Logger.getLogger(Tools.class);
+	
+	//hibernate configuration relation information
+	private static SessionFactory sessionFactory = null;
+	private static Configuration cfg = null;
+	private static boolean autoClose = false;
+		
+    /**
+     * 
+     *
+     */
+	public static void init(String jndiName)
+	{
+	    if(Tools.sessionFactory == null)
+	    {	        
+			try
+			{
+			    log.debug("Loading the PersistenceManager Hibernate System (Started)...........................");
+			    
+			    boolean loadSuccess = true;
+			    try
+			    {
+			        //just to initialize the session factory
+			        Tools.sessionFactory = (SessionFactory)new InitialContext().lookup(jndiName);
+			    }
+			    catch(Exception e)
+			    {
+			        //some reason this is not found in JNDI environment....try and load from hibernate.cfg.xml from 
+			        //classpath
+			        loadSuccess = false;
+			    }
+			    
+			    if(!loadSuccess)
+			    {
+				    //configure session factory from configuration
+				    Tools.cfg = new Configuration();
+					Tools.cfg.configure();
+					Tools.sessionFactory = Tools.cfg.buildSessionFactory();
+					Tools.generateSiteSchema(Tools.cfg);
+			    }
+				
+				
+				log.debug("Loading the PersistenceManager Hibernate System (Done)...........................");
+			}
+			catch(Exception e)
+			{
+				log.error("org.jboss.portal.cms.hibernate.state.Tools",e);
+			}			
+	    }
+	}
+    
+    //---------------------------------------------------------------------------------------------------------------------------------------------------
+	/**
+	 * 
+	 */
+	public static SessionFactory getSessionFactory()
+	{
+	    return Tools.sessionFactory;
+	}
+	
+    /**
+     * 
+     * @return
+     */
+	public static Session getCurrentSession()
+	{        
+		Session session = Tools.sessionFactory.getCurrentSession();
+		return session;
+	}
+	
+    /**
+     * 
+     * @return
+     */
+	public static Session getOpenSession()
+	{        
+		Session session = Tools.sessionFactory.openSession();
+		return session;
+	}
+	
+	/**
+     * 
+     * @param session
+	 */	
+	public static void closeSession(Session session)
+	{
+		if(session!=null && session.isOpen() && !Tools.autoClose)
+		{
+		    session.close();
+		}
+	}
+	//-----------------------schema generation capabilities-------------------------------------------------------------------------------------------
+	/**
+     * 
+     * @param cfg
+	 */	
+	private static void generateSiteSchema(Configuration cfg)	
+	{				
+		if(!doesSiteSchemaExist())
+		{
+			SchemaExport export = new SchemaExport(cfg);
+			export.create(true, //print to the console
+					true //run inside the database
+			);
+		}
+		else
+		{
+			log.info("Site Schema successfully found....No need to recreate it.");
+		}
+	}
+	
+    /**
+     * 
+     * @return
+     */
+	private static boolean doesSiteSchemaExist()
+	{		
+		Session session = null;
+		Transaction tx = null;
+        try
+        {
+	         session = Tools.sessionFactory.openSession();
+	         tx = session.beginTransaction();
+	         ClassMetadata cmd = (ClassMetadata)Tools.sessionFactory.getAllClassMetadata().values().iterator().next();
+	         if(cmd!=null)
+	         {
+	             Query query = session.createQuery("from " + cmd.getEntityName());
+	             query.setFirstResult(0);
+	             query.setMaxResults(0);
+		         try
+		         {
+		               query.list();
+		         }
+	             catch (HibernateException e)
+	             {
+	               // We consider that exception means that the schema deos not exist
+	               return false;               
+	             }
+	         }             
+             //if I get here the schemaExists, dont recreate it
+             return true;
+        }
+        finally
+        {
+        	if(tx!=null)
+        	{
+        		tx.rollback(); //does not matter since this is only a read operation
+        		//this is only so that this operation executes within the context
+        		//of a transaction that performs any necessary cleanup automatically
+        	}
+        	Tools.closeSession(session);        	
+        }		
+	}
+}

Modified: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/VersionNode.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/VersionNode.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/VersionNode.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -27,52 +27,41 @@
 /**
  * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
  */
-public class VersionNode implements Serializable
+public class VersionNode extends Base implements Serializable
 {
    /** The serialVersionUID */
    private static final long serialVersionUID = -2699419131858972327L;
    
-   private Integer key;
-   private String id;
-   private java.sql.Blob data;
+   private String nodeId;
+   private byte[] data;
 
    public VersionNode()
    {
    }
 
-   public VersionNode(String id, Blob data)
+   public VersionNode(String id, byte[] data)
    {
-      this.key = null;
-      this.id = id;
+      this.nodeId = id;
       this.data = data;
    }
 
-   public Integer getKey()
+   
+   public String getNodeId()
    {
-      return key;
+      return nodeId;
    }
 
-   public void setKey(Integer key)
+   public void setNodeId(String id)
    {
-      this.key = key;
+      this.nodeId = id;
    }
 
-   public String getId()
+   public byte[] getData()
    {
-      return id;
-   }
-
-   public void setId(String id)
-   {
-      this.id = id;
-   }
-
-   public Blob getData()
-   {
       return data;
    }
 
-   public void setData(Blob data)
+   public void setData(byte[] data)
    {
       this.data = data;
    }

Modified: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/VersionProp.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/VersionProp.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/VersionProp.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -27,52 +27,41 @@
 /**
  * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
  */
-public class VersionProp implements Serializable
+public class VersionProp extends Base implements Serializable
 {
    /** The serialVersionUID */
    private static final long serialVersionUID = -699585138297339148L;
    
-   private Integer key;
-   private String id;
-   private java.sql.Blob data;
+   private String propId;
+   private byte[] data;
 
    public VersionProp()
    {
    }
 
-   public VersionProp(String id, Blob data)
+   public VersionProp(String id, byte[] data)
    {
-      this.key = null;
-      this.id = id;
+      this.propId = id;
       this.data = data;
    }
 
-   public Integer getKey()
+   
+   public String getPropId()
    {
-      return key;
+      return propId;
    }
 
-   public void setKey(Integer key)
+   public void setPropId(String id)
    {
-      this.key = key;
+      this.propId = id;
    }
 
-   public String getId()
+   public byte[] getData()
    {
-      return id;
-   }
-
-   public void setId(String id)
-   {
-      this.id = id;
-   }
-
-   public Blob getData()
-   {
       return data;
    }
 
-   public void setData(Blob data)
+   public void setData(byte[] data)
    {
       this.data = data;
    }

Modified: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/VersionRefs.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/VersionRefs.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/VersionRefs.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -22,59 +22,45 @@
 package org.jboss.portal.cms.hibernate.state;
 
 import java.io.Serializable;
-import java.sql.Blob;
 
 /**
  * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
  */
-public class VersionRefs implements Serializable
+public class VersionRefs extends Base implements Serializable
 {
    /** The serialVersionUID */
    private static final long serialVersionUID = -4096847492469682729L;
    
-   private Integer key;
-   private String id;
-   private java.sql.Blob data;
+   private String refId;
+   private byte[] data;
 
    public VersionRefs()
    {
    }
 
-   public VersionRefs(String id, Blob data)
+   public VersionRefs(String refId, byte[] data)
    {
-      this.key = null;
-      this.id = id;
+      this.refId = refId;
       this.data = data;
    }
 
-   public Integer getKey()
+   public String getRefId()
    {
-      return key;
+      return this.refId;
    }
 
-   public void setKey(Integer key)
+   public void setRefId(String refId)
    {
-      this.key = key;
+      this.refId = refId;
    }
 
-   public String getId()
+   public byte[] getData()
    {
-      return id;
-   }
-
-   public void setId(String id)
-   {
-      this.id = id;
-   }
-
-   public Blob getData()
-   {
       return data;
    }
 
-   public void setData(Blob data)
+   public void setData(byte[] data)
    {
       this.data = data;
    }
-
 }

Modified: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/WSPNode.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/WSPNode.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/WSPNode.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -27,51 +27,39 @@
 /**
  * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
  */
-public class WSPNode implements Serializable
+public class WSPNode extends Base implements Serializable
 {
    /** The serialVersionUID */
    private static final long serialVersionUID = 624216529218745492L;
-   private Integer key;
-   private String id;
-   private java.sql.Blob data;
+   private String nodeId;
+   private byte[] data;
 
    public WSPNode()
    {
    }
 
-   public WSPNode(String id, Blob data)
+   public WSPNode(String id, byte[] data)
    {
-      this.key = null;
-      this.id = id;
+      this.nodeId = id;
       this.data = data;
    }
 
-   public Integer getKey()
+   public String getNodeId()
    {
-      return key;
+      return nodeId;
    }
 
-   public void setKey(Integer key)
+   public void setNodeId(String id)
    {
-      this.key = key;
+      this.nodeId = id;
    }
 
-   public String getId()
+   public byte[] getData()
    {
-      return id;
-   }
-
-   public void setId(String id)
-   {
-      this.id = id;
-   }
-
-   public Blob getData()
-   {
       return data;
    }
 
-   public void setData(Blob data)
+   public void setData(byte[] data)
    {
       this.data = data;
    }

Modified: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/WSPProp.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/WSPProp.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/WSPProp.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -27,51 +27,39 @@
 /**
  * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
  */
-public class WSPProp implements Serializable
+public class WSPProp extends Base implements Serializable
 {
    /** The serialVersionUID */
    private static final long serialVersionUID = 6490887142311625721L;
-   private Integer key;
-   private String id;
-   private java.sql.Blob data;
+   private String propId;
+   private byte[] data;
 
    public WSPProp()
    {
    }
 
-   public WSPProp(String id, Blob data)
+   public WSPProp(String id, byte[] data)
    {
-      this.key = null;
-      this.id = id;
+      this.propId = id;
       this.data = data;
    }
 
-   public Integer getKey()
+   public String getPropId()
    {
-      return key;
+      return propId;
    }
 
-   public void setKey(Integer key)
+   public void setPropId(String id)
    {
-      this.key = key;
+      this.propId = id;
    }
 
-   public String getId()
+   public byte[] getData()
    {
-      return id;
-   }
-
-   public void setId(String id)
-   {
-      this.id = id;
-   }
-
-   public Blob getData()
-   {
       return data;
    }
 
-   public void setData(Blob data)
+   public void setData(byte[] data)
    {
       this.data = data;
    }

Modified: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/WSPRefs.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/WSPRefs.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/hibernate/state/WSPRefs.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -22,58 +22,45 @@
 package org.jboss.portal.cms.hibernate.state;
 
 import java.io.Serializable;
-import java.sql.Blob;
 
 /**
  * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
  */
-public class WSPRefs implements Serializable
+public class WSPRefs extends Base implements Serializable
 {
    /** The serialVersionUID */
    private static final long serialVersionUID = 5259852110944824462L;
-   private Integer key;
-   private String id;
-   private java.sql.Blob data;
+   private String refId;
+   private byte[] data;
 
    public WSPRefs()
    {
    }
 
-   public WSPRefs(String id, Blob data)
+   public WSPRefs(String refId,byte[] data)
    {
-      this.key = null;
-      this.id = id;
+      this.refId = refId;
       this.data = data;
    }
 
-   public Integer getKey()
+  
+   public String getRefId()
    {
-      return key;
+      return this.refId;
    }
 
-   public void setKey(Integer key)
+   public void setRefId(String refId)
    {
-      this.key = key;
+      this.refId = refId;
    }
 
-   public String getId()
+   public byte[] getData()
    {
-      return id;
-   }
-
-   public void setId(String id)
-   {
-      this.id = id;
-   }
-
-   public Blob getData()
-   {
       return data;
    }
 
-   public void setData(Blob data)
+   public void setData(byte[] data)
    {
       this.data = data;
    }
-
 }

Modified: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -61,6 +61,8 @@
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
+import org.jboss.cache.Version;
+
 /**
  * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
  * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
@@ -160,6 +162,16 @@
     */
    public void startService() throws Exception
    {
+       //check the version of jbosscache being run
+       String cacheVersion = Version.getVersionString(Version.getVersionShort());
+       log.info("JBossCache Version="+cacheVersion);
+       
+       //set the proper logging level for JBossCache and JGroups
+       Logger cacheLogger = Logger.getLogger("org.jboss.cache");
+       cacheLogger.setLevel(Level.ERROR);
+       Logger groupsLogger = Logger.getLogger("org.jgroups");
+       groupsLogger.setLevel(Level.ERROR);
+       
       // See how long it takes us to start up
       StopWatch watch = new StopWatch(true);
       log.info("Starting JCR CMS");
@@ -383,103 +395,101 @@
    }
 
    public Object execute(Command cmd) throws CMSException
-   {
-      org.apache.jackrabbit.core.XASession session = null;
-      try
-      {
-         session = (org.apache.jackrabbit.core.XASession) jcr.login("anonid", "");
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException(e); // Fixme
-      }
-      // get XAResource
-      XAResource xares = session.getXAResource();
+   {      
+       org.apache.jackrabbit.core.XASession session = null;
+       try
+       {
+          session = (org.apache.jackrabbit.core.XASession) jcr.login("anonid", "");
+       }
+       catch (Exception e)
+       {
+          throw new RuntimeException(e); // Fixme
+       }
+       // get XAResource
+       XAResource xares = session.getXAResource();
 
-      // create dummy Xid
-      Xid xid = new Xid()
-      {
-         public byte[] getBranchQualifier()
-         {
-            return new byte[0];
-         }
+       // create dummy Xid
+       Xid xid = new Xid()
+       {
+          public byte[] getBranchQualifier()
+          {
+             return new byte[0];
+          }
 
-         public int getFormatId()
-         {
-            return 0;
-         }
+          public int getFormatId()
+          {
+             return 0;
+          }
 
-         public byte[] getGlobalTransactionId()
-         {
-            return new byte[0];
-         }
-      };
+          public byte[] getGlobalTransactionId()
+          {
+             return new byte[0];
+          }
+       };
 
-      boolean shouldCommit = false;
-      Object obj = new Object();
-      try
-      {
-         xares.start(xid, XAResource.TMNOFLAGS);
+       Object obj = new Object();
+       try
+       {
+          xares.start(xid,XAResource.TMNOFLAGS);
 
-         // .... add new nodes & properties and save them
-         JCRCommand jcrCmd = (JCRCommand) cmd;
-         JCRCommandContext ctx = new JCRCommandContext(session, commandFactory, defaultLocale);
-         jcrCmd.setContext(ctx);
-         
-         
-         if ((cmsStack != null) && (cmsStack.getInterceptors().length != 0))
-         {
-            jcrCmd.invoke(cmsStack.getInterceptors());
-         }
-         else
-         {
-            jcrCmd.dispatch();
-         }
-         obj = jcrCmd.getResult();
-
-         xares.end(xid, XAResource.TMSUCCESS);
-         xares.prepare(xid);
-         shouldCommit = true;
-      }
-      catch(Exception e)
-      {
-         if (e instanceof CMSException)
-         {
-            throw (CMSException)e;
-         }
-         else if (e instanceof RuntimeException)
-         {
-            throw (RuntimeException)e;
-         }
-         else
-         {
-            throw new CMSException(e);
-         }
-      }
-      finally
-      {
-         if (session != null)
-         {
-            try
-            {
-               session.save();
-               if(shouldCommit)
-               {
-                  xares.commit(xid, false);
-               }
-               else
-               {
-                  xares.rollback(xid);
-               }
-               session.logout();
-            }
-            catch(Exception e)
-            {
-               e.printStackTrace();
-            }
-         }
-      }
-      return obj;
+          // .... add new nodes & properties and save them
+          JCRCommand jcrCmd = (JCRCommand) cmd;
+          JCRCommandContext ctx = new JCRCommandContext(session, commandFactory, defaultLocale);
+          jcrCmd.setContext(ctx);
+          
+          
+          if ((cmsStack != null) && (cmsStack.getInterceptors().length != 0))
+          {
+             jcrCmd.invoke(cmsStack.getInterceptors());
+          }
+          else
+          {
+             jcrCmd.dispatch();
+          }
+          obj = jcrCmd.getResult();
+                   
+                            
+          //committ the transaction
+          xares.end(xid, XAResource.TMSUCCESS);
+          xares.prepare(xid);
+          session.save();
+          xares.commit(xid,false);
+       }
+       catch(Exception e)
+       {
+           e.printStackTrace();
+           try
+           {
+               xares.rollback(xid);
+           }
+           catch(Exception ex)
+           {
+               //we tried to roll it back...not sure what more we can do here
+               throw new CMSException(ex);
+           }
+           
+          if (e instanceof CMSException)
+          {
+             throw (CMSException)e;
+          }
+          else if (e instanceof RuntimeException)
+          {
+             throw (RuntimeException)e;
+          }
+          else
+          {
+             throw new CMSException(e);
+          }         
+       }
+       finally
+       {
+          if (session != null)
+          {                          
+              //must do this otherwise, the whole cms will hang
+              session.logout();                          
+          }
+       }
+       return obj;
    }
 
    public void setCmsStack(InterceptorStack cmsStack)

Modified: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ContentGetVersionsCommand.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ContentGetVersionsCommand.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ContentGetVersionsCommand.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -36,10 +36,12 @@
 import org.jboss.portal.cms.model.Content;
 import org.jboss.portal.cms.util.FileUtil;
 
+
 /**
  * Returns all versions for a given path, except the rootVersion.
  *
  * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
+ * @author <a href="mailto:sohil.shah at jboss.com">Sohil Shah</a>
  */
 public class ContentGetVersionsCommand extends JCRCommand
 {
@@ -60,30 +62,50 @@
       {
          Session session = context.getSession();
          Node fileNode = (Node) session.getItem(this.msFilePath);
+         
          VersionHistory vh = fileNode.getVersionHistory();
-         VersionIterator vi = vh.getAllVersions();
          Version liveVersion = vh.getVersionByLabel("LIVE");
+         Version rootVersion = vh.getRootVersion();
+         
+         
+         VersionIterator vi = vh.getAllVersions();         
          while(vi.hasNext()) // loop versions
          {
             Content content = new ContentImpl();
+                        
             Version version = vi.nextVersion();
-            if(!version.getName().equalsIgnoreCase("jcr:rootVersion"))  // ignore the root version
-            {
+            if(!(version.equals(rootVersion)))  // ignore the root version
+            {                
                NodeIterator ni = version.getNodes();
                while(ni.hasNext())
                {
                   Node node = ni.nextNode();
-
+                  
                   content.setTitle(node.getProperty("portalcms:title").getString());
                   content.setDescription(node.getProperty("portalcms:description").getString());
                   content.setLocale(new Locale(node.getProperty("portalcms:language").getString()));
 
+                  content.setVersionPath(node.getPath());
                   content.setBaseUUID(node.getProperty("jcr:frozenUuid").getString());
-                  content.setBasePath(session.getNodeByUUID(content.getBaseUUID()).getPath());
-                  content.setVersionPath(node.getPath());
+                  content.setBasePath(session.getNodeByUUID(content.getBaseUUID()).getPath());                  
                   content.setVersionUUID(node.getUUID());
-
-                  content.setBytes(FileUtil.getBytes(node.getProperty("jcr:data").getStream()));
+                  
+                  /**
+                   * TODO: integate content size as a node property instead of a derived value
+                   *       see explanation in comments
+                   */
+                  //this is the hacked code for now, until the size property is integrated end-to-end.
+                  //getting the size this way leads to unnecessary extraction of actual content
+                  //which slows the system down dramatically
+                  content.setBytes("".getBytes());
+                  
+                  //this should be the new code
+                  /*int size = 0;
+                  if(node.hasProperty("portalcms:size"))
+                  {
+                      size = Integer.parseInt(node.getProperty("portalcms:size").getString());
+                  }*/
+                  
                   content.setMimeType(node.getProperty("jcr:mimeType").getString());
                   content.setLastModified(node.getProperty("jcr:lastModified").getDate().getTime());
                   content.setName(node.getName());
@@ -94,11 +116,14 @@
                   {
                      content.setLive(true);
                   }
+                  
+                  
                   content.setEncoding(node.getProperty("jcr:encoding").getString());
+                                    
                   contents.addElement(content);
                }
             }
-         }
+         }          
       }
       catch(Exception e)
       {

Added: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/impl/jcr/command/FileUpdateAndVersionCommand.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/impl/jcr/command/FileUpdateAndVersionCommand.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/impl/jcr/command/FileUpdateAndVersionCommand.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -0,0 +1,100 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.cms.impl.jcr.command;
+
+import java.util.Calendar;
+
+import javax.jcr.Node;
+
+import org.apache.jackrabbit.value.BinaryValue;
+import org.apache.jackrabbit.value.DateValue;
+import org.jboss.portal.cms.CMSMimeMappings;
+import org.jboss.portal.cms.impl.jcr.JCRCommand;
+import org.jboss.portal.cms.impl.jcr.util.VersionUtil;
+import org.jboss.portal.cms.model.Content;
+import org.jboss.portal.cms.model.File;
+
+/**
+ * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
+ */
+public class FileUpdateAndVersionCommand extends JCRCommand
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 882238623005109537L;
+   File mFile;
+   boolean bMakeLive;
+
+   /**
+    * Updates a given file content in the repo, creating a new version.
+    *
+    * @param file      File obj to update
+    */
+   public FileUpdateAndVersionCommand(File file,boolean makeLive)
+   {
+      this.mFile = file;
+      this.bMakeLive = makeLive;
+   }
+
+   public Object execute()
+   {
+      try
+      {
+         Node contentNode = (Node) context.getSession().getItem(mFile.getContent().getBasePath());
+         contentNode.checkout();
+
+         contentNode.setProperty("portalcms:description", mFile.getContent().getDescription());
+         contentNode.setProperty("portalcms:title", mFile.getContent().getTitle());
+         contentNode.setProperty("portalcms:language", mFile.getContent().getLocale().getLanguage());
+         contentNode.setProperty("jcr:encoding", "UTF-8");
+         contentNode.setProperty("jcr:data", new BinaryValue(mFile.getContent().getBytes()));
+         contentNode.setProperty("jcr:lastModified", new DateValue(Calendar.getInstance()));
+
+         if (mFile.getContent().getMimeType() != null)
+         {
+            contentNode.setProperty("jcr:mimeType", mFile.getContent().getMimeType());
+         }
+         else
+         {
+            String fileExt = mFile.getBasePath().substring(mFile.getBasePath().lastIndexOf(".") + 1, mFile.getBasePath().length());
+            CMSMimeMappings mapper = new CMSMimeMappings();
+            if(mapper.getMimeType(fileExt) != null)
+            {
+               contentNode.setProperty("jcr:mimeType", mapper.getMimeType(fileExt));
+            }
+            else
+            {
+               contentNode.setProperty("jcr:mimeType", "application/octet-stream");
+            }
+         }                  
+         contentNode.save();
+         
+         //make a new version live version
+         Node versionNode = (Node)context.getSession().getItem(mFile.getContent().getBasePath());
+         VersionUtil.createVersion(versionNode,this.bMakeLive); 
+      }
+      catch(Exception e)
+      {
+          throw new RuntimeException(e);
+      }
+      return null;
+   }
+}

Modified: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/AbstractCMSTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/AbstractCMSTestCase.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/AbstractCMSTestCase.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -21,6 +21,8 @@
 */
 package org.jboss.portal.test.cms;
 
+import java.util.Map;
+
 import junit.framework.TestCase;
 
 import org.jboss.portal.test.framework.TestRuntimeContext;
@@ -40,10 +42,23 @@
    /** . */
    private TestRuntimeContext runtimeContext;
 
+   /**
+    * 
+    *
+    */
    public AbstractCMSTestCase(DataSourceSupport.Config dsCfg)
    {
       this.dsCfg = dsCfg;
    }
+   
+   /**
+    * 
+    *
+    */
+   public AbstractCMSTestCase(Map parametrization)
+   {
+      dsCfg = (DataSourceSupport.Config)parametrization.get("DataSourceConfig");
+   }
 
    public void setUp() throws Exception
    {

Added: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/clustering/CMSTestSuite.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/clustering/CMSTestSuite.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/clustering/CMSTestSuite.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -0,0 +1,49 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.test.cms.clustering;
+
+import junit.framework.Test;
+
+import org.jboss.portal.test.framework.container.client.TestSuite;
+import org.jboss.portal.test.framework.container.client.TestCase;
+import org.jboss.portal.test.framework.server.NodeId;
+
+/**
+ * @author <a href="mailto:sohil.shah at jboss.com">Sohil Shah</a>
+ */
+public class CMSTestSuite
+{
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("test-cms-cluster.war", new NodeId[]{NodeId.PORTS_01,NodeId.PORTS_02});
+      
+      //adding file create,update,delete operations in a cluster
+      suite.addTest(new TestCase(NodeId.PORTS_01, "testFileUpdate"));
+      suite.addTest(new TestCase(NodeId.PORTS_01, "testFileDelete"));
+      
+      
+      //adding folder create,update,delete operations in a cluster
+      
+      
+      return suite;
+   }
+}

Added: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/clustering/FileModSequenceBuilder.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/clustering/FileModSequenceBuilder.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/clustering/FileModSequenceBuilder.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -0,0 +1,506 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.test.cms.clustering;
+
+import java.io.IOException;
+import java.util.Locale;
+
+import org.jboss.mx.util.MBeanProxyExt;
+import org.jboss.mx.util.MBeanServerLocator;
+import javax.management.MBeanServer;
+
+import org.jboss.portal.cms.CMS;
+import org.jboss.portal.cms.Command;
+import org.jboss.portal.cms.impl.ContentImpl;
+import org.jboss.portal.cms.impl.FileImpl;
+import org.jboss.portal.cms.model.Content;
+import org.jboss.portal.cms.model.File;
+
+
+import org.jboss.portal.test.framework.portlet.SequenceRegistry;
+import org.jboss.portal.test.framework.portlet.Sequence;
+import org.jboss.portal.test.framework.portlet.SequenceRegistryBuilder;
+import org.jboss.portal.test.framework.portlet.actions.PortletRenderTestAction;
+import org.jboss.portal.test.framework.portlet.universal.UTP1;
+
+
+import org.jboss.portal.test.framework.container.result.Result;
+import org.jboss.portal.test.framework.container.result.EndTestResult;
+import org.jboss.portal.test.framework.container.result.FailureResult;
+import org.jboss.portal.test.framework.container.result.InvokeGetResult;
+import org.jboss.portal.test.framework.container.TestCaseContext;
+import org.jboss.portal.test.framework.server.NodeId;
+
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletSecurityException;
+import javax.portlet.PortletURL;
+
+
+
+/**
+ * @author <a href="mailto:sohil.shah at jboss.com">Sohil Shah</a>
+ */
+public class FileModSequenceBuilder extends SequenceRegistryBuilder
+{
+    /**
+     * 
+     */
+    private String sFilePath = "/index.html";
+    
+    /**
+     * 
+     *
+     */
+    public void createTestFileUpdate(SequenceRegistry registry)
+    {
+      Sequence seq = new Sequence();
+      registry.addSequence("testFileUpdate", seq);
+                  
+      seq.addAction(0, NodeId.PORTS_01, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) 
+         throws PortletException, PortletSecurityException, IOException
+         {
+             System.out.println("-------------------------------------------------------");
+             System.out.println("Performing SetUp on..."+NodeId.PORTS_01+"(createTestFileUpdate)");
+             System.out.println("-------------------------------------------------------");
+                                                               
+             CMS service = null;
+             try
+             {
+                 MBeanServer server=MBeanServerLocator.locateJBoss();
+                 service = (CMS)MBeanProxyExt.create(CMS.class,"portal:service=CMS",server);             
+                 assertNotNull(service);
+                 
+                 Command getCommand = service.getCommandFactory().createFileGetCommand(sFilePath,Locale.ENGLISH);
+                 Object o = service.execute(getCommand);
+                 if(o != null)
+                 {
+                     //this file exists delete it from the system before executing this testcase
+                     Command delete = service.getCommandFactory().createDeleteCommand(sFilePath);
+                     service.execute(delete);
+                 }
+                 
+                 createFile(service);
+                 
+                                  
+                 o = service.execute(getCommand);
+                 //assert this test
+                 assertNotNull(o);
+                 System.out.println("-------------------------------------------------------");
+                 System.out.println("Content Description Before Update="+((File)o).getContent().getDescription());
+                 System.out.println("Live version Before Update="+((File)o).getContent().getVersionNumber());
+                 System.out.println("-------------------------------------------------------");                 
+             }
+             catch(Exception e)
+             {
+                 e.printStackTrace();
+                 return new FailureResult(e.toString());
+             }
+            
+             
+             PortletURL portletURL = response.createRenderURL();
+             String url = TestCaseContext.getCurrentContext().rewriteURLForNode(portletURL.toString(),NodeId.PORTS_02);            
+             return new InvokeGetResult(url);
+         }
+      });
+      seq.addAction(1, NodeId.PORTS_02, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected Result run(Portlet portlet, RenderRequest request, RenderResponse response)
+         throws PortletException, PortletSecurityException, IOException
+         {
+             System.out.println("-------------------------------------------------------");
+             System.out.println("Performing SetUp on node..."+NodeId.PORTS_02+"(createTestFileUpdate)");
+             System.out.println("-------------------------------------------------------");             
+                                     
+            CMS service = null;
+            try
+            {
+                MBeanServer server=MBeanServerLocator.locateJBoss();
+                service = (CMS)MBeanProxyExt.create(CMS.class,"portal:service=CMS",server);             
+                assertNotNull(service);
+            
+                Command getCommand = service.getCommandFactory().createFileGetCommand(sFilePath,Locale.ENGLISH);
+                Object o = service.execute(getCommand);                
+                
+                //assert this test
+                assertNotNull(o);
+                if(o != null)
+                {
+                    System.out.println("-------------------------------------------------------");
+                    System.out.println("Content Description Before Update="+((File)o).getContent().getDescription());
+                    System.out.println("Content Description Before Update="+((File)o).getContent().getVersionNumber());
+                    System.out.println("-------------------------------------------------------");
+                }
+                else
+                {
+                    System.out.println("-------------------------------------------------------");
+                    System.out.println("File Not Found on this node "+sFilePath);
+                    System.out.println("-------------------------------------------------------");
+                }
+            }
+            catch(Exception e)
+            {
+                e.printStackTrace();
+                return new FailureResult(e.toString());
+            }
+            
+            PortletURL portletURL = response.createRenderURL();
+            String url = TestCaseContext.getCurrentContext().rewriteURLForNode(portletURL.toString(),NodeId.PORTS_01);            
+            return new InvokeGetResult(url);
+         }
+      });
+      seq.addAction(2, NodeId.PORTS_01, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) 
+         throws PortletException, PortletSecurityException, IOException
+         {
+             System.out.println("-------------------------------------------------------");
+             System.out.println("Performing FileUpdate on..."+NodeId.PORTS_01+"(createTestFileUpdate)");
+             System.out.println("-------------------------------------------------------");
+             
+                                                  
+             CMS service = null;
+             try
+             {
+                 MBeanServer server=MBeanServerLocator.locateJBoss();
+                 service = (CMS)MBeanProxyExt.create(CMS.class,"portal:service=CMS",server);             
+                 assertNotNull(service);
+                 
+                 Command existsCommand = service.getCommandFactory().createItemExistsCommand(sFilePath);
+                 Boolean exists = (Boolean)service.execute(existsCommand);
+                 if(exists.booleanValue())
+                 {
+                     //update the selected file
+                     Command getCMD = service.getCommandFactory().createFileGetCommand(sFilePath,Locale.ENGLISH);
+                     File newfile = (File) service.execute(getCMD);
+                     Content content = newfile.getContent();
+                     content.setDescription("New English Description");
+                     newfile.setContent(content.getLocale(), content);                     
+                     //Command cmdUpdate = service.getCommandFactory().createFileUpdateCommand(newfile);
+                     Command cmdUpdate = service.getCommandFactory().createUpdateFileCommand(newfile,content,true);
+                     service.execute(cmdUpdate);
+                                          
+                     
+                     newfile = (File)service.execute(getCMD);                     
+                     
+                     //assert and make sure the changes specified took effect
+                     assertEquals(newfile.getContent().getDescription(),"New English Description");
+                                          
+                     System.out.println("-------------------------------------------");
+                     System.out.println("Content Description After Update ="+newfile.getContent().getDescription());
+                     System.out.println("Live Version After Update ="+newfile.getContent().getVersionNumber());                   
+                     System.out.println("-------------------------------------------");                                                               
+                 }             
+                 else
+                 {
+                     System.out.println("The content was not successfully created");
+                     assertTrue("The content was not successfully created",exists.booleanValue());
+                 }
+             }
+             catch(Exception e)
+             {
+                 e.printStackTrace();
+                 return new FailureResult(e.toString());
+             }
+             
+                                                   
+             PortletURL portletURL = response.createRenderURL();
+             String url = TestCaseContext.getCurrentContext().rewriteURLForNode(portletURL.toString(),NodeId.PORTS_02);            
+             return new InvokeGetResult(url);
+         }
+      });
+      seq.addAction(3, NodeId.PORTS_02, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected Result run(Portlet portlet, RenderRequest request, RenderResponse response)
+         throws PortletException, PortletSecurityException, IOException
+         {
+             System.out.println("-------------------------------------------------------");
+             System.out.println("Checking FileUpdate on node..."+NodeId.PORTS_02+"(createTestFileUpdate)");
+             System.out.println("-------------------------------------------------------");             
+                                     
+            CMS service = null;
+            try
+            {
+                MBeanServer server=MBeanServerLocator.locateJBoss();
+                service = (CMS)MBeanProxyExt.create(CMS.class,"portal:service=CMS",server);             
+                assertNotNull(service);
+            
+                Command getCMD = service.getCommandFactory().createFileGetCommand(sFilePath,Locale.ENGLISH);
+                File file = (File) service.execute(getCMD);
+                                                                
+                if(file != null)
+                {                                        
+                    System.out.println("-------------------------------------------");
+                    System.out.println("Content Description After Update ="+file.getContent().getDescription());
+                    System.out.println("Live Version After Update ="+file.getContent().getVersionNumber());
+                    System.out.println("-------------------------------------------");
+                }
+                else
+                {
+                    System.out.println("-------------------------------------------------------");
+                    System.out.println("File Not Found on this node "+sFilePath);
+                    System.out.println("-------------------------------------------------------"); 
+                }
+                
+                assertEquals(file.getContent().getDescription(),"New English Description");
+            }
+            catch(Exception e)
+            {
+                e.printStackTrace();
+                return new FailureResult(e.toString());
+            }
+            
+            return new EndTestResult();
+         }
+      });
+    }
+    
+    /**
+     * 
+     *
+     */
+    public void createTestFileDelete(SequenceRegistry registry)
+    {
+      Sequence seq = new Sequence();
+      registry.addSequence("testFileDelete", seq);
+                  
+      seq.addAction(0, NodeId.PORTS_01, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) 
+         throws PortletException, PortletSecurityException, IOException
+         {
+             System.out.println("-------------------------------------------------------");
+             System.out.println("Performing SetUp on..."+NodeId.PORTS_01+"(createTestFileDelete)");
+             System.out.println("-------------------------------------------------------");
+                                                               
+             CMS service = null;
+             try
+             {
+                 MBeanServer server=MBeanServerLocator.locateJBoss();
+                 service = (CMS)MBeanProxyExt.create(CMS.class,"portal:service=CMS",server);             
+                 assertNotNull(service);
+                 
+                 Command getCommand = service.getCommandFactory().createFileGetCommand(sFilePath,Locale.ENGLISH);
+                 Object o = service.execute(getCommand);
+                 if(o == null)
+                 {
+                     createFile(service);
+                 }
+                 
+                 //assert this test                 
+                 o = service.execute(getCommand);
+                 assertNotNull(o);                                  
+             }
+             catch(Exception e)
+             {
+                 e.printStackTrace();
+                 return new FailureResult(e.toString());
+             }
+            
+             
+             PortletURL portletURL = response.createRenderURL();
+             String url = TestCaseContext.getCurrentContext().rewriteURLForNode(portletURL.toString(),NodeId.PORTS_02);            
+             return new InvokeGetResult(url);
+         }
+      });
+      seq.addAction(1, NodeId.PORTS_02, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected Result run(Portlet portlet, RenderRequest request, RenderResponse response)
+         throws PortletException, PortletSecurityException, IOException
+         {
+             System.out.println("-------------------------------------------------------");
+             System.out.println("Performing SetUp on node..."+NodeId.PORTS_02+"(createTestFileDelete)");
+             System.out.println("-------------------------------------------------------");             
+                                     
+            CMS service = null;
+            try
+            {
+                MBeanServer server=MBeanServerLocator.locateJBoss();
+                service = (CMS)MBeanProxyExt.create(CMS.class,"portal:service=CMS",server);             
+                assertNotNull(service);
+            
+                Command getCommand = service.getCommandFactory().createFileGetCommand(sFilePath,Locale.ENGLISH);
+                Object o = service.execute(getCommand);                
+                
+                //assert this test
+                assertNotNull(o);                                
+            }
+            catch(Exception e)
+            {
+                e.printStackTrace();
+                return new FailureResult(e.toString());
+            }
+            
+            PortletURL portletURL = response.createRenderURL();
+            String url = TestCaseContext.getCurrentContext().rewriteURLForNode(portletURL.toString(),NodeId.PORTS_01);            
+            return new InvokeGetResult(url);
+         }
+      });
+      seq.addAction(2, NodeId.PORTS_01, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) 
+         throws PortletException, PortletSecurityException, IOException
+         {
+             System.out.println("-------------------------------------------------------");
+             System.out.println("Performing FileDelete on..."+NodeId.PORTS_01+"(createTestFileDelete)");
+             System.out.println("-------------------------------------------------------");
+             
+                                                  
+             CMS service = null;
+             try
+             {
+                 MBeanServer server=MBeanServerLocator.locateJBoss();
+                 service = (CMS)MBeanProxyExt.create(CMS.class,"portal:service=CMS",server);             
+                 assertNotNull(service);
+                 
+                 Command existsCommand = service.getCommandFactory().createItemExistsCommand(sFilePath);
+                 Boolean exists = (Boolean)service.execute(existsCommand);
+                 if(exists.booleanValue())
+                 {
+                     //delete the file
+                     Command deleteCMD = service.getCommandFactory().createDeleteCommand(sFilePath);
+                     service.execute(deleteCMD);                     
+                     
+                     //assert and make sure the changes specified took effect
+                     Command existsCMD = service.getCommandFactory().createItemExistsCommand(sFilePath);
+                     Boolean existsCheck = (Boolean)service.execute(existsCMD);
+                     assertFalse(existsCheck.booleanValue());
+                 }             
+                 else
+                 {
+                     System.out.println("The content was not successfully created");
+                     assertTrue("The content was not successfully created",exists.booleanValue());
+                 }
+             }
+             catch(Exception e)
+             {
+                 e.printStackTrace();
+                 return new FailureResult(e.toString());
+             }
+             
+                                                   
+             PortletURL portletURL = response.createRenderURL();
+             String url = TestCaseContext.getCurrentContext().rewriteURLForNode(portletURL.toString(),NodeId.PORTS_02);            
+             return new InvokeGetResult(url);
+         }
+      });
+      seq.addAction(3, NodeId.PORTS_02, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected Result run(Portlet portlet, RenderRequest request, RenderResponse response)
+         throws PortletException, PortletSecurityException, IOException
+         {
+             System.out.println("-------------------------------------------------------");
+             System.out.println("Checking FileDelete on node..."+NodeId.PORTS_02+"(createTestFileDelete)");
+             System.out.println("-------------------------------------------------------");             
+                                     
+            CMS service = null;
+            try
+            {
+                MBeanServer server=MBeanServerLocator.locateJBoss();
+                service = (CMS)MBeanProxyExt.create(CMS.class,"portal:service=CMS",server);             
+                assertNotNull(service);
+            
+                //delete the file
+                Command deleteCMD = service.getCommandFactory().createDeleteCommand(sFilePath);
+                service.execute(deleteCMD);                     
+                
+                //assert and make sure the changes specified took effect
+                Command existsCMD = service.getCommandFactory().createItemExistsCommand(sFilePath);
+                Boolean existsCheck = (Boolean)service.execute(existsCMD);
+                assertFalse("File delete on Node-1 not successfully propagated to Node-2",existsCheck.booleanValue());
+            }
+            catch(Exception e)
+            {
+                e.printStackTrace();
+                return new FailureResult(e.toString());
+            }
+            
+            return new EndTestResult();
+         }
+      });
+    }
+    
+    /**
+     * 
+     *
+     */
+    private void createFile(CMS service)
+    {
+        try
+        {
+	        System.out.println("Creating content for...."+sFilePath);
+	        
+	        //create this content first 
+	        // create file english
+	        File file = new FileImpl();
+	        file.setBasePath(sFilePath);
+	
+	        Content content = new ContentImpl();
+	        content.setEncoding("UTF-8");
+	        content.setTitle("English Title");
+	        content.setDescription("English Description");
+	        content.setBasePath(sFilePath + "/" + Locale.ENGLISH.getLanguage());
+	        content.setBytes("1234567890".getBytes());
+	        content.setMimeType("text/html");
+	        file.setContent(Locale.ENGLISH, content);
+	
+	        // save english file
+	        Command saveFileCMD = service.getCommandFactory().createFileSaveCommand(file);
+	        service.execute(saveFileCMD);
+	
+	        //save english content
+	        Command saveContentCMD = service.getCommandFactory().createContentSaveCommand(file);
+	        service.execute(saveContentCMD);
+	
+	        // version the english content node
+	        Command verCMD = service.getCommandFactory().createContentCreateNewVersionCommand(content, true);
+	        service.execute(verCMD);
+	
+	        // create content spanish
+	        Content contentSP = new ContentImpl();
+	        contentSP.setEncoding("UTF-8");
+	        contentSP.setTitle("Spanish Title");
+	        contentSP.setDescription("Spanish Description");
+	        contentSP.setBasePath(sFilePath + "/es");
+	        contentSP.setBytes("0987654321".getBytes());
+	        contentSP.setMimeType("text/html");
+	        file.setContent(new Locale("es"), contentSP);
+	
+	        //save spanish content
+	        Command saveSPContentCMD = service.getCommandFactory().createContentSaveCommand(file);
+	        service.execute(saveSPContentCMD);
+	
+	        // version the spanish content node
+	        Command verSPCMD = service.getCommandFactory().createContentCreateNewVersionCommand(contentSP, true);
+	        service.execute(verSPCMD);
+        }
+        catch(Exception e)
+        {
+            throw new RuntimeException(e);
+        }
+    }       
+}

Added: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/AbstractCommandTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/AbstractCommandTestCase.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/AbstractCommandTestCase.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -0,0 +1,86 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.test.cms.commands;
+
+import org.jboss.portal.cms.impl.jcr.JCRCMS;
+import org.jboss.portal.common.util.CLLoader;
+import org.jboss.portal.common.util.LoaderResource;
+import org.jboss.portal.common.util.XML;
+import org.jboss.portal.test.cms.AbstractCMSTestCase;
+import org.jboss.portal.test.framework.embedded.DataSourceSupport;
+import org.w3c.dom.Document;
+
+import java.util.Locale;
+import java.util.Map;
+
+/*
+ * Created on Sep 18, 2006
+ *
+ * @author <a href="mailto:sohil.shah at jboss.com">Sohil Shah</a>
+ */
+public class AbstractCommandTestCase extends AbstractCMSTestCase
+{
+    /**
+     * 
+     */
+    protected JCRCMS service;
+
+   public AbstractCommandTestCase(Map parametrization)
+   {
+      super(parametrization);
+   }
+   
+   public AbstractCommandTestCase(DataSourceSupport.Config dsCfg)
+   {
+      super(dsCfg);
+   }
+
+   /**
+     * 
+     */
+    public void setUp() throws Exception
+    {       
+       super.setUp();
+       
+       LoaderResource res = new CLLoader().getResource("jcr/repository.xml");
+       Document config = res.asDocument(XML.getDocumentBuilderFactory().newDocumentBuilder());
+
+       service = new JCRCMS();
+       service.setDoChecking(true);
+       service.setDefaultLocale(Locale.ENGLISH.getDisplayName());
+       service.setDefaultContentLocation("default-content/default");
+
+       service.setConfig(config.getDocumentElement());
+       service.setRepositoryName("repo");
+       service.setHomeDir("repotest");
+       service.startService();
+    }
+
+    /**
+     * 
+     */
+    public void tearDown() throws Exception
+    {
+       service.stopService();      
+       super.tearDown();
+    }
+}

Added: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileArchiveUpload.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileArchiveUpload.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileArchiveUpload.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -0,0 +1,119 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.portal.test.cms.commands;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.List;
+import java.util.Locale;
+
+
+import junit.framework.TestSuite;
+
+import org.jboss.portal.cms.CMSException;
+import org.jboss.portal.cms.Command;
+import org.jboss.portal.cms.model.Folder;
+import org.jboss.portal.test.framework.embedded.DataSourceSupport;
+import org.jboss.portal.test.framework.junit.DatabaseTestSuite;
+
+
+/**
+ * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:sohil.shah at jboss.com">Sohil Shah</a>
+ */
+public class TestFileArchiveUpload extends AbstractCommandTestCase
+{
+    String sFilePath = "/testdoc.gif";
+
+    String sCopyToFilePath = "/testdoccopy.gif";
+
+    // zip vars
+    String sZipPath = "/poop";
+
+    String sZipFile = "resources/test/jcr/ziptest.zip";
+
+    String sJPG = "/hibernate_logo.gif";
+
+    String sText = "/training.txt";
+    
+
+   /**
+    * 
+    *
+    */
+   public TestFileArchiveUpload(DataSourceSupport.Config dsCfg)
+   {
+      super(dsCfg);
+   }
+   
+   /**
+    * 
+    *
+    */
+   public static TestSuite suite() throws Exception
+   {
+      URL configsURL = Thread.currentThread().getContextClassLoader().getResource("datasources.xml");
+      DataSourceSupport.Config[] configs = DataSourceSupport.Config.fromXML(configsURL);
+      DatabaseTestSuite suite = new DatabaseTestSuite(configs);
+      suite.addTestCase(TestFileArchiveUpload.class);
+      return suite;       
+   }
+
+   public void testArchiveUpload() throws CMSException, IOException
+   {
+      service.setDefaultLocale(Locale.ENGLISH.getLanguage());
+      InputStream is = new FileInputStream(sZipFile);
+      Command storearchiveCMD = service.getCommandFactory().createStoreArchiveCommand("", is, "en");
+      List contentsToVersion = (List) service.execute(storearchiveCMD);
+
+      Command createVersions = service.getCommandFactory()
+            .createContentCreateNewVersionCommand(contentsToVersion, true);
+      service.execute(createVersions);
+
+      // retrieve list
+      Command listCMD = service.getCommandFactory().createFolderGetListCommand("/ziptest/poop");
+      Folder whopper = (Folder) service.execute(listCMD);
+      List folders = whopper.getFolders();
+      List files = whopper.getFiles();
+      assertEquals("Folder Size incorrect", folders.size(), 1);
+      assertEquals("File Size incorrect", files.size(), 1);
+
+      // retrieve list
+      Command listCMD2 = service.getCommandFactory().createFolderGetListCommand("/ziptest/poop/music");
+      Folder whopper2 = (Folder) service.execute(listCMD2);
+      List folders2 = whopper2.getFolders();
+      List files2 = whopper2.getFiles();
+      assertEquals("Folder Size incorrect", folders2.size(), 0);
+      assertEquals("File Size incorrect", files2.size(), 1);
+
+      // retrieve list
+      Command listCMD3 = service.getCommandFactory().createFolderGetListCommand("/");
+      Folder whopper3 = (Folder) service.execute(listCMD3);
+      List folders3 = whopper3.getFolders();
+      List files3 = whopper3.getFiles();
+
+      is.close();
+   }      
+}

Deleted: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileCommands.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileCommands.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileCommands.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -1,470 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.portal.test.cms.commands;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.net.URL;
-import java.util.List;
-import java.util.Locale;
-
-import javax.jcr.Item;
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.Session;
-
-import junit.framework.TestSuite;
-
-import org.jboss.portal.cms.Command;
-import org.jboss.portal.cms.CMSException;
-import org.jboss.portal.cms.impl.ContentImpl;
-import org.jboss.portal.cms.impl.FileImpl;
-import org.jboss.portal.cms.impl.jcr.JCRCMS;
-import org.jboss.portal.cms.impl.jcr.JCRCompositeCommand;
-import org.jboss.portal.cms.impl.jcr.composite.NewFileCommand;
-import org.jboss.portal.cms.impl.jcr.util.VersionUtil;
-import org.jboss.portal.cms.model.Content;
-import org.jboss.portal.cms.model.File;
-import org.jboss.portal.cms.model.Folder;
-import org.jboss.portal.cms.util.NodeUtil;
-import org.jboss.portal.cms.util.RepositoryUtil;
-import org.jboss.portal.common.util.CLLoader;
-import org.jboss.portal.common.util.LoaderResource;
-import org.jboss.portal.common.util.XML;
-import org.jboss.portal.test.cms.AbstractCMSTestCase;
-import org.jboss.portal.test.cms.mock.RuntimeExceptionCommand;
-import org.jboss.portal.test.framework.embedded.DataSourceSupport;
-import org.jboss.portal.test.framework.junit.DatabaseTestSuite;
-import org.w3c.dom.Document;
-
-/**
- * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- */
-public class TestFileCommands extends AbstractCMSTestCase
-{
-   JCRCMS service;
-
-   String sFilePath = "/testdoc.gif";
-
-   String sCopyToFilePath = "/testdoccopy.gif";
-
-   // zip vars
-   String sZipPath = "/poop";
-
-   String sZipFile = "resources/test/jcr/ziptest.zip";
-
-   String sJPG = "/hibernate_logo.gif";
-
-   String sText = "/training.txt";
-
-   public TestFileCommands(DataSourceSupport.Config dsCfg)
-   {
-      super(dsCfg);
-   }
-
-   public static TestSuite suite() throws Exception
-   {
-      URL configsURL = Thread.currentThread().getContextClassLoader().getResource("datasources.xml");
-      DataSourceSupport.Config[] configs = DataSourceSupport.Config.fromXML(configsURL);
-      DatabaseTestSuite suite = new DatabaseTestSuite(configs);
-      suite.addTestCase(TestFileCommands.class);
-      return suite;
-   }
-
-   public void setUp() throws Exception
-   {
-      super.setUp();
-
-      // Load config
-      LoaderResource res = new CLLoader().getResource("jcr/repository.xml");
-      Document config = res.asDocument(XML.getDocumentBuilderFactory().newDocumentBuilder());
-
-      service = new JCRCMS();
-      service.setRepositoryName("repo");
-      service.setConfig(config.getDocumentElement());
-      service.setHomeDir("repotest");
-      service.setDoChecking(false);
-      service.start();
-
-   }
-
-   public void tearDown() throws Exception
-   {
-      service.stop();
-      super.tearDown();
-   }
-
-   /*
-    public static Test suite()
-    {
-    return new TestSuite(TestFileCommands.class);
-    }
-    */
-   public void testFileDelete() throws Exception
-   {
-      createFile();
-      // delete old test nodes
-      Command deleteCMD = service.getCommandFactory().createDeleteCommand(sFilePath);
-      service.execute(deleteCMD);
-      Command deleteToCMD = service.getCommandFactory().createDeleteCommand(sCopyToFilePath);
-      service.execute(deleteToCMD);
-
-      // zip deletes
-      Command deleteZipCMD = service.getCommandFactory().createDeleteCommand(sZipPath);
-      service.execute(deleteZipCMD);
-      Command deleteZipJCMD = service.getCommandFactory().createDeleteCommand(sJPG);
-      service.execute(deleteZipJCMD);
-      Command deleteZipTCMD = service.getCommandFactory().createDeleteCommand(sText);
-      service.execute(deleteZipTCMD);
-
-      Session session = RepositoryUtil.login(service.getRepository(), "anonid", "");
-      assertFalse(sFilePath + " not Deleted", session.itemExists(sFilePath));
-      assertFalse(sCopyToFilePath + " not Deleted", session.itemExists(sCopyToFilePath));
-      assertFalse(sZipPath + " not Deleted", session.itemExists(sZipPath));
-      assertFalse(sJPG + " not Deleted", session.itemExists(sJPG));
-      assertFalse(sText + " not Deleted", session.itemExists(sText));
-
-      RepositoryUtil.safeLogout(session);
-   }
-
-   private void createFile() throws CMSException
-   {
-      // create file english
-      File file = new FileImpl();
-      file.setBasePath(sFilePath);
-
-      Content content = new ContentImpl();
-      content.setEncoding("UTF-8");
-      content.setTitle("English Title");
-      content.setDescription("English Description");
-      content.setBasePath(sFilePath + "/" + Locale.ENGLISH.getLanguage());
-      content.setBytes("1234567890".getBytes());
-      content.setMimeType("image/gif");
-      file.setContent(Locale.ENGLISH, content);
-
-      Command newFileCMD = service.getCommandFactory().createNewFileCommand(file, content);
-      service.execute(newFileCMD);
-
-      // create content spanish
-      Content contentSP = new ContentImpl();
-      contentSP.setEncoding("UTF-8");
-      contentSP.setTitle("Spanish Title");
-      contentSP.setDescription("Spanish Description");
-      contentSP.setBasePath(sFilePath + "/es");
-      contentSP.setBytes("0987654321".getBytes());
-      contentSP.setMimeType("image/gif");
-      file.setContent(new Locale("es"), contentSP);
-
-      Command newFileSPCMD = service.getCommandFactory().createNewFileCommand(file, contentSP);
-      service.execute(newFileSPCMD);
-   }
-   
-   
-   public void testFileCreate() throws Exception
-   {
-      // create file english
-      File file = new FileImpl();
-      file.setBasePath(sFilePath);
-
-      Content content = new ContentImpl();
-      content.setEncoding("UTF-8");
-      content.setTitle("English Title");
-      content.setDescription("English Description");
-      content.setBasePath(sFilePath + "/" + Locale.ENGLISH.getLanguage());
-      content.setBytes("1234567890".getBytes());
-      content.setMimeType("image/gif");
-      file.setContent(Locale.ENGLISH, content);
-
-      // save english file
-      Command saveFileCMD = service.getCommandFactory().createFileSaveCommand(file);
-      service.execute(saveFileCMD);
-
-      //save english content
-      Command saveContentCMD = service.getCommandFactory().createContentSaveCommand(file);
-      service.execute(saveContentCMD);
-
-      // version the english content node
-      Command verCMD = service.getCommandFactory().createContentCreateNewVersionCommand(content, true);
-      service.execute(verCMD);
-
-      // create content spanish
-      Content contentSP = new ContentImpl();
-      contentSP.setEncoding("UTF-8");
-      contentSP.setTitle("Spanish Title");
-      contentSP.setDescription("Spanish Description");
-      contentSP.setBasePath(sFilePath + "/es");
-      contentSP.setBytes("0987654321".getBytes());
-      contentSP.setMimeType("image/gif");
-      file.setContent(new Locale("es"), contentSP);
-
-      //save spanish content
-      Command saveSPContentCMD = service.getCommandFactory().createContentSaveCommand(file);
-      service.execute(saveSPContentCMD);
-
-      // version the spanish content node
-      Command verSPCMD = service.getCommandFactory().createContentCreateNewVersionCommand(contentSP, true);
-      service.execute(verSPCMD);
-
-      Session session = null;
-
-      session = RepositoryUtil.login(service.getRepository(), "anonid", "");
-      Node fileNode = (Node) session.getItem(sFilePath);
-      assertEquals("Name incorrect", NodeUtil.getNodeName(file.getBasePath()), fileNode.getName());
-
-      Node contentNodeEN = fileNode.getNode(Locale.ENGLISH.getLanguage());
-      assertEquals("Encoding Incorrect", content.getEncoding(), contentNodeEN.getProperty("jcr:encoding").getString());
-      assertEquals("Mimetype Incorrect", content.getMimeType(), contentNodeEN.getProperty("jcr:mimeType").getString());
-      assertEquals("Language Incorrect", content.getLocale().getLanguage(), contentNodeEN.getProperty(
-            "portalcms:language").getString());
-      assertEquals("Title Incorrect", content.getTitle(), contentNodeEN.getProperty("portalcms:title").getString());
-      assertEquals("Desc Incorrect", content.getDescription(), contentNodeEN.getProperty("portalcms:description")
-            .getString());
-
-      Node contentNodeSP = fileNode.getNode("es");
-      assertEquals("Encoding Incorrect", contentSP.getEncoding(), contentNodeSP.getProperty("jcr:encoding").getString());
-      assertEquals("Mimetype Incorrect", contentSP.getMimeType(), contentNodeSP.getProperty("jcr:mimeType").getString());
-      assertEquals("Language Incorrect", contentSP.getLocale().getLanguage(), contentNodeSP.getProperty(
-            "portalcms:language").getString());
-      assertEquals("Title Incorrect", contentSP.getTitle(), contentNodeSP.getProperty("portalcms:title").getString());
-      assertEquals("Desc Incorrect", contentSP.getDescription(), contentNodeSP.getProperty("portalcms:description")
-            .getString());
-
-      session.logout();
-   }
-
-   /**
-    * Tests retrieval of the version labeled LIVE.
-    */
-   public void testFileGet() throws CMSException
-   {
-      createFile();
-      Command getCMD = service.getCommandFactory().createFileGetCommand(sFilePath, Locale.ENGLISH);
-      File newfile = (File) service.execute(getCMD);
-
-      Content content = newfile.getContent();
-      assertEquals("Encoding Incorrect", content.getEncoding(), "UTF-8");
-      assertEquals("Mimetype Incorrect", content.getMimeType(), "image/gif");
-      assertEquals("Language Incorrect", content.getLocale().getLanguage(), "en");
-      assertEquals("Title Incorrect", content.getTitle(), "English Title");
-      assertEquals("Desc Incorrect", content.getDescription(), "English Description");
-   }
-
-   /**
-    * Tests updating a file and its content.
-    * @throws Exception 
-    */
-   public void testFileUpdate() throws Exception
-   {
-      createFile();
-      Session session = RepositoryUtil.login(service.getRepository(), "anonid", "");
-      Command getCMD = service.getCommandFactory().createFileGetCommand(sFilePath, Locale.ENGLISH);
-      File newfile = (File) service.execute(getCMD);
-      Content content = newfile.getContent();
-      content.setDescription("New English Description");
-      newfile.setContent(content.getLocale(), content);
-      // update file and make "LIVE"
-      Command cmdUpdate = service.getCommandFactory().createFileUpdateCommand(newfile);
-      service.execute(cmdUpdate);
-
-      Command cmdVersion = service.getCommandFactory().createContentCreateNewVersionCommand(content, true);
-      service.execute(cmdVersion);
-
-      boolean descriptionupdated = ((Property) session.getItem("/testdoc.gif/en/portalcms:description")).getString()
-            .equals("New English Description");
-      assertTrue("Incorrect description for file object", descriptionupdated);
-
-      // version std out dump
-      VersionUtil.print((Node) session.getItem(content.getBasePath()));
-   }
-
-   /**
-    * Tests retrieval of a specific version by version number.
-    */
-   public void testFileGetVersion() throws CMSException
-   {
-      createFile();
-      // get specific file version
-      Command getCMDV = service.getCommandFactory().createFileGetCommand(sFilePath, "1.0", Locale.ENGLISH);
-      File Vnewfile = (File) service.execute(getCMDV);
-      assertTrue("Incorrect version number for file object", Vnewfile.getContent().getVersionNumber().equals("1.0"));
-   }
-
-   /**
-    * Tests retrieving a list of contents under a file and the versions for contents.
-    */
-   public void testFileList() throws CMSException
-   {
-      createFile();
-      Command getFileListCMD = service.getCommandFactory().createFileGetListCommand(sFilePath);
-      List contentList = (List) service.execute(getFileListCMD);
-      assertTrue("Incorrect list size", contentList.size() == 2);
-
-      for (int i = 0; i < contentList.size(); i++)
-      {
-         Content content = (Content) contentList.get(i);
-         Command getContentVersionsCMD = service.getCommandFactory().createContentGetVersionsCommand(
-               content.getBasePath());
-         List versionList = (List) service.execute(getContentVersionsCMD);
-      }
-   }
-
-   public void testFileCopy() throws CMSException
-   {
-      createFile();
-      // copy file
-      Command copyCMD = service.getCommandFactory().createCopyCommand(sFilePath, sCopyToFilePath);
-      service.execute(copyCMD);
-
-      Command getCMD = service.getCommandFactory().createFileGetCommand(sCopyToFilePath, Locale.ENGLISH);
-      File newfile = (File) service.execute(getCMD);
-      Content content = newfile.getContent();
-      assertEquals("Encoding Incorrect", content.getEncoding(), "UTF-8");
-      assertEquals("Mimetype Incorrect", content.getMimeType(), "image/gif");
-      assertEquals("Language Incorrect", content.getLocale().getLanguage(), "en");
-      assertEquals("Title Incorrect", content.getTitle(), "English Title");
-      assertEquals("Desc Incorrect", content.getDescription(), "English Description");
-
-      Command getCMDSP = service.getCommandFactory().createFileGetCommand(sCopyToFilePath, new Locale("es"));
-      File newfileSP = (File) service.execute(getCMDSP);
-      Content contentSP = newfileSP.getContent();
-      assertEquals("Encoding Incorrect", contentSP.getEncoding(), "UTF-8");
-      assertEquals("Mimetype Incorrect", contentSP.getMimeType(), "image/gif");
-      assertEquals("Language Incorrect", contentSP.getLocale().getLanguage(), "es");
-      assertEquals("Title Incorrect", contentSP.getTitle(), "Spanish Title");
-      assertEquals("Desc Incorrect", contentSP.getDescription(), "Spanish Description");
-   }
-
-   public void testArchiveUpload() throws CMSException, IOException
-   {
-      service.setDefaultLocale(Locale.ENGLISH.getLanguage());
-      InputStream is = new FileInputStream(sZipFile);
-      Command storearchiveCMD = service.getCommandFactory().createStoreArchiveCommand("", is, "en");
-      List contentsToVersion = (List) service.execute(storearchiveCMD);
-
-      Command createVersions = service.getCommandFactory()
-            .createContentCreateNewVersionCommand(contentsToVersion, true);
-      service.execute(createVersions);
-
-      // retrieve list
-      Command listCMD = service.getCommandFactory().createFolderGetListCommand("/ziptest/poop");
-      Folder whopper = (Folder) service.execute(listCMD);
-      List folders = whopper.getFolders();
-      List files = whopper.getFiles();
-      assertEquals("Folder Size incorrect", folders.size(), 1);
-      assertEquals("File Size incorrect", files.size(), 1);
-
-      // retrieve list
-      Command listCMD2 = service.getCommandFactory().createFolderGetListCommand("/ziptest/poop/music");
-      Folder whopper2 = (Folder) service.execute(listCMD2);
-      List folders2 = whopper2.getFolders();
-      List files2 = whopper2.getFiles();
-      assertEquals("Folder Size incorrect", folders2.size(), 0);
-      assertEquals("File Size incorrect", files2.size(), 1);
-
-      // retrieve list
-      Command listCMD3 = service.getCommandFactory().createFolderGetListCommand("/");
-      Folder whopper3 = (Folder) service.execute(listCMD3);
-      List folders3 = whopper3.getFolders();
-      List files3 = whopper3.getFiles();
-
-      is.close();
-   }
-
-   /*
-    public void testArchiveDownload()
-    {
-    Command getArchiveCMD = service.getCommandFactory().createGetArchiveCommand("/", "en");
-    java.io.File zipOut = (java.io.File) service.execute(getArchiveCMD);
-    try
-    {
-    //System.out.println("%%%%%% " + zipOut.getName() + " %%%%%" + zipOut.getCanonicalPath());
-    }
-    catch(Exception e)
-    {
-    e.printStackTrace();
-    }
-    }
-
-    */
-
-   public void testFileCreateFailed() throws Exception
-   {
-      Session session = null;
-
-      session = RepositoryUtil.login(service.getRepository(), "anonid", "");
-
-      if (session.itemExists(sFilePath))
-      {
-         Item item = session.getItem(sFilePath);
-         Node parentNode = item.getParent();
-         item.remove();
-         parentNode.save();
-      }
-
-      // create file english
-      File file = new FileImpl();
-      file.setBasePath(sFilePath);
-
-      Content content = new ContentImpl();
-      content.setEncoding("UTF-8");
-      content.setTitle("English Title");
-      content.setDescription("English Description");
-      content.setBasePath(sFilePath + "/" + Locale.ENGLISH.getLanguage());
-      content.setBytes("1234567890".getBytes());
-      content.setMimeType("image/gif");
-      file.setContent(Locale.ENGLISH, content);
-
-      // save english file
-
-      class TestCommand extends JCRCompositeCommand
-      {
-         /** The serialVersionUID */
-         private static final long serialVersionUID = -4206026300826187649L;
-
-         public TestCommand(File file, Content content)
-         {
-            Command newFileCMD = new NewFileCommand(file, content);
-            commands.add(newFileCMD);
-            Command runtimeExceptionCMD = new RuntimeExceptionCommand();
-            commands.add(runtimeExceptionCMD);
-         }
-      }
-
-      Command newFileCMD = new TestCommand(file, content);
-
-      try
-      {
-         service.execute(newFileCMD);
-      }
-      catch (RuntimeException e)
-      {
-         // Ignore
-      }
-
-      assertFalse("File has been copied and not rolledback", session.itemExists(sFilePath));
-   }
-
-}
\ No newline at end of file

Added: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileCopy.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileCopy.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileCopy.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -0,0 +1,148 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.portal.test.cms.commands;
+
+import java.net.URL;
+import java.util.Locale;
+
+
+import junit.framework.TestSuite;
+
+import org.jboss.portal.cms.CMSException;
+import org.jboss.portal.cms.Command;
+import org.jboss.portal.cms.impl.ContentImpl;
+import org.jboss.portal.cms.impl.FileImpl;
+import org.jboss.portal.cms.model.Content;
+import org.jboss.portal.cms.model.File;
+import org.jboss.portal.test.framework.embedded.DataSourceSupport;
+import org.jboss.portal.test.framework.junit.DatabaseTestSuite;
+
+
+/**
+ * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:sohil.shah at jboss.com">Sohil Shah</a>
+ */
+public class TestFileCopy extends AbstractCommandTestCase
+{
+    String sFilePath = "/testdoc.gif";
+
+    String sCopyToFilePath = "/testdoccopy.gif";
+
+    // zip vars
+    String sZipPath = "/poop";
+
+    String sZipFile = "resources/test/jcr/ziptest.zip";
+
+    String sJPG = "/hibernate_logo.gif";
+
+    String sText = "/training.txt";
+    
+
+   /**
+    * 
+    *
+    */
+   public TestFileCopy(DataSourceSupport.Config dsCfg)
+   {
+      super(dsCfg);
+   }
+   
+   /**
+    * 
+    *
+    */
+   public static TestSuite suite() throws Exception
+   {
+      URL configsURL = Thread.currentThread().getContextClassLoader().getResource("datasources.xml");
+      DataSourceSupport.Config[] configs = DataSourceSupport.Config.fromXML(configsURL);
+      DatabaseTestSuite suite = new DatabaseTestSuite(configs);
+      suite.addTestCase(TestFileCopy.class);
+      return suite;       
+   }
+
+   /**
+    * 
+    *
+    */
+   public void testFileCopy() throws CMSException
+   {
+      createFile();
+      // copy file
+      Command copyCMD = service.getCommandFactory().createCopyCommand(sFilePath, sCopyToFilePath);
+      service.execute(copyCMD);
+
+      Command getCMD = service.getCommandFactory().createFileGetCommand(sCopyToFilePath, Locale.ENGLISH);
+      File newfile = (File) service.execute(getCMD);
+      Content content = newfile.getContent();
+      assertEquals("Encoding Incorrect", content.getEncoding(), "UTF-8");
+      assertEquals("Mimetype Incorrect", content.getMimeType(), "image/gif");
+      assertEquals("Language Incorrect", content.getLocale().getLanguage(), "en");
+      assertEquals("Title Incorrect", content.getTitle(), "English Title");
+      assertEquals("Desc Incorrect", content.getDescription(), "English Description");
+
+      Command getCMDSP = service.getCommandFactory().createFileGetCommand(sCopyToFilePath, new Locale("es"));
+      File newfileSP = (File) service.execute(getCMDSP);
+      Content contentSP = newfileSP.getContent();
+      assertEquals("Encoding Incorrect", contentSP.getEncoding(), "UTF-8");
+      assertEquals("Mimetype Incorrect", contentSP.getMimeType(), "image/gif");
+      assertEquals("Language Incorrect", contentSP.getLocale().getLanguage(), "es");
+      assertEquals("Title Incorrect", contentSP.getTitle(), "Spanish Title");
+      assertEquals("Desc Incorrect", contentSP.getDescription(), "Spanish Description");
+   }   
+   
+   /**
+    * 
+    *
+    */
+   private void createFile() throws CMSException
+   {
+      // create file english
+      File file = new FileImpl();
+      file.setBasePath(sFilePath);
+
+      Content content = new ContentImpl();
+      content.setEncoding("UTF-8");
+      content.setTitle("English Title");
+      content.setDescription("English Description");
+      content.setBasePath(sFilePath + "/" + Locale.ENGLISH.getLanguage());
+      content.setBytes("1234567890".getBytes());
+      content.setMimeType("image/gif");
+      file.setContent(Locale.ENGLISH, content);
+
+      Command newFileCMD = service.getCommandFactory().createNewFileCommand(file, content);
+      service.execute(newFileCMD);
+
+      // create content spanish
+      Content contentSP = new ContentImpl();
+      contentSP.setEncoding("UTF-8");
+      contentSP.setTitle("Spanish Title");
+      contentSP.setDescription("Spanish Description");
+      contentSP.setBasePath(sFilePath + "/es");
+      contentSP.setBytes("0987654321".getBytes());
+      contentSP.setMimeType("image/gif");
+      file.setContent(new Locale("es"), contentSP);
+
+      Command newFileSPCMD = service.getCommandFactory().createNewFileCommand(file, contentSP);
+      service.execute(newFileSPCMD);
+   }
+}

Added: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileCreate.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileCreate.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileCreate.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -0,0 +1,162 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.portal.test.cms.commands;
+
+import java.net.URL;
+import java.util.Locale;
+
+import javax.jcr.Node;
+import javax.jcr.Session;
+
+
+import junit.framework.TestSuite;
+
+import org.jboss.portal.cms.Command;
+import org.jboss.portal.cms.impl.ContentImpl;
+import org.jboss.portal.cms.impl.FileImpl;
+import org.jboss.portal.cms.model.Content;
+import org.jboss.portal.cms.model.File;
+import org.jboss.portal.cms.util.NodeUtil;
+import org.jboss.portal.cms.util.RepositoryUtil;
+import org.jboss.portal.test.framework.embedded.DataSourceSupport;
+import org.jboss.portal.test.framework.junit.DatabaseTestSuite;
+
+
+/**
+ * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:sohil.shah at jboss.com">Sohil Shah</a>
+ */
+public class TestFileCreate extends AbstractCommandTestCase
+{
+    String sFilePath = "/testdoc.gif";
+
+    String sCopyToFilePath = "/testdoccopy.gif";
+
+    // zip vars
+    String sZipPath = "/poop";
+
+    String sZipFile = "resources/test/jcr/ziptest.zip";
+
+    String sJPG = "/hibernate_logo.gif";
+
+    String sText = "/training.txt";
+    
+
+   /**
+    * 
+    *
+    */
+   public TestFileCreate(DataSourceSupport.Config dsCfg)
+   {
+      super(dsCfg);
+   }
+   
+   /**
+    * 
+    *
+    */
+   public static TestSuite suite() throws Exception
+   {
+      URL configsURL = Thread.currentThread().getContextClassLoader().getResource("datasources.xml");
+      DataSourceSupport.Config[] configs = DataSourceSupport.Config.fromXML(configsURL);
+      DatabaseTestSuite suite = new DatabaseTestSuite(configs);
+      suite.addTestCase(TestFileCreate.class);
+      return suite;       
+   }
+
+   /**
+    * 
+    *
+    */
+   public void testFileCreate() throws Exception
+   {
+      // create file english
+      File file = new FileImpl();
+      file.setBasePath(sFilePath);
+
+      Content content = new ContentImpl();
+      content.setEncoding("UTF-8");
+      content.setTitle("English Title");
+      content.setDescription("English Description");
+      content.setBasePath(sFilePath + "/" + Locale.ENGLISH.getLanguage());
+      content.setBytes("1234567890".getBytes());
+      content.setMimeType("image/gif");
+      file.setContent(Locale.ENGLISH, content);
+
+      // save english file
+      Command saveFileCMD = service.getCommandFactory().createFileSaveCommand(file);
+      service.execute(saveFileCMD);
+
+      //save english content
+      Command saveContentCMD = service.getCommandFactory().createContentSaveCommand(file);
+      service.execute(saveContentCMD);
+
+      // version the english content node
+      Command verCMD = service.getCommandFactory().createContentCreateNewVersionCommand(content, true);
+      service.execute(verCMD);
+
+      // create content spanish
+      Content contentSP = new ContentImpl();
+      contentSP.setEncoding("UTF-8");
+      contentSP.setTitle("Spanish Title");
+      contentSP.setDescription("Spanish Description");
+      contentSP.setBasePath(sFilePath + "/es");
+      contentSP.setBytes("0987654321".getBytes());
+      contentSP.setMimeType("image/gif");
+      file.setContent(new Locale("es"), contentSP);
+
+      //save spanish content
+      Command saveSPContentCMD = service.getCommandFactory().createContentSaveCommand(file);
+      service.execute(saveSPContentCMD);
+
+      // version the spanish content node
+      Command verSPCMD = service.getCommandFactory().createContentCreateNewVersionCommand(contentSP, true);
+      service.execute(verSPCMD);
+
+      Session session = null;
+
+      session = RepositoryUtil.login(service.getRepository(), "anonid", "");
+      Node fileNode = (Node) session.getItem(sFilePath);
+      assertEquals("Name incorrect", NodeUtil.getNodeName(file.getBasePath()), fileNode.getName());
+
+      Node contentNodeEN = fileNode.getNode(Locale.ENGLISH.getLanguage());
+      assertEquals("Encoding Incorrect", content.getEncoding(), contentNodeEN.getProperty("jcr:encoding").getString());
+      assertEquals("Mimetype Incorrect", content.getMimeType(), contentNodeEN.getProperty("jcr:mimeType").getString());
+      assertEquals("Language Incorrect", content.getLocale().getLanguage(), contentNodeEN.getProperty(
+            "portalcms:language").getString());
+      assertEquals("Title Incorrect", content.getTitle(), contentNodeEN.getProperty("portalcms:title").getString());
+      assertEquals("Desc Incorrect", content.getDescription(), contentNodeEN.getProperty("portalcms:description")
+            .getString());
+
+      Node contentNodeSP = fileNode.getNode("es");
+      assertEquals("Encoding Incorrect", contentSP.getEncoding(), contentNodeSP.getProperty("jcr:encoding").getString());
+      assertEquals("Mimetype Incorrect", contentSP.getMimeType(), contentNodeSP.getProperty("jcr:mimeType").getString());
+      assertEquals("Language Incorrect", contentSP.getLocale().getLanguage(), contentNodeSP.getProperty(
+            "portalcms:language").getString());
+      assertEquals("Title Incorrect", contentSP.getTitle(), contentNodeSP.getProperty("portalcms:title").getString());
+      assertEquals("Desc Incorrect", contentSP.getDescription(), contentNodeSP.getProperty("portalcms:description")
+            .getString());
+
+      session.logout();
+   }
+}

Added: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileCreateFailed.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileCreateFailed.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileCreateFailed.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -0,0 +1,150 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.portal.test.cms.commands;
+
+import java.net.URL;
+import java.util.Locale;
+
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.Session;
+
+
+import junit.framework.TestSuite;
+
+import org.jboss.portal.cms.Command;
+import org.jboss.portal.cms.impl.ContentImpl;
+import org.jboss.portal.cms.impl.FileImpl;
+import org.jboss.portal.cms.impl.jcr.JCRCompositeCommand;
+import org.jboss.portal.cms.impl.jcr.composite.NewFileCommand;
+import org.jboss.portal.cms.model.Content;
+import org.jboss.portal.cms.model.File;
+import org.jboss.portal.cms.util.RepositoryUtil;
+import org.jboss.portal.test.cms.mock.RuntimeExceptionCommand;
+import org.jboss.portal.test.framework.embedded.DataSourceSupport;
+import org.jboss.portal.test.framework.junit.DatabaseTestSuite;
+
+
+/**
+ * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:sohil.shah at jboss.com">Sohil Shah</a>
+ */
+public class TestFileCreateFailed extends AbstractCommandTestCase
+{
+    String sFilePath = "/testdoc.gif";
+
+    String sCopyToFilePath = "/testdoccopy.gif";
+
+    // zip vars
+    String sZipPath = "/poop";
+
+    String sZipFile = "resources/test/jcr/ziptest.zip";
+
+    String sJPG = "/hibernate_logo.gif";
+
+    String sText = "/training.txt";
+    
+
+   /**
+    * 
+    *
+    */
+   public TestFileCreateFailed(DataSourceSupport.Config dsCfg)
+   {
+      super(dsCfg);
+   }
+   
+   /**
+    * 
+    *
+    */
+   public static TestSuite suite() throws Exception
+   {
+      URL configsURL = Thread.currentThread().getContextClassLoader().getResource("datasources.xml");
+      DataSourceSupport.Config[] configs = DataSourceSupport.Config.fromXML(configsURL);
+      DatabaseTestSuite suite = new DatabaseTestSuite(configs);
+      suite.addTestCase(TestFileCreateFailed.class);
+      return suite;       
+   }
+
+   /**
+    * 
+    *
+    */
+   public void testFileCreateFailed() throws Exception
+   {
+      Session session = null;
+
+      session = RepositoryUtil.login(service.getRepository(), "anonid", "");
+
+      if (session.itemExists(sFilePath))
+      {
+         Item item = session.getItem(sFilePath);
+         Node parentNode = item.getParent();
+         item.remove();
+         parentNode.save();
+      }
+
+      // create file english
+      File file = new FileImpl();
+      file.setBasePath(sFilePath);
+
+      Content content = new ContentImpl();
+      content.setEncoding("UTF-8");
+      content.setTitle("English Title");
+      content.setDescription("English Description");
+      content.setBasePath(sFilePath + "/" + Locale.ENGLISH.getLanguage());
+      content.setBytes("1234567890".getBytes());
+      content.setMimeType("image/gif");
+      file.setContent(Locale.ENGLISH, content);
+
+      // save english file
+
+      class TestCommand extends JCRCompositeCommand
+      {
+         /** The serialVersionUID */
+         private static final long serialVersionUID = -4206026300826187649L;
+
+         public TestCommand(File file, Content content)
+         {
+            Command newFileCMD = new NewFileCommand(file, content);
+            commands.add(newFileCMD);
+            Command runtimeExceptionCMD = new RuntimeExceptionCommand();
+            commands.add(runtimeExceptionCMD);
+         }
+      }
+
+      Command newFileCMD = new TestCommand(file, content);
+
+      try
+      {
+         service.execute(newFileCMD);
+      }
+      catch (RuntimeException e)
+      {
+         // Ignore
+      }
+
+      assertFalse("File has been copied and not rolledback", session.itemExists(sFilePath));
+   }
+}

Added: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileDelete.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileDelete.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileDelete.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -0,0 +1,153 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.portal.test.cms.commands;
+
+import java.net.URL;
+import java.util.Locale;
+
+import javax.jcr.Session;
+
+
+import junit.framework.TestSuite;
+
+import org.jboss.portal.cms.CMSException;
+import org.jboss.portal.cms.Command;
+import org.jboss.portal.cms.impl.ContentImpl;
+import org.jboss.portal.cms.impl.FileImpl;
+import org.jboss.portal.cms.model.Content;
+import org.jboss.portal.cms.model.File;
+import org.jboss.portal.cms.util.RepositoryUtil;
+import org.jboss.portal.test.framework.embedded.DataSourceSupport;
+import org.jboss.portal.test.framework.junit.DatabaseTestSuite;
+
+
+/**
+ * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:sohil.shah at jboss.com">Sohil Shah</a>
+ */
+public class TestFileDelete extends AbstractCommandTestCase
+{
+    String sFilePath = "/testdoc.gif";
+
+    String sCopyToFilePath = "/testdoccopy.gif";
+
+    // zip vars
+    String sZipPath = "/poop";
+
+    String sZipFile = "resources/test/jcr/ziptest.zip";
+
+    String sJPG = "/hibernate_logo.gif";
+
+    String sText = "/training.txt";
+    
+
+   /**
+    * 
+    *
+    */
+   public TestFileDelete(DataSourceSupport.Config dsCfg)
+   {
+      super(dsCfg);
+   }
+   
+   /**
+    * 
+    *
+    */
+   public static TestSuite suite() throws Exception
+   {
+      URL configsURL = Thread.currentThread().getContextClassLoader().getResource("datasources.xml");
+      DataSourceSupport.Config[] configs = DataSourceSupport.Config.fromXML(configsURL);
+      DatabaseTestSuite suite = new DatabaseTestSuite(configs);
+      suite.addTestCase(TestFileDelete.class);
+      return suite;       
+   }
+
+   /**
+    * 
+    *
+    */
+   public void testFileDelete() throws Exception
+   {
+      createFile();
+      
+      // delete old test nodes
+      Command deleteCMD = service.getCommandFactory().createDeleteCommand(sFilePath);
+      service.execute(deleteCMD);
+      Command deleteToCMD = service.getCommandFactory().createDeleteCommand(sCopyToFilePath);
+      service.execute(deleteToCMD);
+
+      // zip deletes
+      Command deleteZipCMD = service.getCommandFactory().createDeleteCommand(sZipPath);
+      service.execute(deleteZipCMD);
+      Command deleteZipJCMD = service.getCommandFactory().createDeleteCommand(sJPG);
+      service.execute(deleteZipJCMD);
+      Command deleteZipTCMD = service.getCommandFactory().createDeleteCommand(sText);
+      service.execute(deleteZipTCMD);
+
+      Session session = RepositoryUtil.login(service.getRepository(), "anonid", "");
+      assertFalse(sFilePath + " not Deleted", session.itemExists(sFilePath));
+      assertFalse(sCopyToFilePath + " not Deleted", session.itemExists(sCopyToFilePath));
+      assertFalse(sZipPath + " not Deleted", session.itemExists(sZipPath));
+      assertFalse(sJPG + " not Deleted", session.itemExists(sJPG));
+      assertFalse(sText + " not Deleted", session.itemExists(sText));
+
+      RepositoryUtil.safeLogout(session);
+   }   
+   
+   /**
+    * 
+    *
+    */
+   private void createFile() throws CMSException
+   {
+      // create file english
+      File file = new FileImpl();
+      file.setBasePath(sFilePath);
+
+      Content content = new ContentImpl();
+      content.setEncoding("UTF-8");
+      content.setTitle("English Title");
+      content.setDescription("English Description");
+      content.setBasePath(sFilePath + "/" + Locale.ENGLISH.getLanguage());
+      content.setBytes("1234567890".getBytes());
+      content.setMimeType("image/gif");
+      file.setContent(Locale.ENGLISH, content);
+
+      Command newFileCMD = service.getCommandFactory().createNewFileCommand(file, content);
+      service.execute(newFileCMD);
+
+      // create content spanish
+      Content contentSP = new ContentImpl();
+      contentSP.setEncoding("UTF-8");
+      contentSP.setTitle("Spanish Title");
+      contentSP.setDescription("Spanish Description");
+      contentSP.setBasePath(sFilePath + "/es");
+      contentSP.setBytes("0987654321".getBytes());
+      contentSP.setMimeType("image/gif");
+      file.setContent(new Locale("es"), contentSP);
+
+      Command newFileSPCMD = service.getCommandFactory().createNewFileCommand(file, contentSP);
+      service.execute(newFileSPCMD);
+   }
+}

Added: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileGet.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileGet.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileGet.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -0,0 +1,134 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.portal.test.cms.commands;
+
+import java.net.URL;
+import java.util.Locale;
+
+import junit.framework.TestSuite;
+
+import org.jboss.portal.cms.CMSException;
+import org.jboss.portal.cms.Command;
+import org.jboss.portal.cms.impl.ContentImpl;
+import org.jboss.portal.cms.impl.FileImpl;
+import org.jboss.portal.cms.model.Content;
+import org.jboss.portal.cms.model.File;
+import org.jboss.portal.test.framework.embedded.DataSourceSupport;
+import org.jboss.portal.test.framework.junit.DatabaseTestSuite;
+
+
+/**
+ * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:sohil.shah at jboss.com">Sohil Shah</a>
+ */
+public class TestFileGet extends AbstractCommandTestCase
+{
+    String sFilePath = "/testdoc.gif";
+
+    String sCopyToFilePath = "/testdoccopy.gif";
+
+    // zip vars
+    String sZipPath = "/poop";
+
+    String sZipFile = "resources/test/jcr/ziptest.zip";
+
+    String sJPG = "/hibernate_logo.gif";
+
+    String sText = "/training.txt";
+    
+
+   /**
+    * 
+    *
+    */
+   public TestFileGet(DataSourceSupport.Config dsCfg)
+   {
+      super(dsCfg);
+   }
+   
+   /**
+    * 
+    *
+    */
+   public static TestSuite suite() throws Exception
+   {
+      URL configsURL = Thread.currentThread().getContextClassLoader().getResource("datasources.xml");
+      DataSourceSupport.Config[] configs = DataSourceSupport.Config.fromXML(configsURL);
+      DatabaseTestSuite suite = new DatabaseTestSuite(configs);
+      suite.addTestCase(TestFileGet.class);
+      return suite;       
+   }
+
+   /**
+    * Tests retrieval of the version labeled LIVE.
+    */
+   public void testFileGet() throws CMSException
+   {
+      createFile();
+      Command getCMD = service.getCommandFactory().createFileGetCommand(sFilePath, Locale.ENGLISH);
+      File newfile = (File) service.execute(getCMD);
+
+      Content content = newfile.getContent();
+      assertEquals("Encoding Incorrect", content.getEncoding(), "UTF-8");
+      assertEquals("Mimetype Incorrect", content.getMimeType(), "image/gif");
+      assertEquals("Language Incorrect", content.getLocale().getLanguage(), "en");
+      assertEquals("Title Incorrect", content.getTitle(), "English Title");
+      assertEquals("Desc Incorrect", content.getDescription(), "English Description");
+   }   
+   
+   /**
+    * 
+    *
+    */
+   private void createFile() throws CMSException
+   {
+      // create file english
+      File file = new FileImpl();
+      file.setBasePath(sFilePath);
+
+      Content content = new ContentImpl();
+      content.setEncoding("UTF-8");
+      content.setTitle("English Title");
+      content.setDescription("English Description");
+      content.setBasePath(sFilePath + "/" + Locale.ENGLISH.getLanguage());
+      content.setBytes("1234567890".getBytes());
+      content.setMimeType("image/gif");
+      file.setContent(Locale.ENGLISH, content);
+
+      Command newFileCMD = service.getCommandFactory().createNewFileCommand(file, content);
+      service.execute(newFileCMD);
+
+      // create content spanish
+      Content contentSP = new ContentImpl();
+      contentSP.setEncoding("UTF-8");
+      contentSP.setTitle("Spanish Title");
+      contentSP.setDescription("Spanish Description");
+      contentSP.setBasePath(sFilePath + "/es");
+      contentSP.setBytes("0987654321".getBytes());
+      contentSP.setMimeType("image/gif");
+      file.setContent(new Locale("es"), contentSP);
+
+      Command newFileSPCMD = service.getCommandFactory().createNewFileCommand(file, contentSP);
+      service.execute(newFileSPCMD);
+   }
+}

Added: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileGetList.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileGetList.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileGetList.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -0,0 +1,138 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.portal.test.cms.commands;
+
+import java.net.URL;
+import java.util.List;
+import java.util.Locale;
+
+
+import junit.framework.TestSuite;
+
+import org.jboss.portal.cms.CMSException;
+import org.jboss.portal.cms.Command;
+import org.jboss.portal.cms.impl.ContentImpl;
+import org.jboss.portal.cms.impl.FileImpl;
+import org.jboss.portal.cms.model.Content;
+import org.jboss.portal.cms.model.File;
+import org.jboss.portal.test.framework.embedded.DataSourceSupport;
+import org.jboss.portal.test.framework.junit.DatabaseTestSuite;
+
+
+/**
+ * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:sohil.shah at jboss.com">Sohil Shah</a>
+ */
+public class TestFileGetList extends AbstractCommandTestCase
+{
+    String sFilePath = "/testdoc.gif";
+
+    String sCopyToFilePath = "/testdoccopy.gif";
+
+    // zip vars
+    String sZipPath = "/poop";
+
+    String sZipFile = "resources/test/jcr/ziptest.zip";
+
+    String sJPG = "/hibernate_logo.gif";
+
+    String sText = "/training.txt";
+    
+
+   /**
+    * 
+    *
+    */
+   public TestFileGetList(DataSourceSupport.Config dsCfg)
+   {
+      super(dsCfg);
+   }
+   
+   /**
+    * 
+    *
+    */
+   public static TestSuite suite() throws Exception
+   {
+      URL configsURL = Thread.currentThread().getContextClassLoader().getResource("datasources.xml");
+      DataSourceSupport.Config[] configs = DataSourceSupport.Config.fromXML(configsURL);
+      DatabaseTestSuite suite = new DatabaseTestSuite(configs);
+      suite.addTestCase(TestFileGetList.class);
+      return suite;       
+   }
+
+   /**
+    * Tests retrieving a list of contents under a file and the versions for contents.
+    */
+   public void testFileList() throws CMSException
+   {
+      createFile();
+      Command getFileListCMD = service.getCommandFactory().createFileGetListCommand(sFilePath);
+      List contentList = (List) service.execute(getFileListCMD);
+      assertTrue("Incorrect list size", contentList.size() == 2);
+
+      for (int i = 0; i < contentList.size(); i++)
+      {
+         Content content = (Content) contentList.get(i);
+         Command getContentVersionsCMD = service.getCommandFactory().createContentGetVersionsCommand(
+               content.getBasePath());
+         List versionList = (List) service.execute(getContentVersionsCMD);
+      }
+   }   
+   
+   /**
+    * 
+    *
+    */
+   private void createFile() throws CMSException
+   {
+      // create file english
+      File file = new FileImpl();
+      file.setBasePath(sFilePath);
+
+      Content content = new ContentImpl();
+      content.setEncoding("UTF-8");
+      content.setTitle("English Title");
+      content.setDescription("English Description");
+      content.setBasePath(sFilePath + "/" + Locale.ENGLISH.getLanguage());
+      content.setBytes("1234567890".getBytes());
+      content.setMimeType("image/gif");
+      file.setContent(Locale.ENGLISH, content);
+
+      Command newFileCMD = service.getCommandFactory().createNewFileCommand(file, content);
+      service.execute(newFileCMD);
+
+      // create content spanish
+      Content contentSP = new ContentImpl();
+      contentSP.setEncoding("UTF-8");
+      contentSP.setTitle("Spanish Title");
+      contentSP.setDescription("Spanish Description");
+      contentSP.setBasePath(sFilePath + "/es");
+      contentSP.setBytes("0987654321".getBytes());
+      contentSP.setMimeType("image/gif");
+      file.setContent(new Locale("es"), contentSP);
+
+      Command newFileSPCMD = service.getCommandFactory().createNewFileCommand(file, contentSP);
+      service.execute(newFileSPCMD);
+   }
+}

Added: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileGetVersion.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileGetVersion.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileGetVersion.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -0,0 +1,130 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.portal.test.cms.commands;
+
+import java.net.URL;
+import java.util.Locale;
+
+
+import junit.framework.TestSuite;
+
+import org.jboss.portal.cms.CMSException;
+import org.jboss.portal.cms.Command;
+import org.jboss.portal.cms.impl.ContentImpl;
+import org.jboss.portal.cms.impl.FileImpl;
+import org.jboss.portal.cms.model.Content;
+import org.jboss.portal.cms.model.File;
+import org.jboss.portal.test.framework.embedded.DataSourceSupport;
+import org.jboss.portal.test.framework.junit.DatabaseTestSuite;
+
+
+/**
+ * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:sohil.shah at jboss.com">Sohil Shah</a>
+ */
+public class TestFileGetVersion extends AbstractCommandTestCase
+{
+    String sFilePath = "/testdoc.gif";
+
+    String sCopyToFilePath = "/testdoccopy.gif";
+
+    // zip vars
+    String sZipPath = "/poop";
+
+    String sZipFile = "resources/test/jcr/ziptest.zip";
+
+    String sJPG = "/hibernate_logo.gif";
+
+    String sText = "/training.txt";
+    
+
+   /**
+    * 
+    *
+    */
+   public TestFileGetVersion(DataSourceSupport.Config dsCfg)
+   {
+      super(dsCfg);
+   }
+   
+   /**
+    * 
+    *
+    */
+   public static TestSuite suite() throws Exception
+   {
+      URL configsURL = Thread.currentThread().getContextClassLoader().getResource("datasources.xml");
+      DataSourceSupport.Config[] configs = DataSourceSupport.Config.fromXML(configsURL);
+      DatabaseTestSuite suite = new DatabaseTestSuite(configs);
+      suite.addTestCase(TestFileGetVersion.class);
+      return suite;       
+   }
+
+   /**
+    * Tests retrieval of a specific version by version number.
+    */
+   public void testFileGetVersion() throws CMSException
+   {
+      createFile();
+      // get specific file version
+      Command getCMDV = service.getCommandFactory().createFileGetCommand(sFilePath, "1.0", Locale.ENGLISH);
+      File Vnewfile = (File) service.execute(getCMDV);
+      assertTrue("Incorrect version number for file object", Vnewfile.getContent().getVersionNumber().equals("1.0"));
+   }   
+   
+   /**
+    * 
+    *
+    */
+   private void createFile() throws CMSException
+   {
+      // create file english
+      File file = new FileImpl();
+      file.setBasePath(sFilePath);
+
+      Content content = new ContentImpl();
+      content.setEncoding("UTF-8");
+      content.setTitle("English Title");
+      content.setDescription("English Description");
+      content.setBasePath(sFilePath + "/" + Locale.ENGLISH.getLanguage());
+      content.setBytes("1234567890".getBytes());
+      content.setMimeType("image/gif");
+      file.setContent(Locale.ENGLISH, content);
+
+      Command newFileCMD = service.getCommandFactory().createNewFileCommand(file, content);
+      service.execute(newFileCMD);
+
+      // create content spanish
+      Content contentSP = new ContentImpl();
+      contentSP.setEncoding("UTF-8");
+      contentSP.setTitle("Spanish Title");
+      contentSP.setDescription("Spanish Description");
+      contentSP.setBasePath(sFilePath + "/es");
+      contentSP.setBytes("0987654321".getBytes());
+      contentSP.setMimeType("image/gif");
+      file.setContent(new Locale("es"), contentSP);
+
+      Command newFileSPCMD = service.getCommandFactory().createNewFileCommand(file, contentSP);
+      service.execute(newFileSPCMD);
+   }
+}

Added: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileUpdate.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileUpdate.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFileUpdate.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -0,0 +1,151 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.portal.test.cms.commands;
+
+import java.net.URL;
+import java.util.Locale;
+
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.Session;
+
+import junit.framework.TestSuite;
+
+import org.jboss.portal.cms.CMSException;
+import org.jboss.portal.cms.Command;
+import org.jboss.portal.cms.impl.ContentImpl;
+import org.jboss.portal.cms.impl.FileImpl;
+import org.jboss.portal.cms.impl.jcr.util.VersionUtil;
+import org.jboss.portal.cms.model.Content;
+import org.jboss.portal.cms.model.File;
+import org.jboss.portal.cms.util.RepositoryUtil;
+import org.jboss.portal.test.framework.embedded.DataSourceSupport;
+import org.jboss.portal.test.framework.junit.DatabaseTestSuite;
+
+
+/**
+ * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:sohil.shah at jboss.com">Sohil Shah</a>
+ */
+public class TestFileUpdate extends AbstractCommandTestCase
+{
+    String sFilePath = "/testdoc.gif";
+
+    String sCopyToFilePath = "/testdoccopy.gif";
+
+    // zip vars
+    String sZipPath = "/poop";
+
+    String sZipFile = "resources/test/jcr/ziptest.zip";
+
+    String sJPG = "/hibernate_logo.gif";
+
+    String sText = "/training.txt";
+    
+
+   /**
+    * 
+    *
+    */
+   public TestFileUpdate(DataSourceSupport.Config dsCfg)
+   {
+      super(dsCfg);
+   }
+   
+   /**
+    * 
+    *
+    */
+   public static TestSuite suite() throws Exception
+   {
+      URL configsURL = Thread.currentThread().getContextClassLoader().getResource("datasources.xml");
+      DataSourceSupport.Config[] configs = DataSourceSupport.Config.fromXML(configsURL);
+      DatabaseTestSuite suite = new DatabaseTestSuite(configs);
+      suite.addTestCase(TestFileUpdate.class);
+      return suite;       
+   }
+
+   /**
+    * Tests updating a file and its content.
+    * @throws Exception 
+    */
+   public void testFileUpdate() throws Exception
+   {
+      createFile();
+      Session session = RepositoryUtil.login(service.getRepository(), "anonid", "");
+      Command getCMD = service.getCommandFactory().createFileGetCommand(sFilePath, Locale.ENGLISH);
+      File newfile = (File) service.execute(getCMD);
+      Content content = newfile.getContent();
+      content.setDescription("New English Description");
+      newfile.setContent(content.getLocale(), content);
+      // update file and make "LIVE"
+      Command cmdUpdate = service.getCommandFactory().createFileUpdateCommand(newfile);
+      service.execute(cmdUpdate);
+
+      Command cmdVersion = service.getCommandFactory().createContentCreateNewVersionCommand(content, true);
+      service.execute(cmdVersion);
+
+      boolean descriptionupdated = ((Property) session.getItem("/testdoc.gif/en/portalcms:description")).getString()
+            .equals("New English Description");
+      assertTrue("Incorrect description for file object", descriptionupdated);
+
+      // version std out dump
+      VersionUtil.print((Node) session.getItem(content.getBasePath()));
+   }   
+   
+   /**
+    * 
+    *
+    */
+   private void createFile() throws CMSException
+   {
+      // create file english
+      File file = new FileImpl();
+      file.setBasePath(sFilePath);
+
+      Content content = new ContentImpl();
+      content.setEncoding("UTF-8");
+      content.setTitle("English Title");
+      content.setDescription("English Description");
+      content.setBasePath(sFilePath + "/" + Locale.ENGLISH.getLanguage());
+      content.setBytes("1234567890".getBytes());
+      content.setMimeType("image/gif");
+      file.setContent(Locale.ENGLISH, content);
+
+      Command newFileCMD = service.getCommandFactory().createNewFileCommand(file, content);
+      service.execute(newFileCMD);
+
+      // create content spanish
+      Content contentSP = new ContentImpl();
+      contentSP.setEncoding("UTF-8");
+      contentSP.setTitle("Spanish Title");
+      contentSP.setDescription("Spanish Description");
+      contentSP.setBasePath(sFilePath + "/es");
+      contentSP.setBytes("0987654321".getBytes());
+      contentSP.setMimeType("image/gif");
+      file.setContent(new Locale("es"), contentSP);
+
+      Command newFileSPCMD = service.getCommandFactory().createNewFileCommand(file, contentSP);
+      service.execute(newFileSPCMD);
+   }
+}

Deleted: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFolderCommands.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFolderCommands.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFolderCommands.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -1,342 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.portal.test.cms.commands;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.net.URL;
-import java.util.Date;
-import java.util.Locale;
-
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.Session;
-
-import junit.framework.TestSuite;
-
-import org.jboss.portal.cms.Command;
-import org.jboss.portal.cms.CMSException;
-import org.jboss.portal.cms.impl.ContentImpl;
-import org.jboss.portal.cms.impl.FileImpl;
-import org.jboss.portal.cms.impl.FolderImpl;
-import org.jboss.portal.cms.impl.jcr.JCRCMS;
-import org.jboss.portal.cms.model.Content;
-import org.jboss.portal.cms.model.File;
-import org.jboss.portal.cms.model.Folder;
-import org.jboss.portal.cms.util.RepositoryUtil;
-import org.jboss.portal.common.util.CLLoader;
-import org.jboss.portal.common.util.LoaderResource;
-import org.jboss.portal.common.util.XML;
-import org.jboss.portal.test.cms.AbstractCMSTestCase;
-import org.jboss.portal.test.framework.embedded.DataSourceSupport;
-import org.jboss.portal.test.framework.junit.DatabaseTestSuite;
-
-/**
- * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- */
-public class TestFolderCommands extends AbstractCMSTestCase
-{
-   /**
-    * A test folder path *
-    */
-   String sFolderPath = "/alpha";
-
-   /**
-    * A test folder path for copied folder trees *
-    */
-   String sCopyToFolderPath = "/alpha/beta";
-
-   JCRCMS service;
-
-   public TestFolderCommands(DataSourceSupport.Config dsCfg)
-   {
-      super(dsCfg);
-   }
-
-   public void setUp() throws Exception
-   {
-      super.setUp();
-
-      LoaderResource res = new CLLoader().getResource("jcr/repository.xml");
-
-      service = new JCRCMS();
-      service.setDoChecking(true);
-      service.setDefaultLocale(Locale.ENGLISH.getDisplayName());
-      service.setDefaultContentLocation("default-content/default");
-
-      service.setConfig(res.asDocument(XML.getDocumentBuilderFactory().newDocumentBuilder()).getDocumentElement());
-      service.setRepositoryName("repo");
-      service.setHomeDir("repo");
-      service.start();
-   }
-
-   public void tearDown() throws Exception
-   {
-      service.stop();
-      super.tearDown();
-   }
-
-   public static TestSuite suite() throws Exception
-   {
-      URL configsURL = Thread.currentThread().getContextClassLoader().getResource("datasources.xml");
-      DataSourceSupport.Config[] configs = DataSourceSupport.Config.fromXML(configsURL);
-      DatabaseTestSuite suite = new DatabaseTestSuite(configs);
-      suite.addTestCase(TestFolderCommands.class);
-      return suite;
-   }
-
-   /**
-    * Deleted test data from repo, and also tests delete cmd.
-    * @throws Exception
-    */
-   public void testFolderDelete() throws Exception
-   {
-      Session session = RepositoryUtil.login(service.getRepository(), "anonid", "");
-      Command deleteCMD = service.getCommandFactory().createDeleteCommand(sFolderPath);
-      service.execute(deleteCMD);
-      assertFalse(sFolderPath + " failed to delete.", session.itemExists(sFolderPath));
-
-      Command deleteToCMD = service.getCommandFactory().createDeleteCommand(sCopyToFolderPath);
-      service.execute(deleteToCMD);
-      assertFalse(sCopyToFolderPath + " failed to delete.", session.itemExists(sCopyToFolderPath));
-   }
-
-   /**
-    * Copy test data from repo
-    */
-
-   public void testFolderCopy() throws CMSException
-   {
-      // create folder object
-      Folder folder = new FolderImpl();
-      folder.setCreationDate(new Date());
-      folder.setDescription("Folder description");
-      folder.setTitle("Folder Title");
-      folder.setLastModified(new Date());
-      folder.setName("Alpha Folder");
-      folder.setBasePath("/alpha1");
-
-      // save folder
-      Command saveCMD = service.getCommandFactory().createFolderSaveCommand(folder);
-      service.execute(saveCMD);
-
-      // create file english
-      File file = new FileImpl();
-      file.setBasePath("/alpha1/toto.txt");
-
-      Content content = new ContentImpl();
-      content.setEncoding("UTF-8");
-      content.setTitle("English Title");
-      content.setDescription("English Description");
-      content.setBasePath("/alpha1/toto.txt/" + Locale.ENGLISH.getLanguage());
-      content.setBytes("1234567890".getBytes());
-      content.setMimeType("image/gif");
-
-      file.setContent(Locale.ENGLISH, content);
-
-      // save english file
-      Command saveFileCMD = service.getCommandFactory().createNewFileCommand(file, content);
-      service.execute(saveFileCMD);
-
-      Folder folder2 = new FolderImpl();
-      folder2.setCreationDate(new Date());
-      folder2.setDescription("Folder description");
-      folder2.setTitle("Folder Title");
-      folder2.setLastModified(new Date());
-      folder2.setName("Beta Folder");
-      folder2.setBasePath("/beta1");
-
-      // save folder
-      Command saveCMD2 = service.getCommandFactory().createFolderSaveCommand(folder2);
-      service.execute(saveCMD2);
-
-      Command copyFolderCMD = service.getCommandFactory().createCopyCommand("/alpha1", "/beta1/test");
-      service.execute(copyFolderCMD);
-
-      Command getLiveCMD = service.getCommandFactory().createFileGetCommand("/alpha1/toto.txt", Locale.ENGLISH);
-      File fileOrig = (File) service.execute(getLiveCMD);
-
-      assertNotNull("Content of the original file is null", fileOrig.getContent());
-
-      getLiveCMD = service.getCommandFactory().createFileGetCommand("/beta1/test/toto.txt", Locale.ENGLISH);
-      File fileCopy = (File) service.execute(getLiveCMD);
-
-      assertNotNull("Content of the copied file is null", fileCopy.getContent());
-   }
-
-   public void testFolderCreate() throws Exception
-   {
-      // create folder object
-      Folder folder = new FolderImpl();
-      folder.setCreationDate(new Date());
-      folder.setDescription("Folder description");
-      folder.setTitle("Folder Title");
-      folder.setLastModified(new Date());
-      folder.setName("Alpha Folder");
-      folder.setBasePath(sFolderPath);
-
-      // save folder
-      Command saveCMD = service.getCommandFactory().createFolderSaveCommand(folder);
-      service.execute(saveCMD);
-
-      // get folder - RAW
-      Session session = RepositoryUtil.login(service.getRepository(), "anonid", "");
-      Node folderNode = (Node) session.getItem(sFolderPath);
-      assertNotNull("FolderNodeis null", folderNode);
-      assertTrue("Incorrect primarynodetype", folderNode.getPrimaryNodeType().getName().equals("portalcms:folder"));
-      assertTrue("Incorrect Name for " + sFolderPath, folderNode.getName().equals("alpha"));
-      session.save();
-
-      Property description = folderNode.getProperty("portalcms:description");
-      assertNotNull("Folder description  is null", description);
-      assertTrue("Incorrect description for " + sFolderPath, description.getString().equals("Folder description"));
-   }
-
-   public void testFolderGet() throws CMSException
-   {
-      createFolder();
-      // get folder
-      Command getCMD = service.getCommandFactory().createFolderGetCommand(sFolderPath);
-      Folder newFolder = (Folder) service.execute(getCMD);
-      assertTrue("Folder retrieval failed.", newFolder.getDescription().equals("Folder description"));
-   }
-
-   public void testFolderUpdate() throws Exception
-   {
-      createFolder();
-      // get folder
-      Command getCMD = service.getCommandFactory().createFolderGetCommand(sFolderPath);
-      Folder newFolder = (Folder) service.execute(getCMD);
-
-      // update folder
-      newFolder.setDescription("new folder description");
-      Command cmdUpdate = service.getCommandFactory().createFolderUpdateCommand(newFolder);
-      service.execute(cmdUpdate);
-
-      Session session = RepositoryUtil.login(service.getRepository(), "anonid", "");
-      Property prop = (Property) session.getItem("/alpha/portalcms:description");
-      System.out.println(prop.getString());
-      boolean descriptionupdated = ((Property) session.getItem("/alpha/portalcms:description")).getString().equals(
-            "new folder description");
-      assertTrue("Incorrect description for folder: ", descriptionupdated);
-      session.save();
-   }
-
-   public void createFolder() throws CMSException
-   {
-      // create folder object
-      Folder folder = new FolderImpl();
-      folder.setCreationDate(new Date());
-      folder.setDescription("Folder description");
-      folder.setTitle("Folder Title");
-      folder.setLastModified(new Date());
-      folder.setName("Alpha Folder");
-      folder.setBasePath(sFolderPath);
-
-      // save folder
-      Command saveCMD = service.getCommandFactory().createFolderSaveCommand(folder);
-      service.execute(saveCMD);
-   }
-
-   //   public void testFolderCopy()
-   //   {
-   //      try
-   //      {
-   //         // copy folder tree
-   //         Command copyCMD = service.getCommandFactory().createCopyCommand(sFolderPath, sCopyToFolderPath);
-   //         service.execute(copyCMD);
-   //
-   //         Command getcopiedCMD = service.getCommandFactory().createFolderGetCommand(sCopyToFolderPath);
-   //         Folder copiedfolder = (Folder) service.execute(getcopiedCMD);
-   //         assertTrue("Incorrect description for folder object", copiedfolder.getDescription().equals("new folder description"));
-   //      }
-   //      catch(Exception e)
-   //      {
-   //         e.printStackTrace();
-   //         fail("" + e);
-   //      }
-   //   }
-   //
-   //   public void testFolderList()
-   //   {
-   ///*
-   //      // delete old test nodes
-   //      Command deleteCMD = service.getCommandFactory().createDeleteCommand(sFolderPath + "/foo.gif");
-   //      service.execute(deleteCMD);
-   //      Command deleteToCMD = service.getCommandFactory().createDeleteCommand(sFolderPath + "/bar.zip");
-   //      service.execute(deleteToCMD);
-   //
-   //      // create 2 files
-   //      File file = new FileImpl();
-   //      file.setDescription("File description");
-   //      file.setTitle("File Title");
-   //      file.setLastModified(new Date());
-   //      file.setName("foo");
-   ////      file.setLanguage("en");
-   //      Content content = new ContentImpl();
-   ////      content.setContent("1234567890".getBytes());
-   ////      file.setMimeType("plain/text");
-   //      content.setEncoding("utf-8");
-   ////      file.setContent(content);
-   //      file.setBasePath(sFolderPath + "/foo.gif");
-   //      Command saveCMD = service.getCommandFactory().createFileSaveCommand(file);
-   //      service.execute(saveCMD);
-   //      Command verCMD = service.getCommandFactory().createContentCreateNewVersionCommand(file);
-   //      service.execute(verCMD);
-   //
-   //      File file2 = new FileImpl();
-   //      file2.setDescription("File description");
-   //      file2.setTitle("File Title");
-   //      file2.setLastModified(new Date());
-   //      file2.setName("bar");
-   ////      file2.setLanguage("en");
-   //      Content content2 = new ContentImpl();
-   ////      content2.setContent("0987654321".getBytes());
-   ////      file2.setMimeType("text/html");
-   //      content2.setEncoding("utf-8");
-   ////      file2.setContent(content2);
-   //      file2.setBasePath(sFolderPath + "/bar.zip");
-   //      Command saveCMD2 = service.getCommandFactory().createFileSaveCommand(file2);
-   //      service.execute(saveCMD2);
-   //      Command verCMD2 = service.getCommandFactory().createContentCreateNewVersionCommand(file2);
-   //      service.execute(verCMD2);
-   //
-   //      // create child folder object
-   //      Folder folder = new FolderImpl();
-   //      folder.setCreationDate(new Date());
-   //      folder.setDescription("Omega Folder description");
-   //      folder.setTitle("Omega Folder Title");
-   //      folder.setLastModified(new Date());
-   //      folder.setName("Omega Folder");
-   //      folder.setBasePath(sFolderPath + "/omega");
-   //
-   //      // retrieve list
-   //      Command listCMD = service.getCommandFactory().createFolderGetListCommand(sFolderPath);
-   //      Folder whopper = (Folder) service.execute(listCMD);
-   //      List folders = whopper.getFolders();
-   //      List files = whopper.getFiles();
-   //      assertTrue("Incorrect folder size", folders.size() == 1);
-   //      assertTrue("Incorrect number of files in folder", files.size() == 2);
-   //      */
-   //   }
-}

Added: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFolderCopy.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFolderCopy.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFolderCopy.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -0,0 +1,143 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.portal.test.cms.commands;
+
+import java.net.URL;
+import java.util.Date;
+import java.util.Locale;
+
+
+import junit.framework.TestSuite;
+
+import org.jboss.portal.cms.Command;
+import org.jboss.portal.cms.impl.ContentImpl;
+import org.jboss.portal.cms.impl.FileImpl;
+import org.jboss.portal.cms.impl.FolderImpl;
+import org.jboss.portal.cms.model.Content;
+import org.jboss.portal.cms.model.File;
+import org.jboss.portal.cms.model.Folder;
+import org.jboss.portal.test.framework.embedded.DataSourceSupport;
+import org.jboss.portal.test.framework.junit.DatabaseTestSuite;
+
+
+/**
+ * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:sohil.shah at jboss.com">Sohil Shah</a>
+ */
+public class TestFolderCopy extends AbstractCommandTestCase
+{
+   /**
+    * A test folder path *
+    */
+   String sFolderPath = "/alpha";
+
+   /**
+    * A test folder path for copied folder trees *
+    */
+   String sCopyToFolderPath = "/alpha/beta";
+
+   /**
+    * 
+    *
+    */
+   public TestFolderCopy(DataSourceSupport.Config dsCfg)
+   {
+      super(dsCfg);
+   }
+   
+   /**
+    * 
+    *
+    */
+   public static TestSuite suite() throws Exception
+   {
+      URL configsURL = Thread.currentThread().getContextClassLoader().getResource("datasources.xml");
+      DataSourceSupport.Config[] configs = DataSourceSupport.Config.fromXML(configsURL);
+      DatabaseTestSuite suite = new DatabaseTestSuite(configs);
+      suite.addTestCase(TestFolderCopy.class);
+      return suite;       
+   }
+
+   
+   /**
+    * Copy test data from repo
+    */
+   public void testFolderCopy() throws Exception
+   {
+	      // create folder object
+	      Folder folder = new FolderImpl();
+	      folder.setCreationDate(new Date());
+	      folder.setDescription("Folder description");
+	      folder.setTitle("Folder Title");
+	      folder.setLastModified(new Date());
+	      folder.setName("Alpha Folder");
+	      folder.setBasePath("/alpha1");
+	
+	      // save folder
+	      Command saveCMD = service.getCommandFactory().createFolderSaveCommand(folder);
+	      service.execute(saveCMD);
+	
+	      // create file english
+	      File file = new FileImpl();
+	      file.setBasePath("/alpha1/toto.txt");
+	
+	      Content content = new ContentImpl();
+	      content.setEncoding("UTF-8");
+	      content.setTitle("English Title");
+	      content.setDescription("English Description");
+	      content.setBasePath("/alpha1/toto.txt/" + Locale.ENGLISH.getLanguage());
+	      content.setBytes("1234567890".getBytes());
+	      content.setMimeType("image/gif");
+	
+	      file.setContent(Locale.ENGLISH, content);
+	
+	      // save english file
+	      Command saveFileCMD = service.getCommandFactory().createNewFileCommand(file, content);
+	      service.execute(saveFileCMD);
+	
+	      Folder folder2 = new FolderImpl();
+	      folder2.setCreationDate(new Date());
+	      folder2.setDescription("Folder description");
+	      folder2.setTitle("Folder Title");
+	      folder2.setLastModified(new Date());
+	      folder2.setName("Beta Folder");
+	      folder2.setBasePath("/beta1");
+	
+	      // save folder
+	      Command saveCMD2 = service.getCommandFactory().createFolderSaveCommand(folder2);
+	      service.execute(saveCMD2);
+	
+	      Command copyFolderCMD = service.getCommandFactory().createCopyCommand("/alpha1", "/beta1/test");
+	      service.execute(copyFolderCMD);
+	
+	      Command getLiveCMD = service.getCommandFactory().createFileGetCommand("/alpha1/toto.txt", Locale.ENGLISH);
+	      File fileOrig = (File) service.execute(getLiveCMD);
+	
+	      assertNotNull("Content of the original file is null", fileOrig.getContent());
+	
+	      getLiveCMD = service.getCommandFactory().createFileGetCommand("/beta1/test/toto.txt", Locale.ENGLISH);
+	      File fileCopy = (File) service.execute(getLiveCMD);
+	
+	      assertNotNull("Content of the copied file is null", fileCopy.getContent());
+   }   
+}

Added: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFolderCreate.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFolderCreate.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFolderCreate.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -0,0 +1,113 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.portal.test.cms.commands;
+
+import java.net.URL;
+import java.util.Date;
+
+
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.Session;
+
+import junit.framework.TestSuite;
+
+import org.jboss.portal.cms.Command;
+import org.jboss.portal.cms.impl.FolderImpl;
+import org.jboss.portal.cms.model.Folder;
+import org.jboss.portal.cms.util.RepositoryUtil;
+import org.jboss.portal.test.framework.embedded.DataSourceSupport;
+import org.jboss.portal.test.framework.junit.DatabaseTestSuite;
+
+
+/**
+ * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:sohil.shah at jboss.com">Sohil Shah</a>
+ */
+public class TestFolderCreate extends AbstractCommandTestCase
+{
+   /**
+    * A test folder path *
+    */
+   String sFolderPath = "/alpha";
+
+   /**
+    * A test folder path for copied folder trees *
+    */
+   String sCopyToFolderPath = "/alpha/beta";
+
+   /**
+    * 
+    *
+    */
+   public TestFolderCreate(DataSourceSupport.Config dsCfg)
+   {
+      super(dsCfg);
+   }
+   
+   /**
+    * 
+    *
+    */
+   public static TestSuite suite() throws Exception
+   {
+      URL configsURL = Thread.currentThread().getContextClassLoader().getResource("datasources.xml");
+      DataSourceSupport.Config[] configs = DataSourceSupport.Config.fromXML(configsURL);
+      DatabaseTestSuite suite = new DatabaseTestSuite(configs);
+      suite.addTestCase(TestFolderCreate.class);
+      return suite;       
+   }
+
+   
+   /**
+    * 
+    *
+    */
+   public void testFolderCreate() throws Exception
+   {
+      // create folder object
+      Folder folder = new FolderImpl();
+      folder.setCreationDate(new Date());
+      folder.setDescription("Folder description");
+      folder.setTitle("Folder Title");
+      folder.setLastModified(new Date());
+      folder.setName("Alpha Folder");
+      folder.setBasePath(sFolderPath);
+
+      // save folder
+      Command saveCMD = service.getCommandFactory().createFolderSaveCommand(folder);
+      service.execute(saveCMD);
+
+      // get folder - RAW
+      Session session = RepositoryUtil.login(service.getRepository(), "anonid", "");
+      Node folderNode = (Node) session.getItem(sFolderPath);
+      assertNotNull("FolderNodeis null", folderNode);
+      assertTrue("Incorrect primarynodetype", folderNode.getPrimaryNodeType().getName().equals("portalcms:folder"));
+      assertTrue("Incorrect Name for " + sFolderPath, folderNode.getName().equals("alpha"));
+      session.save();
+
+      Property description = folderNode.getProperty("portalcms:description");
+      assertNotNull("Folder description  is null", description);
+      assertTrue("Incorrect description for " + sFolderPath, description.getString().equals("Folder description"));
+   }   
+}

Added: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFolderDelete.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFolderDelete.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFolderDelete.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.portal.test.cms.commands;
+
+import java.net.URL;
+
+import javax.jcr.Session;
+
+import junit.framework.TestSuite;
+
+import org.jboss.portal.cms.Command;
+import org.jboss.portal.cms.util.RepositoryUtil;
+import org.jboss.portal.test.framework.embedded.DataSourceSupport;
+import org.jboss.portal.test.framework.junit.DatabaseTestSuite;
+
+
+/**
+ * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:sohil.shah at jboss.com">Sohil Shah</a>
+ */
+public class TestFolderDelete extends AbstractCommandTestCase
+{
+   /**
+    * A test folder path *
+    */
+   String sFolderPath = "/alpha";
+
+   /**
+    * A test folder path for copied folder trees *
+    */
+   String sCopyToFolderPath = "/alpha/beta";
+
+   /**
+    * 
+    *
+    */
+   public TestFolderDelete(DataSourceSupport.Config dsCfg)
+   {
+      super(dsCfg);
+   }
+   
+   /**
+    * 
+    *
+    */
+   public static TestSuite suite() throws Exception
+   {
+      URL configsURL = Thread.currentThread().getContextClassLoader().getResource("datasources.xml");
+      DataSourceSupport.Config[] configs = DataSourceSupport.Config.fromXML(configsURL);
+      DatabaseTestSuite suite = new DatabaseTestSuite(configs);
+      suite.addTestCase(TestFolderDelete.class);
+      return suite;       
+   }
+
+   /**
+    * Deleted test data from repo, and also tests delete cmd.
+    * @throws Exception
+    */
+   public void testFolderDelete() throws Exception
+   {
+       Session session = RepositoryUtil.login(service.getRepository(), "anonid", "");
+	   Command deleteCMD = service.getCommandFactory().createDeleteCommand(sFolderPath);
+       service.execute(deleteCMD);
+       assertFalse(sFolderPath + " failed to delete.", session.itemExists(sFolderPath));
+
+       Command deleteToCMD = service.getCommandFactory().createDeleteCommand(sCopyToFolderPath);
+       service.execute(deleteToCMD);
+       assertFalse(sCopyToFolderPath + " failed to delete.", session.itemExists(sCopyToFolderPath));
+   }   
+}

Added: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFolderGet.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFolderGet.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFolderGet.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.portal.test.cms.commands;
+
+import java.net.URL;
+import java.util.Date;
+
+import junit.framework.TestSuite;
+
+import org.jboss.portal.cms.Command;
+import org.jboss.portal.cms.CMSException;
+import org.jboss.portal.cms.impl.FolderImpl;
+import org.jboss.portal.cms.model.Folder;
+import org.jboss.portal.test.framework.embedded.DataSourceSupport;
+import org.jboss.portal.test.framework.junit.DatabaseTestSuite;
+
+/**
+ * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:sohil.shah at jboss.com">Sohil Shah</a>
+ */
+public class TestFolderGet extends AbstractCommandTestCase
+{
+   /**
+    * A test folder path *
+    */
+   String sFolderPath = "/alpha";
+
+   /**
+    * A test folder path for copied folder trees *
+    */
+   String sCopyToFolderPath = "/alpha/beta";
+
+   /**
+    * 
+    *
+    */
+   public TestFolderGet(DataSourceSupport.Config dsCfg)
+   {
+      super(dsCfg);
+   }
+   
+   /**
+    * 
+    *
+    */
+   public static TestSuite suite() throws Exception
+   {
+      URL configsURL = Thread.currentThread().getContextClassLoader().getResource("datasources.xml");
+      DataSourceSupport.Config[] configs = DataSourceSupport.Config.fromXML(configsURL);
+      DatabaseTestSuite suite = new DatabaseTestSuite(configs);
+      suite.addTestCase(TestFolderGet.class);
+      return suite;       
+   }
+
+   
+   /**
+    * 
+    *
+    */
+   public void testFolderGet() throws CMSException
+   {
+      createFolder();
+      // get folder
+      Command getCMD = service.getCommandFactory().createFolderGetCommand(sFolderPath);
+      Folder newFolder = (Folder) service.execute(getCMD);
+      assertTrue("Folder retrieval failed.", newFolder.getDescription().equals("Folder description"));
+   }
+   
+   /**
+    * 
+    *
+    */
+   public void createFolder() throws CMSException
+   {
+      // create folder object
+      Folder folder = new FolderImpl();
+      folder.setCreationDate(new Date());
+      folder.setDescription("Folder description");
+      folder.setTitle("Folder Title");
+      folder.setLastModified(new Date());
+      folder.setName("Alpha Folder");
+      folder.setBasePath(sFolderPath);
+
+      // save folder
+      Command saveCMD = service.getCommandFactory().createFolderSaveCommand(folder);
+      service.execute(saveCMD);
+   }
+}

Added: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFolderUpdate.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFolderUpdate.java	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/test/cms/commands/TestFolderUpdate.java	2006-10-10 06:13:26 UTC (rev 5387)
@@ -0,0 +1,125 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.portal.test.cms.commands;
+
+import java.net.URL;
+import java.util.Date;
+
+
+import javax.jcr.Property;
+import javax.jcr.Session;
+
+import junit.framework.TestSuite;
+
+import org.jboss.portal.cms.Command;
+import org.jboss.portal.cms.CMSException;
+import org.jboss.portal.cms.impl.FolderImpl;
+import org.jboss.portal.cms.model.Folder;
+import org.jboss.portal.cms.util.RepositoryUtil;
+import org.jboss.portal.test.framework.embedded.DataSourceSupport;
+import org.jboss.portal.test.framework.junit.DatabaseTestSuite;
+
+/**
+ * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:sohil.shah at jboss.com">Sohil Shah</a>
+ */
+public class TestFolderUpdate extends AbstractCommandTestCase
+{
+   /**
+    * A test folder path *
+    */
+   String sFolderPath = "/alpha";
+
+   /**
+    * A test folder path for copied folder trees *
+    */
+   String sCopyToFolderPath = "/alpha/beta";
+
+   /**
+    * 
+    *
+    */
+   public TestFolderUpdate(DataSourceSupport.Config dsCfg)
+   {
+      super(dsCfg);
+   }
+   
+   /**
+    * 
+    *
+    */
+   public static TestSuite suite() throws Exception
+   {
+      URL configsURL = Thread.currentThread().getContextClassLoader().getResource("datasources.xml");
+      DataSourceSupport.Config[] configs = DataSourceSupport.Config.fromXML(configsURL);
+      DatabaseTestSuite suite = new DatabaseTestSuite(configs);
+      suite.addTestCase(TestFolderUpdate.class);
+      return suite;       
+   }
+
+   
+   /**
+    * 
+    *
+    */
+   public void testFolderUpdate() throws Exception
+   {
+      createFolder();
+      // get folder
+      Command getCMD = service.getCommandFactory().createFolderGetCommand(sFolderPath);
+      Folder newFolder = (Folder) service.execute(getCMD);
+
+      // update folder
+      newFolder.setDescription("new folder description");
+      Command cmdUpdate = service.getCommandFactory().createFolderUpdateCommand(newFolder);
+      service.execute(cmdUpdate);
+
+      Session session = RepositoryUtil.login(service.getRepository(), "anonid", "");
+      Property prop = (Property) session.getItem("/alpha/portalcms:description");
+      System.out.println(prop.getString());
+      boolean descriptionupdated = ((Property) session.getItem("/alpha/portalcms:description")).getString().equals(
+            "new folder description");
+      assertTrue("Incorrect description for folder: ", descriptionupdated);
+      session.save();
+   }
+   
+   /**
+    * 
+    *
+    */
+   public void createFolder() throws CMSException
+   {
+      // create folder object
+      Folder folder = new FolderImpl();
+      folder.setCreationDate(new Date());
+      folder.setDescription("Folder description");
+      folder.setTitle("Folder Title");
+      folder.setLastModified(new Date());
+      folder.setName("Alpha Folder");
+      folder.setBasePath(sFolderPath);
+
+      // save folder
+      Command saveCMD = service.getCommandFactory().createFolderSaveCommand(folder);
+      service.execute(saveCMD);
+   }
+}

Modified: branches/JBoss_Portal_Branch_2_4/cms/src/resources/hibernate/domain.hbm.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/resources/hibernate/domain.hbm.xml	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/resources/hibernate/domain.hbm.xml	2006-10-10 06:13:26 UTC (rev 5387)
@@ -30,14 +30,14 @@
          <generator class="native"/>
       </id>
       <property
-            name="id"
+            name="nodeId"
             column="NODE_ID"
             type="string"
             length="36"/>
       <property
             name="data"
             column="NODE_DATA"
-            type="blob"
+            type="binary"
             length="100000000"
             not-null="true"/>
    </class>
@@ -49,14 +49,14 @@
          <generator class="native"/>
       </id>
       <property
-            name="id"
+            name="propId"
             column="PROP_ID"
             type="string"
             length="255"/>
       <property
             name="data"
             column="PROP_DATA"
-            type="blob"
+            type="binary"
             length="100000000"
             not-null="true"/>
    </class>
@@ -68,14 +68,14 @@
          <generator class="native"/>
       </id>
       <property
-            name="id"
+            name="refId"
             column="NODE_ID"
             type="string"
             length="36"/>
       <property
             name="data"
             column="REFS_DATA"
-            type="blob"
+            type="binary"
             length="100000000"
             not-null="true"/>
    </class>
@@ -106,14 +106,14 @@
          <generator class="native"/>
       </id>
       <property
-            name="id"
+            name="nodeId"
             column="NODE_ID"
             type="string"
             length="36"/>
       <property
             name="data"
             column="NODE_DATA"
-            type="blob"
+            type="binary"
             length="100000000"
             not-null="true"/>
    </class>
@@ -125,14 +125,14 @@
          <generator class="native"/>
       </id>
       <property
-            name="id"
+            name="propId"
             column="PROP_ID"
             type="string"
             length="255"/>
       <property
             name="data"
             column="PROP_DATA"
-            type="blob"
+            type="binary"
             length="100000000"
             not-null="true"/>
    </class>
@@ -144,14 +144,14 @@
          <generator class="native"/>
       </id>
       <property
-            name="id"
+            name="refId"
             column="NODE_ID"
             type="string"
             length="36"/>
       <property
             name="data"
             column="REFS_DATA"
-            type="blob"
+            type="binary"
             length="100000000"
             not-null="true"/>
    </class>
@@ -252,3 +252,4 @@
                 not-null="true"/>
    </class>
 </hibernate-mapping>
+

Added: branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/sar/META-INF/jboss-service.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/sar/META-INF/jboss-service.xml	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/sar/META-INF/jboss-service.xml	2006-10-10 06:13:26 UTC (rev 5387)
@@ -0,0 +1,352 @@
+<server> 	      
+   <mbean
+      code="org.jboss.portal.jems.hibernate.SessionFactoryBinder"
+      name="portal:service=Hibernate,type=CMS"
+      xmbean-dd=""
+      xmbean-code="org.jboss.portal.common.system.JBossServiceModelMBean">
+      <xmbean/>
+      <depends>jboss.jca:service=DataSourceBinding,name=TestPortalDS</depends>
+      <attribute name="DoChecking">true</attribute>
+      <attribute name="ConfigLocation">conf/hibernate/cms/hibernate.cfg.xml</attribute>
+      <attribute name="JNDIName">java:/portal/cms/CMSSessionFactory</attribute>
+   </mbean>
+   
+   <mbean
+      code="org.jboss.portal.cms.impl.jcr.ha.HAJCRCMS"
+      name="portal:service=CMS"
+      xmbean-dd=""
+      xmbean-code="org.jboss.portal.common.system.JBossServiceModelMBean">
+      <xmbean/>
+      
+      <depends>jboss.jca:service=DataSourceBinding,name=TestPortalDS</depends>      
+      <depends>portal:service=Hibernate,type=CMS</depends>      
+      <!--depends>portal:service=JAASLoginModule</depends-->
+      
+      <!--depends optional-attribute-name="StackFactory" proxy-type="attribute">portal:service=InterceptorStackFactory,type=Cms</depends-->
+      
+      <attribute name="DoChecking">true</attribute>
+      <attribute name="DefaultContentLocation">default-content/default/</attribute>
+      <attribute name="DefaultLocale">en</attribute>
+      <attribute name="RepositoryName">PortalRepository</attribute>
+      <attribute name="HomeDir">${jboss.server.data.dir}${/}portal${/}cms${/}conf</attribute>
+      <attribute name="Config">
+         <Repository>
+            <!--
+               | virtual file system where the repository stores global state (e.g. registered namespaces, custom node types, etc.)
+               | Configure to use FS or RDBMS.
+               -->
+
+            <!-- HibernateStore: uses RDBMS + Hibernate for storage -->
+            <FileSystem class="org.jboss.portal.cms.hibernate.HibernateStore">
+               <param name="schemaObjectPrefix" value="RepositoryEntry"/>
+               <param name="JNDIName" value="java:/portal/cms/CMSSessionFactory"/>
+            </FileSystem>
+
+            <!-- LocalFileSystem: uses FileSystem for storage. -->
+            <!--
+            <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+               <param name="path" value="${rep.home}/repository"/>
+            </FileSystem>
+            -->
+            <Security appName="Jackrabbit">
+               <AccessManager class="org.apache.jackrabbit.core.security.SimpleAccessManager"/>
+               <LoginModule class="org.apache.jackrabbit.core.security.SimpleLoginModule">
+                  <!-- anonymous user name ('anonymous' is the default value) -->
+                  <param name="anonid" value="anonymous"/>
+               </LoginModule>
+            </Security>
+            <Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="default"/>
+            <Workspace name="${wsp.name}">
+               <!-- Virtual file system of the workspace:  Configure to use FS or RDBMS. -->
+
+               <!-- HibernateStore: uses RDBMS + Hibernate for storage -->
+               <FileSystem class="org.jboss.portal.cms.hibernate.HibernateStore">
+                  <param name="schemaObjectPrefix" value="CMSEntry"/>
+                  <param name="JNDIName" value="java:portal/cms/CMSSessionFactory"/>
+               </FileSystem>
+               <!-- LocalFileSystem: uses FileSystem for storage. -->
+               <!--<FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+               <param name="path" value="${wsp.home}"/>
+               </FileSystem>-->
+
+               <!--
+                   persistence manager of the workspace.
+                   Use XMLPersistenceManager for LocalFileSystem Store and HibernatePersistentManager .
+               -->
+
+               <!-- HibernatePersistentManager: uses RDBMS + Hibernate for storage -->
+               <PersistenceManager class="org.jboss.portal.cms.hibernate.state.JBossCachePersistenceManager">
+                  <param name="schemaObjectPrefix" value="WSP"/>
+                  <param name="JNDIName" value="java:portal/cms/CMSSessionFactory"/>
+                  <param name="externalBLOBs" value="false"/>
+               </PersistenceManager>
+               
+               <!-- XMLPersistenceManager: uses FileSystem for storage -->
+               <!--<PersistenceManager class="org.apache.jackrabbit.core.state.xml.XMLPersistenceManager"/>-->
+
+               <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+                  <param name="path" value="${wsp.home}/index"/>
+                  <param name="useCompoundFile" value="true"/>
+                  <param name="minMergeDocs" value="100"/>
+                  <param name="volatileIdleTime" value="3"/>
+                  <param name="maxMergeDocs" value="100000"/>
+                  <param name="mergeFactor" value="10"/>
+                  <param name="bufferSize" value="10"/>
+                  <param name="cacheSize" value="1000"/>
+                  <param name="forceConsistencyCheck" value="false"/>
+                  <param name="autoRepair" value="true"/>
+               </SearchIndex>
+            </Workspace>
+            <Versioning rootPath="${rep.home}/versions">
+               <!--
+                   Configures the filesystem to use for versioning for the respective persistence manager
+                   Configure to use FS or RDBMS.
+               -->
+
+               <!-- HibernateStore: uses RDBMS + Hibernate for storage -->
+               <FileSystem class="org.jboss.portal.cms.hibernate.HibernateStore">
+                  <param name="schemaObjectPrefix" value="VersionEntry"/>
+                  <param name="JNDIName" value="java:portal/cms/CMSSessionFactory"/>
+               </FileSystem>
+               
+               <!-- LocalFileSystem: uses FileSystem for storage. -->
+               <!--
+               <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+                <param name="path" value="${rep.home}/versions"/>
+               </FileSystem>
+               -->
+
+               <!--
+                   Configures the persistence manager to be used for persisting version state.
+                   Use XMLPersistenceManager for LocalFileSystem Store and HibernatePersistentManager for HibernateStore.
+               -->
+
+               <!-- HibernatePersistentManager: uses RDBMS + Hibernate for storage -->
+               <PersistenceManager class="org.jboss.portal.cms.hibernate.state.JBossCachePersistenceManager">
+                  <param name="schemaObjectPrefix" value="Version"/>
+                  <param name="JNDIName" value="java:portal/cms/CMSSessionFactory"/>
+                  <param name="externalBLOBs" value="false"/>
+               </PersistenceManager>
+               
+               <!-- XMLPersistenceManager: uses FileSystem for storage -->
+               <!--<PersistenceManager class="org.apache.jackrabbit.core.state.xml.XMLPersistenceManager"/>-->
+            </Versioning>
+         </Repository>
+      </attribute>
+   </mbean>
+   
+   
+   <!--
+      | Uncomment in clustered mode : HASingleton registration      
+   -->
+   <mbean
+      code="org.jboss.invocation.jrmp.server.JRMPProxyFactory"
+      name="portal:service=ProxyFactory,type=CMS">
+      <depends optional-attribute-name="InvokerName">jboss:service=invoker,type=jrmp</depends>
+      <attribute name="TargetName">portal:service=CMS</attribute>
+      <attribute name="ExportedInterfaces">org.jboss.portal.jems.ha.HASingletonInvokerMBean$Proxy</attribute>
+      <attribute name="InvokeTargetMethod">true</attribute>
+      <attribute name="ClientInterceptors">
+        <interceptors>
+          <interceptor>org.jboss.proxy.ClientMethodInterceptor</interceptor>
+          <interceptor>org.jboss.invocation.InvokerInterceptor</interceptor>
+        </interceptors>
+      </attribute>
+   </mbean>
+   <mbean
+      code="org.jboss.portal.jems.ha.HASingletonInvoker"
+      name="portal:service=HASingletonInvoker,type=CMS">
+      <depends>jboss:service=DefaultPartition</depends>
+      <attribute name="RetryWaitingTimeMS">2000</attribute>
+      <attribute name="MaxRetries">5</attribute>
+      <attribute name="JNDIName">MyServiceInvokeTarget</attribute>
+      <attribute name="JNDIProperties">
+         java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+         java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
+         java.naming.provider.url=${jboss.bind.address:localhost}:1100
+         jnp.disableDiscovery=false
+         jnp.partitionName=${jboss.partition.name:DefaultPartition}
+         jnp.discoveryGroup=${jboss.partition.udpGroup:230.0.0.4}
+         jnp.discoveryPort=1102
+         jnp.discoveryTTL=16
+         jnp.discoveryTimeout=5000
+         jnp.maxRetries=1
+      </attribute>
+      <depends optional-attribute-name="Callback" proxy-type="attribute">portal:service=CMS</depends>
+      <depends optional-attribute-name="ProxyFactory">portal:service=ProxyFactory,type=CMS</depends>
+   </mbean>
+   
+   <!-- TreeCache configuration used to cache CMS data -->
+   <mbean code="org.jboss.cache.TreeCache"
+           name="cms.pm.cache:service=TreeCache">
+   
+           <depends>jboss:service=Naming</depends>
+           <depends>jboss:service=TransactionManager</depends>
+           <depends>portal:service=Hibernate,type=CMS</depends>
+           <depends>portal:service=CMS</depends>
+   
+           <!--
+           Configure the TransactionManager
+           -->
+           <attribute name="TransactionManagerLookupClass">org.jboss.cache.GenericTransactionManagerLookup</attribute>
+           
+           <!--
+		Node locking scheme:
+		OPTIMISTIC
+		PESSIMISTIC (default)
+		using the OPTIMISTIC scheme, the ISOLATION_LEVEL value is ignored
+	   -->
+	   <!--attribute name="NodeLockingScheme">OPTIMISTIC</attribute-->
+   
+           <!--
+               Isolation level : SERIALIZABLE
+                                 REPEATABLE_READ (default)
+                                 READ_COMMITTED
+                                 READ_UNCOMMITTED
+                                 NONE
+           -->
+           <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
+           
+           	   
+   
+           <!--
+                Valid modes are LOCAL
+                                REPL_ASYNC
+                                REPL_SYNC
+                                INVALIDATION_ASYNC
+                                INVALIDATION_SYNC
+           -->
+           <!-- in a non-HA environment with the Jackrabbit cluster is activated -->
+           <!--attribute name="CacheMode">INVALIDATION_ASYNC</attribute-->           
+           <!-- in a HA environment since there is only a singleton node for CMS, this can be local -->
+           <attribute name="CacheMode">LOCAL</attribute>           
+   
+           <!--
+           Just used for async repl: use a replication queue
+           -->
+           <attribute name="UseReplQueue">false</attribute>
+   
+           <!--
+               Replication interval for replication queue (in ms)
+           -->
+           <attribute name="ReplQueueInterval">0</attribute>
+   
+           <!--
+               Max number of elements which trigger replication
+           -->
+           <attribute name="ReplQueueMaxElements">0</attribute>
+   
+           <!-- Name of cluster. Needs to be the same for all clusters, in order
+                to find each other
+           -->
+           <attribute name="ClusterName">JCRPMCache</attribute>
+   
+           <!-- JGroups protocol stack properties. Can also be a URL,
+                e.g. file:/home/bela/default.xml
+              <attribute name="ClusterProperties"></attribute>
+           -->
+   
+           <attribute name="ClusterConfig">
+               <config>
+                   <!-- UDP: if you have a multihomed machine,
+                   set the bind_addr attribute to the appropriate NIC IP address -->
+                   <!-- UDP: On Windows machines, because of the media sense feature
+                    being broken with multicast (even after disabling media sense)
+                    set the loopback attribute to true -->
+                   <UDP mcast_addr="228.1.2.3" mcast_port="48866"
+                       ip_ttl="64" ip_mcast="true" 
+                       receive_on_all_interfaces="true"
+                       mcast_send_buf_size="150000" mcast_recv_buf_size="80000"
+                       ucast_send_buf_size="150000" ucast_recv_buf_size="80000"
+                       loopback="false"/>
+                   <PING timeout="2000" num_initial_members="3"
+                       up_thread="false" down_thread="false"/>
+                   <MERGE2 min_interval="10000" max_interval="20000"/>
+                   <!--        <FD shun="true" up_thread="true" down_thread="true" />-->
+                   <FD_SOCK/>
+                   <VERIFY_SUSPECT timeout="1500"
+                       up_thread="false" down_thread="false"/>
+                   <pbcast.NAKACK gc_lag="50" retransmit_timeout="600,1200,2400,4800"
+                       max_xmit_size="8192" up_thread="false" down_thread="false"/>
+                   <UNICAST timeout="600,1200,2400" window_size="100" min_threshold="10"
+                       down_thread="false"/>
+                   <pbcast.STABLE desired_avg_gossip="20000"
+                       up_thread="false" down_thread="false"/>
+                   <FRAG frag_size="8192"
+                       down_thread="false" up_thread="false"/>
+                   <pbcast.GMS join_timeout="5000" join_retry_timeout="2000"
+                       shun="true" print_local_addr="true"/>
+                   <pbcast.STATE_TRANSFER up_thread="true" down_thread="true"/>
+               </config>
+           </attribute>
+   
+           <!--
+            Whether or not to fetch state on joining a cluster
+            NOTE this used to be called FetchStateOnStartup and has been renamed to be more descriptive.
+            
+            Not supported in version 1.2.4SP2 which is what ships by default in 4.0.4GA 
+           -->
+           <!--attribute name="FetchInMemoryState">false</attribute-->
+   
+           <!--
+               The max amount of time (in milliseconds) we wait until the
+               initial state (ie. the contents of the cache) are retrieved from
+               existing members in a clustered environment
+           -->
+           <attribute name="InitialStateRetrievalTimeout">20000</attribute>
+   
+           <!--
+               Number of milliseconds to wait until all responses for a
+               synchronous call have been received.
+           -->
+           <attribute name="SyncReplTimeout">20000</attribute>
+   
+           <!-- Max number of milliseconds to wait for a lock acquisition -->
+           <attribute name="LockAcquisitionTimeout">15000</attribute>
+   
+   
+           <!-- Name of the eviction policy class. -->
+           <attribute name="EvictionPolicyClass"></attribute>
+          
+          <!--
+             Indicate whether to use region based marshalling or not. Set this to true if you are running under a scoped
+             class loader, e.g., inside an application server. Default is "false".
+             
+             Not supported in version 1.2.4SP2 which is what ships by default in 4.0.4GA 
+          -->
+           <!--attribute name="UseRegionBasedMarshalling">false</attribute-->
+           
+           <!--
+           		Configuring the PortalCMSCacheLoader
+           		
+           		CacheLoader configuratoon for 1.4.0
+           -->           
+           <attribute name="CacheLoaderConfiguration">
+               <config>                
+                   <passivation>false</passivation>
+                   <preload></preload>
+                   <shared>false</shared>
+                   <cacheloader>
+                       <class>org.jboss.portal.cms.hibernate.state.PortalCMSCacheLoader</class>
+                       <properties></properties>
+                       <async>false</async>
+                       <fetchPersistentState>false</fetchPersistentState>
+                       <ignoreModifications>false</ignoreModifications>
+                   </cacheloader>
+               </config>
+           </attribute>
+           <!--
+           		Configuring the PortalCMSCacheLoader
+           		
+           		CacheLoader configuratoon for 1.2.4SP2
+           --> 
+           <!--attribute name="CacheLoaderClass">org.jboss.portal.cms.hibernate.state.PortalCMSCacheLoader</attribute>       
+           <attribute name="CacheLoaderConfig" replace="false"></attribute>
+           <attribute name="CacheLoaderPassivation">false</attribute>
+           <attribute name="CacheLoaderPreload"></attribute>
+           <attribute name="CacheLoaderShared">false</attribute>           
+           <attribute name="CacheLoaderFetchTransientState">false</attribute>
+           <attribute name="CacheLoaderFetchPersistentState">false</attribute>
+           <attribute name="CacheLoaderAsynchronous">false</attribute-->          
+    </mbean>      
+</server>

Added: branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/sar/conf/hibernate/cms/domain.hbm.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/sar/conf/hibernate/cms/domain.hbm.xml	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/sar/conf/hibernate/cms/domain.hbm.xml	2006-10-10 06:13:26 UTC (rev 5387)
@@ -0,0 +1,255 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+   "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping>
+   <class name="org.jboss.portal.cms.hibernate.state.VersionBinVal" table="jbp_cms_version_binval" lazy="true">
+      <id
+            name="key"
+            column="PK"
+            type="java.lang.Integer">
+         <generator class="native"/>
+      </id>
+      <property
+            name="id"
+            column="BINVAL_ID"
+            type="string"
+            length="255"/>
+      <property
+            name="data"
+            column="BINVAL_DATA"
+            type="blob"
+            length="100000000"
+            not-null="true"/>
+   </class>
+   <class name="org.jboss.portal.cms.hibernate.state.VersionNode" table="jbp_cms_version_node" lazy="true">
+      <id
+            name="key"
+            column="PK"
+            type="java.lang.Integer">
+         <generator class="native"/>
+      </id>
+      <property
+            name="nodeId"
+            column="NODE_ID"
+            type="string"
+            length="36"/>
+      <property
+            name="data"
+            column="NODE_DATA"
+            type="binary"
+            length="100000000"
+            not-null="true"/>
+   </class>
+   <class name="org.jboss.portal.cms.hibernate.state.VersionProp" table="jbp_cms_version_prop" lazy="true">
+      <id
+            name="key"
+            column="PK"
+            type="java.lang.Integer">
+         <generator class="native"/>
+      </id>
+      <property
+            name="propId"
+            column="PROP_ID"
+            type="string"
+            length="255"/>
+      <property
+            name="data"
+            column="PROP_DATA"
+            type="binary"
+            length="100000000"
+            not-null="true"/>
+   </class>
+   <class name="org.jboss.portal.cms.hibernate.state.VersionRefs" table="jbp_cms_version_refs" lazy="true">
+      <id
+            name="key"
+            column="PK"
+            type="java.lang.Integer">
+         <generator class="native"/>
+      </id>
+      <property
+            name="refId"
+            column="NODE_ID"
+            type="string"
+            length="36"/>
+      <property
+            name="data"
+            column="REFS_DATA"
+            type="binary"
+            length="100000000"
+            not-null="true"/>
+   </class>
+   <class name="org.jboss.portal.cms.hibernate.state.WSPBinVal" table="jbp_cms_wsp_binval" lazy="true">
+      <id
+            name="key"
+            column="PK"
+            type="java.lang.Integer">
+         <generator class="native"/>
+      </id>
+      <property
+            name="id"
+            column="BINVAL_ID"
+            type="string"
+            length="255"/>
+      <property
+            name="data"
+            column="BINVAL_DATA"
+            type="blob"
+            length="100000000"
+            not-null="true"/>
+   </class>
+   <class name="org.jboss.portal.cms.hibernate.state.WSPNode" table="jbp_cms_wsp_node" lazy="true">
+      <id
+            name="key"
+            column="PK"
+            type="java.lang.Integer">
+         <generator class="native"/>
+      </id>
+      <property
+            name="nodeId"
+            column="NODE_ID"
+            type="string"
+            length="36"/>
+      <property
+            name="data"
+            column="NODE_DATA"
+            type="binary"
+            length="100000000"
+            not-null="true"/>
+   </class>
+   <class name="org.jboss.portal.cms.hibernate.state.WSPProp" table="jbp_cms_wsp_prop" lazy="true">
+      <id
+            name="key"
+            column="PK"
+            type="java.lang.Integer">
+         <generator class="native"/>
+      </id>
+      <property
+            name="propId"
+            column="PROP_ID"
+            type="string"
+            length="255"/>
+      <property
+            name="data"
+            column="PROP_DATA"
+            type="binary"
+            length="100000000"
+            not-null="true"/>
+   </class>
+   <class name="org.jboss.portal.cms.hibernate.state.WSPRefs" table="jbp_cms_wsp_refs" lazy="true">
+      <id
+            name="key"
+            column="PK"
+            type="java.lang.Integer">
+         <generator class="native"/>
+      </id>
+      <property
+            name="refId"
+            column="NODE_ID"
+            type="string"
+            length="36"/>
+      <property
+            name="data"
+            column="REFS_DATA"
+            type="binary"
+            length="100000000"
+            not-null="true"/>
+   </class>
+   <class name="org.jboss.portal.cms.hibernate.CMSEntry" table="jbp_cms_cmsentry" lazy="true">
+      <id
+            name="key"
+            column="PK"
+            type="java.lang.Integer">
+         <generator class="native"/>
+      </id>
+      <property
+            name="name"
+            column="FSENTRY_NAME"
+            type="string"
+            length="255"
+            not-null="false"/>
+      <property name="path"
+                column="FSENTRY_PATH"
+                type="string"
+                not-null="true"
+                length="245"/>
+      <property name="data"
+                column="FSENTRY_DATA"
+                type="blob"
+                length="100000000"
+                not-null="false"/>
+      <property name="lastmod"
+                column="FSENTRY_LASTMOD"
+                type="long"
+                not-null="true"/>
+      <property name="length"
+                column="FSENTRY_LENGTH"
+                type="long"
+                not-null="true"/>
+   </class>
+   <class name="org.jboss.portal.cms.hibernate.RepositoryEntry" table="jbp_cms_repositoryentry" lazy="true">
+      <id
+            name="key"
+            column="PK"
+            type="java.lang.Integer">
+         <generator class="native"/>
+      </id>
+      <property
+            name="name"
+            column="FSENTRY_NAME"
+            type="string"
+            length="255"
+            not-null="false"/>
+      <property name="path"
+                column="FSENTRY_PATH"
+                type="string"
+                not-null="true"
+                length="245"/>
+      <property name="data"
+                column="FSENTRY_DATA"
+                type="blob"
+                length="100000000"
+                not-null="false"/>
+      <property name="lastmod"
+                column="FSENTRY_LASTMOD"
+                type="long"
+                not-null="true"/>
+      <property name="length"
+                column="FSENTRY_LENGTH"
+                type="long"
+                not-null="true"/>
+   </class>
+   <class name="org.jboss.portal.cms.hibernate.VersionEntry" table="jbp_cms_versionentry" lazy="true">
+      <id
+            name="key"
+            column="PK"
+            type="java.lang.Integer">
+         <generator class="native"/>
+      </id>
+      <property
+            name="name"
+            column="FSENTRY_NAME"
+            type="string"
+            length="255"
+            not-null="false"/>
+      <property name="path"
+                column="FSENTRY_PATH"
+                type="string"
+                not-null="true"
+                length="245"/>
+      <property name="data"
+                column="FSENTRY_DATA"
+                type="blob"
+                length="100000000"
+                not-null="false"/>
+      <property name="lastmod"
+                column="FSENTRY_LASTMOD"
+                type="long"
+                not-null="true"/>
+      <property name="length"
+                column="FSENTRY_LENGTH"
+                type="long"
+                not-null="true"/>
+   </class>
+</hibernate-mapping>
+

Added: branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/sar/conf/hibernate/cms/hibernate.cfg.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/sar/conf/hibernate/cms/hibernate.cfg.xml	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/sar/conf/hibernate/cms/hibernate.cfg.xml	2006-10-10 06:13:26 UTC (rev 5387)
@@ -0,0 +1,24 @@
+<?xml version='1.0' encoding='utf-8'?>
+<!DOCTYPE hibernate-configuration PUBLIC
+    "-//Hibernate/Hibernate Configuration DTD//EN"
+    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+<hibernate-configuration>
+   <session-factory>
+      <property name="connection.datasource">java:TestPortalDS</property>
+      <property name="show_sql">false</property>
+      <property name="cache.use_second_level_cache">false</property>
+      <property name="cache.use_query_cache">false</property>
+      
+      <!-- managed environment transaction configuration -->      
+      <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
+      <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
+
+      <!-- Force the dialect instead of using autodetection -->
+      <!--
+      <property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
+      -->
+
+      <!-- Mapping files -->
+      <mapping resource="conf/hibernate/cms/domain.hbm.xml"/>
+   </session-factory>
+</hibernate-configuration>
\ No newline at end of file

Added: branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/test-cms-clustering-war/WEB-INF/jboss-portlet.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/test-cms-clustering-war/WEB-INF/jboss-portlet.xml	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/test-cms-clustering-war/WEB-INF/jboss-portlet.xml	2006-10-10 06:13:26 UTC (rev 5387)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
+             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+             xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
+             version="1.0">
+
+   <portlet>
+      <portlet-name>UniversalTestPortletA</portlet-name>
+      <session-config>
+         <distributed>true</distributed>
+      </session-config>
+   </portlet>
+
+</portlet-app>

Added: branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/test-cms-clustering-war/WEB-INF/portlet.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/test-cms-clustering-war/WEB-INF/portlet.xml	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/test-cms-clustering-war/WEB-INF/portlet.xml	2006-10-10 06:13:26 UTC (rev 5387)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
+             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+             xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
+             version="1.0">
+
+   <portlet>
+      <portlet-name>UniversalTestPortletA</portlet-name>
+      <portlet-class>org.jboss.portal.test.framework.portlet.universal.UTP1</portlet-class>
+      <supports>
+        <mime-type>text/html</mime-type>
+      </supports>
+      <portlet-info>
+         <title></title>
+      </portlet-info>
+   </portlet>
+
+</portlet-app>

Added: branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/test-cms-clustering-war/WEB-INF/web.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/test-cms-clustering-war/WEB-INF/web.xml	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/cms/clustering/test-cms-clustering-war/WEB-INF/web.xml	2006-10-10 06:13:26 UTC (rev 5387)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.4"
+         xmlns="http://java.sun.com/xml/ns/j2ee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
+   <listener>
+      <listener-class>org.jboss.portal.test.cms.clustering.FileModSequenceBuilder</listener-class>
+   </listener>
+</web-app>

Modified: branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/jcr/repository.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/jcr/repository.xml	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/jcr/repository.xml	2006-10-10 06:13:26 UTC (rev 5387)
@@ -43,7 +43,7 @@
        -->
        
        <!-- HibernatePersistentManager: uses RDBMS + Hibernate for storage -->
-       <PersistenceManager class="org.jboss.portal.cms.hibernate.state.HibernatePersistenceManager">
+       <PersistenceManager class="org.jboss.portal.cms.hibernate.state.JBossCachePersistenceManager">
           <param name="schemaObjectPrefix" value="WSP"/>
           <param name="JNDIName" value="java:/SessionFactory"/>
           <param name="externalBLOBs" value="false"/>
@@ -90,7 +90,7 @@
        -->
        
        <!-- HibernatePersistentManager: uses RDBMS + Hibernate for storage -->
-       <PersistenceManager class="org.jboss.portal.cms.hibernate.state.HibernatePersistenceManager">
+       <PersistenceManager class="org.jboss.portal.cms.hibernate.state.JBossCachePersistenceManager">
           <param name="schemaObjectPrefix" value="Version"/>
           <param name="JNDIName" value="java:/SessionFactory"/>
           <param name="externalBLOBs" value="false"/>

Added: branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/log4j.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/log4j.xml	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/log4j.xml	2006-10-10 06:13:26 UTC (rev 5387)
@@ -0,0 +1,305 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!--                                                                       -->
+<!--  Log4j Configuration                                                  -->
+<!--                                                                       -->
+<!-- ===================================================================== -->
+
+<!-- $Id: log4j.xml,v 1.26.2.10 2006/04/21 17:29:20 csuconic Exp $ -->
+
+<!--
+   | For more configuration infromation and examples see the Jakarta Log4j
+   | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+   <!-- ================================= -->
+   <!-- Preserve messages in a local file -->
+   <!-- ================================= -->
+
+   <!-- A time/date based rolling appender -->
+   <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
+      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+      <param name="File" value="${jboss.server.log.dir}/server.log"/>
+      <param name="Append" value="false"/>
+      <param name="Threshold" value="ERROR"/>
+
+      <!-- Rollover at midnight each day -->
+      <param name="DatePattern" value="'.'yyyy-MM-dd"/>
+
+      <!-- Rollover at the top of each hour
+      <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
+      -->
+
+      <layout class="org.apache.log4j.PatternLayout">
+         <!-- The default pattern: Date Priority [Category] Message\n -->
+         <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+
+         <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
+         <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
+          -->
+      </layout>
+   </appender>
+
+   <!-- A size based file rolling appender
+   <appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender">
+     <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+     <param name="File" value="${jboss.server.log.dir}/server.log"/>
+     <param name="Append" value="false"/>
+     <param name="MaxFileSize" value="500KB"/>
+     <param name="MaxBackupIndex" value="1"/>
+
+     <layout class="org.apache.log4j.PatternLayout">
+       <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+     </layout>	    
+   </appender>
+   -->
+
+   <!-- ============================== -->
+   <!-- Append messages to the console -->
+   <!-- ============================== -->
+
+   <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+      <param name="Target" value="System.out"/>
+      <param name="Threshold" value="INFO"/>
+
+      <layout class="org.apache.log4j.PatternLayout">
+         <!-- The default pattern: Date Priority [Category] Message\n -->
+         <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+      </layout>
+   </appender>
+
+   <!-- ====================== -->
+   <!-- More Appender examples -->
+   <!-- ====================== -->
+
+   <!-- Buffer events and log them asynchronously
+   <appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
+     <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+     <appender-ref ref="FILE"/>
+     <appender-ref ref="CONSOLE"/>
+     <appender-ref ref="SMTP"/>
+   </appender>
+   -->
+
+   <!-- EMail events to an administrator
+   <appender name="SMTP" class="org.apache.log4j.net.SMTPAppender">
+     <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+     <param name="Threshold" value="ERROR"/>
+     <param name="To" value="admin at myhost.domain.com"/>
+     <param name="From" value="nobody at myhost.domain.com"/>
+     <param name="Subject" value="JBoss Sever Errors"/>
+     <param name="SMTPHost" value="localhost"/>
+     <param name="BufferSize" value="10"/>
+     <layout class="org.apache.log4j.PatternLayout">
+       <param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
+     </layout>
+   </appender>
+   -->
+
+   <!-- Syslog events
+   <appender name="SYSLOG" class="org.apache.log4j.net.SyslogAppender">
+     <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+     <param name="Facility" value="LOCAL7"/>
+     <param name="FacilityPrinting" value="true"/>
+     <param name="SyslogHost" value="localhost"/>
+     <layout class="org.apache.log4j.PatternLayout">
+       <param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
+     </layout>
+   </appender>
+   -->
+
+   <!-- Log events to JMS (requires a topic to be created)
+   <appender name="JMS" class="org.apache.log4j.net.JMSAppender">
+     <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+     <param name="Threshold" value="ERROR"/>
+     <param name="TopicConnectionFactoryBindingName" value="java:/ConnectionFactory"/>
+     <param name="TopicBindingName" value="topic/MyErrorsTopic"/>
+   </appender>
+   -->
+
+   <!-- Log events through SNMP
+   <appender name="TRAP_LOG" class="org.apache.log4j.ext.SNMPTrapAppender">
+     <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+     <param name="ImplementationClassName" value="org.apache.log4j.ext.JoeSNMPTrapSender"/>
+     <param name="ManagementHost" value="127.0.0.1"/>
+     <param name="ManagementHostTrapListenPort" value="162"/>
+     <param name="EnterpriseOID" value="1.3.6.1.4.1.24.0"/>
+     <param name="LocalIPAddress" value="127.0.0.1"/>
+     <param name="LocalTrapSendPort" value="161"/>
+     <param name="GenericTrapType" value="6"/>
+     <param name="SpecificTrapType" value="12345678"/>
+     <param name="CommunityString" value="public"/>
+     <param name="ForwardStackTraceWithTrap" value="true"/>
+     <param name="Threshold" value="DEBUG"/>
+     <param name="ApplicationTrapOID" value="1.3.6.1.4.1.24.12.10.22.64"/>
+     <layout class="org.apache.log4j.PatternLayout">
+            <param name="ConversionPattern" value="%d,%p,[%t],[%c],%m%n"/>
+     </layout>
+   </appender>
+   -->
+
+   <!--  Emit events as JMX notifications
+   <appender name="JMX" class="org.jboss.monitor.services.JMXNotificationAppender">
+      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+      
+      <param name="Threshold" value="WARN"/>
+      <param name="ObjectName" value="jboss.system:service=Logging,type=JMXNotificationAppender"/>
+      
+      <layout class="org.apache.log4j.PatternLayout">
+         <param name="ConversionPattern" value="%d %-5p [%c] %m"/>
+      </layout>
+   </appender>
+   -->
+   
+   <!-- ================ -->
+   <!-- Limit categories -->
+   <!-- ================ -->
+
+   <!-- Limit the org.apache category to INFO as its DEBUG is verbose -->
+   <category name="org.apache">
+      <priority value="INFO"/>
+   </category>
+
+   <!-- Limit the org.jboss.serial (jboss-serialization) to INFO as its DEBUG is verbose -->
+   <category name="org.jboss.serial">
+      <priority value="INFO"/>
+   </category>
+
+   <!-- Limit the org.jgroups category to WARN as its INFO is verbose -->
+   <category name="org.jgroups">
+      <priority value="ERROR"/>
+   </category>
+   
+   <category name="org.jboss.cache">
+         <priority value="ERROR"/>
+   </category>
+
+   <!-- Limit the jacorb category to WARN as its INFO is verbose -->
+   <category name="jacorb">
+      <priority value="WARN"/>
+   </category>
+
+   <!-- Limit JBoss categories
+   <category name="org.jboss">
+      <priority value="INFO"/>
+   </category>
+   -->
+
+   <!-- Limit the JSR77 categories -->
+   <category name="org.jboss.management">
+      <priority value="INFO"/>
+   </category>
+
+   <!-- Limit Axis based webservice category -->
+   <category name="org.jboss.webservice">
+      <priority value="DEBUG"/>
+   </category>
+   <category name="org.jboss.axis">
+      <priority value="INFO"/>
+   </category>
+
+   <!-- Limit JBossWS webservice category
+   <category name="org.jboss.ws">
+      <priority value="DEBUG"/>
+   </category>
+   -->
+
+   <!-- Decrease the priority threshold for the org.jboss.varia category
+   <category name="org.jboss.varia">
+     <priority value="DEBUG"/>
+   </category>
+   -->
+
+   <!-- Show the evolution of the DataSource pool in the logs [inUse/Available/Max]
+   <category name="org.jboss.resource.connectionmanager.JBossManagedConnectionPool">
+     <priority value="TRACE" class="org.jboss.logging.XLevel"/>
+   </category>
+   -->
+
+   <!--
+      | An example of enabling the custom TRACE level priority that is used
+      | by the JBoss internals to diagnose low level details. This example
+      | turns on TRACE level msgs for the org.jboss.ejb.plugins package and its
+      | subpackages. This will produce A LOT of logging output.
+   <category name="org.jboss.system">
+     <priority value="TRACE" class="org.jboss.logging.XLevel"/>
+   </category>
+   <category name="org.jboss.ejb.plugins">
+     <priority value="TRACE" class="org.jboss.logging.XLevel"/>
+   </category>
+   -->
+  
+   <!--
+       | Logs these events to SNMP:
+           - server starts/stops
+           - cluster evolution (node death/startup)
+           - When an EJB archive is deployed (and associated verified messages)
+           - When an EAR archive is deployed
+      	 
+   <category name="org.jboss.system.server.Server">
+     <priority value="INFO" />
+     <appender-ref ref="TRAP_LOG"/>
+   </category>
+  
+   <category name="org.jboss.ha.framework.interfaces.HAPartition.lifecycle">
+     <priority value="INFO" />
+     <appender-ref ref="TRAP_LOG"/>
+   </category>
+
+   <category name="org.jboss.deployment.MainDeployer">
+     <priority value="ERROR" />
+     <appender-ref ref="TRAP_LOG"/>
+   </category>
+   
+   <category name="org.jboss.ejb.EJBDeployer">
+     <priority value="INFO" />
+     <appender-ref ref="TRAP_LOG"/>
+   </category>
+   
+   <category name="org.jboss.deployment.EARDeployer">
+     <priority value="INFO" />
+     <appender-ref ref="TRAP_LOG"/>
+   </category>
+  
+   -->
+
+   <!-- ======================= -->
+   <!-- Setup the Root category -->
+   <!-- ======================= -->
+
+   <root>
+      <appender-ref ref="CONSOLE"/>
+      <appender-ref ref="FILE"/>
+   </root>
+
+   <!-- Clustering logging -->
+   <!-- Uncomment the following to redirect the org.jgroups and
+      org.jboss.ha categories to a cluster.log file.
+
+   <appender name="CLUSTER" class="org.jboss.logging.appender.RollingFileAppender">
+     <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+     <param name="File" value="${jboss.server.log.dir}/cluster.log"/>
+     <param name="Append" value="false"/>
+     <param name="MaxFileSize" value="500KB"/>
+     <param name="MaxBackupIndex" value="1"/>
+
+     <layout class="org.apache.log4j.PatternLayout">
+       <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+     </layout>
+   </appender>
+   <category name="org.jgroups">
+     <priority value="DEBUG" />
+     <appender-ref ref="CLUSTER"/>
+   </category>
+   <category name="org.jboss.ha">
+     <priority value="DEBUG" />
+     <appender-ref ref="CLUSTER"/>
+   </category>
+   -->
+
+</log4j:configuration>

Added: branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/pm-cache.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/pm-cache.xml	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/resources/test/pm-cache.xml	2006-10-10 06:13:26 UTC (rev 5387)
@@ -0,0 +1,163 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!--                                                                       -->
+<!--  Sample TreeCache Service Configuration                               -->
+<!--                                                                       -->
+<!-- ===================================================================== -->
+
+<server>
+    <!-- ==================================================================== -->
+    <!-- Defines TreeCache configuration                                      -->
+    <!-- ==================================================================== -->
+
+   <!-- TreeCache configuration used to cache CMS data -->
+   <mbean code="org.jboss.cache.TreeCache"
+           name="cms.pm.cache:service=TreeCache">
+   
+           <depends>jboss:service=Naming</depends>
+           <depends>jboss:service=TransactionManager</depends>
+           <depends>portal:service=Hibernate,type=CMS</depends>
+   
+           <!--
+           Configure the TransactionManager
+           -->
+           <attribute name="TransactionManagerLookupClass">org.jboss.cache.GenericTransactionManagerLookup</attribute>
+           
+           <!--
+		Node locking scheme:
+		OPTIMISTIC
+		PESSIMISTIC (default)
+		using the OPTIMISTIC scheme, the ISOLATION_LEVEL value is ignored
+	   -->
+	   <!--attribute name="NodeLockingScheme">OPTIMISTIC</attribute-->
+   
+           <!--
+               Isolation level : SERIALIZABLE
+                                 REPEATABLE_READ (default)
+                                 READ_COMMITTED
+                                 READ_UNCOMMITTED
+                                 NONE
+           -->
+           <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
+           
+           	   
+   
+           <!--
+                Valid modes are LOCAL
+                                REPL_ASYNC
+                                REPL_SYNC
+                                INVALIDATION_ASYNC
+                                INVALIDATION_SYNC
+           -->
+           <attribute name="CacheMode">LOCAL</attribute>
+   
+           <!--
+           Just used for async repl: use a replication queue
+           -->
+           <attribute name="UseReplQueue">false</attribute>
+   
+           <!--
+               Replication interval for replication queue (in ms)
+           -->
+           <attribute name="ReplQueueInterval">0</attribute>
+   
+           <!--
+               Max number of elements which trigger replication
+           -->
+           <attribute name="ReplQueueMaxElements">0</attribute>
+   
+           <!-- Name of cluster. Needs to be the same for all clusters, in order
+                to find each other
+           -->
+           <attribute name="ClusterName">JCRPMCache</attribute>
+   
+           <!-- JGroups protocol stack properties. Can also be a URL,
+                e.g. file:/home/bela/default.xml
+              <attribute name="ClusterProperties"></attribute>
+           -->
+   
+           <attribute name="ClusterConfig">
+               <config>
+                   <!-- UDP: if you have a multihomed machine,
+                   set the bind_addr attribute to the appropriate NIC IP address -->
+                   <!-- UDP: On Windows machines, because of the media sense feature
+                    being broken with multicast (even after disabling media sense)
+                    set the loopback attribute to true -->
+                   <UDP mcast_addr="228.1.2.3" mcast_port="48866"
+                       ip_ttl="64" ip_mcast="true"                       
+                       mcast_send_buf_size="150000" mcast_recv_buf_size="80000"
+                       ucast_send_buf_size="150000" ucast_recv_buf_size="80000"
+                       loopback="false"/>
+                   <PING timeout="2000" num_initial_members="3"
+                       up_thread="false" down_thread="false"/>
+                   <MERGE2 min_interval="10000" max_interval="20000"/>
+                   <!--        <FD shun="true" up_thread="true" down_thread="true" />-->
+                   <FD_SOCK/>
+                   <VERIFY_SUSPECT timeout="1500"
+                       up_thread="false" down_thread="false"/>
+                   <pbcast.NAKACK gc_lag="50" retransmit_timeout="600,1200,2400,4800"
+                       max_xmit_size="8192" up_thread="false" down_thread="false"/>
+                   <UNICAST timeout="600,1200,2400" window_size="100" min_threshold="10"
+                       down_thread="false"/>
+                   <pbcast.STABLE desired_avg_gossip="20000"
+                       up_thread="false" down_thread="false"/>
+                   <FRAG frag_size="8192"
+                       down_thread="false" up_thread="false"/>
+                   <pbcast.GMS join_timeout="5000" join_retry_timeout="2000"
+                       shun="true" print_local_addr="true"/>
+                   <pbcast.STATE_TRANSFER up_thread="true" down_thread="true"/>
+               </config>
+           </attribute>
+   
+           <!--
+            Whether or not to fetch state on joining a cluster
+            NOTE this used to be called FetchStateOnStartup and has been renamed to be more descriptive.
+           -->
+           <attribute name="FetchInMemoryState">false</attribute>
+   
+           <!--
+               The max amount of time (in milliseconds) we wait until the
+               initial state (ie. the contents of the cache) are retrieved from
+               existing members in a clustered environment
+           -->
+           <attribute name="InitialStateRetrievalTimeout">20000</attribute>
+   
+           <!--
+               Number of milliseconds to wait until all responses for a
+               synchronous call have been received.
+           -->
+           <attribute name="SyncReplTimeout">20000</attribute>
+   
+           <!-- Max number of milliseconds to wait for a lock acquisition -->
+           <attribute name="LockAcquisitionTimeout">15000</attribute>
+   
+   
+           <!-- Name of the eviction policy class. -->
+           <attribute name="EvictionPolicyClass"></attribute>
+          
+          <!--
+             Indicate whether to use region based marshalling or not. Set this to true if you are running under a scoped
+             class loader, e.g., inside an application server. Default is "false".
+          -->
+           <attribute name="UseRegionBasedMarshalling">false</attribute>
+           
+           <!--
+           	Configuring the PortalCMSCacheLoader
+           -->           
+           <attribute name="CacheLoaderConfiguration">
+               <config>                
+                   <passivation>false</passivation>
+                   <preload></preload>
+                   <shared>false</shared>
+                   <cacheloader>
+                       <class>org.jboss.portal.cms.hibernate.state.PortalCMSCacheLoader</class>
+                       <properties></properties>
+                       <async>false</async>
+                       <fetchPersistentState>true</fetchPersistentState>
+                       <ignoreModifications>false</ignoreModifications>
+                   </cacheloader>
+               </config>
+           </attribute>
+    </mbean>
+</server>

Modified: branches/JBoss_Portal_Branch_2_4/core/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/core/build.xml	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/core/build.xml	2006-10-10 06:13:26 UTC (rev 5387)
@@ -298,6 +298,9 @@
          <fileset dir="${apache.lucene.lib}" includes="lucene.jar"/>
          <fileset dir="${jackrabbit.jackrabbit.lib}" includes="jackrabbit-core-1.0.jar"/>
          <fileset dir="${slf4j.slf4j.lib}" includes="slf4j-log4j12.jar"/>
+	     <!-- cms optimization integration - this contains a clustered cache enabled version -->
+	     <fileset dir="${jboss.cache.lib}" includes="jboss-cache.jar"/>
+		 <fileset dir="${jgroups.jgroups.lib}" includes="jgroups.jar"/>		 
       </copy>
       <!-- hibernate configuration for identity -->
       <copy todir="${build.resources}/jboss-portal/conf/hibernate/user">
@@ -490,6 +493,9 @@
            depends="output-ha">
          <require file="${jboss.home}/server/${portal-ha.deploy.dir}"/>
          <copy file="${build.lib}/jboss-portal-ha.sar" todir="${jboss.home}/server/${portal-ha.deploy.dir}"/>
+         <!-- upgrade the jbosscache version -->
+         <copy file="${jboss.cache.lib}/jboss-cache.jar" todir="${jboss.home}/server/${portal-ha.deploy.dir}/../lib" overwrite="true"/>
+         <copy file="${jgroups.jgroups.lib}/jgroups.jar" todir="${jboss.home}/server/${portal-ha.deploy.dir}/../lib" overwrite="true"/>
    </target>
 
    <target name="deploy-management"

Modified: branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-cms-sar/META-INF/jboss-service.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-cms-sar/META-INF/jboss-service.xml	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-cms-sar/META-INF/jboss-service.xml	2006-10-10 06:13:26 UTC (rev 5387)
@@ -1,60 +1,17 @@
-<server>
-
-
-   <!--mbean
-      code="org.jboss.portal.cms.impl.interceptors.LogInterceptor"
-      name="portal:service=Interceptor,type=Cms,name=Log"
-      xmbean-dd=""
-      xmbean-code="org.jboss.portal.common.system.JBossServiceModelMBean">
-      <xmbean/>
-   </mbean-->
-   
-   <!--
-      @portal.single.xml.close@
-      
+<server>  
    <mbean
-      code="org.jboss.portal.cms.impl.cache.CMSTreeCacheServiceImpl"
-      name="portal:service=CMSTreeCacheService"
+      code="org.jboss.portal.jems.hibernate.SessionFactoryBinder"
+      name="portal:service=Hibernate,type=CMS"
       xmbean-dd=""
       xmbean-code="org.jboss.portal.common.system.JBossServiceModelMBean">
       <xmbean/>
-      <depends optional-attribute-name="Cache" proxy-type="attribute">
-         <mbean
-            code="org.jboss.cache.TreeCache"
-            name="portal:service=CMSTreeCache">
-            <depends>jboss:service=Naming</depends>
-            <depends>jboss:service=TransactionManager</depends>
-            <attribute name="TransactionManagerLookupClass">org.jboss.cache.JBossTransactionManagerLookup</attribute>
-            <attribute name="CacheMode">REPL_ASYNC</attribute>
-            <attribute name="IsolationLevel">NONE</attribute>
-         </mbean>
-      </depends> 
-      <attribute name="JNDIName">java:/portal/cms/CMSTreeCache</attribute>
+      <depends>jboss.jca:service=DataSourceBinding,name=@portal.datasource.name@</depends>
+      <attribute name="DoChecking">true</attribute>
+      <attribute name="ConfigLocation">conf/hibernate/cms/hibernate.cfg.xml</attribute>
+      <attribute name="JNDIName">java:/portal/cms/CMSSessionFactory</attribute>
    </mbean>
-      
+ 
    <mbean
-      code="org.jboss.portal.cms.impl.interceptors.CacheInterceptor"
-      name="portal:service=Interceptor,type=Cms,name=Cache"
-      xmbean-dd=""
-      xmbean-code="org.jboss.portal.common.system.JBossServiceModelMBean">
-      <xmbean/>
-      <depends>portal:service=CMSTreeCacheService</depends>
-   </mbean>
-   <mbean
-      code="org.jboss.portal.server.impl.invocation.JBossInterceptorStack"
-      name="portal:service=InterceptorStack,type=Cms"
-      xmbean-dd=""
-      xmbean-code="org.jboss.portal.common.system.JBossServiceModelMBean">
-      <xmbean/>
-      <depends-list optional-attribute-name="InterceptorNames">
-         <depends-list-element>portal:service=Interceptor,type=Cms,name=Cache</depends-list-element>
-      </depends-list>
-   </mbean>
-   
-   @portal.single.xml.open@
-   -->
-   
-   <mbean
       code="@cms.service.code@"
       name="portal:service=CMS"
       xmbean-dd=""
@@ -63,12 +20,7 @@
       <!-- The datasource hibernate depends on, it can be commented when the file store is used -->
       <depends>jboss.jca:service=DataSourceBinding,name=@portal.datasource.name@</depends>
       <depends>portal:service=JAASLoginModule</depends>
-      <depends>portal:service=Hibernate,type=CMS</depends>
-      <!--
-         @portal.single.xml.close@
-         <depends optional-attribute-name="CmsStack" proxy-type="attribute">portal:service=InterceptorStack,type=Cms</depends>
-      @portal.single.xml.open@
-      -->
+      <depends>portal:service=Hibernate,type=CMS</depends>      
       <attribute name="DoChecking">true</attribute>
       <attribute name="DefaultContentLocation">portal/cms/conf/default-content/default/</attribute>
       <attribute name="DefaultLocale">en</attribute>
@@ -120,7 +72,7 @@
                -->
 
                <!-- HibernatePersistentManager: uses RDBMS + Hibernate for storage -->
-               <PersistenceManager class="org.jboss.portal.cms.hibernate.state.HibernatePersistenceManager">
+               <PersistenceManager class="org.jboss.portal.cms.hibernate.state.JBossCachePersistenceManager">
                   <param name="schemaObjectPrefix" value="WSP"/>
                   <param name="JNDIName" value="java:portal/cms/CMSSessionFactory"/>
                   <param name="externalBLOBs" value="false"/>
@@ -129,7 +81,7 @@
                <!-- XMLPersistenceManager: uses FileSystem for storage -->
                <!--<PersistenceManager class="org.apache.jackrabbit.core.state.xml.XMLPersistenceManager"/>-->
 
-               <!--SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+               <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
                   <param name="path" value="${wsp.home}/index"/>
                   <param name="useCompoundFile" value="true"/>
                   <param name="minMergeDocs" value="100"/>
@@ -140,7 +92,7 @@
                   <param name="cacheSize" value="1000"/>
                   <param name="forceConsistencyCheck" value="false"/>
                   <param name="autoRepair" value="true"/>
-               </SearchIndex-->
+               </SearchIndex>
             </Workspace>
             <Versioning rootPath="${rep.home}/versions">
                <!--
@@ -167,7 +119,7 @@
                -->
 
                <!-- HibernatePersistentManager: uses RDBMS + Hibernate for storage -->
-               <PersistenceManager class="org.jboss.portal.cms.hibernate.state.HibernatePersistenceManager">
+               <PersistenceManager class="org.jboss.portal.cms.hibernate.state.JBossCachePersistenceManager">
                   <param name="schemaObjectPrefix" value="Version"/>
                   <param name="JNDIName" value="java:portal/cms/CMSSessionFactory"/>
                   <param name="externalBLOBs" value="false"/>
@@ -223,21 +175,8 @@
 
    @portal.single.xml.open@
    -->
-
+  
    <mbean
-      code="org.jboss.portal.jems.hibernate.SessionFactoryBinder"
-      name="portal:service=Hibernate,type=CMS"
-      xmbean-dd=""
-      xmbean-code="org.jboss.portal.common.system.JBossServiceModelMBean">
-      <xmbean/>
-      <depends>jboss.jca:service=DataSourceBinding,name=@portal.datasource.name@</depends>
-      <attribute name="DoChecking">true</attribute>
-      <attribute name="ConfigLocation">conf/hibernate/cms/hibernate.cfg.xml</attribute>
-      <attribute name="JNDIName">java:/portal/cms/CMSSessionFactory</attribute>
-   </mbean>
-
-
-   <mbean
       code="org.jboss.portal.core.cms.CMSObjectCommandFactory"
       name="portal:commandFactory=CMSObject"
       xmbean-dd=""
@@ -270,4 +209,178 @@
       <attribute name="Prefix">content</attribute>
       <depends optional-attribute-name="Factory" proxy-type="attribute">portal:urlFactory=Delegating</depends>
    </mbean>
+   
+   <!-- TreeCache configuration used to cache CMS data -->
+   <mbean code="org.jboss.cache.TreeCache"
+           name="cms.pm.cache:service=TreeCache">
+   
+           <depends>jboss:service=Naming</depends>
+           <depends>jboss:service=TransactionManager</depends>
+           <depends>portal:service=Hibernate,type=CMS</depends>
+           <depends>portal:service=CMS</depends>
+   
+           <!--
+           Configure the TransactionManager
+           -->
+           <attribute name="TransactionManagerLookupClass">org.jboss.cache.GenericTransactionManagerLookup</attribute>
+           
+           <!--
+		Node locking scheme:
+		OPTIMISTIC
+		PESSIMISTIC (default)
+		using the OPTIMISTIC scheme, the ISOLATION_LEVEL value is ignored
+	   -->
+	   <!--attribute name="NodeLockingScheme">OPTIMISTIC</attribute-->
+   
+           <!--
+               Isolation level : SERIALIZABLE
+                                 REPEATABLE_READ (default)
+                                 READ_COMMITTED
+                                 READ_UNCOMMITTED
+                                 NONE
+           -->
+           <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
+           
+           	   
+   
+           <!--
+                Valid modes are LOCAL
+                                REPL_ASYNC
+                                REPL_SYNC
+                                INVALIDATION_ASYNC
+                                INVALIDATION_SYNC
+           -->
+           <!-- in a non-HA environment with the Jackrabbit cluster is activated -->
+           <!--attribute name="CacheMode">INVALIDATION_ASYNC</attribute-->           
+           <!-- in a HA environment since there is only a singleton node for CMS, this can be local -->
+           <attribute name="CacheMode">LOCAL</attribute>           
+   
+           <!--
+           Just used for async repl: use a replication queue
+           -->
+           <attribute name="UseReplQueue">false</attribute>
+   
+           <!--
+               Replication interval for replication queue (in ms)
+           -->
+           <attribute name="ReplQueueInterval">0</attribute>
+   
+           <!--
+               Max number of elements which trigger replication
+           -->
+           <attribute name="ReplQueueMaxElements">0</attribute>
+   
+           <!-- Name of cluster. Needs to be the same for all clusters, in order
+                to find each other
+           -->
+           <attribute name="ClusterName">JCRPMCache</attribute>
+   
+           <!-- JGroups protocol stack properties. Can also be a URL,
+                e.g. file:/home/bela/default.xml
+              <attribute name="ClusterProperties"></attribute>
+           -->
+   
+           <attribute name="ClusterConfig">
+               <config>
+                   <!-- UDP: if you have a multihomed machine,
+                   set the bind_addr attribute to the appropriate NIC IP address -->
+                   <!-- UDP: On Windows machines, because of the media sense feature
+                    being broken with multicast (even after disabling media sense)
+                    set the loopback attribute to true -->
+                   <UDP mcast_addr="228.1.2.3" mcast_port="48866"
+                       ip_ttl="64" ip_mcast="true" 
+                       receive_on_all_interfaces="true"
+                       mcast_send_buf_size="150000" mcast_recv_buf_size="80000"
+                       ucast_send_buf_size="150000" ucast_recv_buf_size="80000"
+                       loopback="false"/>
+                   <PING timeout="2000" num_initial_members="3"
+                       up_thread="false" down_thread="false"/>
+                   <MERGE2 min_interval="10000" max_interval="20000"/>
+                   <!--        <FD shun="true" up_thread="true" down_thread="true" />-->
+                   <FD_SOCK/>
+                   <VERIFY_SUSPECT timeout="1500"
+                       up_thread="false" down_thread="false"/>
+                   <pbcast.NAKACK gc_lag="50" retransmit_timeout="600,1200,2400,4800"
+                       max_xmit_size="8192" up_thread="false" down_thread="false"/>
+                   <UNICAST timeout="600,1200,2400" window_size="100" min_threshold="10"
+                       down_thread="false"/>
+                   <pbcast.STABLE desired_avg_gossip="20000"
+                       up_thread="false" down_thread="false"/>
+                   <FRAG frag_size="8192"
+                       down_thread="false" up_thread="false"/>
+                   <pbcast.GMS join_timeout="5000" join_retry_timeout="2000"
+                       shun="true" print_local_addr="true"/>
+                   <pbcast.STATE_TRANSFER up_thread="true" down_thread="true"/>
+               </config>
+           </attribute>
+   
+           <!--
+            Whether or not to fetch state on joining a cluster
+            NOTE this used to be called FetchStateOnStartup and has been renamed to be more descriptive.
+            
+            Not supported in version 1.2.4SP2 which is what ships by default in 4.0.4GA 
+           -->
+           <!--attribute name="FetchInMemoryState">false</attribute-->
+   
+           <!--
+               The max amount of time (in milliseconds) we wait until the
+               initial state (ie. the contents of the cache) are retrieved from
+               existing members in a clustered environment
+           -->
+           <attribute name="InitialStateRetrievalTimeout">20000</attribute>
+   
+           <!--
+               Number of milliseconds to wait until all responses for a
+               synchronous call have been received.
+           -->
+           <attribute name="SyncReplTimeout">20000</attribute>
+   
+           <!-- Max number of milliseconds to wait for a lock acquisition -->
+           <attribute name="LockAcquisitionTimeout">15000</attribute>
+   
+   
+           <!-- Name of the eviction policy class. -->
+           <attribute name="EvictionPolicyClass"></attribute>
+          
+          <!--
+             Indicate whether to use region based marshalling or not. Set this to true if you are running under a scoped
+             class loader, e.g., inside an application server. Default is "false".
+             
+             Not supported in version 1.2.4SP2 which is what ships by default in 4.0.4GA 
+          -->
+           <!--attribute name="UseRegionBasedMarshalling">false</attribute-->
+           
+           <!--
+           		Configuring the PortalCMSCacheLoader
+           		
+           		CacheLoader configuratoon for 1.4.0
+           -->           
+           <attribute name="CacheLoaderConfiguration">
+               <config>                
+                   <passivation>false</passivation>
+                   <preload></preload>
+                   <shared>false</shared>
+                   <cacheloader>
+                       <class>org.jboss.portal.cms.hibernate.state.PortalCMSCacheLoader</class>
+                       <properties></properties>
+                       <async>false</async>
+                       <fetchPersistentState>false</fetchPersistentState>
+                       <ignoreModifications>false</ignoreModifications>
+                   </cacheloader>
+               </config>
+           </attribute>
+           <!--
+           		Configuring the PortalCMSCacheLoader
+           		
+           		CacheLoader configuratoon for 1.2.4SP2
+           --> 
+           <!--attribute name="CacheLoaderClass">org.jboss.portal.cms.hibernate.state.PortalCMSCacheLoader</attribute>       
+           <attribute name="CacheLoaderConfig" replace="false"></attribute>
+           <attribute name="CacheLoaderPassivation">false</attribute>
+           <attribute name="CacheLoaderPreload"></attribute>
+           <attribute name="CacheLoaderShared">false</attribute>           
+           <attribute name="CacheLoaderFetchTransientState">false</attribute>
+           <attribute name="CacheLoaderFetchPersistentState">false</attribute>
+           <attribute name="CacheLoaderAsynchronous">false</attribute-->          
+    </mbean>
 </server>

Modified: branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-cms-sar/conf/hibernate/cms/domain.hbm.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-cms-sar/conf/hibernate/cms/domain.hbm.xml	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-cms-sar/conf/hibernate/cms/domain.hbm.xml	2006-10-10 06:13:26 UTC (rev 5387)
@@ -30,14 +30,14 @@
          <generator class="native"/>
       </id>
       <property
-            name="id"
+            name="nodeId"
             column="NODE_ID"
             type="string"
             length="36"/>
       <property
             name="data"
             column="NODE_DATA"
-            type="blob"
+            type="binary"
             length="100000000"
             not-null="true"/>
    </class>
@@ -49,14 +49,14 @@
          <generator class="native"/>
       </id>
       <property
-            name="id"
+            name="propId"
             column="PROP_ID"
             type="string"
             length="255"/>
       <property
             name="data"
             column="PROP_DATA"
-            type="blob"
+            type="binary"
             length="100000000"
             not-null="true"/>
    </class>
@@ -68,14 +68,14 @@
          <generator class="native"/>
       </id>
       <property
-            name="id"
+            name="refId"
             column="NODE_ID"
             type="string"
             length="36"/>
       <property
             name="data"
             column="REFS_DATA"
-            type="blob"
+            type="binary"
             length="100000000"
             not-null="true"/>
    </class>
@@ -106,14 +106,14 @@
          <generator class="native"/>
       </id>
       <property
-            name="id"
+            name="nodeId"
             column="NODE_ID"
             type="string"
             length="36"/>
       <property
             name="data"
             column="NODE_DATA"
-            type="blob"
+            type="binary"
             length="100000000"
             not-null="true"/>
    </class>
@@ -125,14 +125,14 @@
          <generator class="native"/>
       </id>
       <property
-            name="id"
+            name="propId"
             column="PROP_ID"
             type="string"
             length="255"/>
       <property
             name="data"
             column="PROP_DATA"
-            type="blob"
+            type="binary"
             length="100000000"
             not-null="true"/>
    </class>
@@ -144,14 +144,14 @@
          <generator class="native"/>
       </id>
       <property
-            name="id"
+            name="refId"
             column="NODE_ID"
             type="string"
             length="36"/>
       <property
             name="data"
             column="REFS_DATA"
-            type="blob"
+            type="binary"
             length="100000000"
             not-null="true"/>
    </class>
@@ -252,3 +252,4 @@
                 not-null="true"/>
    </class>
 </hibernate-mapping>
+

Modified: branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-cms-sar/conf/hibernate/cms/hibernate.cfg.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-cms-sar/conf/hibernate/cms/hibernate.cfg.xml	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-cms-sar/conf/hibernate/cms/hibernate.cfg.xml	2006-10-10 06:13:26 UTC (rev 5387)
@@ -8,6 +8,10 @@
       <property name="show_sql">@portal.sql.show@</property>
       <property name="cache.use_second_level_cache">false</property>
       <property name="cache.use_query_cache">false</property>
+      
+      <!-- managed environment transaction configuration -->      
+      <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
+      <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
 
       <!-- Force the dialect instead of using autodetection -->
       <!--


Property changes on: branches/JBoss_Portal_Branch_2_4/portlet
___________________________________________________________________
Name: svn:ignore
   - bin
output

   + bin
output
*.log


Modified: branches/JBoss_Portal_Branch_2_4/portlet/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/build.xml	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/portlet/build.xml	2006-10-10 06:13:26 UTC (rev 5387)
@@ -174,6 +174,11 @@
       <jar jarfile="${build.lib}/portal-portlet-test-lib.jar">
          <fileset dir="${build.classes}" includes="org/jboss/portal/portlet/test/**"/>
       </jar>
+	
+	 <!-- Portlet test framework lib jar...this is used by the cms clustering testcases -->
+	 <jar jarfile="${build.lib}/portal-portlet-testframework-lib.jar">	  	
+		<fileset dir="${build.classes}" includes="org/jboss/portal/test/framework/portlet/**"/>
+	 </jar>
 
       <!-- Portlet tck lib jar -->
       <jar jarfile="${build.lib}/portal-portlet-tck-lib.jar">
@@ -245,6 +250,11 @@
       <jar jarfile="${build.lib}/portal-portlet-test-lib.jar">
          <fileset dir="${build.classes}" includes="org/jboss/portal/portlet/test/**"/>
       </jar>
+			
+		  <!-- Portlet test framework lib jar...this is used by the cms clustering testcases -->
+		  <jar jarfile="${build.lib}/portal-portlet-testframework-lib.jar">	  	
+			<fileset dir="${build.classes}" includes="org/jboss/portal/test/framework/portlet/**"/>
+		  </jar>
 
       <!-- Portlet tck lib jar -->
       <jar jarfile="${build.lib}/portal-portlet-tck-lib.jar">


Property changes on: branches/JBoss_Portal_Branch_2_4/test
___________________________________________________________________
Name: svn:ignore
   - output
bin

   + output
bin
*.log


Modified: branches/JBoss_Portal_Branch_2_4/tools/etc/buildfragments/modules.ent
===================================================================
--- branches/JBoss_Portal_Branch_2_4/tools/etc/buildfragments/modules.ent	2006-10-10 00:30:26 UTC (rev 5386)
+++ branches/JBoss_Portal_Branch_2_4/tools/etc/buildfragments/modules.ent	2006-10-10 06:13:26 UTC (rev 5387)
@@ -59,6 +59,7 @@
   <path id="jboss.portal-portlet.classpath">
     <pathelement path="${jboss.portal-portlet.lib}/portal-portlet-lib.jar"/>
     <pathelement path="${jboss.portal-portlet.lib}/portal-portlet-test-lib.jar"/>
+    <pathelement path="${jboss.portal-portlet.lib}/portal-portlet-testframework-lib.jar"/>
   </path>
 
   <!-- federation -->




More information about the jboss-svn-commits mailing list