You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by tr...@apache.org on 2009/08/12 14:19:38 UTC

svn commit: r803470 - in /jackrabbit/trunk: jackrabbit-core/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/ jac...

Author: tripod
Date: Wed Aug 12 12:19:37 2009
New Revision: 803470

URL: http://svn.apache.org/viewvc?rev=803470&view=rev
Log:
JCR-2255  activity storage path

Modified:
    jackrabbit/trunk/jackrabbit-core/pom.xml
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryCopier.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalXAVersionManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/AbstractVISProvider.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/VirtualItemStateProvider.java
    jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/ActivitiesTest.java

Modified: jackrabbit/trunk/jackrabbit-core/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/pom.xml?rev=803470&r1=803469&r2=803470&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/pom.xml (original)
+++ jackrabbit/trunk/jackrabbit-core/pom.xml Wed Aug 12 12:19:37 2009
@@ -95,7 +95,6 @@
               <name>known.issues</name>
               <value>
                 org.apache.jackrabbit.core.xml.DocumentViewTest#testMultiValue
-                org.apache.jackrabbit.test.api.version.ActivitiesTest#testActivitiesPath
               </value>
             </property>
           </systemProperties>

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryCopier.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryCopier.java?rev=803470&r1=803469&r2=803470&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryCopier.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryCopier.java Wed Aug 12 12:19:37 2009
@@ -250,6 +250,7 @@
                 target.getVersionManagerImpl().getPersistenceManager(),
                 target.getDataStore());
         copier.copy(RepositoryImpl.VERSION_STORAGE_NODE_ID);
