jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r712088 [2/2] - in /jackrabbit/branches/1.5/jackrabbit-jcr2spi/src: main/java/org/apache/jackrabbit/jcr2spi/ main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ main/java/org/apache/jackrabbit/jcr2spi/lock/ main/java/org/apache/jackrabbit/jc...
Date Fri, 07 Nov 2008 08:52:46 GMT
Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java Fri Nov  7 00:52:32 2008
@@ -252,23 +252,25 @@
      * @see HierarchyEntry#remove()
      */
     public void remove() {
-        ItemState state = internalGetItemState();
-        if (state != null) {
-            if (getStatus() == Status.EXISTING_MODIFIED) {
-                state.setStatus(Status.STALE_DESTROYED);
-            } else {
-                state.setStatus(Status.REMOVED);
-                parent.internalRemoveChildEntry(this);
-            }
-        } else {
-            // unresolved: ignore.
-            parent.internalRemoveChildEntry(this);
+        // handle this entry first
+        super.internalRemove(false);
+        boolean staleParent = (getStatus() == Status.STALE_DESTROYED);
+        // now remove all child-entries (or mark them accordingly)
+        for (Iterator it = getAllChildEntries(true); it.hasNext();) {
+            HierarchyEntryImpl ce = (HierarchyEntryImpl) it.next();
+            ce.internalRemove(staleParent);
         }
+    }
 
-        // now remove all child-entries.
+    void internalRemove(boolean staleParent) {
+        // handle this entry first
+        super.internalRemove(staleParent);
+        staleParent = (staleParent || (getStatus() == Status.STALE_DESTROYED));
+
+        // now remove all child-entries (or mark them accordingly)
         for (Iterator it = getAllChildEntries(true); it.hasNext();) {
             HierarchyEntryImpl ce = (HierarchyEntryImpl) it.next();
-            ce.remove();
+            ce.internalRemove(staleParent);
         }
     }
 
@@ -367,17 +369,17 @@
 
     /**
      * @inheritDoc
-     * @see NodeEntry#getDeepEntry(Path)
+     * @see NodeEntry#getDeepNodeEntry(Path)
      */
-    public HierarchyEntry getDeepEntry(Path path) throws PathNotFoundException, RepositoryException {
+    public NodeEntry getDeepNodeEntry(Path path) throws PathNotFoundException, RepositoryException {
         NodeEntryImpl entry = this;
         Path.Element[] elems = path.getElements();
         for (int i = 0; i < elems.length; i++) {
             Path.Element elem = (Path.Element) elems[i];
             // check for root element
             if (elem.denotesRoot()) {
-                if (getParent() != null) {
-                    throw new RepositoryException("NodeEntry out of 'hierarchy'" + path.toString());
+                if (entry.getParent() != null) {
+                    throw new RepositoryException("NodeEntry out of 'hierarchy' " + path.toString());
                 }
                 continue;
             }
@@ -389,9 +391,6 @@
             NodeEntry cne = entry.getNodeEntry(name, index, false);
             if (cne != null) {
                 entry = (NodeEntryImpl) cne;
-            } else if (index == Path.INDEX_DEFAULT && i == path.getLength() - 1 && entry.properties.contains(name)) {
-                // property must not have index && must be final path element
-                return entry.properties.get(name);
             } else {
                 // no valid entry
                 // -> if cnes are complete -> assume that it doesn't exist.
@@ -406,6 +405,11 @@
                 if (entry.containsAtticChild(siblings, name, index)) {
                     throw new PathNotFoundException(path.toString());
                 }
+                // shortcut: entry is NEW and still unresolved remaining path
+                // elements -> hierarchy doesn't exist anyway.
+                if (entry.getStatus() == Status.NEW) {
+                    throw new PathNotFoundException(path.toString());
+                }
                /*
                 * Unknown entry (not-existing or not yet loaded):
                 * Skip all intermediate entries and directly try to load the ItemState
@@ -423,12 +427,6 @@
                 }
                 Path remainingPath = pb.getPath();
 
-                // shortcut: entry is NEW and still unresolved remaining path
-                // elements -> hierarchy doesn't exist anyway.
-                if (entry.getStatus() == Status.NEW) {
-                    throw new PathNotFoundException(path.toString());
-                }
-
                 NodeId parentId = entry.getWorkspaceId();
                 IdFactory idFactory = factory.getIdFactory();
 
@@ -437,18 +435,7 @@
                 if (ne != null) {
                     return ne;
                 } else {
-                    if (index != Path.INDEX_DEFAULT) {
-                        throw new PathNotFoundException(path.toString());
-                    }
-                    // maybe a property entry exists
-                    parentId = (remainingPath.getLength() == 1) ? parentId : idFactory.createNodeId(parentId, remainingPath.getAncestor(1));
-                    PropertyId propId = idFactory.createPropertyId(parentId, remainingPath.getNameElement().getName());
-                    PropertyEntry pe = entry.loadPropertyEntry(propId);
-                    if (pe != null) {
-                        return pe;
-                    } else {
-                        throw new PathNotFoundException(path.toString());
-                    }
+                    throw new PathNotFoundException(path.toString());
                 }
             }
         }
@@ -456,6 +443,82 @@
     }
 
     /**
+     * @see NodeEntry#getDeepPropertyEntry(Path)
+     */
+    public PropertyEntry getDeepPropertyEntry(Path path) throws PathNotFoundException, RepositoryException {
+        NodeEntryImpl entry = this;
+        Path.Element[] elems = path.getElements();
+        int i = 0;
+        for (; i < elems.length-1; i++) {
+            Path.Element elem = (Path.Element) elems[i];
+            if (elems[i].denotesRoot()) {
+                if (entry.getParent() != null) {
+                    throw new RepositoryException("NodeEntry out of 'hierarchy' " + path.toString());
+                }
+                continue;
+            }
+
+            int index = elem.getNormalizedIndex();
+            Name name = elem.getName();
+
+            // first try to resolve to known node or property entry
+            NodeEntry cne = entry.getNodeEntry(name, index, false);
+            if (cne != null) {
+                entry = (NodeEntryImpl) cne;
+            } else {
+                // no valid ancestor node entry
+                // -> if cnes are complete -> assume that it doesn't exist.
+                //    refresh will bring up new entries added in the mean time
+                //    on the persistent layer.
+                if (entry.childNodeEntries.isComplete()) {
+                    throw new PathNotFoundException(path.toString());
+                }
+                // -> check for moved child entry in node-attic
+                // -> check if child points to a removed/moved sns
+                List siblings = entry.childNodeEntries.get(name);
+                if (entry.containsAtticChild(siblings, name, index)) {
+                    throw new PathNotFoundException(path.toString());
+                }
+                // break out of the loop and start deep loading the property
+                break;
+            }
+        }
+
+        int st = entry.getStatus();
+        PropertyEntry pe;
+        if (i == elems.length-1 && Status.INVALIDATED != st && Status._UNDEFINED_ != st) {
+            // all node entries present in the hierarchy and the direct ancestor
+            // has already been resolved and isn't invalidated -> no need to
+            // retrieve property entry from SPI
+            pe = entry.properties.get(path.getNameElement().getName());
+        } else {
+            /*
+            * Unknown parent entry (not-existing or not yet loaded) or a parent
+            * entry that has been invalidated:
+            * Skip all intermediate entries and directly try to load the
+            * PropertyState (including building the itermediate entries. If that
+            * fails ItemNotFoundException is thrown.
+            */
+            PathBuilder pb = new PathBuilder(factory.getPathFactory());
+            for (int j = i; j < elems.length; j++) {
+                pb.addLast(elems[j]);
+            }
+            Path remainingPath = pb.getPath();
+
+            IdFactory idFactory = factory.getIdFactory();
+            NodeId parentId = entry.getWorkspaceId();
+            parentId = (remainingPath.getLength() == 1) ? parentId : idFactory.createNodeId(parentId, remainingPath.getAncestor(1));
+            PropertyId propId = idFactory.createPropertyId(parentId, remainingPath.getNameElement().getName());
+            pe = entry.loadPropertyEntry(propId);
+        }
+
+        if (pe == null) {
+            throw new PathNotFoundException(path.toString());
+        }
+        return pe;
+    }
+
+    /**
      * @see NodeEntry#lookupDeepEntry(Path)
      */
     public HierarchyEntry lookupDeepEntry(Path workspacePath) {
@@ -528,10 +591,14 @@
         if (entries.size() >= index) {
             // position of entry might differ from index-1 if a SNS with lower
             // index has been transiently removed.
-            for (int i = index-1; i < entries.size() && cne == null; i++) {
+            int eIndex = 1;
+            for (int i = 0; i < entries.size() && cne == null; i++) {
                 NodeEntry ne = (NodeEntry) entries.get(i);
                 if (EntryValidation.isValidNodeEntry(ne)) {
-                    cne = ne;
+                    if (eIndex == index) {
+                        cne = ne;
+                    }
+                    eIndex++;
                 }
             }
         }
@@ -869,19 +936,11 @@
             case Event.PROPERTY_REMOVED:
                 if (child != null) {
                     int status = child.getStatus();
-                    if (Status.isTransient(status) || Status.isStale(status)) {
-                        if (Status.EXISTING_REMOVED == status) {
-                            // colliding item removal -> mark parent stale
-                            internalGetItemState().setStatus(Status.MODIFIED);
-                        }
-                        // pending changes -> don't remove entry in the hierarchy
-                        // but rather change status to 'STALE_DESTROYED'
-                        ItemState childState = ((HierarchyEntryImpl) child).internalGetItemState();
-                        childState.setStatus(Status.STALE_DESTROYED);
-                    } else {
-                        // no pending changes -> save to remove the entry.
-                        child.remove();
+                    if (Status.EXISTING_REMOVED == status) {
+                        // colliding item removal -> mark parent stale
+                        internalGetItemState().setStatus(Status.MODIFIED);
                     }
+                    child.remove();
                 } // else: child-Entry has not been loaded yet -> ignore
                 break;
 
@@ -1530,12 +1589,14 @@
         private final Name oldName;
         private final int oldIndex;
         private final NodeEntryImpl oldSuccessor;
+        private final NodeEntryImpl oldPredecessor;
 
         private RevertInfo() throws InvalidItemStateException, RepositoryException {
             this.oldParent = parent;
             this.oldName = name;
             this.oldIndex = getIndex();
             this.oldSuccessor = (NodeEntryImpl) ((ChildNodeEntriesImpl) parent.childNodeEntries).getNext(NodeEntryImpl.this);
+            this.oldPredecessor = (NodeEntryImpl) ((ChildNodeEntriesImpl) parent.childNodeEntries).getPrevious(NodeEntryImpl.this);
         }
 
         private boolean isMoved() {
@@ -1546,7 +1607,7 @@
             if (!persisted) {
                 NodeEntryImpl ne = NodeEntryImpl.this;
                 ChildNodeEntriesImpl parentCNEs = (ChildNodeEntriesImpl) parent.childNodeEntries;
-                parentCNEs.reorder(ne, revertInfo.oldSuccessor);
+                parentCNEs.reorderAfter(ne, revertInfo.oldPredecessor);
                 try {
                     if (oldIndex != ne.getIndex()) {
                         // TODO: TOBEFIXED

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/PropertyEntryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/PropertyEntryImpl.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/PropertyEntryImpl.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/PropertyEntryImpl.java Fri Nov  7 00:52:32 2008
@@ -110,25 +110,6 @@
     }
 
     /**
-     * @see HierarchyEntry#remove()
-     */
-    public void remove() {
-        ItemState state = internalGetItemState();
-        int status = getStatus();
-        if (state != null) {
-            if (status == Status.EXISTING_MODIFIED) {
-                state.setStatus(Status.STALE_DESTROYED);
-            } else {
-                state.setStatus(Status.REMOVED);
-                parent.internalRemoveChildEntry(this);
-            }
-        } else {
-            // unresolved
-            parent.internalRemoveChildEntry(this);
-        }
-    }
-
-    /**
      * @see HierarchyEntry#complete(Operation)
      */
     public void complete(Operation operation) throws RepositoryException {

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/UniqueIdResolver.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/UniqueIdResolver.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/UniqueIdResolver.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/UniqueIdResolver.java Fri Nov  7 00:52:32 2008
@@ -30,7 +30,6 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.ItemNotFoundException;
 import java.util.Map;
-import java.util.Iterator;
 
 /**
  * <code>UniqueIdResolver</code> allows to retrieve <code>NodeEntry</code> instances
@@ -61,16 +60,15 @@
         lookUp.clear();
     }
 
-    public NodeEntry lookup(NodeId nodeId) {
-        if (nodeId.getPath() != null) {
+    public NodeEntry lookup(String uniqueId) {
+        if (uniqueId == null) {
             throw new IllegalArgumentException();
         }
-        NodeEntry entry = (NodeEntry) lookUp.get(nodeId.getUniqueID());
-        return (entry != null) ? entry : null;
+        return (NodeEntry) lookUp.get(uniqueId);
     }
 
     public NodeEntry resolve(NodeId nodeId, NodeEntry rootEntry) throws ItemNotFoundException, RepositoryException {
-        NodeEntry entry = lookup(nodeId);
+        NodeEntry entry = lookup(nodeId.getUniqueID());
         if (entry == null) {
             NodeState state = isf.createDeepNodeState(nodeId, rootEntry);
             entry = state.getNodeEntry();
@@ -90,30 +88,45 @@
      * @see ItemStateLifeCycleListener#statusChanged(ItemState, int)
      */
     public void statusChanged(ItemState state, int previousStatus) {
-        if (Status.isTerminal(state.getStatus())) {
-            if (state.isNode()) {
-                NodeState nodeState = (NodeState) state;
-                String uniqueID = nodeState.getUniqueID();
-                if (uniqueID != null) {
-                    lookUp.remove(uniqueID);
+        synchronized (lookUp) {
+            if (Status.isTerminal((state.getStatus()))) {
+                if (state.isNode()) {
+                    NodeEntry entry = (NodeEntry) state.getHierarchyEntry();
+                    String uniqueID = entry.getUniqueID();
+                    if (uniqueID != null) {
+                        NodeEntry mapEntry = (NodeEntry) lookUp.get(uniqueID);
+                        if (mapEntry == entry) {
+                            lookUp.remove(uniqueID);
+                        } // else: removed entry is not present in lookup but
+                          //       only it's replacement -> ignore
+                    }
                 }
-            }
-            state.removeListener(this);
-        } else {
-            putToCache(state);
+                // stop listening if a state reached status REMOVED.
+                if (Status.REMOVED == state.getStatus()) {
+                    state.removeListener(this);
+                }
+            } // else: any other status than REMOVED -> ignore.
         }
     }
 
     //------------------------------------------< ItemStateCreationListener >---
     /**
-     * Updates the internal id-lookup if the created state is a NodeState that
-     * is identified by a uniqueID.
+     * Nothing to do. The lookUp is filled entry creation and/or modification
+     * of its uniqueID
      *
      * @param state
      * @see ItemStateCreationListener#created(ItemState)
      */
     public void created(ItemState state) {
-        putToCache(state);
+        if (state.isNode()) {
+            NodeEntry entry = (NodeEntry) state.getHierarchyEntry();
+            String uniqueID = entry.getUniqueID();
+            if (uniqueID != null) {
+                if (!lookUp.containsKey(uniqueID) || lookUp.get(uniqueID) != entry) {
+                    log.error("Created NodeState identified by UniqueID that is not contained in the lookup.");
+                }
+            }
+        }
     }
 
     //-------------------------------------< EntryFactory.NodeEntryListener >---
@@ -124,15 +137,7 @@
         synchronized (lookUp) {
             String uniqueID = entry.getUniqueID();
             if (uniqueID != null) {
-                // get an previous entry first and remove it before adding the
-                // new one. otherwise the newly added entry will be removed
-                // again upon removal of the original entry.
-                Object previous = lookUp.get(uniqueID);
-                if (previous != null) {
-                    lookUp.remove(uniqueID);
-                    ((NodeEntry) previous).remove();
-                }
-                lookUp.put(uniqueID, entry);
+                putToLookup(uniqueID, entry);
             }
         }
     }
@@ -144,56 +149,56 @@
         synchronized (lookUp) {
             if (previousUniqueID != null) {
                 Object previous = lookUp.get(previousUniqueID);
-                if (previous != entry) {
-                    // changed entry was not in this cache -> return.
-                    return;
-                } else {
+                if (previous == entry) {
                     lookUp.remove(previousUniqueID);
-                }
+                } // else: previousUniqueID points to another entry -> ignore
             }
             String uniqueID = entry.getUniqueID();
             if (uniqueID != null) {
-                Object previous = lookUp.put(uniqueID, entry);
-                if (previous != null && previous != entry) {
-                    // some other entry existed before with the same uniqueID
-                    ((NodeEntry) previous).remove();
-                }
+                putToLookup(uniqueID, entry);
             }
         }
     }
+
     //------------------------------------------------------------< private >---
-    /**
-     * Put the given <code>ItemState</code> in the internal cache.
-     *
-     * @param state
-     */
-    private void putToCache(ItemState state) {
-        if (!state.isNode()) {
-            return;
+    private void putToLookup(String uniqueID, NodeEntry entry) {
+        Object previous = lookUp.put(uniqueID, entry);
+        if (previous != null) {
+            // some other entry existed before with the same uniqueID
+            if (!sameEntry((NodeEntry) previous, entry)) {
+                // if the new entry represents the externally moved/renamed
+                // correspondance of the previous the latter needs to marked
+                // removed/stale-destroyed.
+                // otherwise (both represent the same entry) the creation
+                // of entry is the result of gc of the node or any of the
+                // ancestors. in this case there is not need to 'remove'
+                // the previous entry. instead it is just removed from this
+                // cache and left for collection.
+                ((NodeEntry) previous).remove();
+            } else {
+                log.debug("Replacement of NodeEntry identified by UniqueID");
+            }
         }
+    }
 
-        if (state.getStatus() == Status.EXISTING || state.getStatus() == Status.MODIFIED) {
-            NodeEntry entry = ((NodeState)state).getNodeEntry();
-            // NOTE: uniqueID is retrieved from the state and not from the NodeId.
-            String uniqueID = entry.getUniqueID();
-            synchronized (lookUp) {
-                if (uniqueID != null) {
-                    if (lookUp.get(uniqueID) != entry) {
-                        lookUp.put(uniqueID, entry);
-                    }
-                } else {
-                    // ev. uniqueID was removed -> remove the entry from the lookUp
-                    if (lookUp.containsValue(entry)) {
-                        for (Iterator it = lookUp.entrySet().iterator(); it.hasNext();) {
-                            Map.Entry next = (Map.Entry) it.next();
-                            if (next.getValue() == entry) {
-                                it.remove();
-                                break;
-                            }
-                        }
-                    }
+    private static boolean sameEntry(NodeEntry previous, NodeEntry entry) {
+        if (previous == entry) {
+            return true;
+        } else if (Status.REMOVED != previous.getStatus() &&
+                previous.getName().equals(entry.getName())) {
+
+            NodeEntry parent = previous.getParent();
+            NodeEntry parent2 = entry.getParent();
+            if (parent == parent2) {
+                return true;
+            } else {
+                try {
+                    return parent.getPath().equals(parent2.getPath());
+                } catch (RepositoryException e) {
+                    // TODO: add some fallback
                 }
             }
         }
+        return false;
     }
 }

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java Fri Nov  7 00:52:32 2008
@@ -324,17 +324,12 @@
         if (lockNodeId.equals(nId)) {
             lockHoldingState = nodeState;
         } else {
-            HierarchyEntry lockedEntry = wspManager.getHierarchyManager().getHierarchyEntry(lockNodeId);
-            if (lockedEntry.denotesNode()) {
-                try {
-                    lockHoldingState = ((NodeEntry) lockedEntry).getNodeState();
-                } catch (RepositoryException e) {
-                    log.warn("Cannot build LockState");
-                    throw new RepositoryException("Cannot build LockState", e);
-                }
-            } else {
-                // should never occur
-                throw new RepositoryException("Internal error: NodeId points to a Property.");
+            NodeEntry lockedEntry = wspManager.getHierarchyManager().getNodeEntry(lockNodeId);
+            try {
+                lockHoldingState = ((NodeEntry) lockedEntry).getNodeState();
+            } catch (RepositoryException e) {
+                log.warn("Cannot build LockState");
+                throw new RepositoryException("Cannot build LockState", e);
             }
         }
 
@@ -547,7 +542,7 @@
                 try {
                     if (!lockHoldingState.hasPropertyName(NameConstants.JCR_LOCKISDEEP)) {
                         // force reloading of the lock holding node.
-                        itemManager.getItem(lockHoldingState.getNodeEntry().getPath());
+                        itemManager.getItem(lockHoldingState.getNodeEntry());
                     }
                     PropertyState ps = lockHoldingState.getPropertyState(NameConstants.JCR_LOCKISDEEP);
                     ps.addListener(this);

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AbstractCopy.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AbstractCopy.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AbstractCopy.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AbstractCopy.java Fri Nov  7 00:52:32 2008
@@ -16,17 +16,14 @@
  */
 package org.apache.jackrabbit.jcr2spi.operation;
 
-import org.apache.jackrabbit.jcr2spi.state.ItemState;
-import org.apache.jackrabbit.jcr2spi.state.NodeState;
 import org.apache.jackrabbit.jcr2spi.ManagerProvider;
-import org.apache.jackrabbit.jcr2spi.util.LogUtil;
-import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.jcr2spi.state.NodeState;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.NodeId;
-import org.slf4j.LoggerFactory;
+import org.apache.jackrabbit.spi.Path;
 import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-import javax.jcr.PathNotFoundException;
 import javax.jcr.RepositoryException;
 
 /**
@@ -51,12 +48,9 @@
                  ManagerProvider srcMgrProvider, ManagerProvider destMgrProvider)
         throws RepositoryException {
 
-        ItemState srcItemState = srcMgrProvider.getHierarchyManager().getItemState(srcPath);
-        if (!srcItemState.isNode()) {
-            throw new PathNotFoundException("Source path " + LogUtil.safeGetJCRPath(srcPath, srcMgrProvider.getPathResolver()) + " is not a valid path.");
-        }
+        NodeState srcItemState = getNodeState(srcPath, srcMgrProvider.getHierarchyManager());
         this.srcState = (NodeState)srcItemState;
-        this.destParentState = getNodeState(destPath.getAncestor(1), destMgrProvider.getHierarchyManager(), destMgrProvider.getNamePathResolver());
+        this.destParentState = getNodeState(destPath.getAncestor(1), destMgrProvider.getHierarchyManager());
 
         // check for illegal index present in destination path
         Path.Element destElement = destPath.getNameElement();

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AbstractOperation.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AbstractOperation.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AbstractOperation.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AbstractOperation.java Fri Nov  7 00:52:32 2008
@@ -16,17 +16,15 @@
  */
 package org.apache.jackrabbit.jcr2spi.operation;
 
-import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyManager;
 import org.apache.jackrabbit.jcr2spi.state.ItemState;
 import org.apache.jackrabbit.jcr2spi.state.NodeState;
-import org.apache.jackrabbit.jcr2spi.util.LogUtil;
-import org.apache.jackrabbit.spi.commons.conversion.PathResolver;
+import org.apache.jackrabbit.spi.Path;
 
 import javax.jcr.PathNotFoundException;
 import javax.jcr.RepositoryException;
-import java.util.Collection;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 
 /**
@@ -82,17 +80,13 @@
      *
      * @param nodePath
      * @param hierMgr
-     * @param resolver
      * @return
      * @throws PathNotFoundException
      * @throws RepositoryException
      */
-    protected static NodeState getNodeState(Path nodePath, HierarchyManager hierMgr, PathResolver resolver) throws PathNotFoundException, RepositoryException {
-        ItemState itemState = hierMgr.getItemState(nodePath);
-        if (!itemState.isNode()) {
-            throw new PathNotFoundException(LogUtil.safeGetJCRPath(nodePath, resolver));
-        }
-        return (NodeState) itemState;
+    protected static NodeState getNodeState(Path nodePath, HierarchyManager hierMgr) throws PathNotFoundException, RepositoryException {
+        NodeState nodeState = hierMgr.getNodeState(nodePath);
+        return nodeState;
     }
 
     /**

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Move.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Move.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Move.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Move.java Fri Nov  7 00:52:32 2008
@@ -175,9 +175,9 @@
             throw new RepositoryException(msg);
         }
 
-        NodeState srcState = getNodeState(srcPath, hierMgr, resolver);
-        NodeState srcParentState = getNodeState(srcPath.getAncestor(1), hierMgr, resolver);
-        NodeState destParentState = getNodeState(destPath.getAncestor(1), hierMgr, resolver);
+        NodeState srcState = getNodeState(srcPath, hierMgr);
+        NodeState srcParentState = getNodeState(srcPath.getAncestor(1), hierMgr);
+        NodeState destParentState = getNodeState(destPath.getAncestor(1), hierMgr);
         Name destName = destElement.getName();
 
         if (sessionMove) {

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Remove.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Remove.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Remove.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Remove.java Fri Nov  7 00:52:32 2008
@@ -89,6 +89,11 @@
 
     //------------------------------------------------------------< Factory >---
     public static Operation create(ItemState state) throws RepositoryException {
+        if (state.isNode() && ((NodeState) state).getDefinition().allowsSameNameSiblings()) {
+            // in case of SNS-siblings make sure the parent hierarchy entry has
+            // its child entries loaded.
+            assertChildNodeEntries(state.getParent());
+        }
         return new Remove(state, state.getParent());
     }
 }
\ No newline at end of file

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/NodeIteratorImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/NodeIteratorImpl.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/NodeIteratorImpl.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/NodeIteratorImpl.java Fri Nov  7 00:52:32 2008
@@ -214,7 +214,7 @@
             try {
                 QueryResultRow row = (QueryResultRow) rows.next();
                 nextId = row.getNodeId();
-                Item tmp = itemMgr.getItem(hierarchyMgr.getHierarchyEntry(nextId));
+                Item tmp = itemMgr.getItem(hierarchyMgr.getNodeEntry(nextId));
 
                 if (tmp.isNode()) {
                     next = (Node) tmp;

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java Fri Nov  7 00:52:32 2008
@@ -421,7 +421,6 @@
             VersionException, LockException, ItemNotFoundException,
             ReferentialIntegrityException, RepositoryException {
 
-        // TODO: missing check if all affected child-states can be removed as well
         if (targetState.isNode() && ((NodeState)targetState).isRoot()) {
             // root node
             throw new ConstraintViolationException("Cannot remove root node.");

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java Fri Nov  7 00:52:32 2008
@@ -313,7 +313,7 @@
         removedStates.add(state);
     }
 
-   /**
+    /**
      *
      * @param parent
      * @param state
@@ -321,26 +321,26 @@
      */
     private static boolean containedInTree(ItemState parent, ItemState state) {
         HierarchyEntry he = state.getHierarchyEntry();
-       HierarchyEntry pHe = parent.getHierarchyEntry();
-       // short cuts first
-       if (he == pHe || he.getParent() == pHe) {
-           return true;
-       }
-       if (!parent.isNode() || he == pHe.getParent()) {
-           return false;
-       }
-       // none of the simple cases: walk up hierarchy
-       HierarchyEntry pe = he.getParent();
-       while (pe != null) {
-           if (pe == pHe) {
-               return true;
-           }
-           pe = pe.getParent();
-       }
+        HierarchyEntry pHe = parent.getHierarchyEntry();
+        // short cuts first
+        if (he == pHe || he.getParent() == pHe) {
+            return true;
+        }
+        if (!parent.isNode() || he == pHe.getParent()) {
+            return false;
+        }
+        // none of the simple cases: walk up hierarchy
+        HierarchyEntry pe = he.getParent();
+        while (pe != null) {
+            if (pe == pHe) {
+                return true;
+            }
+            pe = pe.getParent();
+        }
 
-       // state isn't descendant of 'parent'
-       return false;
-   }
+        // state isn't descendant of 'parent'
+        return false;
+    }
 
     //-----------------------------------------< ItemStateLifeCycleListener >---
     /**
@@ -404,14 +404,16 @@
                         removed(state);
                         break;
                 }
+                // in any case: stop listening to status changes
+                state.removeListener(this);
                 break;
             case Status.STALE_DESTROYED:
             case Status.STALE_MODIFIED:
                 /**
-                state is stale due to external modification -> move it to
-                the collection of stale item states.
-                validation omitted for only 'existing_modified' states can
-                become stale see {@link Status#isValidStatusChange(int, int)}
+                 state is stale due to external modification -> move it to
+                 the collection of stale item states.
+                 validation omitted for only 'existing_modified' states can
+                 become stale see {@link Status#isValidStatusChange(int, int)}
                  */
                 modifiedStates.remove(state);
                 staleStates.add(state);

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java Fri Nov  7 00:52:32 2008
@@ -19,7 +19,6 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.jackrabbit.jcr2spi.NodeImpl;
-import org.apache.jackrabbit.jcr2spi.ItemManager;
 import org.apache.jackrabbit.jcr2spi.SessionImpl;
 import org.apache.jackrabbit.jcr2spi.ItemLifeCycleListener;
 import org.apache.jackrabbit.jcr2spi.LazyItemIterator;
@@ -58,10 +57,9 @@
     private final NodeEntry vhEntry;
     private final NodeEntry labelNodeEntry;
 
-    public VersionHistoryImpl(ItemManager itemMgr, SessionImpl session,
-                              NodeState state, ItemLifeCycleListener[] listeners)
-        throws VersionException, RepositoryException {
-        super(itemMgr, session, state, listeners);
+    public VersionHistoryImpl(SessionImpl session, NodeState state, ItemLifeCycleListener[] listeners)
+            throws VersionException, RepositoryException {
+        super(session, state, listeners);
         this.vhEntry = (NodeEntry) state.getHierarchyEntry();
 
         // retrieve hierarchy entry of the jcr:versionLabels node
@@ -99,7 +97,7 @@
             log.error(msg);
             throw new RepositoryException(msg);
         }
-        return (Version) itemMgr.getItem(vEntry);
+        return (Version) getItemManager().getItem(vEntry);
     }
 
     /**
@@ -120,7 +118,7 @@
                 versionEntries.add(entry);
             }
         }
-        return new LazyItemIterator(itemMgr, new RangeIteratorAdapter(versionEntries));
+        return new LazyItemIterator(getItemManager(), new RangeIteratorAdapter(versionEntries));
     }
 
     /**
@@ -134,7 +132,7 @@
     public Version getVersion(String versionName) throws VersionException, RepositoryException {
         checkStatus();
         NodeState vState = getVersionState(versionName);
-        return (Version) itemMgr.getItem(vState.getHierarchyEntry());
+        return (Version) getItemManager().getItem(vState.getHierarchyEntry());
     }
 
     /**
@@ -378,7 +376,7 @@
         if (pEntry == null) {
             throw new VersionException("Version with label '" + qLabel + "' does not exist.");
         }
-        Node version = ((Property) itemMgr.getItem(pEntry)).getNode();
+        Node version = ((Property) getItemManager().getItem(pEntry)).getNode();
         return (Version) version;
     }
 

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionImpl.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionImpl.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionImpl.java Fri Nov  7 00:52:32 2008
@@ -43,9 +43,9 @@
 
     private static Logger log = LoggerFactory.getLogger(VersionImpl.class);
 
-    public VersionImpl(ItemManager itemMgr, SessionImpl session, NodeState state,
+    public VersionImpl(SessionImpl session, NodeState state,
                        ItemLifeCycleListener[] listeners) {
-        super(itemMgr, session, state, listeners);
+        super(session, state, listeners);
     }
 
     //------------------------------------------------------------< Version >---

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java Fri Nov  7 00:52:32 2008
@@ -61,7 +61,7 @@
     public NodeEntry checkin(NodeState nodeState) throws RepositoryException {
         Checkin ci = Checkin.create(nodeState, this);
         workspaceManager.execute(ci);
-        return (NodeEntry) workspaceManager.getHierarchyManager().getHierarchyEntry(ci.getNewVersionId());
+        return workspaceManager.getHierarchyManager().getNodeEntry(ci.getNewVersionId());
     }
 
     public void checkout(NodeState nodeState) throws RepositoryException {
@@ -187,13 +187,13 @@
         String uniqueID = ps.getValue().getString();
 
         NodeId versionableId = workspaceManager.getIdFactory().createNodeId(uniqueID);
-        return (NodeEntry) workspaceManager.getHierarchyManager().getHierarchyEntry(versionableId);
+        return workspaceManager.getHierarchyManager().getNodeEntry(versionableId);
     }
 
     public NodeEntry getVersionHistoryEntry(NodeState versionableState) throws RepositoryException {
         PropertyState ps = versionableState.getPropertyState(NameConstants.JCR_VERSIONHISTORY);
         String uniqueID = ps.getValue().getString();
         NodeId vhId = workspaceManager.getIdFactory().createNodeId(uniqueID);
-        return (NodeEntry) workspaceManager.getHierarchyManager().getHierarchyEntry(vhId);
+        return workspaceManager.getHierarchyManager().getNodeEntry(vhId);
     }
 }
\ No newline at end of file

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java Fri Nov  7 00:52:32 2008
@@ -18,7 +18,6 @@
 
 import org.apache.jackrabbit.jcr2spi.SessionImpl;
 import org.apache.jackrabbit.jcr2spi.SessionListener;
-import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry;
 import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
 import org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry;
 import org.apache.jackrabbit.jcr2spi.nodetype.EffectiveNodeType;
@@ -29,7 +28,6 @@
 import org.apache.jackrabbit.jcr2spi.operation.Remove;
 import org.apache.jackrabbit.jcr2spi.operation.SetMixin;
 import org.apache.jackrabbit.jcr2spi.operation.SetPropertyValue;
-import org.apache.jackrabbit.jcr2spi.state.ItemState;
 import org.apache.jackrabbit.jcr2spi.state.ItemStateValidator;
 import org.apache.jackrabbit.jcr2spi.state.NodeState;
 import org.apache.jackrabbit.jcr2spi.state.PropertyState;
@@ -37,19 +35,19 @@
 import org.apache.jackrabbit.jcr2spi.state.Status;
 import org.apache.jackrabbit.jcr2spi.util.LogUtil;
 import org.apache.jackrabbit.jcr2spi.util.ReferenceChangeTracker;
-import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.NodeId;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.commons.name.NameConstants;
+import org.apache.jackrabbit.spi.commons.value.ValueFormat;
 import org.apache.jackrabbit.util.Base64;
 import org.apache.jackrabbit.util.TransientFileFactory;
 import org.apache.jackrabbit.uuid.UUID;
-import org.apache.jackrabbit.spi.commons.value.ValueFormat;
 import org.apache.jackrabbit.value.ValueHelper;
-import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -126,11 +124,7 @@
 
         // perform preliminary checks
         try {
-            ItemState itemState = session.getHierarchyManager().getItemState(parentPath);
-            if (!itemState.isNode()) {
-                throw new PathNotFoundException(LogUtil.safeGetJCRPath(parentPath, session.getPathResolver()));
-            }
-            importTarget = (NodeState) itemState;
+            importTarget = session.getHierarchyManager().getNodeState(parentPath);
 
             // check if import target is writable, not-locked and checked-out.
             int options = ItemStateValidator.CHECK_ACCESS | ItemStateValidator.CHECK_LOCK | ItemStateValidator.CHECK_VERSIONING;
@@ -217,7 +211,7 @@
                // potential uuid conflict
                try {
                    NodeId conflictingId = session.getIdFactory().createNodeId(nodeInfo.getUUID());
-                   HierarchyEntry conflicting = session.getHierarchyManager().getHierarchyEntry(conflictingId);
+                   NodeEntry conflicting = session.getHierarchyManager().getNodeEntry(conflictingId);
                    // assert that the entry is available
                    conflicting.getItemState();
 

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractMoveTreeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractMoveTreeTest.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractMoveTreeTest.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractMoveTreeTest.java Fri Nov  7 00:52:32 2008
@@ -27,6 +27,8 @@
 import javax.jcr.version.VersionException;
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.lock.LockException;
+import java.util.List;
+import java.util.ArrayList;
 
 /**
  * <code>AbstractMoveTreeTest</code>...
@@ -44,6 +46,7 @@
 
     protected String srcPath;
     protected String destinationPath;
+    protected List childPaths = new ArrayList();
 
     protected void setUp() throws Exception {
         super.setUp();
@@ -59,6 +62,9 @@
         childNode = moveNode.addNode(nodeName2, testNodeType);
         grandChildNode = childNode.addNode(nodeName3, testNodeType);
 
+        childPaths.add(grandChildNode.getPath());
+        childPaths.add(childNode.getPath());
+
         doMove(moveNode.getPath(), destinationPath);
     }
 

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ExternalModificationTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ExternalModificationTest.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ExternalModificationTest.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ExternalModificationTest.java Fri Nov  7 00:52:32 2008
@@ -27,6 +27,7 @@
 import javax.jcr.Node;
 import javax.jcr.InvalidItemStateException;
 import javax.jcr.Item;
+import javax.jcr.Property;
 
 /** <code>ExternalModificationTest</code>... */
 public class ExternalModificationTest extends AbstractJCRTest {
@@ -152,19 +153,14 @@
         superuser.move(refNode.getPath(), destParentNode.getPath() + "/" + nodeName2);
         superuser.save();
 
+        testSession.getItem(destParentNode.getPath() + "/" + nodeName2);
+
+        assertItemStatus(refNode2, Status.STALE_DESTROYED);
         try {
-            refNode2.refresh(true);
-            Node parent = refNode2.getParent();
+            refNode2.refresh(false);
+            fail();
         } catch (InvalidItemStateException e) {
-        }
-
-        if (isItemStatus(refNode2, Status.STALE_DESTROYED)) {
-            try {
-                refNode2.refresh(false);
-                fail();
-            } catch (InvalidItemStateException e) {
-                // correct behaviour
-            }
+            // correct behaviour
         }
     }
 
@@ -175,15 +171,230 @@
         superuser.move(refNode.getPath(), destParentNode.getPath() + "/" + nodeName2);
         superuser.save();
 
+        testSession.getItem(destParentNode.getPath() + "/" + nodeName2);
+
+        assertItemStatus(refNode2, Status.STALE_DESTROYED);
+        testSession.refresh(false);
+        assertItemStatus(refNode2, Status.REMOVED);
+    }
+
+    public void testStaleDestroyed3() throws RepositoryException, NotExecutableException {
+        String uuid = refNode.getUUID();
+
+        Node refNode2 = (Node) testSession.getItem(refNode.getPath());
+        // TODO: for generic jsr 170 test isSame must be replace by 'Item.isSame'
+        assertSame(refNode2, testSession.getNodeByUUID(uuid));
+        // add some modification
+        refNode2.addMixin(mixLockable);
+
+        String srcPath = refNode.getPath();
+        String destPath = destParentNode.getPath() + "/" + nodeName2;
+        superuser.move(srcPath, destPath);
+        superuser.save();
+
+        testSession.getItem(destPath);
+
+        assertItemStatus(refNode2, Status.STALE_DESTROYED);
+        // the uuid must be transfered to the 'moved' node
+        Node n = testSession.getNodeByUUID(uuid);
+        // TODO: for generic jsr 170 test assertSame must be replace by 'Item.isSame'
+        assertSame(n, testSession.getItem(destPath));
+        assertSame(refNode2, testSession.getItem(srcPath));
+    }
+
+    public void testExternalRemoval() throws RepositoryException, NotExecutableException {
+        String uuid = refNode.getUUID();
+        Node refNode2 = (Node) testSession.getNodeByUUID(uuid);
+
+        String srcPath = refNode.getPath();
+        String destPath = destParentNode.getPath() + "/" + nodeName2;
+        superuser.move(srcPath, destPath);
+        superuser.save();
+
         try {
             refNode2.refresh(true);
             Node parent = refNode2.getParent();
         } catch (InvalidItemStateException e) {
         }
 
-        if (isItemStatus(refNode2, Status.STALE_DESTROYED)) {
-            testSession.refresh(false);
-            assertItemStatus(refNode2, Status.REMOVED);
+        assertItemStatus(refNode2, Status.REMOVED);
+        // the uuid must be transfered to the 'moved' node
+        Node n = testSession.getNodeByUUID(uuid);
+        // TODO: for generic jsr 170 test assertSame must be replace by 'Item.isSame'
+        assertSame(n, testSession.getItem(destPath));
+    }
+
+    public void testExternalRemoval2() throws RepositoryException, NotExecutableException {
+        Node childN = refNode.addNode(nodeName3);
+        Property p = childN.setProperty(propertyName1, "anyvalue");
+        refNode.save();
+
+        String uuid = refNode.getUUID();
+        Node refNode2 = (Node) testSession.getNodeByUUID(uuid);
+        Node c2 =  (Node) testSession.getItem(childN.getPath());
+        Property p2 = (Property) testSession.getItem(p.getPath());
+        // transiently remove the property -> test effect of external removal.
+        p2.remove();
+
+        String srcPath = refNode.getPath();
+        String destPath = destParentNode.getPath() + "/" + nodeName2;
+        superuser.move(srcPath, destPath);
+        superuser.save();
+
+        try {
+            refNode2.refresh(true);
+            Node parent = refNode2.getParent();
+        } catch (InvalidItemStateException e) {
         }
+
+        assertItemStatus(refNode2, Status.REMOVED);
+        assertItemStatus(c2, Status.STALE_DESTROYED);
+        assertItemStatus(p2, Status.REMOVED);
+    }
+
+    public void testExternalRemoval3() throws RepositoryException, NotExecutableException {
+        Node childN = refNode.addNode(nodeName3);
+        Property p = childN.setProperty(propertyName1, "anyvalue");
+        refNode.save();
+
+        String uuid = refNode.getUUID();
+        Node refNode2 = (Node) testSession.getNodeByUUID(uuid);
+        Node c2 =  (Node) testSession.getItem(childN.getPath());
+        Property p2 = (Property) testSession.getItem(p.getPath());
+        // transiently modify  -> test effect of external removal.
+        p2.setValue("changedValue");
+
+        String srcPath = refNode.getPath();
+        String destPath = destParentNode.getPath() + "/" + nodeName2;
+        superuser.move(srcPath, destPath);
+        superuser.save();
+
+        try {
+            refNode2.refresh(true);
+            Node parent = refNode2.getParent();
+        } catch (InvalidItemStateException e) {
+        }
+
+        assertItemStatus(refNode2, Status.REMOVED);
+        assertItemStatus(c2, Status.REMOVED);
+        assertItemStatus(p2, Status.STALE_DESTROYED);
+        assertEquals("changedValue", p2.getString());
+    }
+
+    public void testNewItemsUponStaleDestroyed() throws RepositoryException, NotExecutableException {
+        String uuid = refNode.getUUID();
+        Node refNode2 = (Node) testSession.getItem(refNode.getPath());
+        refNode2.addMixin(mixLockable);
+
+        Node childN = refNode2.addNode(nodeName3);
+        String childNPath = childN.getPath();
+
+        Property childP = refNode2.setProperty(propertyName2, "someValue");
+        String childPPath = childP.getPath();
+
+        String destPath = destParentNode.getPath() + "/" + nodeName2;
+        superuser.move(refNode.getPath(), destPath);
+        superuser.save();
+
+        testSession.refresh(true);
+        testSession.getItem(destPath);
+
+        assertItemStatus(refNode2, Status.STALE_DESTROYED);
+        assertItemStatus(refNode2.getProperty(jcrMixinTypes), Status.STALE_DESTROYED);
+        assertItemStatus(childN, Status.NEW);
+        assertItemStatus(childP, Status.NEW);
+        assertItemStatus(childN.getProperty(jcrPrimaryType), Status.NEW);
+
+        assertTrue(testSession.itemExists(childNPath));
+        assertSame(childN, testSession.getItem(childNPath));
+
+        assertTrue(testSession.itemExists(childPPath));
+        assertSame(childP, testSession.getItem(childPPath));
+
+        testSession.refresh(false);
+
+        assertItemStatus(childN, Status.REMOVED);
+        assertItemStatus(childP, Status.REMOVED);
+        assertFalse(testSession.itemExists(childNPath));
+        assertFalse(testSession.itemExists(childPPath));
+    }
+
+    public void testChildItemsUponStaleDestroyed() throws RepositoryException, NotExecutableException {
+        Node cNode = refNode.addNode(nodeName3);
+        Node cNode2 = cNode.addNode(nodeName4);
+        refNode.save();
+
+        String uuid = refNode.getUUID();
+        Node refNode2 = (Node) testSession.getItem(refNode.getPath());
+        refNode2.addMixin(mixLockable);
+
+        Node child =  (Node) testSession.getItem(cNode.getPath());
+        Node child2 = (Node) testSession.getItem(cNode2.getPath());
+        Node child3 = child2.addNode(nodeName4);
+        String child3Path = child3.getPath();
+
+        String destPath = destParentNode.getPath() + "/" + nodeName2;
+        superuser.move(refNode.getPath(), destPath);
+        superuser.save();
+
+        testSession.refresh(true);
+        testSession.getItem(destPath);
+
+        assertItemStatus(refNode2, Status.STALE_DESTROYED);
+        assertItemStatus(refNode2.getProperty(jcrMixinTypes), Status.STALE_DESTROYED);
+        assertItemStatus(child, Status.REMOVED);
+        assertItemStatus(child2, Status.STALE_DESTROYED);
+        assertItemStatus(child3, Status.NEW);
+        assertItemStatus(child3.getProperty(jcrPrimaryType), Status.NEW);
+
+        testSession.refresh(false);
+
+        assertItemStatus(child2, Status.REMOVED);
+        assertItemStatus(child3, Status.REMOVED);
+    }
+
+    public void testUnmodifiedAncestorRemoved() throws RepositoryException, NotExecutableException {
+        String uuid = refNode.getUUID();
+        Node n3 = refNode.addNode(nodeName3, testNodeType);
+        refNode.save();
+
+        Node refNode2 = (Node) testSession.getItem(refNode.getPath());
+        // add transient modification to non-referenceable child node
+        Node node3 = (Node) testSession.getItem(n3.getPath());
+        node3.addMixin(mixLockable);
+
+        // add new child node and child property below
+        Node childN = node3.addNode(nodeName3);
+        String childNPath = childN.getPath();
+
+        Property childP = node3.setProperty(propertyName2, "someValue");
+        String childPPath = childP.getPath();
+
+        // externally move the 'refNode' in order to provoke uuid-conflict
+        // in testSession -> refNode2 gets removed, since it doesn't have
+        // transient modifications.
+        String destPath = destParentNode.getPath() + "/" + nodeName2;
+        superuser.move(refNode.getPath(), destPath);
+        superuser.save();
+
+        testSession.refresh(true);
+        testSession.getItem(destPath);
+
+        assertItemStatus(refNode2, Status.REMOVED);
+        assertItemStatus(node3, Status.STALE_DESTROYED);
+        assertItemStatus(childN, Status.NEW);
+        assertItemStatus(childP, Status.NEW);
+
+        // since 'refNode2' is removed -> child items must not be accessible
+        // any more.
+        assertFalse(testSession.itemExists(childNPath));
+        assertFalse(testSession.itemExists(childPPath));
+
+        // revert all pending changes...
+        testSession.refresh(false);
+        // must mark all modified/new items as removed.
+        assertItemStatus(node3, Status.REMOVED);
+        assertItemStatus(childN, Status.REMOVED);
+        assertItemStatus(childP, Status.REMOVED);
     }
 }
\ No newline at end of file

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/GetPropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/GetPropertyTest.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/GetPropertyTest.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/GetPropertyTest.java Fri Nov  7 00:52:32 2008
@@ -19,17 +19,23 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.jackrabbit.test.AbstractJCRTest;
+import org.apache.jackrabbit.test.NotExecutableException;
+import org.apache.jackrabbit.util.Text;
 
 import javax.jcr.Node;
 import javax.jcr.Property;
 import javax.jcr.Session;
 import javax.jcr.RepositoryException;
+import javax.jcr.PropertyIterator;
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.PathNotFoundException;
 
 /** <code>GetPropertyTest</code>... */
 public class GetPropertyTest extends AbstractJCRTest {
 
     private static Logger log = LoggerFactory.getLogger(GetPropertyTest.class);
 
+    private String node1Path;
     private String prop1Path;
     private String prop2Path;
 
@@ -39,6 +45,8 @@
         super.setUp();
 
         Node n = testRootNode.addNode(nodeName1, testNodeType);
+        node1Path = n.getPath();
+
         Property p = n.setProperty(propertyName1, "string1");
         prop1Path = p.getPath();
 
@@ -82,4 +90,126 @@
         trn.getProperty(prop1Path.substring(testPath.length() + 1));
         trn.getProperty(prop2Path.substring(testPath.length() + 1));
     }
+
+    public void testGetDeepProperty() throws RepositoryException {
+        Node n2 = testRootNode.getNode(nodeName1).addNode(nodeName2);
+        testRootNode.save();
+
+        // other session directly accesses n2.
+        // consequently n1 is not yet resolved
+        Node node2 = (Node) readOnly.getItem(n2.getPath());
+
+        // now try to access properties below n1 -> should be existing although
+        // n1 has not yet been resolved.
+        assertTrue(readOnly.itemExists(prop1Path));
+        Property p1 = (Property) readOnly.getItem(prop1Path);
+        assertTrue(p1.isSame(node2.getProperty("../" + Text.getName(prop1Path))));
+
+        PropertyIterator it = node2.getParent().getProperties();
+        assertTrue(it.getSize() >= 3);
+    }
+
+    public void testGetExternallyAddedItems() throws RepositoryException {
+        Node node1 = (Node) readOnly.getItem(node1Path);
+
+        Node n2 = testRootNode.getNode(nodeName1).addNode(nodeName2);
+        Property p3 = n2.setProperty(propertyName1, "test");
+        testRootNode.save();
+
+        node1.refresh(true);
+
+        assertTrue(readOnly.itemExists(n2.getPath()));
+        assertTrue(readOnly.itemExists(p3.getPath()));
+    }
+
+    public void testGetDeepSNSProperties() throws RepositoryException, NotExecutableException {
+        Node n = testRootNode.getNode(nodeName1);
+        if (!n.getDefinition().allowsSameNameSiblings()) {
+            throw new NotExecutableException();
+        }
+        Node sib2 = testRootNode.addNode(nodeName1);
+        Property p2 = sib2.setProperty(propertyName1, "sib2-prop");
+
+        Node sib3 = testRootNode.addNode(nodeName1);
+        Property p3 = sib3.setProperty(propertyName1, "sib3-prop");
+        testRootNode.save();
+
+        Session s = helper.getReadWriteSession();
+        try {
+            Node sibNode = (Node) s.getItem(sib2.getPath());
+            sibNode.remove();
+
+            // after transient removal of the sibling2, sibling3 must match its
+            // path -> the property must have the proper value.
+            Property pp3 = (Property) s.getItem(sib2.getPath() + "/" + propertyName1);
+            assertEquals("sib3-prop", pp3.getString());
+
+            // the tree starting with node[3] must not be accessible any more.
+            assertFalse(s.itemExists(p3.getPath()));
+            assertFalse(s.itemExists(sib3.getPath()));
+        } finally {
+            s.logout();
+        }
+    }
+
+    public void testGetDeepRefNodeProperties() throws RepositoryException, NotExecutableException {
+        Node n = testRootNode.getNode(nodeName1);
+        n.addMixin(mixReferenceable);
+        Node n2 = n.addNode(nodeName2);
+        Property p3 = n2.setProperty(propertyName1, "test");
+        testRootNode.save();
+
+        // other session directly accesses p3.
+        // consequently n1 is not yet resolved
+        Property prop3 = (Property) readOnly.getItem(p3.getPath());
+
+        // now try to access properties below n1 -> should be existing although
+        // n1 has not yet been resolved.
+        assertTrue(readOnly.itemExists(prop2Path));
+        Property p1 = (Property) readOnly.getItem(prop2Path);
+
+        Node node1 = readOnly.getNodeByUUID(n.getUUID());
+        assertTrue(p1.isSame(node1.getProperty(Text.getName(prop2Path))));
+    }
+
+    public void testGetPropertyOfRemovedAncestor() throws RepositoryException {
+        Session rw = helper.getReadWriteSession();
+        try {
+            // add modification to a property.
+            Property p = (Property) rw.getItem(prop1Path);
+            p.setValue("changedValue");
+
+            // transiently remove the test root node
+            rw.getItem(testRootNode.getPath()).remove();
+
+            try {
+                p.getValue();
+                fail("modified property must be marked removed upon parent removal");
+            } catch (InvalidItemStateException e) {
+                // success
+            }
+            try {
+                rw.getItem(prop1Path);
+                fail("modified property must be marked removed upon parent removal");
+            } catch (PathNotFoundException e) {
+                // success
+            }
+            try {
+                Property p2 = (Property) rw.getItem(prop2Path);
+                fail("existing property must be marked removed upon parent removal");
+            } catch (PathNotFoundException e) {
+                // success
+            }
+
+            // revert all transient modifications
+            rw.refresh(false);
+            Property pAgain = (Property) rw.getItem(prop1Path);
+
+            // TODO: for generic jsr 170 test: change assert to p.isSame(pAgain)
+            assertSame(p, pAgain);
+            assertEquals("string1", p.getString());
+        } finally {
+            rw.logout();
+        }
+    }
 }
\ No newline at end of file

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/MoveMultipleTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/MoveMultipleTest.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/MoveMultipleTest.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/MoveMultipleTest.java Fri Nov  7 00:52:32 2008
@@ -16,21 +16,15 @@
  */
 package org.apache.jackrabbit.jcr2spi;
 
+import org.apache.jackrabbit.util.Text;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.apache.jackrabbit.util.Text;
 
-import javax.jcr.nodetype.ConstraintViolationException;
-import javax.jcr.nodetype.NoSuchNodeTypeException;
-import javax.jcr.ItemExistsException;
-import javax.jcr.RepositoryException;
-import javax.jcr.Property;
-import javax.jcr.Node;
 import javax.jcr.InvalidItemStateException;
-import javax.jcr.AccessDeniedException;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
 import javax.jcr.Session;
-import javax.jcr.lock.LockException;
-import javax.jcr.version.VersionException;
 
 /**
  * <code>MoveMultipleTest</code>...
@@ -54,7 +48,7 @@
      * Transiently move a persisted node multiple times and check results
      * after each move as well as after saving.
      */
-    public void testMultipleMove() throws RepositoryException, ConstraintViolationException, ItemExistsException, VersionException {
+    public void testMultipleMove() throws RepositoryException {
         // 1. move
         doMove(moveNode.getPath(), destinationPath);
 
@@ -103,7 +97,7 @@
     /**
      * Move a new node multiple times and check the hierarchy after saving.
      */
-    public void testMultipleMoveNewNode() throws RepositoryException, LockException, ConstraintViolationException, VersionException {
+    public void testMultipleMoveNewNode() throws RepositoryException {
         // add additional nodes
         Node moveNode2 = moveNode.addNode(nodeName3, testNodeType);
 
@@ -140,7 +134,7 @@
      * Separately move the persisted 'moveNode' and its transiently added
      * child node.
      */
-    public void testMoveParentAndChild() throws RepositoryException, LockException, ConstraintViolationException, VersionException {
+    public void testMoveParentAndChild() throws RepositoryException {
         // add additional nodes
         Node moveNode2 = moveNode.addNode(nodeName3, testNodeType);
         Property childProperty = moveNode2.setProperty(propertyName2, "anyString");
@@ -175,7 +169,7 @@
     /**
      * Move a node that has a child node and finally revert the 'move' operations.
      */
-    public void testRevertingMoveParentAndChild() throws RepositoryException, LockException, ConstraintViolationException, NoSuchNodeTypeException, ItemExistsException, VersionException {
+    public void testRevertingMoveParentAndChild() throws RepositoryException {
         Node moveNode2 = moveNode.addNode(nodeName3, testNodeType);
         // moveNode2 must be persisted in order not to have it removed upon
         // refresh(false).
@@ -198,7 +192,7 @@
      * Separately move the new 'moveNode' and its child node. Save 'add' and
      * 'move' ops in one step.
      */
-    public void testMoveNewParentAndNewChild() throws RepositoryException, LockException, ConstraintViolationException, VersionException {
+    public void testMoveNewParentAndNewChild() throws RepositoryException {
         Node moveNode2 = moveNode.addNode("moveNode2", testNodeType);
         Property childProperty = moveNode2.setProperty(propertyName2, "anyString");
         Node childNode = moveNode2.addNode("childNode", testNodeType);
@@ -222,7 +216,7 @@
      * Check if reverting the changes removes the 'new' child and moves
      * the persisted moveNode back.
      */
-    public void testRevertingMoveParentAndNewChild() throws RepositoryException, LockException, ConstraintViolationException, NoSuchNodeTypeException, ItemExistsException, VersionException {
+    public void testRevertingMoveParentAndNewChild() throws RepositoryException {
         Node moveNode2 = moveNode.addNode(nodeName3, testNodeType);
 
         doMove(moveNode.getPath(), destinationPath);
@@ -247,7 +241,7 @@
      * Move a node with child items without having loaded the children before.
      * Test if children can be accessed afterwards.
      */
-    public void testAccessChildrenAfterMove() throws RepositoryException, ConstraintViolationException, InvalidItemStateException, AccessDeniedException, NoSuchNodeTypeException, ItemExistsException, VersionException {
+    public void testAccessChildrenAfterMove() throws RepositoryException {
         Property childProperty = moveNode.setProperty(propertyName2, "anyString");
         Node childNode = moveNode.addNode(nodeName2, testNodeType);
         testRootNode.save();

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/MoveTreeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/MoveTreeTest.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/MoveTreeTest.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/MoveTreeTest.java Fri Nov  7 00:52:32 2008
@@ -46,7 +46,6 @@
         assertTrue("Moving a node must move all child items as well.", ancestor.isSame(destParentNode));
         ancestor = grandChildNode.getAncestor(degree);
         assertTrue("Moving a node must move all child items as well.", ancestor.isSame(destParentNode));
-
     }
 
     public void testTreeEntries() throws RepositoryException {
@@ -65,17 +64,40 @@
         } catch (PathNotFoundException e) {
             // ok
         }
+    }
+
+    public void testOldPropertyPath() throws RepositoryException {
         try {
             superuser.getItem(srcPath + "/" + propertyName2);
             fail("Moving a node must move all child items as well.");
         } catch (PathNotFoundException e) {
             // ok
         }
-        try {
-            superuser.getItem(srcPath + "/" + nodeName2 + "/" + nodeName3);
-            fail("Moving a node must move all child items as well.");
-        } catch (PathNotFoundException e) {
-            // ok
+    }
+
+    public void testOldChildPath() throws RepositoryException {
+        for (int i = 0; i < childPaths.size(); i++) {
+            String path = childPaths.get(i).toString();
+            assertFalse(superuser.itemExists(path));
+            try {
+                superuser.getItem(path);
+                fail("Moving a node must move all child items as well.");
+            } catch (PathNotFoundException e) {
+                // ok
+            }
+        }
+    }
+
+    public void testOldChildPropertyPath() throws RepositoryException {
+        for (int i = 0; i < childPaths.size(); i++) {
+            String propPath = childPaths.get(i).toString() + "/" + jcrPrimaryType;
+            assertFalse(superuser.itemExists(propPath));
+            try {
+                superuser.getItem(propPath);
+                fail("Moving a node must move all child items as well.");
+            } catch (PathNotFoundException e) {
+                // ok
+            }
         }
     }
 

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/UpdateTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/UpdateTest.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/UpdateTest.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/UpdateTest.java Fri Nov  7 00:52:32 2008
@@ -16,27 +16,21 @@
  */
 package org.apache.jackrabbit.jcr2spi;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.apache.jackrabbit.test.AbstractJCRTest;
 import org.apache.jackrabbit.test.NotExecutableException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-import javax.jcr.RepositoryException;
-import javax.jcr.NoSuchWorkspaceException;
 import javax.jcr.InvalidItemStateException;
-import javax.jcr.AccessDeniedException;
-import javax.jcr.Node;
 import javax.jcr.ItemNotFoundException;
-import javax.jcr.ItemExistsException;
-import javax.jcr.Session;
-import javax.jcr.Property;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.Node;
 import javax.jcr.PathNotFoundException;
-import javax.jcr.version.VersionException;
-import javax.jcr.nodetype.ConstraintViolationException;
-import javax.jcr.nodetype.NoSuchNodeTypeException;
-import javax.jcr.lock.LockException;
-import java.util.List;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
 import java.util.Arrays;
+import java.util.List;
 
 /**
  * <code>UpdateTest</code>...
@@ -53,7 +47,7 @@
         currentWorkspace = testRootNode.getSession().getWorkspace().getName();
     }
 
-    public void testInvalidSrcWorkspace() throws RepositoryException, InvalidItemStateException, AccessDeniedException {
+    public void testInvalidSrcWorkspace() throws RepositoryException {
         String nonExistingWorkspace = "nonExistingWorkspace";
         String[] accessibleWorkspaces = testRootNode.getSession().getWorkspace().getAccessibleWorkspaceNames();
         List l = Arrays.asList(accessibleWorkspaces);
@@ -68,7 +62,7 @@
         }
     }
 
-    public void testNoCorrespondingNode() throws RepositoryException, InvalidItemStateException, AccessDeniedException, NotExecutableException {
+    public void testNoCorrespondingNode() throws RepositoryException, NotExecutableException {
         Node n = testRootNode.addNode(nodeName2, testNodeType);
         testRootNode.save();
 
@@ -96,7 +90,7 @@
         }
     }
 
-    public void testSameWorkspace() throws RepositoryException, InvalidItemStateException, AccessDeniedException, NotExecutableException {
+    public void testSameWorkspace() throws RepositoryException, NotExecutableException {
         try {
             // update without corresponding node must be a nop
             testRootNode.update(currentWorkspace);
@@ -105,7 +99,7 @@
         }
     }
 
-    public void testPendingChangesSameWorkspace() throws RepositoryException, InvalidItemStateException, AccessDeniedException, NotExecutableException {
+    public void testPendingChangesSameWorkspace() throws RepositoryException, NotExecutableException {
         testRootNode.addNode(nodeName2, testNodeType);
 
         try {
@@ -116,7 +110,7 @@
         }
     }
 
-    public void testPendingChanges() throws RepositoryException, LockException, ConstraintViolationException, NoSuchNodeTypeException, ItemExistsException, VersionException, NotExecutableException {
+    public void testPendingChanges() throws RepositoryException, NotExecutableException {
         testRootNode.addNode(nodeName2, testNodeType);
 
         String srcWorkspace = getAnotherWorkspace();
@@ -128,7 +122,7 @@
         }
     }
 
-    public void testPendingChangesOnOtherNode() throws RepositoryException, LockException, ConstraintViolationException, NoSuchNodeTypeException, ItemExistsException, VersionException, NotExecutableException {
+    public void testPendingChangesOnOtherNode() throws RepositoryException, NotExecutableException {
         try {
         Node root = testRootNode.getSession().getRootNode();
             if (root.isSame(testRootNode)) {



Mime
View raw message