You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by an...@apache.org on 2008/11/07 09:52:46 UTC

svn commit: r712088 [1/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...

Author: angela
Date: Fri Nov  7 00:52:32 2008
New Revision: 712088

URL: http://svn.apache.org/viewvc?rev=712088&view=rev
Log:
1.5: Merged revisions 709211 (JCR-1819, JCR-1843, JCR-1293 and JCR-1811)

Modified:
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManager.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LazyItemIterator.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/PropertyImpl.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntries.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildPropertyEntriesImpl.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntryImpl.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyManager.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyManagerImpl.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/PropertyEntryImpl.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/UniqueIdResolver.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AbstractCopy.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AbstractOperation.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Move.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Remove.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/NodeIteratorImpl.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionImpl.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractMoveTreeTest.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ExternalModificationTest.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/GetPropertyTest.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/MoveMultipleTest.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/MoveTreeTest.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/UpdateTest.java

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java Fri Nov  7 00:52:32 2008
@@ -17,40 +17,39 @@
 package org.apache.jackrabbit.jcr2spi;
 
 import org.apache.commons.collections.map.ReferenceMap;
+import org.apache.jackrabbit.jcr2spi.config.CacheBehaviour;
+import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry;
+import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
+import org.apache.jackrabbit.jcr2spi.operation.Operation;
+import org.apache.jackrabbit.jcr2spi.operation.Remove;
 import org.apache.jackrabbit.jcr2spi.state.ItemState;
-import org.apache.jackrabbit.jcr2spi.state.ItemStateValidator;
 import org.apache.jackrabbit.jcr2spi.state.ItemStateLifeCycleListener;
-import org.apache.jackrabbit.jcr2spi.state.Status;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateValidator;
 import org.apache.jackrabbit.jcr2spi.state.NodeState;
-import org.apache.jackrabbit.jcr2spi.operation.Remove;
-import org.apache.jackrabbit.jcr2spi.operation.Operation;
+import org.apache.jackrabbit.jcr2spi.state.Status;
 import org.apache.jackrabbit.jcr2spi.util.LogUtil;
-import org.apache.jackrabbit.jcr2spi.config.CacheBehaviour;
-import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry;
-import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
-import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.Name;
-import org.slf4j.LoggerFactory;
+import org.apache.jackrabbit.spi.Path;
 import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-import javax.jcr.lock.LockException;
-import javax.jcr.version.VersionException;
-import javax.jcr.nodetype.ConstraintViolationException;
-import javax.jcr.RepositoryException;
-import javax.jcr.ItemNotFoundException;
 import javax.jcr.AccessDeniedException;
+import javax.jcr.InvalidItemStateException;
 import javax.jcr.Item;
+import javax.jcr.ItemNotFoundException;
 import javax.jcr.ItemVisitor;
-import javax.jcr.InvalidItemStateException;
+import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
 import javax.jcr.ReferentialIntegrityException;
 import javax.jcr.Repository;
-import javax.jcr.UnsupportedRepositoryOperationException;
-import javax.jcr.PathNotFoundException;
-import javax.jcr.Node;
+import javax.jcr.RepositoryException;
 import javax.jcr.Session;
-
-import java.util.Map;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.version.VersionException;
 import java.util.Collections;
+import java.util.Map;
 
 /**
  * <code>ItemImpl</code>...
@@ -61,8 +60,9 @@
 
     private ItemState state;
 
-    // protected fields for VersionImpl and VersionHistoryImpl
-    protected ItemManager itemMgr;
+    /**
+     * The session that created this item.
+     */
     protected SessionImpl session;
 
     /**
@@ -70,11 +70,9 @@
      */
     protected final Map listeners = Collections.synchronizedMap(new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK));
 
-    public ItemImpl(ItemManager itemManager, SessionImpl session, ItemState state,
+    public ItemImpl(SessionImpl session, ItemState state,
                     ItemLifeCycleListener[] listeners) {
         this.session = session;
-
-        this.itemMgr = itemManager;
         this.state = state;
 
         if (listeners != null) {
@@ -119,7 +117,11 @@
                 throw new ItemNotFoundException();
             }
             Path ancestorPath = path.getAncestor(relDegree);
-            return itemMgr.getItem(ancestorPath);
+            if (relDegree == 0) {
+                return this;
+            } else {
+                return getItemManager().getNode(ancestorPath);
+            }
         } catch (PathNotFoundException pnfe) {
             throw new ItemNotFoundException();
         }
@@ -139,7 +141,7 @@
         }
 
         NodeEntry parentEntry = getItemState().getHierarchyEntry().getParent();
-        return (Node) itemMgr.getItem(parentEntry);
+        return (Node) getItemManager().getItem(parentEntry);
     }
 
     /**
@@ -315,25 +317,23 @@
              * - Status#EXISTING : modifications reverted or saved
              * - Status#EXISTING_MODIFIED : transient modification
              * - Status#STALE_MODIFIED : external modifications while transient changes pending
+             * - Status#STALE_DESTROYED : external modifications while transient changes pending
              * - Status#MODIFIED : externaly modified -> marker for sessionISM states only
+             * - Status#EXISTING_REMOVED : transient removal
              */
             case Status.EXISTING:
             case Status.EXISTING_MODIFIED:
             case Status.STALE_MODIFIED:
+            case Status.STALE_DESTROYED:
             case Status.MODIFIED:
+            case Status.EXISTING_REMOVED:
                 break;
             /**
              * Notify listeners that this item is transiently or permanently
              * destroyed.
-             * - Status#EXISTING_REMOVED : transient removal
              * - Status#REMOVED : permanent removal. item will never get back to life
-             * - Status#STALE_DESTROYED : permanent removal. item will never get back to life
              */
-            case Status.EXISTING_REMOVED:
-                notifyDestroyed();
-                break;
             case Status.REMOVED:
-            case Status.STALE_DESTROYED:
                 state.removeListener(this);
                 notifyDestroyed();
                 break;
@@ -534,6 +534,15 @@
     }
 
     /**
+     * Returns the ItemManager associated with this item's Session.
+     *
+     * @return ItemManager
+     */
+    protected ItemManager getItemManager() {
+        return session.getItemManager();
+    }
+
+    /**
      * Failsafe conversion of internal <code>Path</code> to JCR path for use in
      * error messages etc.
      *

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManager.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManager.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManager.java Fri Nov  7 00:52:32 2008
@@ -21,12 +21,13 @@
 import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
 
 import javax.jcr.PathNotFoundException;
-import javax.jcr.AccessDeniedException;
 import javax.jcr.RepositoryException;
 import javax.jcr.ItemNotFoundException;
 import javax.jcr.NodeIterator;
 import javax.jcr.PropertyIterator;
 import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.Property;
 
 /**
  * There's one <code>ItemManager</code> instance per <code>Session</code>
@@ -58,12 +59,20 @@
     public void dispose();
 
     /**
-     * Checks if the item with the given path exists.
+     * Checks if the node with the given path exists.
      *
-     * @param path path to the item to be checked
+     * @param path path to the node to be checked
      * @return true if the specified item exists
      */
-    public boolean itemExists(Path path);
+    public boolean nodeExists(Path path);
+
+    /**
+     * Checks if the property with the given path exists.
+     *
+     * @param path path to the property to be checked
+     * @return true if the specified item exists
+     */
+    public boolean propertyExists(Path path);
 
     /**
      * Checks if the item for given HierarchyEntry exists.
@@ -76,66 +85,63 @@
     /**
      *
      * @param path
-     * @return The item for the given path.
-     * @throws javax.jcr.PathNotFoundException
-     * @throws javax.jcr.AccessDeniedException
-     * @throws javax.jcr.RepositoryException
+     * @return
+     * @throws PathNotFoundException
+     * @throws RepositoryException
+     */
+    public Node getNode(Path path) throws PathNotFoundException, RepositoryException;
+
+    /**
+     *
+     * @param path
+     * @return
+     * @throws PathNotFoundException
+     * @throws RepositoryException
      */
-    public Item getItem(Path path)
-        throws PathNotFoundException, AccessDeniedException, RepositoryException;
+    public Property getProperty(Path path) throws PathNotFoundException, RepositoryException;
 
     /**
      *
      * @param hierarchyEntry
      * @return
      * @throws ItemNotFoundException
-     * @throws AccessDeniedException
      * @throws RepositoryException
      */
-    public Item getItem(HierarchyEntry hierarchyEntry)
-        throws ItemNotFoundException, AccessDeniedException, RepositoryException;
+    public Item getItem(HierarchyEntry hierarchyEntry) throws ItemNotFoundException, RepositoryException;
 
     /**
      *
      * @param parentEntry
      * @return
      * @throws ItemNotFoundException
-     * @throws AccessDeniedException
      * @throws RepositoryException
      */