+        copier.copy(RepositoryImpl.ACTIVITIES_NODE_ID);
     }
 
     private void copyWorkspaces() throws RepositoryException {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?rev=803470&r1=803469&r2=803470&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java Wed Aug 12 12:19:37 2009
@@ -148,7 +148,7 @@
      * for referential integrity.
      * Should be changed very carefully by experienced developers only.
      *
-     * @see https://issues.apache.org/jira/browse/JCR-954
+     * @see "https://issues.apache.org/jira/browse/JCR-954"
      */
     private boolean checkReferences = true;
 
@@ -208,7 +208,7 @@
      * Enables or disables the referential integrity checking, this
      * should be used very carefully by experienced developers only.
      *
-     * @see https://issues.apache.org/jira/browse/JCR-954
+     * @see "https://issues.apache.org/jira/browse/JCR-954"
      * @param checkReferences whether to do referential integrity checks
      */
     public void setCheckReferences(boolean checkReferences) {
@@ -1295,6 +1295,9 @@
         // add child node entry for virtual jcr:versionStorage
         jcrSystemState.addChildNodeEntry(NameConstants.JCR_VERSIONSTORAGE, RepositoryImpl.VERSION_STORAGE_NODE_ID);
 
+        // add child node entry for virtual jcr:activities
+        jcrSystemState.addChildNodeEntry(NameConstants.JCR_ACTIVITIES, RepositoryImpl.ACTIVITIES_NODE_ID);
+
         // add child node entry for virtual jcr:nodeTypes
         jcrSystemState.addChildNodeEntry(NameConstants.JCR_NODETYPES, RepositoryImpl.NODETYPES_NODE_ID);
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java?rev=803470&r1=803469&r2=803470&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java Wed Aug 12 12:19:37 2009
@@ -496,6 +496,7 @@
      *
      * @param name new version name
      * @param src source node to version
+     * @param created optional created date
      * @return the newly created version
      * @throws RepositoryException if an error occurs
      */

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java?rev=803470&r1=803469&r2=803470&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java Wed Aug 12 12:19:37 2009
@@ -63,26 +63,24 @@
      */
     protected final NodeTypeRegistry ntReg;
 
-    /**
-     * Persistent root node of the version histories.
-     */
-    protected NodeStateEx historyRoot;
+    protected final NodeId historiesId;
 
-    /**
-     * Persistent root node of the activities.
-     */
-    protected NodeStateEx activitiesRoot;
+    protected final NodeId activitiesId;
 
     /**
      * the lock on this version manager
      */
     private final DefaultISMLocking rwLock = new DefaultISMLocking();
 
-    public InternalVersionManagerBase(NodeTypeRegistry ntReg) {
+    protected InternalVersionManagerBase(NodeTypeRegistry ntReg,
+                                         NodeId historiesId,
+                                         NodeId activitiesId) {
         this.ntReg = ntReg;
+        this.historiesId = historiesId;
+        this.activitiesId = activitiesId;
     }
 
-    //-------------------------------------------------------< InternalVersionManager >
+//-------------------------------------------------------< InternalVersionManager >
 
     /**
      * {@inheritDoc}
@@ -142,7 +140,7 @@
             String uuid = id.toString();
             Name name = getName(uuid);
 
-            NodeStateEx parent = getParentNode(historyRoot, uuid, null);
+            NodeStateEx parent = getParentNode(getHistoryRoot(), uuid, null);
             if (parent != null && parent.hasNode(name)) {
                 NodeStateEx history = parent.getNode(name, 1);
                 return getVersionHistory(history.getNodeId());
@@ -199,6 +197,21 @@
     }
 
     /**
+     * returns the id of the version history root node
+     *
+     * @return the id of the version history root node
+     */
+    abstract protected NodeStateEx getHistoryRoot();
+
+    /**
+     * returns the id of the activities root node
+     *
+     * @return the id of the activities root node
+     */
+    abstract protected NodeStateEx getActivitiesRoot();
+
+
+    /**
      * Helper for managing write operations.
      */
     private class WriteOperation {
@@ -293,7 +306,7 @@
             String uuid = node.getNodeId().toString();
             Name name = getName(uuid);
 
-            NodeStateEx parent = getParentNode(historyRoot, uuid, null);
+            NodeStateEx parent = getParentNode(getHistoryRoot(), uuid, null);
             if (parent != null && parent.hasNode(name)) {
                 NodeStateEx history = parent.getNode(name, 1);
                 Name root = NameConstants.JCR_ROOTVERSION;
@@ -395,7 +408,7 @@
         try {
             // create deep path
             String uuid = node.getNodeId().toString();
-            NodeStateEx parent = getParentNode(historyRoot, uuid, NameConstants.REP_VERSIONSTORAGE);
+            NodeStateEx parent = getParentNode(getHistoryRoot(), uuid, NameConstants.REP_VERSIONSTORAGE);
             Name name = getName(uuid);
             if (parent.hasNode(name)) {
                 // already exists
@@ -433,7 +446,7 @@
         try {
             // create deep path
             NodeId activityId = new NodeId();
-            NodeStateEx parent = getParentNode(activitiesRoot, activityId.toString(), NameConstants.REP_ACTIVITIES);
+            NodeStateEx parent = getParentNode(getActivitiesRoot(), activityId.toString(), NameConstants.REP_ACTIVITIES);
             Name name = getName(activityId.toString());
 
             // create new activity node in the persistent state
@@ -482,7 +495,7 @@
                 NodeStateEx parent = getNodeStateEx(parentId);
                 parent.removeNode(name);
                 parent.store();
-                if (parent.getChildNodes().length == 0 && !parentId.equals(activitiesRoot.getNodeId())) {
+                if (parent.getChildNodes().length == 0 && !parentId.equals(activitiesId)) {
                     name = parent.getName();
                     parentId = parent.getParentId();
                 } else {
@@ -546,6 +559,7 @@
      * @param history the version history
      * @param node node to checkin
      * @param simple flag indicates simple versioning
+     * @param created optional created date.
      * @return internal version
      * @throws javax.jcr.RepositoryException if an error occurs
      * @see javax.jcr.Node#checkin()

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerImpl.java?rev=803470&r1=803469&r2=803470&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerImpl.java Wed Aug 12 12:19:37 2009
@@ -29,6 +29,7 @@
 
 import org.apache.commons.collections.map.ReferenceMap;
 import org.apache.jackrabbit.core.SessionImpl;
+import org.apache.jackrabbit.core.RepositoryImpl;
 import org.apache.jackrabbit.core.cluster.UpdateEventChannel;
 import org.apache.jackrabbit.core.cluster.UpdateEventListener;
 import org.apache.jackrabbit.core.fs.FileSystem;
@@ -75,9 +76,14 @@
     private static Logger log = LoggerFactory.getLogger(InternalVersionManager.class);
 
     /**
+     * The path of the jcr:system node: /jcr:system
+     */
+    private static final Path SYSTEM_PATH;
+
+    /**
      * The path to the version storage: /jcr:system/jcr:versionStorage
      */
-    private static final Path VERSION_STORAGE_PATH;
+    private static final Path HISTORIES_PATH;
 
     /**
      * The path to the version storage: /jcr:system/jcr:versionStorage/jcr:activities
@@ -89,13 +95,17 @@
             PathBuilder builder = new PathBuilder();
             builder.addRoot();
             builder.addLast(NameConstants.JCR_SYSTEM);
-            builder.addLast(NameConstants.JCR_VERSIONSTORAGE);
-            VERSION_STORAGE_PATH = builder.getPath();
+            SYSTEM_PATH = builder.getPath();
 
             builder = new PathBuilder();
             builder.addRoot();
             builder.addLast(NameConstants.JCR_SYSTEM);
             builder.addLast(NameConstants.JCR_VERSIONSTORAGE);
+            HISTORIES_PATH = builder.getPath();
+
+            builder = new PathBuilder();
+            builder.addRoot();
+            builder.addLast(NameConstants.JCR_SYSTEM);
             builder.addLast(NameConstants.JCR_ACTIVITIES);
             ACTIVITIES_PATH = builder.getPath();
 
@@ -131,6 +141,16 @@
     private final DynamicESCFactory escFactory;
 
     /**
+     * Persistent root node of the version histories.
+     */
+    private final NodeStateEx historyRoot;
+
+    /**
+     * Persistent root node of the activities.
+     */
+    private final NodeStateEx activitiesRoot;
+    
+    /**
      * Map of returned items. this is kept for invalidating
      */
     @SuppressWarnings("unchecked")
@@ -144,8 +164,8 @@
      * @param fs workspace file system
      * @param ntReg node type registry
      * @param obsMgr observation manager
-     * @param rootParentId node id of the version storage parent (i.e. jcr:system)
-     * @param storageId node id of the version storage (i.e. jcr:versionStorage)
+     * @param systemId node id of the version storage parent (i.e. jcr:system)
+     * @param historiesId node id of the version storage (i.e. jcr:versionStorage)
      * @param activitiesId node id of the activities storage (i.e. jcr:activities)
      * @param cacheFactory item state cache factory
      * @param ismLocking workspace item state locking
@@ -154,26 +174,52 @@
     public InternalVersionManagerImpl(PersistenceManager pMgr, FileSystem fs,
                               NodeTypeRegistry ntReg,
                               DelegatingObservationDispatcher obsMgr,
-                              NodeId rootParentId,
-                              NodeId storageId,
+                              NodeId systemId,
+                              NodeId historiesId,
                               NodeId activitiesId,
                               ItemStateCacheFactory cacheFactory,
                               ISMLocking ismLocking) throws RepositoryException {
-        super(ntReg);
+        super(ntReg, historiesId, activitiesId);
         try {
             this.pMgr = pMgr;
             this.fs = fs;
             this.escFactory = new DynamicESCFactory(obsMgr);
 
+            // need to recreate the jcr:system node in this pm, too. so that
+            // it can act as parent for the histories and activities.
+            if (false && !pMgr.exists(systemId)) {
+                NodeState root = pMgr.createNew(systemId);
+                root.setParentId(RepositoryImpl.ROOT_NODE_ID);
+                root.setDefinitionId(ntReg.getEffectiveNodeType(NameConstants.REP_ROOT).getApplicableChildNodeDef(
+                        NameConstants.JCR_SYSTEM, NameConstants.REP_SYSTEM, ntReg).getId());
+                root.setNodeTypeName(NameConstants.REP_SYSTEM);
+                PropertyState pt = pMgr.createNew(new PropertyId(systemId, NameConstants.JCR_PRIMARYTYPE));
+                pt.setDefinitionId(ntReg.getEffectiveNodeType(NameConstants.REP_SYSTEM).getApplicablePropertyDef(
+                        NameConstants.JCR_PRIMARYTYPE, PropertyType.NAME, false).getId());
+                pt.setMultiValued(false);
+                pt.setType(PropertyType.NAME);
+                pt.setValues(new InternalValue[]{InternalValue.create(NameConstants.REP_SYSTEM)});
+                root.addPropertyName(pt.getName());
+
+                // add version storage and activities as child node entries
+                root.addChildNodeEntry(NameConstants.JCR_VERSIONSTORAGE, historiesId);
+                root.addChildNodeEntry(NameConstants.JCR_ACTIVITIES, activitiesId);
+
+                ChangeLog cl = new ChangeLog();
+                cl.added(root);
+                cl.added(pt);
+                pMgr.store(cl);
+            }
+
             // need to store the version storage root directly into the persistence manager
-            if (!pMgr.exists(storageId)) {
-                NodeState root = pMgr.createNew(storageId);
-                root.setParentId(rootParentId);
+            if (!pMgr.exists(historiesId)) {
+                NodeState root = pMgr.createNew(historiesId);
+                root.setParentId(systemId);
                 root.setDefinitionId(ntReg.getEffectiveNodeType(NameConstants.REP_SYSTEM).getApplicableChildNodeDef(
                         NameConstants.JCR_VERSIONSTORAGE, NameConstants.REP_VERSIONSTORAGE, ntReg).getId());
                 root.setNodeTypeName(NameConstants.REP_VERSIONSTORAGE);
-                PropertyState pt = pMgr.createNew(new PropertyId(storageId, NameConstants.JCR_PRIMARYTYPE));
-                pt.setDefinitionId(ntReg.getEffectiveNodeType(NameConstants.REP_SYSTEM).getApplicablePropertyDef(
+                PropertyState pt = pMgr.createNew(new PropertyId(historiesId, NameConstants.JCR_PRIMARYTYPE));
+                pt.setDefinitionId(ntReg.getEffectiveNodeType(NameConstants.REP_VERSIONSTORAGE).getApplicablePropertyDef(
                         NameConstants.JCR_PRIMARYTYPE, PropertyType.NAME, false).getId());
                 pt.setMultiValued(false);
                 pt.setType(PropertyType.NAME);
@@ -188,8 +234,8 @@
             // check for jcr:activities
             if (!pMgr.exists(activitiesId)) {
                 NodeState root = pMgr.createNew(activitiesId);
-                root.setParentId(storageId);
-                root.setDefinitionId(ntReg.getEffectiveNodeType(NameConstants.REP_VERSIONSTORAGE).getApplicableChildNodeDef(
+                root.setParentId(systemId);
+                root.setDefinitionId(ntReg.getEffectiveNodeType(NameConstants.REP_SYSTEM).getApplicableChildNodeDef(
                         NameConstants.JCR_ACTIVITIES, NameConstants.REP_ACTIVITIES, ntReg).getId());
                 root.setNodeTypeName(NameConstants.REP_ACTIVITIES);
                 PropertyState pt = pMgr.createNew(new PropertyId(activitiesId, NameConstants.JCR_PRIMARYTYPE));
@@ -199,32 +245,25 @@
                 pt.setType(PropertyType.NAME);
                 pt.setValues(new InternalValue[]{InternalValue.create(NameConstants.REP_ACTIVITIES)});
                 root.addPropertyName(pt.getName());
-
-                // add activities as child
-                NodeState historyState = pMgr.load(storageId);
-                historyState.addChildNodeEntry(NameConstants.JCR_ACTIVITIES, activitiesId);
-                                
                 ChangeLog cl = new ChangeLog();
                 cl.added(root);
                 cl.added(pt);
-                cl.modified(historyState);
                 pMgr.store(cl);
             }
 
-            sharedStateMgr = createItemStateManager(pMgr, storageId, ntReg, cacheFactory, ismLocking);
+            sharedStateMgr = createItemStateManager(pMgr, systemId, ntReg, cacheFactory, ismLocking);
 
             stateMgr = LocalItemStateManager.createInstance(sharedStateMgr, escFactory, cacheFactory);
             stateMgr.addListener(this);
 
-            NodeState nodeState = (NodeState) stateMgr.getItemState(storageId);
+            NodeState nodeState = (NodeState) stateMgr.getItemState(historiesId);
             historyRoot = new NodeStateEx(stateMgr, ntReg, nodeState, NameConstants.JCR_VERSIONSTORAGE);
 
             nodeState = (NodeState) stateMgr.getItemState(activitiesId);
             activitiesRoot =  new NodeStateEx(stateMgr, ntReg, nodeState, NameConstants.JCR_ACTIVITIES);
 
             // create the virtual item state provider
-            versProvider = new VersionItemStateProvider(
-                    getHistoryRootId(), sharedStateMgr);
+            versProvider = new VersionItemStateProvider(historiesId, activitiesId, sharedStateMgr);
 
         } catch (ItemStateException e) {
             throw new RepositoryException(e);
@@ -339,7 +378,10 @@
     protected InternalVersionItem getItem(NodeId id)
             throws RepositoryException {
 
-        if (id.equals(getHistoryRootId())) {
+        if (id.equals(historiesId)) {
+            return null;
+        }
+        if (id.equals(activitiesId)) {
             return null;
         }
         ReadLock lock = acquireReadLock();
@@ -564,12 +606,21 @@
     }
 
     /**
-     * returns the id of the version history root node
+     * returns the version history root node
+     *
+     * @return the version history root node
+     */
+    protected NodeStateEx getHistoryRoot() {
+        return historyRoot;
+    }
+
+    /**
+     * returns the activities root node
      *
-     * @return the id of the version history root node
+     * @return the activities root node
      */
-    NodeId getHistoryRootId() {
-        return historyRoot.getState().getNodeId();
+    protected NodeStateEx getActivitiesRoot() {
+        return activitiesRoot;
     }
 
     /**
@@ -703,7 +754,7 @@
          * the update, an internal event source is used.
          */
         public EventStateCollection createEventStateCollection(SessionImpl source) {
-            return obsMgr.createEventStateCollection(source, VERSION_STORAGE_PATH);
+            return obsMgr.createEventStateCollection(source, SYSTEM_PATH);
         }
 
         /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalXAVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalXAVersionManager.java?rev=803470&r1=803469&r2=803470&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalXAVersionManager.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalXAVersionManager.java Wed Aug 12 12:19:37 2009
@@ -94,6 +94,16 @@
     private WriteLock vmgrLock;
 
     /**
+     * Persistent root node of the version histories.
+     */
+    private final NodeStateEx historyRoot;
+
+    /**
+     * Persistent root node of the activities.
+     */
+    private final NodeStateEx activitiesRoot;
+
+    /**
      * Creates a new instance of this class.
      *
      * @param vMgr the underlying version manager
@@ -105,7 +115,7 @@
     public InternalXAVersionManager(InternalVersionManagerImpl vMgr, NodeTypeRegistry ntReg,
                             SessionImpl session, ItemStateCacheFactory cacheFactory)
             throws RepositoryException {
-        super(ntReg);
+        super(ntReg, vMgr.historiesId, vMgr.activitiesId);
         this.vMgr = vMgr;
         this.session = session;
         this.stateMgr = XAItemStateManager.createInstance(vMgr.getSharedStateMgr(),
@@ -113,11 +123,17 @@
 
         NodeState state;
         try {
-            state = (NodeState) stateMgr.getItemState(vMgr.getHistoryRootId());
+            state = (NodeState) stateMgr.getItemState(historiesId);
         } catch (ItemStateException e) {
             throw new RepositoryException("Unable to retrieve history root", e);
         }
         this.historyRoot = new NodeStateEx(stateMgr, ntReg, state, NameConstants.JCR_VERSIONSTORAGE);
+        try {
+            state = (NodeState) stateMgr.getItemState(activitiesId);
+        } catch (ItemStateException e) {
+            throw new RepositoryException("Unable to retrieve activities root", e);
+        }
+        this.activitiesRoot = new NodeStateEx(stateMgr, ntReg, state, NameConstants.JCR_ACTIVITIES);
     }
 
     //------------------------------------------< EventStateCollectionFactory >
@@ -286,6 +302,12 @@
      * {@inheritDoc}
      */
     public NodeId getVirtualRootId() {
+        // never used
+        return null;
+    }
+
+    public NodeId[] getVirtualRootIds() {
+        // never used
         return null;
     }
 
@@ -397,6 +419,20 @@
     /**
      * {@inheritDoc}
      */
+    protected NodeStateEx getHistoryRoot() {
+        return historyRoot;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    protected NodeStateEx getActivitiesRoot() {
+        return activitiesRoot;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
      protected InternalVersionItem getItem(NodeId id) throws RepositoryException {
         InternalVersionItem item = null;
         if (xaItems != null) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java?rev=803470&r1=803469&r2=803470&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java Wed Aug 12 12:19:37 2009
@@ -43,6 +43,11 @@
     private final NodeId historyRootId;
 
     /**
+     * The root node UUID for the activity storage
+     */
+    private final NodeId activitiesRootId;
+
+    /**
      * The item state manager directly on the version persistence mgr
      */
     private final VersionItemStateManager stateMgr;
@@ -57,8 +62,10 @@
      *
      */
     public VersionItemStateProvider(NodeId historyRootId,
+                                    NodeId activitiesRootId,
                                     VersionItemStateManager stateMgr) {
         this.historyRootId = historyRootId;
+        this.activitiesRootId = activitiesRootId;
         this.stateMgr = stateMgr;
 
         stateMgr.addListener(this);
@@ -70,7 +77,7 @@
      * @inheritDoc
      */
     public boolean isVirtualRoot(ItemId id) {
-        return id.equals(historyRootId);
+        return id.equals(historyRootId) || id.equals(activitiesRootId);
     }
 
     /**
@@ -83,6 +90,13 @@
     /**
      * @inheritDoc
      */
+    public NodeId[] getVirtualRootIds() {
+        return new NodeId[]{historyRootId, activitiesRootId};
+    }
+
+    /**
+     * @inheritDoc
+     */
     public VirtualPropertyState createPropertyState(VirtualNodeState parent,
                                                     Name name, int type,
                                                     boolean multiValued)

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/AbstractVISProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/AbstractVISProvider.java?rev=803470&r1=803469&r2=803470&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/AbstractVISProvider.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/AbstractVISProvider.java Wed Aug 12 12:19:37 2009
@@ -169,6 +169,13 @@
     }
 
     /**
+     * {@inheritDoc}
+     */
+    public NodeId[] getVirtualRootIds() {
+        return new NodeId[]{rootNodeId};
+    }
+
+    /**
      * Returns the root state
      *
      * @return the root state

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/VirtualItemStateProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/VirtualItemStateProvider.java?rev=803470&r1=803469&r2=803470&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/VirtualItemStateProvider.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/VirtualItemStateProvider.java Wed Aug 12 12:19:37 2009
@@ -43,10 +43,18 @@
      * Returns the id of the root node of the virtual tree.
      *
      * @return the id of the root node of the virtual tree.
+     * @deprecated use {@link #getVirtualRootIds()} instead.
      */
     NodeId getVirtualRootId();
 
     /**
+     * Returns the ids of the root nodes of the virtual tree.
+     *
+     * @return the ids of the roots node of the virtual tree.
+     */
+    NodeId[] getVirtualRootIds();
+
+    /**
      * Creats a new virtual property state
      *
      * @param parent

Modified: jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd?rev=803470&r1=803469&r2=803470&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd Wed Aug 12 12:19:37 2009
@@ -491,9 +491,6 @@
 // J A C K R A B B I T   I N T E R N A L S
 //------------------------------------------------------------------------------
 
-[rep:nodeTypes]
-  + * (nt:nodeType) = nt:nodeType protected ABORT
-
 [rep:root] > nt:unstructured
   + jcr:system (rep:system) = rep:system mandatory IGNORE
 
@@ -501,37 +498,51 @@
   orderable
   + jcr:versionStorage (rep:versionStorage) = rep:versionStorage mandatory protected ABORT
   + jcr:nodeTypes (rep:nodeTypes) = rep:nodeTypes mandatory protected ABORT
-  + jcr:configurations (rep:Configurations) = rep:Configurations protected sns ABORT
-  + * (nt:base) = nt:unstructured sns IGNORE
+  // @since 2.0
+  + jcr:activities (rep:Activities) = rep:Activities mandatory protected ABORT
+  // @since 2.0
+  + jcr:configurations (rep:Configurations) = rep:Configurations protected ABORT
+  + * (nt:base) = nt:base IGNORE
 
-// implementation note: currently we keep the activities below the version storage
-// because of the complexity of adding new virtual item state providers.
-// the future goal is to keep them as siblings, of course.
 
+/**
+ * Node Types (virtual) storage
+ */
+[rep:nodeTypes]
+  + * (nt:nodeType) = nt:nodeType protected ABORT
+
+/**
+ * Version storage
+ */
 [rep:versionStorage]
-  + * (nt:versionHistory) = nt:versionHistory protected sns ABORT
-  + * (rep:versionStorage) = rep:versionStorage protected sns ABORT
-  + * (rep:Activities) = rep:Activities protected sns ABORT
+  + * (nt:versionHistory) = nt:versionHistory protected ABORT
+  + * (rep:versionStorage) = rep:versionStorage protected ABORT
 
+/**
+ * Activities storage
+ * @since 2.0
+ */
 [rep:Activities]
-  + * (nt:activity) = nt:activity protected sns ABORT
-  + * (rep:Activities) = rep:Activities protected sns ABORT
+  + * (nt:activity) = nt:activity protected ABORT
+  + * (rep:Activities) = rep:Activities protected ABORT
 
 /**
  * the intermediate nodes for the configurations storage.
  * Note: since the versionable node points to the configuration and vice versa,
  * a configuration could never be removed because no such API exists. therefore
  * the child node definitions are not protected.
+ * @since 2.0
  */
 [rep:Configurations]
-  + * (nt:configuration) = nt:configuration sns ABORT
-  + * (rep:Configurations) = rep:Configurations sns ABORT
+  + * (nt:configuration) = nt:configuration ABORT
+  + * (rep:Configurations) = rep:Configurations ABORT
 
 /**
  * mixin that provides a multi value property for referencing versions.
  * This is used for recording the baseline versions in the nt:configuration
  * node, and to setup a bidirectional relationship between activities and
  * the respective versions
+ * @since 2.0
  */
 [rep:VersionReference] mix
   - rep:versions (REFERENCE) protected multiple

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/ActivitiesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/ActivitiesTest.java?rev=803470&r1=803469&r2=803470&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/ActivitiesTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/ActivitiesTest.java Wed Aug 12 12:19:37 2009
@@ -20,6 +20,7 @@
 import javax.jcr.Property;
 import javax.jcr.PropertyType;
 import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.version.VersionManager;
 
@@ -106,8 +107,13 @@
             assertTrue("path for activity must be below " + PREFIX + ", but was " + an.getPath(), an.getPath().startsWith(PREFIX));
 
             Node activities = superuser.getNode(PREFIX);
-            
-            assertFalse(activities.getPrimaryNodeType().canAddChildNode("foobar"));
+
+            try {
+                activities.addNode("foobar");
+                fail("/jcr:system/jcr:activities must be protected.");
+            } catch (RepositoryException e) {
+                // ok
+            }
         }
         finally {
             if (an != null) {