jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r165309 - in /incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core: BatchedItemOperations.java version/PersistentVersionManager.java version/VersionManager.java xml/WorkspaceImporter.java
Date Fri, 29 Apr 2005 14:06:24 GMT
Author: stefan
Date: Fri Apr 29 07:06:23 2005
New Revision: 165309

URL: http://svn.apache.org/viewcvs?rev=165309&view=rev
Log:
port to jcr api v0.16.4.1

Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/BatchedItemOperations.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/PersistentVersionManager.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManager.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/BatchedItemOperations.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/BatchedItemOperations.java?rev=165309&r1=165308&r2=165309&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/BatchedItemOperations.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/BatchedItemOperations.java
Fri Apr 29 07:06:23 2005
@@ -1632,8 +1632,6 @@
             }
             newState = stateMgr.createNew(uuid, srcState.getNodeTypeName(), destParentUUID);
             // copy node state
-            // @todo special handling required for nodes with special semantics (e.g. those
defined by mix:versionable, et.al.)
-            // FIXME delegate to 'node type instance handler'
             newState.setMixinTypeNames(srcState.getMixinTypeNames());
             newState.setDefinitionId(srcState.getDefinitionId());
             // copy child nodes
@@ -1645,6 +1643,14 @@
                     continue;
                 }
                 NodeState srcChildState = (NodeState) srcStateMgr.getItemState(nodeId);
+
+                /**
+                 * special handling required for child nodes with special semantics
+                 * (e.g. those defined by nt:version,  et.al.)
+                 *
+                 * todo FIXME delegate to 'node type instance handler'
+                 */
+
                 // recursive copying of child node
                 NodeState newChildState = copyNodeState(srcChildState,
                         srcStateMgr, srcAccessMgr, uuid, flag, refTracker);
@@ -1663,6 +1669,21 @@
                 }
                 PropertyState srcChildState =
                         (PropertyState) srcStateMgr.getItemState(propId);
