jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r431887 [2/2] - in /jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: ./ lock/ operation/ state/ version/ xml/
Date Wed, 16 Aug 2006 12:24:32 GMT
Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java?rev=431887&r1=431886&r2=431887&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java Wed Aug 16 05:24:30 2006
@@ -132,8 +132,8 @@
      *                      instance.
      */
     protected NodeState(QName name, String uuid, NodeState parent,
-                     QName nodeTypeName, int initialStatus, boolean isTransient,
-                     ItemStateFactory isf, IdFactory idFactory) {
+                        QName nodeTypeName, int initialStatus, boolean isTransient,
+                        ItemStateFactory isf, IdFactory idFactory) {
         super(parent, initialStatus, isTransient, idFactory);
         this.name = name;
         this.uuid = uuid;
@@ -154,8 +154,8 @@
      *                       instance.
      */
     protected NodeState(NodeState overlayedState, NodeState parent,
-                     int initialStatus, boolean isTransient,
-                     ItemStateFactory isf, IdFactory idFactory) {
+                        int initialStatus, boolean isTransient,
+                        ItemStateFactory isf, IdFactory idFactory) {
         super(overlayedState, parent, initialStatus, isTransient, idFactory);
         pull();
         this.isf = isf;
@@ -224,8 +224,7 @@
      * state should be 'free floating', i.e. detached from the repository's
      * hierarchy.
      */
-    // TODO: change to private and only let new parent node state set the parent.
-    void setParent(NodeState parent) {
+    private void setParent(NodeState parent) {
         this.parent = parent;
     }
 
@@ -431,7 +430,6 @@
      * @return the <code>ChildNodeEntry</code> with the specified <code>NodeId</code> or
      *         <code>null</code> if there's no matching entry.
      * @see #addChildNodeEntry
-     * @see #removeChildNodeEntry
      */
     public synchronized ChildNodeEntry getChildNodeEntry(NodeId id) {
         return childNodeEntries.get(id);
@@ -443,7 +441,6 @@
      *
      * @return collection of <code>ChildNodeEntry</code> objects
      * @see #addChildNodeEntry
-     * @see #removeChildNodeEntry
      */
     public synchronized Collection getChildNodeEntries() {
         // NOTE: List representation of 'ChildNodeEntries' is already unmodifiable
@@ -457,7 +454,6 @@
      * @param nodeName name of the child node entries that should be returned
      * @return list of <code>ChildNodeEntry</code> objects
      * @see #addChildNodeEntry
-     * @see #removeChildNodeEntry
      */
     public synchronized List getChildNodeEntries(QName nodeName) {
         // NOTE: SubList retrieved from 'ChildNodeEntries' is already unmodifiable
@@ -471,8 +467,7 @@
      * @param id the id the new entry is refering to.
      * @return the newly added <code>ChildNodeEntry</code>
      */
-    synchronized ChildNodeEntry addChildNodeEntry(QName nodeName,
-                                                  NodeId id) {
+    synchronized ChildNodeEntry addChildNodeEntry(QName nodeName, NodeId id) {
         ChildNodeEntry entry = childNodeEntries.add(nodeName, id);
         notifyNodeAdded(entry);
         return entry;
@@ -504,72 +499,13 @@
     }
 
     /**
-     * Renames a new <code>ChildNodeEntry</code>.
-     *
-     * @param oldName <code>QName</code> object specifying the entry's old name
-     * @param index 1-based index if there are same-name child node entries
-     * @param newName <code>QName</code> object specifying the entry's new name
-     * @return <code>true</code> if the entry was sucessfully renamed;
-     *         otherwise <code>false</code>
-     */
-    synchronized boolean renameChildNodeEntry(QName oldName, int index,
-                                                     QName newName) {
-        ChildNodeEntry oldEntry = childNodeEntries.remove(oldName, index);
-        if (oldEntry != null) {
-            ChildNodeEntry newEntry = childNodeEntries.add(newName, oldEntry.getId());
-            notifyNodeAdded(newEntry);
-            notifyNodeRemoved(oldEntry);
-            return true;
-        }
-        return false;
-    }
-
-    /**
-     * Removes a <code>ChildNodeEntry</code>.
-     *
-     * @param nodeName <code>ChildNodeEntry</code> object specifying a node name
-     * @param index    1-based index if there are same-name child node entries
-     * @return <code>true</code> if the specified child node entry was found
-     *         in the list of child node entries and could be removed.
-     */
-    synchronized boolean removeChildNodeEntry(QName nodeName, int index) {
-        ChildNodeEntry entry = childNodeEntries.remove(nodeName, index);
-        if (entry != null) {
-            notifyNodeRemoved(entry);
-        }
-        return entry != null;
-    }
-
-    /**
-     * Removes a <code>ChildNodeEntry</code>.
-     *
-     * @param id the id of the entry to be removed
-     * @return <code>true</code> if the specified child node entry was found
-     *         in the list of child node entries and could be removed.
-     */
-    synchronized boolean removeChildNodeEntry(NodeId id) {
-        ChildNodeEntry entry = childNodeEntries.remove(id);
-        if (entry != null) {
-            notifyNodeRemoved(entry);
-        }
-        return entry != null;
-    }
-
-    /**
-     * Removes all <code>ChildNodeEntry</code>s.
-     */
-    synchronized void removeAllChildNodeEntries() {
-        childNodeEntries.removeAll();
-    }
-
-    /**
      * Notifies this node state that a child node state has been removed.
      *
      * @param nodeState the node state that has been removed.
      * @throws IllegalArgumentException if <code>this</code> is not the parent
      *                                  of <code>nodeState</code>.
      */
-    synchronized void childNodeStateRemoved(NodeState nodeState) {
+    private synchronized void childNodeStateRemoved(NodeState nodeState) {
         if (nodeState.getParent() != this) {
             throw new IllegalArgumentException("This NodeState is not the parent of nodeState");
         }
@@ -593,21 +529,6 @@
     }
 
     /**
-     * Sets the list of <code>ChildNodeEntry</code> objects denoting the
-     * child nodes of this node.
-     */
-    synchronized void setChildNodeEntries(List nodeEntries) {
-        // re-create child node entries
-        childNodeEntries.clear(); // TODO: any mre cleanup work to do? try some kind of merging?
-        for (Iterator it = nodeEntries.iterator(); it.hasNext(); ) {
-            ChildNodeEntry cne = (ChildNodeEntry) it.next();
-            childNodeEntries.add(cne.getName(), cne.getId());
-        }
-        notifyNodesReplaced();
-    }
-
-    /**
-
     /**
      * @inheritDoc
      * @see ItemState#remove()
@@ -661,7 +582,6 @@
      *
      * @return set of <code>QNames</code> objects
      * @see #addPropertyName
-     * @see #removePropertyName
      */
     public synchronized Collection getPropertyNames() {
         return Collections.unmodifiableSet(properties.keySet());
@@ -672,7 +592,6 @@
      *
      * @return unmodifiable collection of <code>ChildPropertyEntry</code> objects
      * @see #addPropertyName
-     * @see #removePropertyName
      */
     public synchronized Collection getPropertyEntries() {
         return Collections.unmodifiableCollection(properties.values());
@@ -712,17 +631,6 @@
     }
 
     /**
-     * Removes a property name entry.
-     *
-     * @param propName <code>QName</code> object specifying the property name
-     * @return <code>true</code> if the specified property name was found
-     *         in the list of property name entries and could be removed.
-     */
-    synchronized boolean removePropertyName(QName propName) {
-        return properties.remove(propName) != null;
-    }
-
-    /**
      * Notifies this node state that a property state has been removed.
      *
      * @param propState the property state that has been removed.
@@ -741,25 +649,7 @@
         markModified();
     }
 
-    /**
-     * Removes all property name entries.
-     */
-    synchronized void removeAllPropertyNames() {
-        properties.clear();
-    }
-
-    /**
-     * Sets the set of <code>QName</code> objects denoting the
-     * properties of this node.
-     */
-    synchronized void setPropertyNames(Set propNames) {
-        removeAllPropertyNames();
-        for (Iterator it = propNames.iterator(); it.hasNext(); ) {
-            addPropertyName((QName) it.next());
-        }
-    }
-
-    /**
+    /*
      * Returns the property state with the given name.
      *
      * @param propertyName the name of the property state to return.
@@ -868,6 +758,113 @@
     }
 
     /**
+     *
+     * @param insertNodeId
+     * @param beforeNodeId
+     */
+    synchronized void reorderChildNodeEntries(NodeId insertNodeId, NodeId beforeNodeId)
+        throws NoSuchItemStateException {
+        // validate existance of child node entries even if this has been
+        // checked within NodeImpl.
+        if (childNodeEntries.get(insertNodeId) == null) {
+            throw new NoSuchItemStateException("No such child node entry: " + insertNodeId);
+        }
+        if (beforeNodeId != null && childNodeEntries.get(insertNodeId) == null) {
+            throw new NoSuchItemStateException("No such child node entry: " + beforeNodeId);
+        }
+
+        // TODO: check again. Reorder with SPI-Id
+        ArrayList nodeEntries = new ArrayList(childNodeEntries);
+        int srcInd = -1, destInd = -1;
+        for (int i = 0; i < nodeEntries.size(); i++) {
+            ChildNodeEntry entry = (ChildNodeEntry) nodeEntries.get(i);
+            if (srcInd == -1) {
+                if (entry.getId().equals(insertNodeId)) {
+                    srcInd = i;
+                }
+            }
+            if (destInd == -1 && beforeNodeId != null) {
+                if (entry.getId().equals(beforeNodeId)) {
+                    destInd = i;
+                    if (srcInd != -1) {
+                        break;
+                    }
+                }
+            } else {
+                if (srcInd != -1) {
+                    break;
+                }
+            }
+        }
+
+        // check if resulting order would be different to current order
+        if (destInd == -1) {
+            if (srcInd == nodeEntries.size() - 1) {
+                // no change, we're done
+                return;
+            }
+        } else {
+            if ((destInd - srcInd) == Path.INDEX_DEFAULT) {
+                // no change, we're done
+                return;
+            }
+        }
+        // reorder list
+        if (destInd == -1) {
+            nodeEntries.add(nodeEntries.remove(srcInd));
+        } else {
+            if (srcInd < destInd) {
+                nodeEntries.add(destInd, nodeEntries.get(srcInd));
+                nodeEntries.remove(srcInd);
+            } else {
+                nodeEntries.add(destInd, nodeEntries.remove(srcInd));
+            }
+        }
+
+        // re-create child node entries
+        childNodeEntries.clear(); // TODO: any mre cleanup work to do? try some kind of merging?
+        for (Iterator it = nodeEntries.iterator(); it.hasNext(); ) {
+            ChildNodeEntry cne = (ChildNodeEntry) it.next();
+            childNodeEntries.add(cne.getName(), cne.getId());
+        }
+        // TODO: correct?
+        notifyNodesReplaced();
+    }
+
+    /**
+     * Renames a new <code>ChildNodeEntry</code>.
+     *
+     * @param newParent
+     * @param childState
+     * @param newName
+     * @param newName <code>QName</code> object specifying the entry's new name
+     * @throws RepositoryException if the given child state is not a child
+     * of this node state.
+     */
+    // TODO: review. move with SPI Ids
+    synchronized void moveChildNodeEntry(NodeState newParent, NodeState childState, QName newName)
+        throws RepositoryException {
+        NodeId childId = childState.getNodeId();
+        // rename only
+        ChildNodeEntry oldEntry = childNodeEntries.remove(childId);
+        if (oldEntry != null) {
+            if (newParent == this) {
+                ChildNodeEntry newEntry = childNodeEntries.add(name, oldEntry.getId());
+                notifyNodeAdded(newEntry);
+                notifyNodeRemoved(oldEntry);
+            } else {
+                notifyNodeRemoved(oldEntry);
+                // re-parent target node
+                childState.setParent(newParent);
+                // add child node entry to new parent
+                newParent.addChildNodeEntry(newName, childId);
+            }
+        } else {
+            throw new RepositoryException("Unexpected error: Child state to be renamed does not exist.");
+        }
+    }
+    
+    /**
      * TODO: find a better way to provide the index of a child node entry
      * Returns the index of the given <code>ChildNodeEntry</code> and with
      * <code>name</code>.
@@ -923,7 +920,7 @@
     /**
      * Notify the listeners that a child node entry has been added
      */
-    protected void notifyNodeAdded(ChildNodeEntry added) {
+    private void notifyNodeAdded(ChildNodeEntry added) {
         synchronized (listeners) {
             Iterator iter = listeners.iterator();
             while (iter.hasNext()) {
@@ -938,7 +935,7 @@
     /**
      * Notify the listeners that the child node entries have been replaced
      */
-    protected void notifyNodesReplaced() {
+    private void notifyNodesReplaced() {
         synchronized (listeners) {
             Iterator iter = listeners.iterator();
             while (iter.hasNext()) {
@@ -953,7 +950,7 @@
     /**
      * Notify the listeners that a child node entry has been removed
      */
-    protected void notifyNodeRemoved(ChildNodeEntry removed) {
+    private void notifyNodeRemoved(ChildNodeEntry removed) {
         synchronized (listeners) {
             Iterator iter = listeners.iterator();
             while (iter.hasNext()) {

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java?rev=431887&r1=431886&r2=431887&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java Wed Aug 16 05:24:30 2006
@@ -53,7 +53,6 @@
 import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.spi.NodeId;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
-import org.apache.jackrabbit.name.Path;
 import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.ItemId;
 import org.apache.jackrabbit.spi.IdFactory;
@@ -338,6 +337,10 @@
         // check status of current item's state
         if (itemState.isTransient()) {
             switch (itemState.getStatus()) {
+                // safety... should have been checked befoe
+                case ItemState.STATUS_NEW:
+                    throw new ItemStateException("Unexpected state: cannot start undo from a new item state.");
+
                 case ItemState.STATUS_STALE_MODIFIED:
                 case ItemState.STATUS_STALE_DESTROYED:
                 case ItemState.STATUS_EXISTING_MODIFIED:
@@ -385,12 +388,12 @@
          * build set of item id's which are within the scope of
          * (i.e. affected by) this cancel operation
          */
-        Set affectedIds = new HashSet();
+        Set affectedStates = new HashSet();
         Iterator it = new IteratorChain(changeLog.modifiedStates(), changeLog.deletedStates());
         while (it.hasNext()) {
-            affectedIds.add(((ItemState) it.next()).getId());
+            affectedStates.add(((ItemState) it.next()));
         }
-        collectOperations(affectedIds, changeLog);
+        collectOperations(affectedStates, changeLog);
 
         // process list of 'new', 'modified' or 'stale' transient states
         Iterator transIter = changeLog.modifiedStates();
@@ -627,6 +630,7 @@
      * @throws ItemStateException
      */
     private ChangeLog getChangeLog(ItemState itemState) throws StaleItemStateException, ItemStateException {
+
         ChangeLog changeLog = new ChangeLog();
         if (itemState.getParent() == null) {
             // root state -> get all item states
@@ -652,13 +656,13 @@
              * (i.e. affected by) this save operation
              */
             Iterator it = new IteratorChain(changeLog.modifiedStates(), changeLog.deletedStates());
-            Set affectedIds = new HashSet();
+            Set affectedStates = new HashSet();
             while (it.hasNext()) {
-                affectedIds.add(((ItemState) it.next()).getId());
+                affectedStates.add((ItemState) it.next());
             }
 
-            checkIsSelfContained(affectedIds, changeLog);
-            collectOperations(affectedIds, changeLog);
+            checkIsSelfContained(affectedStates, changeLog);
+            collectOperations(affectedStates, changeLog);
         }
         return changeLog;
     }
@@ -799,19 +803,19 @@
 
     /**
      * Retuns a list of operations that are in the scope the the change set
-     * defined by the affected <code>itemIds</code>.
+     * defined by the affected <code>ItemState</code>s.
      *
-     * @param affectedIds
+     * @param affectedStates
      * @param changeLog
      */
-    private void collectOperations(Set affectedIds, ChangeLog changeLog) {
+    private void collectOperations(Set affectedStates, ChangeLog changeLog) {
         Iterator opsIter = transientStateMgr.getOperations();
         while (opsIter.hasNext()) {
             Operation op = (Operation) opsIter.next();
-            Iterator ids = op.getAffectedItemIds().iterator();
-            while (ids.hasNext()) {
-                ItemId id = (ItemId) ids.next();
-                if (affectedIds.contains(id)) {
+            Iterator states = op.getAffectedItemStates().iterator();
+            while (states.hasNext()) {
+                ItemState state = (ItemState) states.next();
+                if (affectedStates.contains(state)) {
                     changeLog.addOperation(op);
                     break;
                 }
@@ -826,31 +830,30 @@
      * (e.g. moving a node requires that the target node including both
      * old and new parents are saved)
      *
-     * @param affectedIds
+     * @param affectedStates
      * @param changeLog
      */
-    private void checkIsSelfContained(Set affectedIds, ChangeLog changeLog) throws ItemStateException {
+    private void checkIsSelfContained(Set affectedStates, ChangeLog changeLog) throws ItemStateException {
         Iterator it = new IteratorChain(changeLog.modifiedStates(), changeLog.deletedStates());
         while (it.hasNext()) {
             ItemState transientState = (ItemState) it.next();
             if (transientState.isNode()) {
                 NodeState nodeState = (NodeState) transientState;
-                Set dependentIDs = new HashSet();
+                Set dependentStates = new HashSet();
                 if (nodeState.hasOverlayedState()) {
-                    // TODO: review usage of NodeId
-                    NodeId oldParentId = nodeState.getOverlayedState().getParent().getNodeId();
-                    NodeId newParentId = nodeState.getParent().getNodeId();
-                    if (oldParentId != null) {
-                        if (newParentId == null) {
+                    NodeState oldParentState = nodeState.getOverlayedState().getParent();
+                    NodeState newParentState = nodeState.getParent();
+                    if (oldParentState != null) {
+                        if (newParentState == null) {
                             // node has been removed, add old parent
                             // to dependencies
-                            dependentIDs.add(oldParentId);
+                            dependentStates.add(oldParentState);
                         } else {
-                            if (!oldParentId.equals(newParentId)) {
+                            if (!oldParentState.equals(newParentState)) {
                                 // node has been moved, add old and new parent
                                 // to dependencies
-                                dependentIDs.add(oldParentId);
-                                dependentIDs.add(newParentId);
+                                dependentStates.add(oldParentState);
+                                dependentStates.add(newParentState);
                             }
                         }
                     }
@@ -859,24 +862,23 @@
                 Iterator cneIt = nodeState.getRemovedChildNodeEntries().iterator();
                 while (cneIt.hasNext()) {
                     ChildNodeEntry cne = (ChildNodeEntry) cneIt.next();
-                    dependentIDs.add(cne.getId());
+                    dependentStates.add(cne.getNodeState());
                 }
                 // added child node entries
                 cneIt = nodeState.getAddedChildNodeEntries().iterator();
                 while (cneIt.hasNext()) {
                     ChildNodeEntry cne = (ChildNodeEntry) cneIt.next();
-                    dependentIDs.add(cne.getId());
+                    dependentStates.add(cne.getNodeState());
                 }
 
                 // now walk through dependencies and check whether they
                 // are within the scope of this save operation
-                Iterator depIt = dependentIDs.iterator();
+                Iterator depIt = dependentStates.iterator();
                 while (depIt.hasNext()) {
-                    NodeId id = (NodeId) depIt.next();
-                    if (!affectedIds.contains(id)) {
+                    NodeState dependantState = (NodeState) depIt.next();
+                    if (!affectedStates.contains(dependantState)) {
                         // need to save the parent as well
-                        // TODO convert id to human-readable id
-                        String msg = id.toString() + " needs to be saved as well.";
+                        String msg = LogUtil.safeGetJCRPath(dependantState, nsResolver, hierMgr) + " needs to be saved as well.";
                         log.debug(msg);
                         throw new ItemStateException(msg);
                     }
@@ -893,7 +895,7 @@
         int options = ItemStateValidator.CHECK_LOCK | ItemStateValidator.CHECK_COLLISION
             | ItemStateValidator.CHECK_VERSIONING | ItemStateValidator.CHECK_CONSTRAINTS;
 
-        NodeState parent = getNodeState(operation.getParentId());
+        NodeState parent = operation.getParentState();
         QNodeDefinition def = validator.getApplicableNodeDefinition(operation.getNodeName(), operation.getNodeTypeName(), parent);
         addNodeState(parent, operation.getNodeName(), operation.getNodeTypeName(), operation.getUuid(), def, options);
 
@@ -904,7 +906,7 @@
      * @inheritDoc
      */
     public void visit(AddProperty operation) throws ValueFormatException, LockException, ConstraintViolationException, AccessDeniedException, ItemExistsException, UnsupportedRepositoryOperationException, VersionException, RepositoryException {
-        NodeState parent = getNodeState(operation.getParentId());
+        NodeState parent = operation.getParentState();
         QName propertyName = operation.getPropertyName();
         QPropertyDefinition pDef = validator.getApplicablePropertyDefinition(propertyName, operation.getPropertyType(), operation.isMultiValued(), parent);
         int targetType = pDef.getRequiredType();
@@ -943,10 +945,10 @@
     public void visit(Move operation) throws LockException, ConstraintViolationException, AccessDeniedException, ItemExistsException, UnsupportedRepositoryOperationException, VersionException, RepositoryException {
 
         // retrieve states and assert they are modifiable
-        NodeState srcState = getNodeState(operation.getNodeId());
-        NodeState srcParent = getNodeState(operation.getSourceParentId());
+        NodeState srcState = operation.getNodeState();
+        NodeState srcParent = operation.getSourceParentState();
 
-        NodeState destParent = getNodeState(operation.getDestinationParentId());
+        NodeState destParent = operation.getDestinationParentState();
 
         // state validation: move-Source can be removed from old/added to new parent
         validator.checkRemoveItem(srcState,
@@ -965,27 +967,7 @@
         QNodeDefinition newDefinition = validator.getApplicableNodeDefinition(operation.getDestinationName(), srcState.getNodeTypeName(), destParent);
 
         // perform the move (modifying states)
-        // TODO: TO-BE-FIXED. Move with SPI id
-        boolean renameOnly = srcParent.getNodeId().equals(destParent.getNodeId());
-        ChildNodeEntry cne = srcParent.getChildNodeEntry(srcState.getNodeId());
-        if (cne == null) {
-            String msg = "Unexpected error: Move source " + LogUtil.safeGetJCRPath(srcParent, nsResolver, hierMgr) + " does not contain a child node entry with the given id" + LogUtil.safeGetJCRPath(srcState, nsResolver, hierMgr);
-            log.error(msg);
-            throw new RepositoryException(msg);
-        }
-        QName srcName = cne.getName();
-        int srcIndex = cne.getIndex();
-        if (renameOnly) {
-            // change child node entry
-            destParent.renameChildNodeEntry(srcName, srcIndex, operation.getDestinationName());
-        } else {
-            // remove child node entry from old parent
-            srcParent.removeChildNodeEntry(srcName, srcIndex);
-            // re-parent target node
-            srcState.setParent(destParent);
-            // add child node entry to new parent
-            destParent.addChildNodeEntry(operation.getDestinationName(), srcState.getNodeId());
-        }
+        srcParent.moveChildNodeEntry(destParent, srcState, operation.getDestinationName());
 
         // change definition of target node
         srcState.setDefinition(newDefinition);
@@ -1002,19 +984,13 @@
      * @inheritDoc
      */
     public void visit(Remove operation) throws ConstraintViolationException, AccessDeniedException, UnsupportedRepositoryOperationException, VersionException, RepositoryException {
-        try {
-            ItemState state = getItemState(operation.getRemoveId());
-            int options = ItemStateValidator.CHECK_LOCK
-                | ItemStateValidator.CHECK_VERSIONING
-                | ItemStateValidator.CHECK_CONSTRAINTS;
-            removeItemState(state, options);
-            // remember operation
-            transientStateMgr.addOperation(operation);
-        } catch (NoSuchItemStateException e) {
-            throw new PathNotFoundException(e);
-        } catch (ItemStateException e) {
-            throw new RepositoryException(e);
-        }
+        ItemState state = operation.getRemoveState();
+        int options = ItemStateValidator.CHECK_LOCK
+            | ItemStateValidator.CHECK_VERSIONING
+            | ItemStateValidator.CHECK_CONSTRAINTS;
+        removeItemState(state, options);
+        // remember operation
+        transientStateMgr.addOperation(operation);
     }
 
     /**
@@ -1025,7 +1001,7 @@
         boolean anyRemoved;
 
         QName[] mixinNames = operation.getMixinNames();
-        NodeState nState = getNodeState(operation.getNodeId());
+        NodeState nState = operation.getNodeState();
 
         // mixin-names to be execute on the nodestate (and corresponding property state)
         if (mixinNames != null && mixinNames.length > 0) {
@@ -1127,83 +1103,23 @@
      * @inheritDoc
      */
     public void visit(SetPropertyValue operation) throws ValueFormatException, LockException, ConstraintViolationException, AccessDeniedException, ItemExistsException, UnsupportedRepositoryOperationException, VersionException, RepositoryException {
-        try {
-            PropertyState pState = (PropertyState) getItemState(operation.getPropertyId());
-            setPropertyStateValue(pState, operation.getValues(), operation.getPropertyType());
-            transientStateMgr.addOperation(operation);
-        } catch (NoSuchItemStateException nsise) {
-            // TODO convert id to human-readable id
-            throw new ItemNotFoundException(operation.getPropertyId().toString());
-        } catch (ItemStateException ise) {
-            // TODO convert id to human-readable id
-            String msg = "internal error: failed to retrieve state of " + operation.getPropertyId().toString();
-            log.debug(msg);
-            throw new RepositoryException(msg, ise);
-        }
+        PropertyState pState = operation.getPropertyState();
+        setPropertyStateValue(pState, operation.getValues(), operation.getPropertyType());
+        transientStateMgr.addOperation(operation);
     }
 
     /**
      * @inheritDoc
      */
     public void visit(ReorderNodes operation) throws ConstraintViolationException, AccessDeniedException, UnsupportedRepositoryOperationException, VersionException, RepositoryException {
-        NodeState parent = getNodeState(operation.getParentId());
-
-        NodeId srcId = operation.getInsertNodeId();
-        NodeId beforeId = operation.getBeforeNodeId();
-
-        // TODO: TO-BE-FIXED. Reorder with SPI-Id -> instable ids
-        ArrayList list = new ArrayList(parent.getChildNodeEntries());
-        int srcInd = -1, destInd = -1;
-        for (int i = 0; i < list.size(); i++) {
-            ChildNodeEntry entry = (ChildNodeEntry) list.get(i);
-            if (srcInd == -1) {
-                if (entry.getId().equals(srcId)) {
-                    srcInd = i;
-                }
-            }
-            if (destInd == -1 && beforeId != null) {
-                if (entry.getId().equals(beforeId)) {
-                    destInd = i;
-                    if (srcInd != -1) {
-                        break;
-                    }
-                }
-            } else {
-                if (srcInd != -1) {
-                    break;
-                }
-            }
-        }
-
-        // check if resulting order would be different to current order
-        if (destInd == -1) {
-            if (srcInd == list.size() - 1) {
-                // no change, we're done
-                return;
-            }
-        } else {
-            if ((destInd - srcInd) == Path.INDEX_DEFAULT) {
-                // no change, we're done
-                return;
-            }
-        }
-        // reorder list
-        if (destInd == -1) {
-            list.add(list.remove(srcInd));
-        } else {
-            if (srcInd < destInd) {
-                list.add(destInd, list.get(srcInd));
-                list.remove(srcInd);
-            } else {
-                list.add(destInd, list.remove(srcInd));
-            }
+        NodeState parent = operation.getParentState();
+        // modify the parent node state
+        try {
+            parent.reorderChildNodeEntries(operation.getInsertNodeId(), operation.getBeforeNodeId());
+        } catch (NoSuchItemStateException e) {
+            // invalid reorder-ids
+            throw new ItemNotFoundException(e);
         }
-
-        // modify the the parent node state ...
-        // TODO: do not set whole list but rather implement a proper reorder on NodeState!
-        // TODO: then remove NodeState.setChildNodeEntries()
-        parent.setChildNodeEntries(list);
-
         // remember the operation
         transientStateMgr.addOperation(operation);
     }
@@ -1458,29 +1374,5 @@
             }
         }
         return genValues;
-    }
-
-
-    /**
-     * Retrieves the state of the item with the specified id using the given
-     * item state manager.
-     * <p/>
-     * Note that access rights are <b><i>not</i></b> enforced!
-     *
-     * @param id
-     * @return
-     * @throws ItemNotFoundException
-     * @throws RepositoryException
-     */
-    private NodeState getNodeState(NodeId id) throws ItemNotFoundException, RepositoryException {
-        try {
-            return (NodeState) getItemState(id);
-        } catch (NoSuchItemStateException e) {
-            throw new ItemNotFoundException(id.toString());
-        } catch (ItemStateException e) {
-            String msg = "internal error: failed to retrieve state of " + id.toString();
-            log.debug(msg);
-            throw new RepositoryException(msg, e);
-        }
     }
 }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/DefaultVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/DefaultVersionManager.java?rev=431887&r1=431886&r2=431887&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/DefaultVersionManager.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/DefaultVersionManager.java Wed Aug 16 05:24:30 2006
@@ -47,15 +47,15 @@
         return true;
     }
 
-    public void removeVersion(NodeId versionHistoryId, NodeId versionId) throws RepositoryException {
+    public void removeVersion(NodeState versionHistoryState, NodeState versionState) throws RepositoryException {
         throw new UnsupportedRepositoryOperationException("Versioning ist not supported by this repository.");
     }
 
-    public void addVersionLabel(NodeId versionHistoryId, NodeId versionId, QName qLabel, boolean moveLabel) throws RepositoryException {
+    public void addVersionLabel(NodeState versionHistoryState, NodeState versionState, QName qLabel, boolean moveLabel) throws RepositoryException {
         throw new UnsupportedRepositoryOperationException("Versioning ist not supported by this repository.");
     }
 
-    public void removeVersionLabel(NodeId versionHistoryId, NodeId versionId, QName qLabel) throws RepositoryException {
+    public void removeVersionLabel(NodeState versionHistoryState, NodeState versionState, QName qLabel) throws RepositoryException {
         throw new UnsupportedRepositoryOperationException("Versioning ist not supported by this repository.");
     }
 
@@ -67,11 +67,11 @@
         throw new UnsupportedRepositoryOperationException("Versioning ist not supported by this repository.");
     }
 
-    public Collection merge(NodeId nodeId, String workspaceName, boolean bestEffort) throws RepositoryException {
+    public Collection merge(NodeState nodeState, String workspaceName, boolean bestEffort) throws RepositoryException {
         throw new UnsupportedRepositoryOperationException("Versioning ist not supported by this repository.");
     }
 
-    public void resolveMergeConflict(NodeId nodeId, NodeId versionId, boolean done) throws RepositoryException {
+    public void resolveMergeConflict(NodeState nodeState, NodeState versionState, boolean done) throws RepositoryException {
         throw new UnsupportedRepositoryOperationException("Versioning ist not supported by this repository.");
     }
 }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java?rev=431887&r1=431886&r2=431887&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java Wed Aug 16 05:24:30 2006
@@ -30,7 +30,6 @@
 import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.name.NameException;
 import org.apache.jackrabbit.name.NoPrefixDeclaredException;
-import org.apache.jackrabbit.spi.NodeId;
 import org.apache.jackrabbit.name.Path;
 import org.apache.jackrabbit.name.NameFormat;
 
@@ -148,13 +147,8 @@
      * @see VersionHistory#getVersion(String)
      */
     public Version getVersion(String versionName) throws VersionException, RepositoryException {
-        try {
-            NodeState vState = getVersionEntry(versionName).getNodeState();
-            return (Version) itemMgr.getItem(vState);
-        } catch (ItemStateException e) {
-            // should not occur
-            throw new RepositoryException(e);
-        }
+        NodeState vState = getVersionState(versionName);
+        return (Version) itemMgr.getItem(vState);
     }
 
     /**
@@ -165,13 +159,8 @@
      * @see VersionHistory#getVersionByLabel(String)
      */
     public Version getVersionByLabel(String label) throws RepositoryException {
-        ChildNodeEntry vEntry = getVersionEntryByLabel(getQLabel(label));
-        try {
-            return (Version) itemMgr.getItem(vEntry.getNodeState());
-        } catch (ItemStateException e) {
-            // should not occur
-            throw new RepositoryException(e);
-        }
+        NodeState vState = getVersionStateByLabel(getQLabel(label));
+        return (Version) itemMgr.getItem(vState);
     }
 
     /**
@@ -185,9 +174,9 @@
      */
     public void addVersionLabel(String versionName, String label, boolean moveLabel) throws VersionException, RepositoryException {
         QName qLabel = getQLabel(label);
-        ChildNodeEntry vEntry = getVersionEntry(versionName);
+        NodeState vState = getVersionState(versionName);
         // delegate to version manager that operates on workspace directely
-        session.getVersionManager().addVersionLabel(getNodeId(), vEntry.getId(), qLabel, moveLabel);
+        session.getVersionManager().addVersionLabel(vhState, vState, qLabel, moveLabel);
     }
 
     /**
@@ -199,10 +188,9 @@
      */
     public void removeVersionLabel(String label) throws VersionException, RepositoryException {
         QName qLabel = getQLabel(label);
-        ChildNodeEntry vEntry = getVersionEntryByLabel(getQLabel(label));
-
+        NodeState vState = getVersionStateByLabel(getQLabel(label));
         // delegate to version manager that operates on workspace directely
-        session.getVersionManager().removeVersionLabel(getNodeId(), vEntry.getId(), qLabel);
+        session.getVersionManager().removeVersionLabel(vhState, vState, qLabel);
     }
 
     /**
@@ -240,8 +228,8 @@
         QName[] qLabels = getQLabels();
         for (int i = 0; i < qLabels.length; i++) {
             if (qLabels[i].equals(l)) {
-                NodeId vId = getVersionEntryByLabel(qLabels[i]).getId();
-                return vUUID.equals(vId.getUUID());
+                String uuid = getVersionStateByLabel(qLabels[i]).getUUID();
+                return vUUID.equals(uuid);
             }
         }
         return false;
@@ -283,8 +271,8 @@
         List vlabels = new ArrayList();
         QName[] qLabels = getQLabels();
         for (int i = 0; i < qLabels.length; i++) {
-            NodeId vId = getVersionEntryByLabel(qLabels[i]).getId();
-            if (vUUID.equals(vId.getUUID())) {
+            String uuid = getVersionStateByLabel(qLabels[i]).getUUID();
+            if (vUUID.equals(uuid)) {
                 try {
                     vlabels.add(NameFormat.format(qLabels[i], session.getNamespaceResolver()));
                 } catch (NoPrefixDeclaredException e) {
@@ -307,8 +295,8 @@
      * @see VersionHistory#removeVersion(String)
      */
     public void removeVersion(String versionName) throws RepositoryException {
-        ChildNodeEntry vEntry = getVersionEntry(versionName);
-        session.getVersionManager().removeVersion(vEntry.getId(), getNodeId());
+        NodeState vState = getVersionState(versionName);
+        session.getVersionManager().removeVersion(vhState, vState);
     }
 
     //---------------------------------------------------------------< Item >---
@@ -321,9 +309,9 @@
     public boolean isSame(Item otherItem) {
         if (otherItem instanceof VersionHistoryImpl) {
             // since all version histories are referenceable, protected and live
-            // in the same workspace, a simple comparison of the ids is sufficient
+            // in the same workspace, a simple comparison of the UUIDs is sufficient.
             VersionHistoryImpl other = ((VersionHistoryImpl) otherItem);
-            return getNodeId().equals(other.getNodeId());
+            return vhState.getUUID().equals(other.vhState.getUUID());
         }
         return false;
     }
@@ -345,17 +333,20 @@
      * @throws VersionException
      * @throws RepositoryException
      */
-    private ChildNodeEntry getVersionEntry(String versionName) throws VersionException, RepositoryException {
+    private NodeState getVersionState(String versionName) throws VersionException, RepositoryException {
         try {
             QName vQName = NameFormat.parse(versionName, session.getNamespaceResolver());
             ChildNodeEntry vEntry = vhState.getChildNodeEntry(vQName, Path.INDEX_DEFAULT);
             if (vEntry == null) {
                 throw new VersionException("Version '" + versionName + "' does not exist in this version history.");
             } else {
-                return vEntry;
+                return vEntry.getNodeState();
             }
         } catch (NameException e) {
             throw new RepositoryException(e);
+        } catch (ItemStateException e) {
+            // should not occure
+            throw new RepositoryException(e);
         }
     }
 
@@ -366,13 +357,13 @@
      * @throws VersionException
      * @throws RepositoryException
      */
-    private ChildNodeEntry getVersionEntryByLabel(QName qLabel) throws VersionException, RepositoryException {
+    private NodeState getVersionStateByLabel(QName qLabel) throws VersionException, RepositoryException {
         if (labelNodeState.hasPropertyName(qLabel)) {
             // retrieve reference property value -> and convert it to a NodeId
             try {
                 PropertyState pState = labelNodeState.getPropertyState(qLabel);
                 Node version = ((Property) itemMgr.getItem(pState)).getNode();
-                return getVersionEntry(version.getName());
+                return getVersionState(version.getName());
             } catch (ItemStateException e) {
                 // should not occur. existance of property state has been checked
                 throw new RepositoryException(e);

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionImpl.java?rev=431887&r1=431886&r2=431887&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionImpl.java Wed Aug 16 05:24:30 2006
@@ -97,9 +97,14 @@
     public boolean isSame(Item otherItem) {
         if (otherItem instanceof VersionImpl) {
             // since all versions are referenceable, protected and live
-            // in the same workspace, a simple comparision of the ids is sufficient
+            // in the same workspace, a simple comparision of the UUIDs is sufficient
             VersionImpl other = ((VersionImpl) otherItem);
-            return other.getNodeId().equals(other.getNodeId());
+            try {
+                return other.getUUID().equals(other.getUUID());
+            } catch (RepositoryException e) {
+                // should never occur
+                log.error("Internal error while retrieve UUID of version.", e);
+            }
         }
         return false;
     }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManager.java?rev=431887&r1=431886&r2=431887&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManager.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManager.java Wed Aug 16 05:24:30 2006
@@ -37,11 +37,11 @@
 
     public boolean isCheckedOut(NodeState nodeState) throws RepositoryException;
 
-    public void removeVersion(NodeId versionHistoryId, NodeId versionId) throws RepositoryException;
+    public void removeVersion(NodeState versionHistoryState, NodeState versionState) throws RepositoryException;
 
-    public void addVersionLabel(NodeId versionHistoryId, NodeId versionId, QName qLabel, boolean moveLabel) throws RepositoryException;
+    public void addVersionLabel(NodeState versionHistoryState, NodeState versionState, QName qLabel, boolean moveLabel) throws RepositoryException;
 
-    public void removeVersionLabel(NodeId versionHistoryId, NodeId versionId, QName qLabel) throws RepositoryException;
+    public void removeVersionLabel(NodeState versionHistoryState, NodeState versionState, QName qLabel) throws RepositoryException;
 
     public void restore(NodeId nodeId, NodeId versionId, boolean removeExisting) throws RepositoryException;
 
@@ -49,22 +49,22 @@
 
     /**
      *
-     * @param nodeId
+     * @param nodeState
      * @param workspaceName
      * @param bestEffort
      * @return A Collection of <code>ItemId</code> containing the ids of those
      * <code>Node</code>s that failed to be merged and need manual resolution
      * by the user of the API.
-     * @see #resolveMergeConflict(NodeId,NodeId,boolean)
+     * @see #resolveMergeConflict(NodeState,NodeState,boolean)
      */
-    public Collection merge(NodeId nodeId, String workspaceName, boolean bestEffort) throws RepositoryException;
+    public Collection merge(NodeState nodeState, String workspaceName, boolean bestEffort) throws RepositoryException;
 
     /**
      * 
-     * @param nodeId
-     * @param versionId
+     * @param nodeState
+     * @param versionState
      * @param done
      * @throws RepositoryException
      */
-    public void resolveMergeConflict(NodeId nodeId, NodeId versionId, boolean done) throws RepositoryException;
+    public void resolveMergeConflict(NodeState nodeState, NodeState versionState, boolean done) throws RepositoryException;
 }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java?rev=431887&r1=431886&r2=431887&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java Wed Aug 16 05:24:30 2006
@@ -57,12 +57,12 @@
     }
 
     public void checkin(NodeState nodeState) throws RepositoryException {
-        Operation ci = Checkin.create(nodeState.getNodeId());
+        Operation ci = Checkin.create(nodeState);
         stateManager.execute(ci);
     }
 
     public void checkout(NodeState nodeState) throws RepositoryException {
-        Operation co = Checkout.create(nodeState.getNodeId());
+        Operation co = Checkout.create(nodeState);
         stateManager.execute(co);
     }
 
@@ -98,18 +98,18 @@
         }
     }
 
-    public void removeVersion(NodeId versionHistoryId, NodeId versionId) throws RepositoryException {
-        Operation op = Remove.create(versionId, versionHistoryId);
+    public void removeVersion(NodeState versionHistoryState, NodeState versionState) throws RepositoryException {
+        Operation op = Remove.create(versionState);
         stateManager.execute(op);
     }
 
-    public void addVersionLabel(NodeId versionHistoryId, NodeId versionId, QName qLabel, boolean moveLabel) throws RepositoryException {
-        Operation op = AddLabel.create(versionHistoryId, versionId, qLabel, moveLabel);
+    public void addVersionLabel(NodeState versionHistoryState, NodeState versionState, QName qLabel, boolean moveLabel) throws RepositoryException {
+        Operation op = AddLabel.create(versionHistoryState, versionState, qLabel, moveLabel);
         stateManager.execute(op);
     }
 
-    public void removeVersionLabel(NodeId versionHistoryId, NodeId versionId, QName qLabel) throws RepositoryException {
-        Operation op = RemoveLabel.create(versionHistoryId, versionId, qLabel);
+    public void removeVersionLabel(NodeState versionHistoryState, NodeState versionState, QName qLabel) throws RepositoryException {
+        Operation op = RemoveLabel.create(versionHistoryState, versionState, qLabel);
         stateManager.execute(op);
     }
 
@@ -123,7 +123,7 @@
         stateManager.execute(op);
     }
 
-    public Collection merge(NodeId nodeId, String workspaceName, boolean bestEffort) throws RepositoryException {
+    public Collection merge(NodeState nodeState, String workspaceName, boolean bestEffort) throws RepositoryException {
         // TODO find better solution to build the mergeFailed-collection
         final List failedIds = new ArrayList();
         InternalEventListener mergeFailedCollector = new InternalEventListener() {
@@ -139,13 +139,13 @@
             }
         };
 
-        Operation op = Merge.create(nodeId, workspaceName, bestEffort, mergeFailedCollector);
+        Operation op = Merge.create(nodeState, workspaceName, bestEffort, mergeFailedCollector);
         stateManager.execute(op);
         return failedIds;
     }
 
-    public void resolveMergeConflict(NodeId nodeId, NodeId versionId, boolean done) throws RepositoryException {
-        Operation op = ResolveMergeConflict.create(nodeId, versionId, done);
+    public void resolveMergeConflict(NodeState nodeState, NodeState versionState, boolean done) throws RepositoryException {
+        Operation op = ResolveMergeConflict.create(nodeState, versionState, done);
         stateManager.execute(op);
     }
 }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java?rev=431887&r1=431886&r2=431887&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java Wed Aug 16 05:24:30 2006
@@ -52,7 +52,6 @@
 import javax.jcr.lock.LockException;
 import javax.jcr.version.VersionException;
 import javax.jcr.nodetype.ConstraintViolationException;
-import org.apache.jackrabbit.spi.PropertyId;
 import org.apache.jackrabbit.name.Path;
 import org.apache.jackrabbit.name.MalformedPathException;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
@@ -424,8 +423,7 @@
                         propDef = session.getValidator().getApplicablePropertyDefinition(newName, conflicting.getType(), true, parent);
                     }
 
-                    PropertyId newPId = session.getIdFactory().createPropertyId(parent.getNodeId(), newName);
-                    Operation ap = AddProperty.create(newPId, conflicting.getType(), propDef, conflicting.getValues());
+                    Operation ap = AddProperty.create(parent, newName, conflicting.getType(), propDef, conflicting.getValues());
                     stateMgr.execute(ap);
                     Operation rm = Remove.create(conflicting);
                     stateMgr.execute(rm);
@@ -442,8 +440,7 @@
             log.debug("Skipping protected nodeState (" + nodeInfo.getName() + ")");
             return null;
         } else {
-            NodeId newId = session.getIdFactory().createNodeId(nodeInfo.getUUID());
-            Operation an = AddNode.create(parent, nodeInfo.getName(), nodeInfo.getNodeTypeName(), newId);
+            Operation an = AddNode.create(parent, nodeInfo.getName(), nodeInfo.getNodeTypeName(), nodeInfo.getUUID());
             stateMgr.execute(an);
             // retrieve id of state that has been created during execution of AddNode
             NodeState childState;
@@ -461,8 +458,7 @@
             }
 
             // and set mixin types
-            PropertyId mixinPId = session.getIdFactory().createPropertyId(childState.getNodeId(), QName.JCR_MIXINTYPES);
-            Operation sm = SetMixin.create(mixinPId, nodeInfo.getMixinNames());
+            Operation sm = SetMixin.create(childState, nodeInfo.getMixinNames());
             stateMgr.execute(sm);
             return childState;
         }
@@ -471,7 +467,7 @@
     /**
      *
      * @param pi
-     * @param nodeState
+     * @param parentState
      * @param nsResolver
      * @throws RepositoryException
      * @throws ConstraintViolationException
@@ -537,8 +533,7 @@
         QValue[] values = getPropertyValues(pi, targetType, def.isMultiple(), nsResolver);
         if (propState == null) {
             // create new property
-            PropertyId newPId = session.getIdFactory().createPropertyId(parentState.getNodeId(), propName);
-            Operation ap = AddProperty.create(newPId, targetType, def, values);
+            Operation ap = AddProperty.create(parentState, propName, targetType, def, values);
             stateMgr.execute(ap);
             try {
                 propState = parentState.getPropertyState(propName);



Mime
View raw message