jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r478979 - in /jackrabbit/branches/1.1/jackrabbit/src/main/java/org/apache/jackrabbit/core: RepositoryImpl.java state/SharedItemStateManager.java
Date Fri, 24 Nov 2006 20:19:05 GMT
Author: jukka
Date: Fri Nov 24 12:19:05 2006
New Revision: 478979

URL: http://svn.apache.org/viewvc?view=rev&rev=478979
Log:
1.1: Merged revisions 469480 and 469480 (JCR-605)

Modified:
    jackrabbit/branches/1.1/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
    jackrabbit/branches/1.1/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java

Modified: jackrabbit/branches/1.1/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.1/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java?view=diff&rev=478979&r1=478978&r2=478979
==============================================================================
--- jackrabbit/branches/1.1/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
(original)
+++ jackrabbit/branches/1.1/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
Fri Nov 24 12:19:05 2006
@@ -35,7 +35,6 @@
 import org.apache.jackrabbit.core.fs.FileSystemResource;
 import org.apache.jackrabbit.core.lock.LockManager;
 import org.apache.jackrabbit.core.lock.LockManagerImpl;
-import org.apache.jackrabbit.core.nodetype.NodeTypeImpl;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.nodetype.virtual.VirtualNodeTypeStateManager;
 import org.apache.jackrabbit.core.observation.DelegatingObservationDispatcher;
@@ -533,20 +532,9 @@
          * - all other workspaces should be dynamic workspaces based on
          *   this 'read-only' system workspace
          *
-         * for now, we just create a /jcr:system node in every workspace
+         * for now, the jcr:system node is created in
+         * {@link org.apache.jackrabbit.core.state.SharedItemStateManager#createRootNodeState}
          */
-        NodeImpl rootNode = (NodeImpl) sysSession.getRootNode();
-        if (!rootNode.hasNode(QName.JCR_SYSTEM)) {
-            NodeTypeImpl nt = sysSession.getNodeTypeManager().getNodeType(QName.REP_SYSTEM);
-            NodeImpl sysRoot = rootNode.internalAddChildNode(QName.JCR_SYSTEM, nt, SYSTEM_ROOT_NODE_ID);
-            // add version storage
-            nt = sysSession.getNodeTypeManager().getNodeType(QName.REP_VERSIONSTORAGE);
-            sysRoot.internalAddChildNode(QName.JCR_VERSIONSTORAGE, nt, VERSION_STORAGE_NODE_ID);
-            // add node types
-            nt = sysSession.getNodeTypeManager().getNodeType(QName.REP_NODETYPES);
-            sysRoot.internalAddChildNode(QName.JCR_NODETYPES, nt, NODETYPES_NODE_ID);
-            rootNode.save();
-        }
 
         // register the repository as event listener for keeping repository statistics
         wsp.getObservationManager().addEventListener(this,

Modified: jackrabbit/branches/1.1/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.1/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?view=diff&rev=478979&r1=478978&r2=478979
==============================================================================
--- jackrabbit/branches/1.1/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
(original)
+++ jackrabbit/branches/1.1/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
Fri Nov 24 12:19:05 2006
@@ -21,6 +21,8 @@
 import org.apache.jackrabbit.core.ItemId;
 import org.apache.jackrabbit.core.NodeId;
 import org.apache.jackrabbit.core.PropertyId;
+import org.apache.jackrabbit.core.RepositoryImpl;
+import org.apache.jackrabbit.core.persistence.PersistenceManager;
 import org.apache.jackrabbit.core.version.XAVersionManager;
 import org.apache.jackrabbit.core.nodetype.EffectiveNodeType;
 import org.apache.jackrabbit.core.nodetype.NodeDefId;
@@ -798,6 +800,7 @@
             throws ItemStateException {
 
         NodeState rootState = createInstance(rootNodeId, QName.REP_ROOT, null);
+        NodeState jcrSystemState = createInstance(RepositoryImpl.SYSTEM_ROOT_NODE_ID, QName.REP_SYSTEM,
rootNodeId);
 
         // FIXME need to manually setup root node by creating mandatory jcr:primaryType property
         // @todo delegate setup of root node to NodeTypeInstanceHandler
@@ -806,11 +809,14 @@
         NodeDefId nodeDefId;
         // definition of jcr:primaryType property
         PropDef propDef;
+        // id of the jcr:system node's definition
+        NodeDefId jcrSystemDefId;
         try {
             nodeDefId = ntReg.getRootNodeDef().getId();
             EffectiveNodeType ent = ntReg.getEffectiveNodeType(QName.REP_ROOT);
             propDef = ent.getApplicablePropertyDef(QName.JCR_PRIMARYTYPE,
                     PropertyType.NAME, false);
+            jcrSystemDefId = ent.getApplicableChildNodeDef(QName.JCR_SYSTEM, QName.REP_SYSTEM,
ntReg).getId();
         } catch (NoSuchNodeTypeException nsnte) {
             String msg = "internal error: failed to create root node";
             log.error(msg, nsnte);
@@ -821,8 +827,9 @@
             throw new ItemStateException(msg, cve);
         }
         rootState.setDefinitionId(nodeDefId);
+        jcrSystemState.setDefinitionId(jcrSystemDefId);
 
-        // create jcr:primaryType property
+        // create jcr:primaryType property on root node state
         rootState.addPropertyName(propDef.getName());
 
         PropertyState prop = createInstance(propDef.getName(), rootNodeId);
@@ -831,9 +838,30 @@
         prop.setMultiValued(propDef.isMultiple());
         prop.setDefinitionId(propDef.getId());
 
+        // create jcr:primaryType property on jcr:system node state
+        jcrSystemState.addPropertyName(propDef.getName());
+
+        PropertyState primaryTypeProp = createInstance(propDef.getName(), jcrSystemState.getNodeId());
+        primaryTypeProp.setValues(new InternalValue[]{InternalValue.create(QName.REP_SYSTEM)});
+        primaryTypeProp.setType(propDef.getRequiredType());
+        primaryTypeProp.setMultiValued(propDef.isMultiple());
+        primaryTypeProp.setDefinitionId(propDef.getId());
+
+        // add child node entry for jcr:system node
+        rootState.addChildNodeEntry(QName.JCR_SYSTEM, RepositoryImpl.SYSTEM_ROOT_NODE_ID);
+
+        // add child node entry for virtual jcr:versionStorage
+        jcrSystemState.addChildNodeEntry(QName.JCR_VERSIONSTORAGE, RepositoryImpl.VERSION_STORAGE_NODE_ID);
+
+        // add child node entry for virtual jcr:nodeTypes
+        jcrSystemState.addChildNodeEntry(QName.JCR_NODETYPES, RepositoryImpl.NODETYPES_NODE_ID);
+
+
         ChangeLog changeLog = new ChangeLog();
         changeLog.added(rootState);
         changeLog.added(prop);
+        changeLog.added(jcrSystemState);
+        changeLog.added(primaryTypeProp);
 
         persistMgr.store(changeLog);
         changeLog.persisted();



Mime
View raw message