-    public boolean hasChildNodes(NodeEntry parentEntry)
-        throws ItemNotFoundException, AccessDeniedException, RepositoryException;
+    public boolean hasChildNodes(NodeEntry parentEntry) throws ItemNotFoundException, RepositoryException;
 
     /**
      *
      * @param parentEntry
      * @return
      * @throws ItemNotFoundException
-     * @throws AccessDeniedException
      * @throws RepositoryException
      */
-    public NodeIterator getChildNodes(NodeEntry parentEntry)
-        throws ItemNotFoundException, AccessDeniedException, RepositoryException;
+    public NodeIterator getChildNodes(NodeEntry parentEntry) throws ItemNotFoundException, RepositoryException;
 
     /**
      *
      * @param parentEntry
      * @return
      * @throws ItemNotFoundException
-     * @throws AccessDeniedException
      * @throws RepositoryException
      */
-    public boolean hasChildProperties(NodeEntry parentEntry)
-            throws ItemNotFoundException, AccessDeniedException, RepositoryException;
+    public boolean hasChildProperties(NodeEntry parentEntry) throws ItemNotFoundException, RepositoryException;
 
     /**
      *
      * @param parentEntry
      * @return
      * @throws ItemNotFoundException
-     * @throws AccessDeniedException
      * @throws RepositoryException
      */
-    public PropertyIterator getChildProperties(NodeEntry parentEntry)
-            throws ItemNotFoundException, AccessDeniedException, RepositoryException;
+    public PropertyIterator getChildProperties(NodeEntry parentEntry) throws ItemNotFoundException, RepositoryException;
 }

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java Fri Nov  7 00:52:32 2008
@@ -16,14 +16,15 @@
  */
 package org.apache.jackrabbit.jcr2spi;
 
-import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyManager;
 import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry;
+import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyManager;
 import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
 import org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry;
 import org.apache.jackrabbit.jcr2spi.state.ItemState;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateCreationListener;
 import org.apache.jackrabbit.jcr2spi.state.NodeState;
 import org.apache.jackrabbit.jcr2spi.state.PropertyState;
-import org.apache.jackrabbit.jcr2spi.state.ItemStateCreationListener;
+import org.apache.jackrabbit.jcr2spi.state.Status;
 import org.apache.jackrabbit.jcr2spi.util.Dumpable;
 import org.apache.jackrabbit.jcr2spi.util.LogUtil;
 import org.apache.jackrabbit.jcr2spi.version.VersionHistoryImpl;
@@ -31,16 +32,17 @@
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
-import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-import javax.jcr.AccessDeniedException;
+import javax.jcr.Item;
 import javax.jcr.ItemNotFoundException;
+import javax.jcr.Node;
 import javax.jcr.NodeIterator;
 import javax.jcr.PathNotFoundException;
+import javax.jcr.Property;
 import javax.jcr.PropertyIterator;
 import javax.jcr.RepositoryException;
-import javax.jcr.Item;
 import javax.jcr.Workspace;
 import java.io.PrintStream;
 import java.util.Iterator;
@@ -100,13 +102,30 @@
     }
 
     /**
-     * @see ItemManager#itemExists(Path)
+     * @see ItemManager#nodeExists(Path)
+     */
+    public boolean nodeExists(Path path) {
+        try {
+            // session-sanity & permissions are checked upon itemExists(ItemState)
+            NodeState nodeState = hierMgr.getNodeState(path);
+            return itemExists(nodeState);
+        } catch (PathNotFoundException pnfe) {
+            return false;
+        } catch (ItemNotFoundException infe) {
+            return false;
+        } catch (RepositoryException re) {
+            return false;
+        }
+    }
+
+    /**
+     * @see ItemManager#propertyExists(Path)
      */