+
+                /**
+                 * special handling required for properties with special semantics
+                 * (e.g. those defined by mix:referenceable, mix:versionable,
+                 * mix:lockable, et.al.)
+                 *
+                 * todo FIXME delegate to 'node type instance handler'
+                 */
+                PropDefId defId = srcChildState.getDefinitionId();
+                PropDef def = ntReg.getPropDef(defId);
+                if (def.getDeclaringNodeType().equals(MIX_LOCKABLE)) {
+                    // skip properties defined by mix:lockable
+                    continue;
+                }
+
                 PropertyState newChildState =
                         copyPropertyState(srcChildState, uuid, entry.getName());
                 if (newChildState.getType() == PropertyType.REFERENCE) {
@@ -1695,34 +1716,34 @@
                                             QName propName)
             throws RepositoryException {
 
-        // @todo special handling required for properties with special semantics
-        // (e.g. those defined by mix:versionable, mix:lockable, et.al.)
-        PropertyState newState = stateMgr.createNew(propName, parentUUID);
         PropDefId defId = srcState.getDefinitionId();
+        PropDef def = ntReg.getPropDef(defId);
+
+        PropertyState newState = stateMgr.createNew(propName, parentUUID);
+
         newState.setDefinitionId(defId);
         newState.setType(srcState.getType());
         newState.setMultiValued(srcState.isMultiValued());
         InternalValue[] values = srcState.getValues();
         if (values != null) {
-            InternalValue[] newValues = new InternalValue[values.length];
-            for (int i = 0; i < values.length; i++) {
-                if (values[i] != null) {
+            /**
+             * special handling required for properties with special semantics
+             * (e.g. those defined by mix:referenceable, mix:versionable,
+             * mix:lockable, et.al.)
+             *
+             * todo FIXME delegate to 'node type instance handler'
+             */
+            if (def.getDeclaringNodeType().equals(MIX_REFERENCEABLE)
+                    && propName.equals(JCR_UUID)) {
+                // set correct value of jcr:uuid property
+                newState.setValues(new InternalValue[]{InternalValue.create(parentUUID)});
+            } else {
+                InternalValue[] newValues = new InternalValue[values.length];
+                for (int i = 0; i < values.length; i++) {
                     newValues[i] = values[i].createCopy();
-                } else {
-                    newValues[i] = null;
                 }
             }
             newState.setValues(values);
-            // FIXME delegate to 'node type instance handler'
-            if (defId != null) {
-                PropDef def = ntReg.getPropDef(defId);
-                if (def.getDeclaringNodeType().equals(MIX_REFERENCEABLE)) {
-                    if (propName.equals(JCR_UUID)) {
-                        // set correct value of jcr:uuid property
-                        newState.setValues(new InternalValue[]{InternalValue.create(parentUUID)});
-                    }
-                }
-            }
         }
         return newState;
     }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/PersistentVersionManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/PersistentVersionManager.java?rev=165309&r1=165308&r2=165309&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/PersistentVersionManager.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/PersistentVersionManager.java
Fri Apr 29 07:06:23 2005
@@ -25,8 +25,8 @@
 
 /**
  * This interface defines the access to the persistence layer of the
- * versioning. The way how the versions are stored may totaly differ from
- * the way they are exposed to the client.
+ * versioning. The way how the versions are stored may be totally different
+ * from the way they are exposed to the client.
  */
 public interface PersistentVersionManager {
 
@@ -126,7 +126,7 @@
      * @param node
      * @return
      * @throws RepositoryException
-     * @see Node#checkin()
+     * @see javax.jcr.Node#checkin()
      */
     InternalVersion checkin(NodeImpl node) throws RepositoryException;
 

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManager.java?rev=165309&r1=165308&r2=165309&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManager.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManager.java
Fri Apr 29 07:06:23 2005
@@ -43,7 +43,7 @@
 
     /**
      * Creates a new version history. This action is needed either when creating
-     * a new 'mix:versionable' node or when adding the 'mix:versionalbe' mixin
+     * a new 'mix:versionable' node or when adding the 'mix:versionable' mixin
      * to a node.
      *
      * @param node

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java?rev=165309&r1=165308&r2=165309&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java
Fri Apr 29 07:06:23 2005
@@ -248,6 +248,68 @@
         return node;
     }
 
+    /**
+     * Post-process imported node (initialize properties with special
+     * semantics etc.)
+     *
+     * @param node
+     * @throws RepositoryException
+     */
+    protected void postProcessNode(NodeState node) throws RepositoryException {
+        /**
+         * special handling required for properties with special semantics
+         * (e.g. those defined by mix:referenceable, mix:versionable,
+         * mix:lockable, et.al.)
+         *
+         * todo FIXME delegate to 'node type instance handler'
+         */
+        EffectiveNodeType ent = itemOps.getEffectiveNodeType(node);
+        if (ent.includesNodeType(MIX_VERSIONABLE)) {
+            PropDef def;
+            PropertyState prop;
+
+            // @todo FIXME initialize version history
+            String dummyUUID = "00000000-0000-0000-0000-000000000000";
+
+            // jcr:versionHistory
+            if (!node.hasPropertyEntry(JCR_VERSIONHISTORY)) {
+                def = itemOps.findApplicablePropertyDefinition(JCR_VERSIONHISTORY,
+                        PropertyType.REFERENCE, false, node);
+                prop = itemOps.createPropertyState(node, JCR_VERSIONHISTORY,
+                        PropertyType.REFERENCE, def);
+                prop.setValues(new InternalValue[]{InternalValue.create(new UUID(dummyUUID))});
+            }
+
+            // jcr:baseVersion
+            if (!node.hasPropertyEntry(JCR_BASEVERSION)) {
+                def = itemOps.findApplicablePropertyDefinition(JCR_BASEVERSION,
+                        PropertyType.REFERENCE, false, node);
+                prop = itemOps.createPropertyState(node, JCR_BASEVERSION,
+                        PropertyType.REFERENCE, def);
+                prop.setValues(new InternalValue[]{InternalValue.create(new UUID(dummyUUID))});
+            }
+
+            // jcr:predecessors
+            if (!node.hasPropertyEntry(JCR_PREDECESSORS)) {
+                def = itemOps.findApplicablePropertyDefinition(JCR_PREDECESSORS,
+                        PropertyType.REFERENCE, true, node);
+                prop = itemOps.createPropertyState(node, JCR_PREDECESSORS,
+                        PropertyType.REFERENCE, def);
+                prop.setValues(new InternalValue[]{InternalValue.create(new UUID(dummyUUID))});
+            }
+
+            // jcr:isCheckedOut
+            if (!node.hasPropertyEntry(JCR_ISCHECKEDOUT)) {
+                def = itemOps.findApplicablePropertyDefinition(JCR_ISCHECKEDOUT,
+                        PropertyType.BOOLEAN, false, node);
+                prop = itemOps.createPropertyState(node, JCR_ISCHECKEDOUT,
+                        PropertyType.BOOLEAN, def);
+                prop.setValues(new InternalValue[]{InternalValue.create(true)});
+            }
+
+        }
+    }
+
     //-------------------------------------------------------------< Importer >
     /**
      * {@inheritDoc}
@@ -576,6 +638,9 @@
         try {
             // check sanity of workspace/session first
             wsp.sanityCheck();
+
+            // post-process node (initialize properties with special semantics etc.)
+            postProcessNode(node);
 
             // make sure node is valid according to its definition
             itemOps.validate(node);



Mime
View raw message