jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r165408 - in /incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core: ./ version/ version/persistence/ xml/
Date Sat, 30 Apr 2005 15:22:50 GMT
Author: tripod
Date: Sat Apr 30 08:22:48 2005
New Revision: 165408

URL: http://svn.apache.org/viewcvs?rev=165408&view=rev
Log:
- adding correct mix:versionable handle for workspaceimporter

Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.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/version/VersionManagerImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionNodeState.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalFrozenNodeImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalVersionHistoryImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativePVM.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java?rev=165408&r1=165407&r2=165408&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java Sat Apr 30
08:22:48 2005
@@ -882,7 +882,7 @@
                 NodeImpl node = (NodeImpl) itemMgr.getItem(itemState.getId());
                 if (node.isNodeType(MIX_VERSIONABLE)) {
                     if (!node.hasProperty(JCR_VERSIONHISTORY)) {
-                        VersionHistory hist = session.getVersionManager().createVersionHistory(node);
+                        VersionHistory hist = session.getVersionManager().createVersionHistory(session,
(NodeState) itemState);
                         node.internalSetProperty(JCR_VERSIONHISTORY, InternalValue.create(new
UUID(hist.getUUID())));
                         node.internalSetProperty(JCR_BASEVERSION, InternalValue.create(new
UUID(hist.getRootVersion().getUUID())));
                         node.internalSetProperty(JCR_ISCHECKEDOUT, InternalValue.create(true));

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=165408&r1=165407&r2=165408&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
Sat Apr 30 08:22:48 2005
@@ -18,6 +18,7 @@
 
 import org.apache.jackrabbit.core.NodeImpl;
 import org.apache.jackrabbit.core.state.UpdatableItemStateManager;
+import org.apache.jackrabbit.core.state.NodeState;
 
 import javax.jcr.RepositoryException;
 import java.util.Iterator;
@@ -37,7 +38,7 @@
      * @return the newly created version history.
      * @throws RepositoryException
      */
-    InternalVersionHistory createVersionHistory(NodeImpl node)
+    InternalVersionHistory createVersionHistory(NodeState 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=165408&r1=165407&r2=165408&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
Sat Apr 30 08:22:48 2005
@@ -19,9 +19,11 @@
 import org.apache.jackrabbit.core.NodeImpl;
 import org.apache.jackrabbit.core.QName;
 import org.apache.jackrabbit.core.state.ItemStateManager;
+import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.virtual.VirtualItemStateProvider;
 
 import javax.jcr.RepositoryException;
+import javax.jcr.Session;
 import javax.jcr.version.Version;
 import javax.jcr.version.VersionHistory;
 import java.util.Iterator;
@@ -50,7 +52,7 @@
      * @return
      * @throws RepositoryException
      */
-    VersionHistory createVersionHistory(NodeImpl node) throws RepositoryException;
+    VersionHistory createVersionHistory(Session session, NodeState node) throws RepositoryException;
 
     /**
      * invokes the checkin() on the persistent version manager and remaps the

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java?rev=165408&r1=165407&r2=165408&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
Sat Apr 30 08:22:48 2005
@@ -29,12 +29,14 @@
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.nodetype.NodeTypeImpl;
 import org.apache.jackrabbit.core.state.ItemStateManager;
+import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.virtual.VirtualItemStateProvider;
 import org.apache.log4j.Logger;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.PropertyIterator;
 import javax.jcr.NodeIterator;
+import javax.jcr.Session;
 import javax.jcr.version.Version;
 import javax.jcr.version.VersionHistory;
 import javax.jcr.version.VersionException;
@@ -141,15 +143,15 @@
      * @return
      * @throws javax.jcr.RepositoryException
      */
-    public VersionHistory createVersionHistory(NodeImpl node) throws RepositoryException
{
+    public VersionHistory createVersionHistory(Session session, NodeState node) throws RepositoryException
{
         InternalVersionHistory history = vMgr.createVersionHistory(node);
         virtProvider.invalidateItem(new NodeId(VERSION_STORAGE_NODE_UUID), false);
-        VersionHistoryImpl vh = (VersionHistoryImpl) node.getSession().getNodeByUUID(history.getId());
+        VersionHistoryImpl vh = (VersionHistoryImpl) session.getNodeByUUID(history.getId());
 
         // generate observation events
         List events = new ArrayList();
         recursiveAdd(events, (NodeImpl) vh.getParent(), vh);
-        obsMgr.dispatch(events, (SessionImpl) node.getSession());
+        obsMgr.dispatch(events, (SessionImpl) session);
 
         return vh;
     }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionNodeState.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionNodeState.java?rev=165408&r1=165407&r2=165408&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionNodeState.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionNodeState.java
Sat Apr 30 08:22:48 2005
@@ -18,7 +18,6 @@
 
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.core.QName;
-import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.core.util.uuid.UUID;
 import org.apache.jackrabbit.core.virtual.VirtualNodeState;
 import org.apache.jackrabbit.core.virtual.VirtualPropertyState;

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalFrozenNodeImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalFrozenNodeImpl.java?rev=165408&r1=165407&r2=165408&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalFrozenNodeImpl.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalFrozenNodeImpl.java
Sat Apr 30 08:22:48 2005
@@ -21,7 +21,6 @@
 import org.apache.jackrabbit.core.NodeImpl;
 import org.apache.jackrabbit.core.PropertyImpl;
 import org.apache.jackrabbit.core.QName;
-import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.core.nodetype.NodeTypeImpl;
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.NodeState;
@@ -50,26 +49,20 @@
         implements InternalFrozenNode, Constants {
 
     /**
-     * checkin mode init. specifies, that node is only initialized
+     * checkin mode version.
      */
-    public static final int MODE_INIT = 0;
-
-    /**
-     * checkin mode version. specifies, that the OPV value should be used to
-     * determine the checkin behaviour.
-     */
-    public static final int MODE_VERSION = 1;
+    private static final int MODE_VERSION = 0;
 
     /**
      * checkin mode copy. specifies, that the items are always copied.
      */
-    private static final int MODE_COPY = 2;
+    private static final int MODE_COPY = 1;
 
     /**
      * mode flag specifies, that the mode should be recursed. otherwise i
      * will be redetermined by the opv.
      */
-    private static final int MODE_COPY_RECURSIVE = 6;
+    private static final int MODE_COPY_RECURSIVE = 3;
 
     /**
      * the underlying persistance node
@@ -268,22 +261,37 @@
      * @throws RepositoryException
      */
     protected static PersistentNode checkin(PersistentNode parent, QName name,
-                                            NodeImpl src, int mode)
+                                            NodeImpl src)
             throws RepositoryException {
+        return checkin(parent, name, src, MODE_VERSION);
+    }
 
-        PersistentNode node;
+    /**
+     * Checks-in a <code>src</code> node. It creates a new child node of
+     * <code>parent</code> with the given <code>name</code> and adds
the
+     * source nodes properties according to their OPV value to the
+     * list of frozen properties. It creates frozen child nodes for each child
+     * node of <code>src</code> according to its OPV value.
+     *
+     * @param parent
+     * @param name
+     * @param src
+     * @return
+     * @throws RepositoryException
+     */
+    private static PersistentNode checkin(PersistentNode parent, QName name,
+                                            NodeImpl src, int mode)
+            throws RepositoryException {
 
         // create new node
-        node = parent.addNode(name, NativePVM.NT_REP_FROZEN, null);
+        PersistentNode node = parent.addNode(name, NativePVM.NT_REP_FROZEN, null);
 
         // initialize the internal properties
         if (src.isNodeType(MIX_REFERENCEABLE)) {
             node.setPropertyValue(JCR_FROZENUUID, InternalValue.create(src.getUUID()));
         }
-
         node.setPropertyValue(JCR_FROZENPRIMARYTYPE,
                 InternalValue.create(((NodeTypeImpl) src.getPrimaryNodeType()).getQName()));
-
         if (src.hasProperty(NodeImpl.JCR_MIXINTYPES)) {
             NodeType[] mixins = src.getMixinNodeTypes();
             InternalValue[] ivalues = new InternalValue[mixins.length];
@@ -292,67 +300,65 @@
             }
             node.setPropertyValues(JCR_FROZENMIXINTYPES, PropertyType.NAME, ivalues);
         }
-        if (mode != MODE_INIT) {
-            // add the properties
-            PropertyIterator piter = src.getProperties();
-            while (piter.hasNext()) {
-                PropertyImpl prop = (PropertyImpl) piter.nextProperty();
-                int opv;
-                if ((mode & MODE_COPY) > 0) {
-                    opv = OnParentVersionAction.COPY;
-                } else {
-                    opv = prop.getDefinition().getOnParentVersion();
-                }
-                switch (opv) {
-                    case OnParentVersionAction.ABORT:
-                        parent.reload();
-                        throw new VersionException("Checkin aborted due to OPV in " + prop.safeGetJCRPath());
-                    case OnParentVersionAction.COMPUTE:
-                    case OnParentVersionAction.IGNORE:
-                    case OnParentVersionAction.INITIALIZE:
-                        break;
-                    case OnParentVersionAction.VERSION:
-                    case OnParentVersionAction.COPY:
-                        node.copyFrom(prop);
-                        break;
-                }
-            }
 
+        // add the properties
+        PropertyIterator piter = src.getProperties();
+        while (piter.hasNext()) {
+            PropertyImpl prop = (PropertyImpl) piter.nextProperty();
+            int opv;
+            if ((mode & MODE_COPY) > 0) {
+                opv = OnParentVersionAction.COPY;
+            } else {
+                opv = prop.getDefinition().getOnParentVersion();
+            }
+            switch (opv) {
+                case OnParentVersionAction.ABORT:
+                    parent.reload();
+                    throw new VersionException("Checkin aborted due to OPV in " + prop.safeGetJCRPath());
+                case OnParentVersionAction.COMPUTE:
+                case OnParentVersionAction.IGNORE:
+                case OnParentVersionAction.INITIALIZE:
+                    break;
+                case OnParentVersionAction.VERSION:
+                case OnParentVersionAction.COPY:
+                    node.copyFrom(prop);
+                    break;
+            }
+        }
 
-            // add the frozen children and vistories
-            NodeIterator niter = src.getNodes();
-            while (niter.hasNext()) {
-                NodeImpl child = (NodeImpl) niter.nextNode();
-                int opv;
-                if ((mode & MODE_COPY_RECURSIVE) > 0) {
-                    opv = OnParentVersionAction.COPY;
-                } else {
-                    opv = child.getDefinition().getOnParentVersion();
-                }
-                switch (opv) {
-                    case OnParentVersionAction.ABORT:
-                        throw new VersionException("Checkin aborted due to OPV in " + child.safeGetJCRPath());
-                    case OnParentVersionAction.COMPUTE:
-                    case OnParentVersionAction.IGNORE:
-                    case OnParentVersionAction.INITIALIZE:
-                        break;
-                    case OnParentVersionAction.VERSION:
-                        if (child.isNodeType(MIX_VERSIONABLE)) {
-                            // create frozen versionable child
-                            PersistentNode newChild = node.addNode(child.getQName(), NativePVM.NT_REP_FROZEN_HISTORY,
null);
-                            newChild.setPropertyValue(JCR_VERSIONHISTORY,
-                                    InternalValue.create(child.getVersionHistory().getUUID()));
-                            newChild.setPropertyValue(JCR_BASEVERSION,
-                                    InternalValue.create(child.getBaseVersion().getUUID()));
-                            break;
-                        }
-                        // else copy but do not recurse
-                        checkin(node, child.getQName(), child, MODE_COPY);
-                        break;
-                    case OnParentVersionAction.COPY:
-                        checkin(node, child.getQName(), child, MODE_COPY_RECURSIVE);
+        // add the frozen children and vistories
+        NodeIterator niter = src.getNodes();
+        while (niter.hasNext()) {
+            NodeImpl child = (NodeImpl) niter.nextNode();
+            int opv;
+            if ((mode & MODE_COPY_RECURSIVE) > 0) {
+                opv = OnParentVersionAction.COPY;
+            } else {
+                opv = child.getDefinition().getOnParentVersion();
+            }
+            switch (opv) {
+                case OnParentVersionAction.ABORT:
+                    throw new VersionException("Checkin aborted due to OPV in " + child.safeGetJCRPath());
+                case OnParentVersionAction.COMPUTE:
+                case OnParentVersionAction.IGNORE:
+                case OnParentVersionAction.INITIALIZE:
+                    break;
+                case OnParentVersionAction.VERSION:
+                    if (child.isNodeType(MIX_VERSIONABLE)) {
+                        // create frozen versionable child
+                        PersistentNode newChild = node.addNode(child.getQName(), NativePVM.NT_REP_FROZEN_HISTORY,
null);
+                        newChild.setPropertyValue(JCR_VERSIONHISTORY,
+                                InternalValue.create(child.getVersionHistory().getUUID()));
+                        newChild.setPropertyValue(JCR_BASEVERSION,
+                                InternalValue.create(child.getBaseVersion().getUUID()));
                         break;
-                }
+                    }
+                    // else copy but do not recurse
+                    checkin(node, child.getQName(), child, MODE_COPY);
+                    break;
+                case OnParentVersionAction.COPY:
+                    checkin(node, child.getQName(), child, MODE_COPY_RECURSIVE);
+                    break;
             }
         }
         return node;

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalVersionHistoryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalVersionHistoryImpl.java?rev=165408&r1=165407&r2=165408&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalVersionHistoryImpl.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalVersionHistoryImpl.java
Sat Apr 30 08:22:48 2005
@@ -21,6 +21,7 @@
 import org.apache.jackrabbit.core.QName;
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.UpdatableItemStateManager;
+import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.util.uuid.UUID;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.core.version.InternalVersion;
@@ -38,6 +39,7 @@
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
 
 /**
  *
@@ -383,7 +385,7 @@
         vNode.setPropertyValues(JCR_PREDECESSORS, PropertyType.STRING, predecessors);
 
         // checkin source node
-        InternalFrozenNodeImpl.checkin(vNode, JCR_FROZENNODE, src, InternalFrozenNodeImpl.MODE_VERSION);
+        InternalFrozenNodeImpl.checkin(vNode, JCR_FROZENNODE, src);
 
         // and store
         node.store();
@@ -456,14 +458,14 @@
      * @throws RepositoryException
      */
     protected static InternalVersionHistoryImpl create(PersistentVersionManager vMgr, PersistentNode
parent,
-                                                       String historyId, QName name, NodeImpl
src)
+                                                       String historyId, QName name, NodeState
nodeState)
             throws RepositoryException {
 
         // create history node
         PersistentNode pNode = parent.addNode(name, NativePVM.NT_REP_VERSION_HISTORY, historyId);
 
         // set the versionable uuid
-        pNode.setPropertyValue(NativePVM.PROPNAME_VERSIONABLE_ID, InternalValue.create(src.internalGetUUID()));
+        pNode.setPropertyValue(NativePVM.PROPNAME_VERSIONABLE_ID, InternalValue.create(nodeState.getUUID()));
 
         // create label node
         pNode.addNode(NativePVM.NODENAME_VERSION_LABELS, NativePVM.NT_REP_VERSION_LABELS,
null);
@@ -478,7 +480,22 @@
         vNode.setPropertyValues(JCR_PREDECESSORS, PropertyType.REFERENCE, InternalValue.EMPTY_ARRAY);
 
         // add also an empty frozen node to the root version
-        InternalFrozenNodeImpl.checkin(vNode, JCR_FROZENNODE, src, InternalFrozenNodeImpl.MODE_INIT);
+        PersistentNode node = vNode.addNode(JCR_FROZENNODE, NativePVM.NT_REP_FROZEN, null);
+
+        // initialize the internal properties
+        node.setPropertyValue(JCR_FROZENUUID, InternalValue.create(nodeState.getUUID()));
+        node.setPropertyValue(JCR_FROZENPRIMARYTYPE,
+                InternalValue.create(nodeState.getNodeTypeName()));
+
+        Set mixins = nodeState.getMixinTypeNames();
+        if (mixins.size()>0) {
+            InternalValue[] ivalues = new InternalValue[mixins.size()];
+            Iterator iter=mixins.iterator();
+            for (int i = 0; i < mixins.size(); i++) {
+                ivalues[i] = InternalValue.create((QName) iter.next());
+            }
+            node.setPropertyValues(JCR_FROZENMIXINTYPES, PropertyType.NAME, ivalues);
+        }
 
         parent.store();
         return new InternalVersionHistoryImpl(vMgr, pNode);

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativePVM.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativePVM.java?rev=165408&r1=165407&r2=165408&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativePVM.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativePVM.java
Sat Apr 30 08:22:48 2005
@@ -227,11 +227,11 @@
      * @return the newly created version history.
      * @throws RepositoryException
      */
-    public InternalVersionHistory createVersionHistory(NodeImpl node)
+    public InternalVersionHistory createVersionHistory(NodeState node)
             throws RepositoryException {
 
         // check if version history for that node already exists
-        InternalVersionHistoryImpl hist = getHistoryByVersionableUUID(node.internalGetUUID());
+        InternalVersionHistoryImpl hist = getHistoryByVersionableUUID(node.getUUID());
         if (hist != null) {
             return hist;
         }
@@ -272,7 +272,7 @@
         versionedUUIDs.put(hist.getVersionableUUID(), hist.getId());
 
         log.info("Created new version history " + hist.getId()
-                + " for " + node.safeGetJCRPath()
+                + " for " + node
                 + ". NumHistories=" + versionedUUIDs.size());
         return hist;
     }

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=165408&r1=165407&r2=165408&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
Sat Apr 30 08:22:48 2005
@@ -48,6 +48,7 @@
 import javax.jcr.lock.LockException;
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.version.VersionException;
+import javax.jcr.version.VersionHistory;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -267,9 +268,8 @@
         if (ent.includesNodeType(MIX_VERSIONABLE)) {
             PropDef def;
             PropertyState prop;
-
-            // @todo FIXME initialize version history
-            String dummyUUID = "00000000-0000-0000-0000-000000000000";
+            SessionImpl session = (SessionImpl) wsp.getSession();
+            VersionHistory hist = session.getVersionManager().createVersionHistory(session,
node);
 
             // jcr:versionHistory
             if (!node.hasPropertyEntry(JCR_VERSIONHISTORY)) {
@@ -277,7 +277,7 @@
                         PropertyType.REFERENCE, false, node);
                 prop = itemOps.createPropertyState(node, JCR_VERSIONHISTORY,
                         PropertyType.REFERENCE, def);
-                prop.setValues(new InternalValue[]{InternalValue.create(new UUID(dummyUUID))});
+                prop.setValues(new InternalValue[]{InternalValue.create(new UUID(hist.getUUID()))});
             }
 
             // jcr:baseVersion
@@ -286,7 +286,7 @@
                         PropertyType.REFERENCE, false, node);
                 prop = itemOps.createPropertyState(node, JCR_BASEVERSION,
                         PropertyType.REFERENCE, def);
-                prop.setValues(new InternalValue[]{InternalValue.create(new UUID(dummyUUID))});
+                prop.setValues(new InternalValue[]{InternalValue.create(new UUID(hist.getRootVersion().getUUID()))});
             }
 
             // jcr:predecessors
@@ -295,7 +295,7 @@
                         PropertyType.REFERENCE, true, node);
                 prop = itemOps.createPropertyState(node, JCR_PREDECESSORS,
                         PropertyType.REFERENCE, def);
-                prop.setValues(new InternalValue[]{InternalValue.create(new UUID(dummyUUID))});
+                prop.setValues(new InternalValue[]{InternalValue.create(new UUID(hist.getRootVersion().getUUID()))});
             }
 
             // jcr:isCheckedOut



Mime
View raw message