-    public boolean itemExists(Path path) {
+    public boolean propertyExists(Path path) {
         try {
             // session-sanity & permissions are checked upon itemExists(ItemState)
-            ItemState itemState = hierMgr.getItemState(path);
-            return itemExists(itemState);
+            PropertyState propState = hierMgr.getPropertyState(path);
+            return itemExists(propState);
         } catch (PathNotFoundException pnfe) {
             return false;
         } catch (ItemNotFoundException infe) {
@@ -151,49 +170,48 @@
     }
 
     /**
-     * @see ItemManager#getItem(Path)
+     * @see ItemManager#getNode(Path)
      */
-    public synchronized Item getItem(Path path)
-            throws PathNotFoundException, AccessDeniedException, RepositoryException {
-        HierarchyEntry itemEntry = hierMgr.getHierarchyEntry(path);
+    public synchronized Node getNode(Path path) throws PathNotFoundException, RepositoryException {
+        NodeEntry nodeEntry = hierMgr.getNodeEntry(path);
         try {
-            return getItem(itemEntry);
+            return (Node) getItem(nodeEntry);
         } catch (ItemNotFoundException infe) {
             throw new PathNotFoundException(LogUtil.safeGetJCRPath(path, session.getPathResolver()));
         }
     }
 
     /**
-     * @see ItemManager#getItem(HierarchyEntry)
+     * @see ItemManager#getProperty(Path)
      */
-    public Item getItem(HierarchyEntry hierarchyEntry) throws ItemNotFoundException, AccessDeniedException, RepositoryException {
-        ItemState itemState = hierarchyEntry.getItemState();
-        return getItem(itemState);
+    public synchronized Property getProperty(Path path) throws PathNotFoundException, RepositoryException {
+        PropertyEntry propertyEntry = hierMgr.getPropertyEntry(path);
+        try {
+            return (Property) getItem(propertyEntry);
+        } catch (ItemNotFoundException infe) {
+            throw new PathNotFoundException(LogUtil.safeGetJCRPath(path, session.getPathResolver()));
+        }
     }
 
     /**
-     *
-     * @param itemState
-     * @return
-     * @throws ItemNotFoundException
-     * @throws AccessDeniedException
-     * @throws RepositoryException
+     * @see ItemManager#getItem(HierarchyEntry)
      */
-    private Item getItem(ItemState itemState) throws ItemNotFoundException, AccessDeniedException, RepositoryException {
+    public Item getItem(HierarchyEntry hierarchyEntry) throws ItemNotFoundException, RepositoryException {
         session.checkIsAlive();
-        if (!itemState.isValid()) {
+        ItemState state = hierarchyEntry.getItemState();
+        if (!state.isValid()) {
             throw new ItemNotFoundException();
         }
 
         // first try to access item from cache
-        Item item = itemCache.getItem(itemState);
+        Item item = itemCache.getItem(state);
         // not yet in cache, need to create instance
         if (item == null) {
             // create instance of item
-            if (itemState.isNode()) {
-                item = createNodeInstance((NodeState) itemState);
+            if (hierarchyEntry.denotesNode()) {
+                item = createNodeInstance((NodeState) state);
             } else {
-                item = createPropertyInstance((PropertyState) itemState);
+                item = createPropertyInstance((PropertyState) state);
             }
         }
         return item;
@@ -203,7 +221,7 @@
      * @see ItemManager#hasChildNodes(NodeEntry)
      */
     public synchronized boolean hasChildNodes(NodeEntry parentEntry)
-            throws ItemNotFoundException, AccessDeniedException, RepositoryException {
+            throws ItemNotFoundException, RepositoryException {
         // check sanity of session
         session.checkIsAlive();
 
@@ -226,7 +244,7 @@
      * @see ItemManager#getChildNodes(NodeEntry)
      */
     public synchronized NodeIterator getChildNodes(NodeEntry parentEntry)
-            throws ItemNotFoundException, AccessDeniedException, RepositoryException {
+            throws ItemNotFoundException, RepositoryException {
         // check sanity of session
         session.checkIsAlive();
 
@@ -238,7 +256,7 @@
      * @see ItemManager#hasChildProperties(NodeEntry)
      */
     public synchronized boolean hasChildProperties(NodeEntry parentEntry)
-            throws ItemNotFoundException, AccessDeniedException, RepositoryException {
+            throws ItemNotFoundException, RepositoryException {
         // check sanity of session
         session.checkIsAlive();
 
@@ -261,7 +279,7 @@
      * @see ItemManager#getChildProperties(NodeEntry)
      */
     public synchronized PropertyIterator getChildProperties(NodeEntry parentEntry)
-            throws ItemNotFoundException, AccessDeniedException, RepositoryException {
+            throws ItemNotFoundException, RepositoryException {
         // check sanity of session
         session.checkIsAlive();
 
@@ -300,13 +318,13 @@
         Name ntName = state.getNodeTypeName();
         if (NameConstants.NT_VERSION.equals(ntName)) {
             // version
-            return new VersionImpl(this, session, state, listeners);
+            return new VersionImpl(session, state, listeners);
         } else if (NameConstants.NT_VERSIONHISTORY.equals(ntName)) {
             // version-history
-            return new VersionHistoryImpl(this, session, state, listeners);
+            return new VersionHistoryImpl(session, state, listeners);
         } else {
             // create common node object
-            return new NodeImpl(this, session, state, listeners);
+            return new NodeImpl(session, state, listeners);
         }
     }
 
@@ -319,7 +337,7 @@
         // in order to maintain item cache consistency
         ItemLifeCycleListener[] listeners = new ItemLifeCycleListener[]{itemCache};
         // create property object
-        PropertyImpl prop = new PropertyImpl(this, session, state, listeners);
+        PropertyImpl prop = new PropertyImpl(session, state, listeners);
         return prop;
     }
 
@@ -342,7 +360,11 @@
     }
 
     public void statusChanged(ItemState state, int previousStatus) {
-        // nothing to do -> Item is listening to status changes and forces
-        // cleanup of cache entries through it's own status changes.
+        // stop listening if an state reached Status.REMOVED.
+        if (Status.REMOVED == state.getStatus()) {
+            state.removeListener(this);
+        }
+        // otherwise: nothing to do -> Item is listening to status changes and
+        // forces cleanup of cache entries through it's own status changes.
     }
 }

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LazyItemIterator.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LazyItemIterator.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LazyItemIterator.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LazyItemIterator.java Fri Nov  7 00:52:32 2008
@@ -21,6 +21,8 @@
 import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry;
 import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyManager;
 import org.apache.jackrabbit.spi.ItemId;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.PropertyId;
 
 import javax.jcr.NodeIterator;
 import javax.jcr.PropertyIterator;
@@ -106,7 +108,13 @@
         List entries = new ArrayList();
         while (itemIds.hasNext()) {
             ItemId id = (ItemId) itemIds.next();
-            entries.add(hierarchyMgr.getHierarchyEntry(id));
+            HierarchyEntry entry;
+            if (id.denotesNode()) {
+                entry = hierarchyMgr.getNodeEntry((NodeId) id);
+            } else {
+                entry = hierarchyMgr.getPropertyEntry((PropertyId) id);
+            }
+            entries.add(entry);
         }
         iter = entries.iterator();
         size = entries.size();

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java Fri Nov  7 00:52:32 2008
@@ -16,72 +16,71 @@
  */
 package org.apache.jackrabbit.jcr2spi;
 
-import org.apache.jackrabbit.util.ChildrenCollectorFilter;
-import org.apache.jackrabbit.value.ValueHelper;
-import org.apache.jackrabbit.spi.commons.value.ValueFormat;
 import org.apache.jackrabbit.commons.iterator.NodeIteratorAdapter;
 import org.apache.jackrabbit.commons.iterator.PropertyIteratorAdapter;
-import org.apache.jackrabbit.spi.commons.conversion.NameException;
-import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.spi.Path;
-import org.apache.jackrabbit.jcr2spi.state.NodeState;
-import org.apache.jackrabbit.jcr2spi.state.ItemStateValidator;
-import org.apache.jackrabbit.jcr2spi.state.Status;
-import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeManagerImpl;
+import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
+import org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry;
+import org.apache.jackrabbit.jcr2spi.lock.LockManager;
 import org.apache.jackrabbit.jcr2spi.nodetype.EffectiveNodeType;
 import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeImpl;
-import org.apache.jackrabbit.jcr2spi.operation.SetMixin;
-import org.apache.jackrabbit.jcr2spi.operation.AddProperty;
+import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeManagerImpl;
 import org.apache.jackrabbit.jcr2spi.operation.AddNode;
-import org.apache.jackrabbit.jcr2spi.operation.ReorderNodes;
+import org.apache.jackrabbit.jcr2spi.operation.AddProperty;
 import org.apache.jackrabbit.jcr2spi.operation.Operation;
+import org.apache.jackrabbit.jcr2spi.operation.ReorderNodes;
+import org.apache.jackrabbit.jcr2spi.operation.SetMixin;
 import org.apache.jackrabbit.jcr2spi.operation.Update;
-import org.apache.jackrabbit.jcr2spi.lock.LockManager;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateValidator;
+import org.apache.jackrabbit.jcr2spi.state.NodeState;
+import org.apache.jackrabbit.jcr2spi.state.Status;
+import org.apache.jackrabbit.jcr2spi.state.ItemState;
 import org.apache.jackrabbit.jcr2spi.util.LogUtil;
 import org.apache.jackrabbit.jcr2spi.util.StateUtility;
-import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
-import org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry;
-import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry;
-import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.Name;
+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.NameException;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
+import org.apache.jackrabbit.spi.commons.value.ValueFormat;
+import org.apache.jackrabbit.util.ChildrenCollectorFilter;
+import org.apache.jackrabbit.value.ValueHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.jcr.AccessDeniedException;
+import javax.jcr.InvalidItemStateException;
 import javax.jcr.Item;
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
+import javax.jcr.ItemExistsException;
 import javax.jcr.ItemNotFoundException;
-import javax.jcr.AccessDeniedException;
 import javax.jcr.ItemVisitor;
-import javax.jcr.ItemExistsException;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
 import javax.jcr.PathNotFoundException;
+import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
 import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.Value;
 import javax.jcr.ValueFormatException;
-import javax.jcr.PropertyType;
-import javax.jcr.NodeIterator;
-import javax.jcr.PropertyIterator;
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.lock.Lock;
+import javax.jcr.lock.LockException;
 import javax.jcr.nodetype.ConstraintViolationException;
-import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.nodetype.NodeDefinition;
-import javax.jcr.lock.LockException;
-import javax.jcr.lock.Lock;
-import javax.jcr.version.VersionException;
+import javax.jcr.nodetype.NodeType;
 import javax.jcr.version.Version;
+import javax.jcr.version.VersionException;
 import javax.jcr.version.VersionHistory;
-
 import java.io.InputStream;
-import java.util.Calendar;
 import java.util.ArrayList;
-import java.util.List;
 import java.util.Arrays;
+import java.util.Calendar;
 import java.util.Iterator;
+import java.util.List;
 
 /**
  * <code>NodeImpl</code>...
@@ -92,9 +91,8 @@
 
     private Name primaryTypeName;
 
-    protected NodeImpl(ItemManager itemMgr, SessionImpl session,
-                       NodeState state, ItemLifeCycleListener[] listeners) {
-        super(itemMgr, session, state, listeners);
+    protected NodeImpl(SessionImpl session, NodeState state, ItemLifeCycleListener[] listeners) {
+        super(session, state, listeners);
         Name nodeTypeName = state.getNodeTypeName();
         // make sure the nodetype name is valid
         if (session.getNodeTypeManager().hasNodeType(nodeTypeName)) {
@@ -153,30 +151,28 @@
     public Node addNode(String relPath, String primaryNodeTypeName) throws ItemExistsException, PathNotFoundException, NoSuchNodeTypeException, LockException, VersionException, ConstraintViolationException, RepositoryException {
         checkIsWritable();
         // 1. build qualified path and retrieve parent node
-        Path nodePath = getQPath(relPath);
+        Path nodePath = getQPath(relPath).getNormalizedPath();
         if (nodePath.getNameElement().getIndex() != Path.INDEX_UNDEFINED) {
             String msg = "Illegal subscript specified: " + relPath;
             log.debug(msg);
             throw new RepositoryException(msg);
         }
-        Path parentPath = nodePath.getAncestor(1);
+
         NodeImpl parentNode;
-        try {
-            Item parent = itemMgr.getItem(parentPath);
-            if (!parent.isNode()) {
+        if (nodePath.getLength() == 1) {
+            parentNode = this;
+        } else {
+            Path parentPath = nodePath.getAncestor(1);
+            ItemManager itemMgr = getItemManager();
+            if (itemMgr.nodeExists(parentPath)) {
+                parentNode = (NodeImpl) itemMgr.getNode(parentPath);
+            } else if (itemMgr.propertyExists(parentPath)) {
                 String msg = "Cannot add a node to property " + LogUtil.safeGetJCRPath(parentPath, session.getPathResolver());
                 log.debug(msg);
                 throw new ConstraintViolationException(msg);
-            } else if (!(parent instanceof NodeImpl)) {
-                // should never occur
-                String msg = "Incompatible Node object: " + parent + "(" + safeGetJCRPath() + ")";
-                log.debug(msg);
-                throw new RepositoryException(msg);
             } else {
-                parentNode = (NodeImpl) parent;
+                throw new PathNotFoundException("Cannot add a new node to a non-existing parent at " + LogUtil.safeGetJCRPath(parentPath, session.getPathResolver()));
             }
-        } catch (AccessDeniedException ade) {
-            throw new PathNotFoundException(relPath);
         }
 
         // 2. get qualified names for node and nt
@@ -401,7 +397,7 @@
             throw new PathNotFoundException(relPath);
         }
         try {
-            return (Node) itemMgr.getItem(nodeEntry);
+            return (Node) getItemManager().getItem(nodeEntry);
         } catch (ItemNotFoundException e) {
             throw new PathNotFoundException(relPath, e);
         }
@@ -415,7 +411,7 @@
         // NOTE: Don't use a class derived from TraversingElementVisitor to traverse
         // the child nodes because this would lead to an infinite recursion.
         try {
-            return itemMgr.getChildNodes(getNodeEntry());
+            return getItemManager().getChildNodes(getNodeEntry());
         } catch (ItemNotFoundException infe) {
             String msg = "Failed to list the child nodes of " + safeGetJCRPath();
             log.debug(msg);
@@ -448,7 +444,7 @@
             throw new PathNotFoundException(relPath);
         }
         try {
-            return (Property) itemMgr.getItem(entry);
+            return (Property) getItemManager().getItem(entry);
         } catch (AccessDeniedException e) {
             throw new PathNotFoundException(relPath);
         } catch (ItemNotFoundException e) {
@@ -462,7 +458,7 @@
     public PropertyIterator getProperties() throws RepositoryException {
         checkStatus();
         try {
-            return itemMgr.getChildProperties(getNodeEntry());
+            return getItemManager().getChildProperties(getNodeEntry());
         } catch (ItemNotFoundException infe) {
             String msg = "Failed to list the child properties of " + getPath();
             log.debug(msg);
@@ -534,7 +530,7 @@
     public PropertyIterator getReferences() throws RepositoryException {
         checkStatus();
         List refs = Arrays.asList(getNodeState().getNodeReferences());
-        return new LazyItemIterator(itemMgr, session.getHierarchyManager(), refs.iterator());
+        return new LazyItemIterator(getItemManager(), session.getHierarchyManager(), refs.iterator());
     }
 
     /**
@@ -543,7 +539,7 @@
     public boolean hasNode(String relPath) throws RepositoryException {
         checkStatus();
         NodeEntry nodeEntry = resolveRelativeNodePath(relPath);
-        return (nodeEntry != null) && itemMgr.itemExists(nodeEntry);
+        return (nodeEntry != null) && getItemManager().itemExists(nodeEntry);
     }
 
     /**
@@ -552,7 +548,7 @@
     public boolean hasProperty(String relPath) throws RepositoryException {
         checkStatus();
         PropertyEntry childEntry = resolveRelativePropertyPath(relPath);
-        return (childEntry != null) && itemMgr.itemExists(childEntry);
+        return (childEntry != null) && getItemManager().itemExists(childEntry);
     }
 
     /**
@@ -571,7 +567,7 @@
      */
     public boolean hasNodes() throws RepositoryException {
         checkStatus();
-        return itemMgr.hasChildNodes(getNodeEntry());
+        return getItemManager().hasChildNodes(getNodeEntry());
     }
 
     /**
@@ -579,7 +575,7 @@
      */
     public boolean hasProperties() throws RepositoryException {
         checkStatus();
-        return itemMgr.hasChildProperties(getNodeEntry());
+        return getItemManager().hasChildProperties(getNodeEntry());
     }
 
     /**
@@ -755,7 +751,7 @@
         checkIsLocked();
         if (isCheckedOut()) {
             NodeEntry newVersion = session.getVersionManager().checkin(getNodeState());
-            return (Version) itemMgr.getItem(newVersion);
+            return (Version) getItemManager().getItem(newVersion);
         } else {
             // nothing to do
             log.debug("Node " + safeGetJCRPath() + " is already checked in.");
@@ -870,7 +866,7 @@
         session.checkAccessibleWorkspace(srcWorkspace);
 
         Iterator failedIds = session.getVersionManager().merge(getNodeState(), srcWorkspace, bestEffort);
-        return new LazyItemIterator(itemMgr, session.getHierarchyManager(), failedIds);
+        return new LazyItemIterator(getItemManager(), session.getHierarchyManager(), failedIds);
     }
 
     /**
@@ -895,7 +891,7 @@
             // otherwise access referenceable ancestor and calcuate correspond. path.
             String correspondingPath;
             if (referenceableNode.getDepth() == Path.ROOT_DEPTH) {
-                if (!srcSession.getItemManager().itemExists(getQPath())) {
+                if (!srcSession.getItemManager().nodeExists(getQPath())) {
                     throw new ItemNotFoundException("No corresponding path found in workspace " + workspaceName + "(" + safeGetJCRPath() + ")");
                 } else {
                     correspondingPath = getPath();
@@ -970,17 +966,16 @@
             // node at 'relPath' does not yet exist -> build the NodeId
             Path nPath = getQPath(relPath);
             Path parentPath = nPath.getAncestor(1);
-            if (itemMgr.itemExists(parentPath)) {
-                Item parent = itemMgr.getItem(parentPath);
-                if (parent.isNode()) {
-                    Path relQPath = parentPath.computeRelativePath(nPath);
-                    NodeImpl parentNode = ((NodeImpl)parent);
-                    // call the restore
-                    restore(parentNode, relQPath, version, removeExisting);
-                } else {
-                    // the item at parentParentPath is Property
-                    throw new ConstraintViolationException("Cannot restore to a parent presenting a property (relative path = '" + relPath + "'");
-                }
+            ItemManager itemMgr = getItemManager();
+            if (itemMgr.nodeExists(parentPath)) {
+                Node parent = itemMgr.getNode(parentPath);
+                Path relQPath = parentPath.computeRelativePath(nPath);
+                NodeImpl parentNode = ((NodeImpl)parent);
+                // call the restore
+                restore(parentNode, relQPath, version, removeExisting);
+            } else if (itemMgr.propertyExists(parentPath)) {
+                // the item at parentParentPath is Property
+                throw new ConstraintViolationException("Cannot restore to a parent presenting a property (relative path = '" + relPath + "'");
             } else {
                 // although the node itself must not exist, is direct ancestor must.
                 throw new PathNotFoundException("Cannot restore to relative path '" + relPath + ": Ancestor does not exist.");
@@ -1273,7 +1268,8 @@
 
         // finally retrieve the new node
         List addedStates = ((AddNode) an).getAddedStates();
-        return (Node) itemMgr.getItem(((NodeState) addedStates.get(0)).getHierarchyEntry());
+        ItemState nState = (ItemState) addedStates.get(0);
+        return (Node) getItemManager().getItem(nState.getHierarchyEntry());
     }
 
     /**
@@ -1291,7 +1287,7 @@
             if (pEntry == null) {
                 throw new PathNotFoundException(qName.toString());
             }
-            return (Property) itemMgr.getItem(pEntry);
+            return (Property) getItemManager().getItem(pEntry);
         } catch (AccessDeniedException e) {
             throw new PathNotFoundException(qName.toString());
         }
@@ -1539,10 +1535,7 @@
             } else {
                 // rp length > 1
                 Path p = getQPath(rp);
-                HierarchyEntry entry = session.getHierarchyManager().getHierarchyEntry(p.getCanonicalPath());
-                if (entry.denotesNode()) {
-                    targetEntry = (NodeEntry) entry;
-                } // else:  not a node
+                targetEntry = session.getHierarchyManager().getNodeEntry(p.getCanonicalPath());
             }
         } catch (PathNotFoundException e) {
             // item does not exist -> ignore and return null
@@ -1581,10 +1574,7 @@
                 // build and resolve absolute path
                 Path p = getQPath(rp).getCanonicalPath();
                 try {
-                    HierarchyEntry entry = session.getHierarchyManager().getHierarchyEntry(p);
-                    if (!entry.denotesNode()) {
-                        targetEntry = (PropertyEntry) entry;
-                    } // else: not a property
+                    targetEntry = session.getHierarchyManager().getPropertyEntry(p);
                 } catch (PathNotFoundException e) {
                     // ignore -> return null;
                 }

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/PropertyImpl.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/PropertyImpl.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/PropertyImpl.java Fri Nov  7 00:52:32 2008
@@ -53,9 +53,8 @@
 
     public static final int UNDEFINED_PROPERTY_LENGTH = -1;
 
-    public PropertyImpl(ItemManagerImpl itemManager, SessionImpl session,
-                        PropertyState state, ItemLifeCycleListener[] listeners) {
-        super(itemManager, session, state, listeners);
+    public PropertyImpl(SessionImpl session, PropertyState state, ItemLifeCycleListener[] listeners) {
+        super(session, state, listeners);
         // value will be read (and converted from qualified value) on demand.
     }
 

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java Fri Nov  7 00:52:32 2008
@@ -16,48 +16,48 @@
  */
 package org.apache.jackrabbit.jcr2spi;
 
+import org.apache.commons.collections.map.ReferenceMap;
 import org.apache.jackrabbit.commons.AbstractSession;
+import org.apache.jackrabbit.jcr2spi.config.CacheBehaviour;
+import org.apache.jackrabbit.jcr2spi.config.RepositoryConfig;
+import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry;
 import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyManager;
 import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
-import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry;
-import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeManagerImpl;
-import org.apache.jackrabbit.jcr2spi.nodetype.ItemDefinitionProvider;
+import org.apache.jackrabbit.jcr2spi.lock.LockManager;
 import org.apache.jackrabbit.jcr2spi.nodetype.EffectiveNodeTypeProvider;
+import org.apache.jackrabbit.jcr2spi.nodetype.ItemDefinitionProvider;
+import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeManagerImpl;
+import org.apache.jackrabbit.jcr2spi.operation.Move;
+import org.apache.jackrabbit.jcr2spi.operation.Operation;
 import org.apache.jackrabbit.jcr2spi.security.AccessManager;
-import org.apache.jackrabbit.jcr2spi.state.SessionItemStateManager;
-import org.apache.jackrabbit.jcr2spi.state.UpdatableItemStateManager;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateFactory;
 import org.apache.jackrabbit.jcr2spi.state.ItemStateValidator;
-import org.apache.jackrabbit.jcr2spi.state.ItemState;
 import org.apache.jackrabbit.jcr2spi.state.NodeState;
-import org.apache.jackrabbit.jcr2spi.state.ItemStateFactory;
+import org.apache.jackrabbit.jcr2spi.state.PropertyState;
+import org.apache.jackrabbit.jcr2spi.state.SessionItemStateManager;
+import org.apache.jackrabbit.jcr2spi.state.UpdatableItemStateManager;
+import org.apache.jackrabbit.jcr2spi.version.VersionManager;
 import org.apache.jackrabbit.jcr2spi.xml.ImportHandler;
-import org.apache.jackrabbit.jcr2spi.xml.SessionImporter;
 import org.apache.jackrabbit.jcr2spi.xml.Importer;
-import org.apache.jackrabbit.jcr2spi.lock.LockManager;
-import org.apache.jackrabbit.jcr2spi.version.VersionManager;
-import org.apache.jackrabbit.jcr2spi.operation.Move;
-import org.apache.jackrabbit.jcr2spi.operation.Operation;
-import org.apache.jackrabbit.jcr2spi.config.RepositoryConfig;
-import org.apache.jackrabbit.jcr2spi.config.CacheBehaviour;
-import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
-import org.apache.jackrabbit.spi.Path;
-import org.apache.jackrabbit.spi.commons.name.NameConstants;
-import org.apache.jackrabbit.spi.SessionInfo;
-import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.jcr2spi.xml.SessionImporter;
 import org.apache.jackrabbit.spi.IdFactory;
-import org.apache.jackrabbit.spi.XASessionInfo;
-import org.apache.jackrabbit.spi.QValueFactory;
 import org.apache.jackrabbit.spi.NameFactory;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.PathFactory;
-import org.apache.jackrabbit.spi.commons.value.ValueFactoryQImpl;
-import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.jackrabbit.spi.SessionInfo;
+import org.apache.jackrabbit.spi.XASessionInfo;
+import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
 import org.apache.jackrabbit.spi.commons.conversion.NameException;
-import org.apache.jackrabbit.spi.commons.conversion.PathResolver;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.conversion.NameResolver;
-import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
-import org.apache.commons.collections.map.ReferenceMap;
-import org.slf4j.LoggerFactory;
+import org.apache.jackrabbit.spi.commons.conversion.PathResolver;
+import org.apache.jackrabbit.spi.commons.name.NameConstants;
+import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
+import org.apache.jackrabbit.spi.commons.value.ValueFactoryQImpl;
 import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
@@ -82,12 +82,11 @@
 import javax.jcr.Workspace;
 import javax.jcr.lock.LockException;
 import javax.jcr.nodetype.ConstraintViolationException;
-import javax.jcr.version.VersionException;
 import javax.jcr.version.Version;
-import javax.xml.parsers.SAXParserFactory;
-import javax.xml.parsers.SAXParser;
+import javax.jcr.version.VersionException;
 import javax.xml.parsers.ParserConfigurationException;
-
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
 import java.io.IOException;
 import java.io.InputStream;
 import java.security.AccessControlException;
@@ -248,8 +247,8 @@
         // check sanity of this session
         checkIsAlive();
         try {
-            HierarchyEntry hierarchyEntry = getHierarchyManager().getHierarchyEntry(id);
-            Item item = getItemManager().getItem(hierarchyEntry);
+            NodeEntry nodeEntry = getHierarchyManager().getNodeEntry(id);
+            Item item = getItemManager().getItem(nodeEntry);
             if (item.isNode()) {
                 return (Node) item;
             } else {
@@ -267,8 +266,13 @@
     public Item getItem(String absPath) throws PathNotFoundException, RepositoryException {
         checkIsAlive();
         try {
-            Path qPath = getQPath(absPath);
-            return getItemManager().getItem(qPath.getNormalizedPath());
+            Path qPath = getQPath(absPath).getNormalizedPath();
+            ItemManager itemMgr = getItemManager();
+            if (itemMgr.nodeExists(qPath)) {
+                return itemMgr.getNode(qPath);
+            } else {
+                return itemMgr.getProperty(qPath);
+            }
         } catch (AccessDeniedException ade) {
             throw new PathNotFoundException(absPath);
         }
@@ -279,8 +283,9 @@
      */
     public boolean itemExists(String absPath) throws RepositoryException {
         checkIsAlive();
-        Path qPath = getQPath(absPath);
-        return getItemManager().itemExists(qPath.getNormalizedPath());
+        Path qPath = getQPath(absPath).getNormalizedPath();
+        ItemManager itemMgr = getItemManager();
+        return (itemMgr.nodeExists(qPath)) ? true : itemMgr.propertyExists(qPath);
     }
 
     /**
@@ -346,19 +351,19 @@
 
         boolean isGranted;
         // The given abs-path may point to a non-existing item
-        if (itemExists(absPath)) {
-            ItemState itemState = getHierarchyManager().getItemState(targetPath);
-            isGranted = getAccessManager().isGranted(itemState, actionsArr);
+        if (itemManager.nodeExists(targetPath)) {
+            NodeState nState = getHierarchyManager().getNodeState(targetPath);
+            isGranted = getAccessManager().isGranted(nState, actionsArr);
+        } else if (itemManager.propertyExists(targetPath)) {
+            PropertyState pState = getHierarchyManager().getPropertyState(targetPath);
+            isGranted = getAccessManager().isGranted(pState, actionsArr);
         } else {
             NodeState parentState = null;
             Path parentPath = targetPath;
             while (parentState == null) {
                 parentPath = parentPath.getAncestor(1);
-                if (itemManager.itemExists(parentPath)) {
-                    ItemState itemState = getHierarchyManager().getItemState(parentPath);
-                    if (itemState.isNode()) {
-                        parentState = (NodeState) itemState;
-                    }
+                if (itemManager.nodeExists(parentPath)) {
+                    parentState = getHierarchyManager().getNodeState(parentPath);
                 }
             }
             // parentState is the nearest existing nodeState or the root state.
@@ -738,9 +743,9 @@
      * @return the NodeState associated with the specified version.
      */
     NodeState getVersionState(Version version) throws RepositoryException {
-        ItemState itemState;
+        NodeState nodeState;
         if (version.getSession() == this) {
-            itemState = ((NodeImpl) version).getItemState();
+            nodeState = (NodeState) ((NodeImpl) version).getItemState();
         } else {
             Path p = getQPath(version.getPath());
             Path parentPath = p.getAncestor(1);
@@ -749,9 +754,9 @@
                 // make sure the parent entry is up to date
                 parentEntry.invalidate(false);
             }
-            itemState = getHierarchyManager().getItemState(p);
+            nodeState = getHierarchyManager().getNodeState(p);
         }
-        return (NodeState) itemState;
+        return nodeState;
     }
     //------------------------------------------------------< check methods >---
     /**

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java Fri Nov  7 00:52:32 2008
@@ -16,67 +16,66 @@
  */
 package org.apache.jackrabbit.jcr2spi;
 
+import org.apache.jackrabbit.jcr2spi.config.CacheBehaviour;
+import org.apache.jackrabbit.jcr2spi.config.RepositoryConfig;
 import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyManager;
-import org.apache.jackrabbit.jcr2spi.state.UpdatableItemStateManager;
-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.ItemStateFactory;
-import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeRegistry;
-import org.apache.jackrabbit.jcr2spi.nodetype.ItemDefinitionProvider;
+import org.apache.jackrabbit.jcr2spi.lock.LockManager;
+import org.apache.jackrabbit.jcr2spi.lock.LockManagerImpl;
 import org.apache.jackrabbit.jcr2spi.nodetype.EffectiveNodeTypeProvider;
-import org.apache.jackrabbit.jcr2spi.query.QueryManagerImpl;
-import org.apache.jackrabbit.jcr2spi.operation.Move;
-import org.apache.jackrabbit.jcr2spi.operation.Copy;
+import org.apache.jackrabbit.jcr2spi.nodetype.ItemDefinitionProvider;
+import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeRegistry;
+import org.apache.jackrabbit.jcr2spi.observation.ObservationManagerImpl;
 import org.apache.jackrabbit.jcr2spi.operation.Clone;
+import org.apache.jackrabbit.jcr2spi.operation.Copy;
+import org.apache.jackrabbit.jcr2spi.operation.Move;
 import org.apache.jackrabbit.jcr2spi.operation.Operation;
 import org.apache.jackrabbit.jcr2spi.operation.WorkspaceImport;
+import org.apache.jackrabbit.jcr2spi.query.QueryManagerImpl;
 import org.apache.jackrabbit.jcr2spi.security.AccessManager;
-import org.apache.jackrabbit.jcr2spi.lock.LockManager;
-import org.apache.jackrabbit.jcr2spi.lock.LockManagerImpl;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateFactory;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateValidator;
+import org.apache.jackrabbit.jcr2spi.state.NodeState;
+import org.apache.jackrabbit.jcr2spi.state.UpdatableItemStateManager;
 import org.apache.jackrabbit.jcr2spi.version.VersionManager;
 import org.apache.jackrabbit.jcr2spi.version.VersionManagerImpl;
-import org.apache.jackrabbit.jcr2spi.observation.ObservationManagerImpl;
 import org.apache.jackrabbit.jcr2spi.xml.WorkspaceContentHandler;
-import org.apache.jackrabbit.jcr2spi.config.CacheBehaviour;
-import org.apache.jackrabbit.jcr2spi.config.RepositoryConfig;
 import org.apache.jackrabbit.spi.IdFactory;
-import org.apache.jackrabbit.spi.RepositoryService;
-import org.apache.jackrabbit.spi.SessionInfo;
-import org.apache.jackrabbit.spi.QValueFactory;
-import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.NameFactory;
+import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.PathFactory;
+import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.jackrabbit.spi.RepositoryService;
+import org.apache.jackrabbit.spi.SessionInfo;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.conversion.NameResolver;
 import org.apache.jackrabbit.spi.commons.conversion.PathResolver;
-import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
-import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.xml.sax.ContentHandler;
 
-import javax.jcr.observation.ObservationManager;
-import javax.jcr.query.QueryManager;
-import javax.jcr.lock.LockException;
-import javax.jcr.version.VersionException;
-import javax.jcr.version.Version;
-import javax.jcr.nodetype.ConstraintViolationException;
-import javax.jcr.nodetype.NodeTypeManager;
-import javax.jcr.Workspace;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
 import javax.jcr.AccessDeniedException;
-import javax.jcr.PathNotFoundException;
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.InvalidSerializedDataException;
 import javax.jcr.ItemExistsException;
-import javax.jcr.Repository;
+import javax.jcr.NamespaceRegistry;
 import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
 import javax.jcr.UnsupportedRepositoryOperationException;
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.NamespaceRegistry;
-import javax.jcr.InvalidSerializedDataException;
 import javax.jcr.ValueFactory;
-import java.io.InputStream;
+import javax.jcr.Workspace;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NodeTypeManager;
+import javax.jcr.observation.ObservationManager;
+import javax.jcr.query.QueryManager;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionException;
 import java.io.IOException;
+import java.io.InputStream;
 
 /**
  * <code>WorkspaceImpl</code>...
@@ -314,17 +313,14 @@
         session.checkIsAlive();
 
         Path parentPath = session.getQPath(parentAbsPath);
-        ItemState parentState = getHierarchyManager().getItemState(parentPath);
-        if (parentState.isNode()) {
-            // make sure the given import target is accessible, not locked and checked out.
-            int options = ItemStateValidator.CHECK_ACCESS | ItemStateValidator.CHECK_LOCK | ItemStateValidator.CHECK_VERSIONING;
-            getValidator().checkIsWritable((NodeState) parentState, options);
-
-            // build the content handler
-            return new WorkspaceContentHandler(this, parentAbsPath, uuidBehavior);
-        } else {
-            throw new PathNotFoundException("No node at path " + parentAbsPath);
-        }
+        NodeState parentState = getHierarchyManager().getNodeState(parentPath);
+
+        // make sure the given import target is accessible, not locked and checked out.
+        int options = ItemStateValidator.CHECK_ACCESS | ItemStateValidator.CHECK_LOCK | ItemStateValidator.CHECK_VERSIONING;
+        getValidator().checkIsWritable((NodeState) parentState, options);
+
+        // build the content handler
+        return new WorkspaceContentHandler(this, parentAbsPath, uuidBehavior);
     }
 
     /**
@@ -339,18 +335,13 @@
         session.checkIsAlive();
 
         Path parentPath = session.getQPath(parentAbsPath);
-        ItemState itemState = getHierarchyManager().getItemState(parentPath);
-        if (itemState.isNode()) {
-            // make sure the given import target is accessible, not locked and checked out.
-            NodeState parentState = (NodeState) itemState;
-            int options = ItemStateValidator.CHECK_ACCESS | ItemStateValidator.CHECK_LOCK | ItemStateValidator.CHECK_VERSIONING;
-            getValidator().checkIsWritable(parentState, options);
-
-            // run the import
-            wspManager.execute(WorkspaceImport.create(parentState, in, uuidBehavior));
-        } else {
-            throw new PathNotFoundException("No node at path " + parentAbsPath);
-        }
+        NodeState parentState = getHierarchyManager().getNodeState(parentPath);
+        // make sure the given import target is accessible, not locked and checked out.
+        int options = ItemStateValidator.CHECK_ACCESS | ItemStateValidator.CHECK_LOCK | ItemStateValidator.CHECK_VERSIONING;
+        getValidator().checkIsWritable(parentState, options);
+
+        // run the import
+        wspManager.execute(WorkspaceImport.create(parentState, in, uuidBehavior));
     }
 
     //----------------------------------------------------< ManagerProvider >---

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntries.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntries.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntries.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntries.java Fri Nov  7 00:52:32 2008
@@ -147,4 +147,19 @@
      * in this <code>ChildNodeEntries</code>.
      */
     NodeEntry reorder(NodeEntry insertEntry, NodeEntry beforeEntry);
+
+    /**
+     * Reorders an existing <code>NodeEntry</code> after another
+     * <code>NodeEntry</code>. If <code>afterEntry</code> is
+     * <code>null</code> <code>insertEntry</code> is moved to the beginning of
+     * the child node entries.
+     *
+     * @param insertEntry the NodeEntry to move.
+     * @param afterEntry the NodeEntry where <code>insertEntry</code> is
+     * reordered behind.
+     * @throws NoSuchElementException if <code>insertEntry</code> or
+     * <code>afterEntry</code> does not have a <code>NodeEntry</code>
+     * in this <code>ChildNodeEntries</code>.
+     */
+    void reorderAfter(NodeEntry insertEntry, NodeEntry afterEntry);
 }

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java Fri Nov  7 00:52:32 2008
@@ -35,8 +35,8 @@
 import java.util.Map;
 import java.util.HashMap;
 import java.util.Collections;
-import java.lang.ref.WeakReference;
 import java.lang.ref.Reference;
+import java.lang.ref.WeakReference;
 
 /**
  * <code>ChildNodeEntriesImpl</code> implements a memory sensitive implementation
@@ -107,6 +107,18 @@
     }
 
     /**
+     * @param childEntry
+     * @return The node entry that directly preceeds the given <code>childEntry</code>
+     * or <code>null</code> if the given <code>childEntry</code> is the first
+     * or was not found in this <code>ChildNodeEntries</code>.
+     */
+    NodeEntry getPrevious(NodeEntry childEntry) {
+        LinkedEntries.LinkNode ln = entries.getLinkNode(childEntry);
+        LinkedEntries.LinkNode prevLn = (ln == null) ? null : ln.getPreviousLinkNode();
+        return (prevLn == null) ? null : prevLn.getNodeEntry();
+    }
+
+    /**
      * @see ChildNodeEntries#isComplete()
      */
     public boolean isComplete() {
@@ -191,7 +203,7 @@
         }
         return Collections.unmodifiableList(l).iterator();
     }
-    
+
     /**
      * @see ChildNodeEntries#get(Name)
      */
@@ -370,6 +382,27 @@
     }
 
     /**
+     * @see ChildNodeEntries#reorderAfter(NodeEntry, NodeEntry)
+     */
+    public void reorderAfter(NodeEntry insertEntry, NodeEntry afterEntry) {
+        // the link node to move
+        LinkedEntries.LinkNode insertLN = entries.getLinkNode(insertEntry);
+        if (insertLN == null) {
+            throw new NoSuchElementException();
+        }
+        // the link node where insertLN is ordered before
+        LinkedEntries.LinkNode afterLN = (afterEntry != null) ? entries.getLinkNode(afterEntry) : null;
+        if (afterEntry != null && afterLN == null) {
+            throw new NoSuchElementException();
+        }
+
+        LinkedEntries.LinkNode previousLN = insertLN.getPreviousLinkNode();
+        if (previousLN != afterLN) {
+            reorderAfter(insertLN, afterLN);
+        } // else: already in correct position. nothing to do
+    }
+
+    /**
      *
      * @param insertName
      * @param insertLN
@@ -653,6 +686,13 @@
             public LinkedEntries.LinkNode getNextLinkNode() {
                 return (LinkedEntries.LinkNode) super.getNextNode();
             }
+
+            /**
+             * @return the next LinkNode.
+             */
+            public LinkedEntries.LinkNode getPreviousLinkNode() {
+                return (LinkedEntries.LinkNode) super.getPreviousNode();
+            }
         }
 
         //----------------------------------------------------------------------

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildPropertyEntriesImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildPropertyEntriesImpl.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildPropertyEntriesImpl.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildPropertyEntriesImpl.java Fri Nov  7 00:52:32 2008
@@ -79,7 +79,7 @@
     public Collection getPropertyEntries() {
         synchronized (properties) {
             Set entries = new HashSet(properties.size());
-            for (Iterator it = getPropertyNames().iterator(); it.hasNext();) {
+            for (Iterator it = properties.keySet().iterator(); it.hasNext();) {
                 Name propName = (Name) it.next();
                 entries.add(get(propName));
             }
@@ -91,15 +91,17 @@
      * @see ChildPropertyEntries#getPropertyNames()
      */
     public Collection getPropertyNames() {
-        return properties.keySet();
+        return Collections.unmodifiableCollection(properties.keySet());
     }
 
     /**
      * @see ChildPropertyEntries#add(PropertyEntry)
      */
     public void add(PropertyEntry propertyEntry) {
-        Reference ref = new WeakReference(propertyEntry);
-        properties.put(propertyEntry.getName(), ref);
+        synchronized (properties) {
+            Reference ref = new WeakReference(propertyEntry);
+            properties.put(propertyEntry.getName(), ref);
+        }
     }
 
     /**
@@ -118,13 +120,15 @@
      * @see ChildPropertyEntries#remove(PropertyEntry)
      */
     public boolean remove(PropertyEntry propertyEntry) {
-        Name pName = propertyEntry.getName();
-        PropertyEntry pe = get(pName);
-        if (pe == propertyEntry) {
-            properties.remove(pName);
-            return true;
-        } else {
-            return false;
+        synchronized (properties) {
+            Name pName = propertyEntry.getName();
+            PropertyEntry pe = get(pName);
+            if (pe == propertyEntry) {
+                properties.remove(pName);
+                return true;
+            } else {
+                return false;
+            }
         }
     }
 }
\ No newline at end of file

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntryImpl.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntryImpl.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntryImpl.java Fri Nov  7 00:52:32 2008
@@ -28,6 +28,7 @@
 import javax.jcr.ItemNotFoundException;
 import javax.jcr.RepositoryException;
 import java.lang.ref.WeakReference;
+import java.lang.ref.Reference;
 
 /**
  * <code>HierarchyEntryImpl</code> implements base functionality for child node
@@ -40,7 +41,7 @@
     /**
      * Cached weak reference to the target ItemState.
      */
-    private WeakReference target;
+    private Reference target;
 
     /**
      * The name of the target item state.
@@ -269,7 +270,9 @@
                 break;
             case Status.NEW:
                 // reverting a NEW state is equivalent to its removal.
-                // however: don't remove the complete hierarchy
+                // however: no need remove the complete hierarchy as revert is
+                // always related to Item#refresh(false) which affects the
+                // complete tree (and all add-operations within it) anyway.
                 state.setStatus(Status.REMOVED);
                 parent.internalRemoveChildEntry(this);
                 break;
@@ -361,4 +364,38 @@
                 throw new RepositoryException("Cannot transiently remove an ItemState with status " + Status.getName(state.getStatus()));
         }
     }
+
+    /**
+     * @see HierarchyEntry#remove()
+     */
+    public void remove() {
+        internalRemove(false);
+    }
+
+    //--------------------------------------------------------------------------
+    /**
+     *
+     * @param keepNew
+     */
+    void internalRemove(boolean staleParent) {
+        ItemState state = internalGetItemState();
+        int status = getStatus();
+        if (state != null) {
+            if (status == Status.EXISTING_MODIFIED) {
+                state.setStatus(Status.STALE_DESTROYED);
+            } else if (status == Status.NEW && staleParent) {
+                // keep status NEW
+            } else {
+                state.setStatus(Status.REMOVED);
+                if (!staleParent) {
+                    parent.internalRemoveChildEntry(this);
+                }
+            }
+        } else {
+            // unresolved
+            if (!staleParent) {
+                parent.internalRemoveChildEntry(this);
+            }
+        }
+    }
 }

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyManager.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyManager.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyManager.java Fri Nov  7 00:52:32 2008
@@ -16,13 +16,16 @@
  */
 package org.apache.jackrabbit.jcr2spi.hierarchy;
 
-import org.apache.jackrabbit.spi.Path;
-import org.apache.jackrabbit.jcr2spi.state.ItemState;
+import org.apache.jackrabbit.jcr2spi.state.NodeState;
+import org.apache.jackrabbit.jcr2spi.state.PropertyState;
 import org.apache.jackrabbit.spi.ItemId;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.PropertyId;
 
+import javax.jcr.ItemNotFoundException;
 import javax.jcr.PathNotFoundException;
 import javax.jcr.RepositoryException;
-import javax.jcr.ItemNotFoundException;
 
 /**
  * <code>HierarchyManager</code>...
@@ -45,9 +48,10 @@
      * if a entry (or any of its ancestors) has been transiently moved or
      * reordered.<p/>
      * If the Hierarchy already lists the entry with the given workspaceItemId it is
-     * returned otherwise <code>null</code>. See {@link #getHierarchyEntry(ItemId)}
-     * for a method that resolves the ItemId including lookup in the persistence
-     * layer if the entry has not been loaded yet.
+     * returned otherwise <code>null</code>. See {@link #getNodeEntry(NodeId)}
+     * or {@link #getPropertyEntry(PropertyId)} for methods that resolves the
+     * ItemId including lookup in the persistence layer if the entry has not been
+     * loaded yet.
      *
      * @param workspaceItemId
      * @return
@@ -59,9 +63,9 @@
      * if a entry (or any of its ancestors) has been transiently moved or
      * reordered.<p/>
      * If the Hierarchy already lists the entry with the given path it is
-     * returned otherwise <code>null</code>. See {@link #getHierarchyEntry(Path)}
-     * for a method that resolves the ItemId including lookup in the persistence
-     * layer if the entry has not been loaded yet.
+     * returned otherwise <code>null</code>. See {@link #getNodeEntry(Path)}
+     * or {@link #getPropertyEntry(Path)} for methods that resolves the path
+     * including lookup in the persistence layer if the entry has not been loaded yet.
      *
      * @param workspaceItemId
      * @return
@@ -71,33 +75,64 @@
     /**
      * Resolves a itemId into a <code>HierarchyEntry</code>.
      *
-     * @param itemId
+     * @param nodeId
      * @return
      * @throws PathNotFoundException
      * @throws RepositoryException
      */
-    public HierarchyEntry getHierarchyEntry(ItemId itemId) throws ItemNotFoundException, RepositoryException;
+    public NodeEntry getNodeEntry(NodeId nodeId) throws ItemNotFoundException, RepositoryException;
 
     /**
-     * Resolves a path into a <code>HierarchyEntry</code>.
+     * Resolves a path into a <code>NodeEntry</code>.
      *
      * @param qPath
      * @return
      * @throws PathNotFoundException
      * @throws RepositoryException
      */
-    public HierarchyEntry getHierarchyEntry(Path qPath) throws PathNotFoundException, RepositoryException;
+    public NodeEntry getNodeEntry(Path qPath) throws PathNotFoundException, RepositoryException;
 
     /**
-     * Retrieves the <code>HierarchyEntry</code> corresponding to the given
-     * path and resolves it to the underlying <code>ItemState</code>.
+     * Resolves a propertyId into a <code>PropertyEntry</code>.
+     *
+     * @param propertyId
+     * @return
+     * @throws PathNotFoundException
+     * @throws RepositoryException
+     */
+    public PropertyEntry getPropertyEntry(PropertyId propertyId) throws ItemNotFoundException, RepositoryException;
+
+    /**
+     * Resolves a path into a <code>PropertyEntry</code>.
+     *
+     * @param qPath
+     * @return
+     * @throws PathNotFoundException
+     * @throws RepositoryException
+     */
+    public PropertyEntry getPropertyEntry(Path qPath) throws PathNotFoundException, RepositoryException;
+
+     /**
+     * Retrieves the <code>NodeEntry</code> corresponding to the given
+     * path and resolves it to the underlying <code>NodeState</code>.
+     *
+     * @param qPath
+     * @return
+     * @throws PathNotFoundException
+     * @throws RepositoryException
+     */
+    public NodeState getNodeState(Path qPath) throws PathNotFoundException, RepositoryException;
+
+     /**
+     * Retrieves the <code>PropertyEntry</code> corresponding to the given
+     * path and resolves it to the underlying <code>PropertyState</code>.
      *
      * @param qPath
      * @return
      * @throws PathNotFoundException
      * @throws RepositoryException
      */
-    public ItemState getItemState(Path qPath) throws PathNotFoundException, RepositoryException;
+    public PropertyState getPropertyState(Path qPath) throws PathNotFoundException, RepositoryException;
 
     /**
      * Returns the depth of the specified item. The depth reflects the

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyManagerImpl.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyManagerImpl.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyManagerImpl.java Fri Nov  7 00:52:32 2008
@@ -16,19 +16,21 @@
  */
 package org.apache.jackrabbit.jcr2spi.hierarchy;
 
-import org.apache.jackrabbit.jcr2spi.state.ItemState;
+import org.apache.jackrabbit.jcr2spi.state.NodeState;
+import org.apache.jackrabbit.jcr2spi.state.PropertyState;
 import org.apache.jackrabbit.jcr2spi.state.TransientItemStateFactory;
-import org.apache.jackrabbit.spi.Path;
-import org.apache.jackrabbit.spi.ItemId;
 import org.apache.jackrabbit.spi.IdFactory;
+import org.apache.jackrabbit.spi.ItemId;
 import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.PathFactory;
+import org.apache.jackrabbit.spi.PropertyId;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.jcr.ItemNotFoundException;
 import javax.jcr.PathNotFoundException;
 import javax.jcr.RepositoryException;
-import javax.jcr.ItemNotFoundException;
 
 /**
  * <code>HierarchyManagerImpl</code> implements the <code>HierarchyManager</code>
@@ -72,7 +74,7 @@
         if (uniqueID == null) {
             return rootEntry.lookupDeepEntry(workspaceItemId.getPath());
         } else {
-            NodeEntry nEntry = uniqueIdResolver.lookup(idFactory.createNodeId(uniqueID));
+            NodeEntry nEntry = uniqueIdResolver.lookup(uniqueID);
             Path path = workspaceItemId.getPath();
             if (path == null) {
                 return nEntry;
@@ -90,49 +92,101 @@
     }
 
     /**
-     * @see HierarchyManager#getHierarchyEntry(ItemId)
+     * @see HierarchyManager#getNodeEntry(NodeId)
      */
-    public HierarchyEntry getHierarchyEntry(ItemId itemId) throws ItemNotFoundException, RepositoryException {
-        String uniqueID = itemId.getUniqueID();
+    public NodeEntry getNodeEntry(NodeId nodeId)
+            throws ItemNotFoundException, RepositoryException {
+        String uniqueID = nodeId.getUniqueID();
         if (uniqueID == null) {
-            return getHierarchyEntry(itemId.getPath());
+            return getNodeEntry(nodeId.getPath());
         } else {
-            if (itemId.getPath() == null) {
-                NodeEntry nEntry = uniqueIdResolver.resolve((NodeId) itemId, rootEntry);
+            if (nodeId.getPath() == null) {
+                NodeEntry nEntry = uniqueIdResolver.resolve(nodeId, rootEntry);
                 return nEntry;
             } else {
                 NodeEntry nEntry = uniqueIdResolver.resolve(idFactory.createNodeId(uniqueID), rootEntry);
-                return nEntry.getDeepEntry(itemId.getPath());
+                return nEntry.getDeepNodeEntry(nodeId.getPath());
             }
         }
     }
 
     /**
-     * @see HierarchyManager#getHierarchyEntry(Path)
+     * @see HierarchyManager#getNodeEntry(Path)
      */
-    public HierarchyEntry getHierarchyEntry(Path qPath) throws PathNotFoundException, RepositoryException {
+    public NodeEntry getNodeEntry(Path qPath) throws PathNotFoundException, RepositoryException {
         NodeEntry rootEntry = getRootEntry();
         // shortcut
         if (qPath.denotesRoot()) {
             return rootEntry;
         }
+        if (!qPath.isCanonical()) {
+            String msg = "Path is not canonical";
+            log.debug(msg);
+            throw new RepositoryException(msg);
+        }
+        return rootEntry.getDeepNodeEntry(qPath);
+    }
 
+    /**
+     * @see HierarchyManager#getPropertyEntry(PropertyId)
+     */
+    public PropertyEntry getPropertyEntry(PropertyId propertyId)
+            throws ItemNotFoundException, RepositoryException {
+        String uniqueID = propertyId.getUniqueID();
+        if (uniqueID == null) {
+            return getPropertyEntry(propertyId.getPath());
+        } else {
+            if (propertyId.getPath() == null) {
+                // a property id always contains a Path part.
+                throw new ItemNotFoundException();
+            } else {
+                NodeEntry nEntry = uniqueIdResolver.resolve(idFactory.createNodeId(uniqueID), rootEntry);
+                return nEntry.getDeepPropertyEntry(propertyId.getPath());
+            }
+        }
+    }
+
+    /**
+     * @see HierarchyManager#getPropertyEntry(Path)
+     */
+    public PropertyEntry getPropertyEntry(Path qPath)
+            throws PathNotFoundException, RepositoryException {
+        // shortcut
+        if (qPath.denotesRoot()) {
+            throw new PathNotFoundException("The root path never points to a Property.");
+        }
         if (!qPath.isCanonical()) {
             String msg = "Path is not canonical";
             log.debug(msg);
             throw new RepositoryException(msg);
         }
+        return getRootEntry().getDeepPropertyEntry(qPath);
+    }
 
-        return rootEntry.getDeepEntry(qPath);
+    /**
+     * @see HierarchyManager#getNodeState(Path)
+     */
+    public NodeState getNodeState(Path qPath) throws PathNotFoundException, RepositoryException {
+        NodeEntry entry = getNodeEntry(qPath);
+        try {
+            NodeState state = entry.getNodeState();
+            if (state.isValid()) {
+                return state;
+            } else {
+                throw new PathNotFoundException();
+            }
+        } catch (ItemNotFoundException e) {
+            throw new PathNotFoundException(e);
+        }
     }
 
     /**
-     * @see HierarchyManager#getItemState(Path)
+     * @see HierarchyManager#getPropertyState(Path)
      */
-    public ItemState getItemState(Path qPath) throws PathNotFoundException, RepositoryException {
-        HierarchyEntry entry = getHierarchyEntry(qPath);
+    public PropertyState getPropertyState(Path qPath) throws PathNotFoundException, RepositoryException {
+        PropertyEntry entry = getPropertyEntry(qPath);
         try {
-            ItemState state = entry.getItemState();
+            PropertyState state = entry.getPropertyState();
             if (state.isValid()) {
                 return state;
             } else {

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java?rev=712088&r1=712087&r2=712088&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java Fri Nov  7 00:52:32 2008
@@ -89,16 +89,29 @@
     /**
      * Traverse the tree below this entry and return the child entry matching
      * the given path. If that entry has not been loaded yet, try to do so.
-     * NOTE: In contrast to 'getNodeEntry', getNodeEntries, getPropertyEntry
-     * and getPropertyEntries this method may return invalid entries, i.e.
-     * entries connected to a removed or stale ItemState.
+     * NOTE: In contrast to getNodeEntry, getNodeEntries this method may return
+     * invalid entries, i.e. entries connected to a removed or stale ItemState.
      *
      * @param path
      * @return the entry at the given path.
      * @throws PathNotFoundException
      * @throws RepositoryException
      */
-    public HierarchyEntry getDeepEntry(Path path) throws PathNotFoundException, RepositoryException;
+    public NodeEntry getDeepNodeEntry(Path path) throws PathNotFoundException, RepositoryException;
+
+    /**
+     * Traverse the tree below this entry and return the child entry matching
+     * the given path. If that entry has not been loaded yet, try to do so.
+     * NOTE: In contrast to getPropertyEntry and getPropertyEntries this method
+     * may return invalid entries, i.e. entries connected to a removed or stale
+     * ItemState.
+     *
+     * @param path
+     * @return the property entry at the given path.
+     * @throws PathNotFoundException
+     * @throws RepositoryException
+     */
+    public PropertyEntry getDeepPropertyEntry(Path path) throws PathNotFoundException, RepositoryException;
 
     /**
      * Traverse the tree below this entry and return the child entry matching