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 2006/10/09 18:46:18 UTC

svn commit: r454423 [3/3] - in /jackrabbit/trunk/contrib/spi: jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/ jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ jcr2spi/src/main/jav...

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientISFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientISFactory.java?view=diff&rev=454423&r1=454422&r2=454423
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientISFactory.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientISFactory.java Mon Oct  9 09:46:16 2006
@@ -54,11 +54,11 @@
                                         NodeState parent, QName nodetypeName,
                                         QNodeDefinition definition) {
         NodeState nodeState = new NodeState(name, uuid, parent, nodetypeName,
-            definition, ItemState.STATUS_NEW, this, idFactory);
+            definition, Status.NEW, this, idFactory, false);
         // get a notification when this item state is saved or invalidated
         nodeState.addListener(listener);
         // notify listener that a node state has been created
-        listener.statusChanged(nodeState, ItemState.STATUS_NEW);
+        listener.statusChanged(nodeState, Status.NEW);
         return nodeState;
     }
 
@@ -68,11 +68,11 @@
      */
     public PropertyState createNewPropertyState(QName name, NodeState parent, QPropertyDefinition definition) {
         PropertyState propState = new PropertyState(name, parent,
-            definition, ItemState.STATUS_NEW, idFactory);
+            definition, Status.NEW, idFactory, false);
         // get a notification when this item state is saved or invalidated
         propState.addListener(listener);
         // notify listener that a property state has been created
-        listener.statusChanged(propState, ItemState.STATUS_NEW);
+        listener.statusChanged(propState, Status.NEW);
         return propState;
     }
 
@@ -85,7 +85,7 @@
         // retrieve state to overlay
         NodeState overlayedState = (NodeState) parent.getRootState();
         NodeState nodeState = new NodeState(overlayedState, null,
-            ItemState.STATUS_EXISTING, this, idFactory);
+            Status.EXISTING, this, idFactory);
         nodeState.addListener(listener);
         return nodeState;
     }
@@ -104,7 +104,7 @@
             parentState = (NodeState) ism.getItemState(overlayedParent.getId());
         }
         NodeState nodeState = new NodeState(overlayedState, parentState,
-            ItemState.STATUS_EXISTING, this, idFactory);
+            Status.EXISTING, this, idFactory);
         nodeState.addListener(listener);
         return nodeState;
     }
@@ -118,7 +118,7 @@
         // retrieve state to overlay
         NodeState overlayedState = (NodeState) parent.getItemState(nodeId);
         NodeState nodeState = new NodeState(overlayedState, parentState,
-            ItemState.STATUS_EXISTING, this, idFactory);
+            Status.EXISTING, this, idFactory);
         nodeState.addListener(listener);
         return nodeState;
     }
@@ -133,7 +133,7 @@
         // retrieve state to overlay
         PropertyState overlayedState = (PropertyState) parent.getItemState(propertyId);
         PropertyState propState = new PropertyState(overlayedState, parentState,
-            ItemState.STATUS_EXISTING, idFactory);
+            Status.EXISTING, idFactory);
         propState.addListener(listener);
         return propState;
     }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java?view=diff&rev=454423&r1=454422&r2=454423
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java Mon Oct  9 09:46:16 2006
@@ -194,7 +194,7 @@
     /**
      * Return an item state given its id. Please note that this implementation
      * also returns item states that are in removed state ({@link
-     * ItemState.STATUS_EXISTING_REMOVED} but not yet saved.
+     * Status#EXISTING_REMOVED} but not yet saved.
      *
      * @return item state.
      * @throws NoSuchItemStateException if there is no item state (not even a
@@ -252,56 +252,56 @@
         // a state which changes from 'existing' to 'existing modified' will
         // go into the modified set of the change log, etc.
         switch (state.getStatus()) {
-            case ItemState.STATUS_EXISTING:
+            case Status.EXISTING:
                 switch (previousStatus) {
-                    case ItemState.STATUS_EXISTING_MODIFIED:
+                    case Status.EXISTING_MODIFIED:
                         // was modified and is now refreshed
                         changeLog.modifiedStates.remove(state);
                         break;
-                    case ItemState.STATUS_EXISTING_REMOVED:
+                    case Status.EXISTING_REMOVED:
                         // was removed and is now refreshed
                         changeLog.deletedStates.remove(state);
                         break;
-                    case ItemState.STATUS_STALE_MODIFIED:
+                    case Status.STALE_MODIFIED:
                         // was modified and state and is now refreshed
                         changeLog.modifiedStates.remove(state);
                         break;
-                    case ItemState.STATUS_NEW:
+                    case Status.NEW:
                         // was new and has been saved now
                         changeLog.addedStates.remove(state);
                         break;
                 }
                 break;
-            case ItemState.STATUS_EXISTING_MODIFIED:
+            case Status.EXISTING_MODIFIED:
                 changeLog.modified(state);
                 break;
-            case ItemState.STATUS_EXISTING_REMOVED:
+            case Status.EXISTING_REMOVED:
                 // check if modified earlier
-                if (previousStatus == ItemState.STATUS_EXISTING_MODIFIED) {
+                if (previousStatus == Status.EXISTING_MODIFIED) {
                     changeLog.modifiedStates.remove(state);
                     // todo: remove operation(s) as well
                 }
                 changeLog.deleted(state);
                 break;
-            case ItemState.STATUS_REMOVED:
-                if (previousStatus == ItemState.STATUS_NEW) {
+            case Status.REMOVED:
+                if (previousStatus == Status.NEW) {
                     // was new and now removed again
                     changeLog.addedStates.remove(state);
                     // TODO: remove operation as well
-                } else if (previousStatus == ItemState.STATUS_EXISTING_REMOVED) {
+                } else if (previousStatus == Status.EXISTING_REMOVED) {
                     // was removed and is now saved
                     changeLog.deletedStates.remove(state);
                 }
                 break;
-            case ItemState.STATUS_STALE_DESTROYED:
+            case Status.STALE_DESTROYED:
                 // state is now stale. remove from modified
                 changeLog.modifiedStates.remove(state);
                 // TODO: remove operation as well
                 break;
-            case ItemState.STATUS_STALE_MODIFIED:
+            case Status.STALE_MODIFIED:
                 // state is now stale. keep in modified. wait until refreshed
                 break;
-            case ItemState.STATUS_NEW:
+            case Status.NEW:
                 // new state has been created
                 changeLog.added(state);
                 break;

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java?view=diff&rev=454423&r1=454422&r2=454423
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java Mon Oct  9 09:46:16 2006
@@ -29,6 +29,7 @@
 import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.value.QValue;
 import org.apache.jackrabbit.jcr2spi.WorkspaceManager;
+import org.apache.jackrabbit.jcr2spi.state.entry.ChildNodeEntry;
 import org.apache.jackrabbit.jcr2spi.nodetype.EffectiveNodeType;
 import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeConflictException;
 import org.apache.jackrabbit.name.QName;
@@ -142,18 +143,18 @@
 
             // build the node state
             String uuid = null;
-            if (info.getId().getRelativePath() == null) {
+            if (info.getId().getPath() == null) {
                 uuid = info.getId().getUUID();
             }
             NodeState state = new NodeState(info.getQName(), uuid, parent, info.getNodetype(),
-                definition, ItemState.STATUS_EXISTING, this, service.getIdFactory());
+                definition, Status.EXISTING, this, service.getIdFactory(), true);
 
             // child node entries
             Set childNodeEntries = new HashSet();
             for (IdIterator it = info.getNodeIds(); it.hasNext(); ) {
                 NodeInfo childInfo = service.getNodeInfo(sessionInfo, (NodeId) it.nextId());
                 String childUUID = null;
-                if (childInfo.getId().getRelativePath() == null) {
+                if (childInfo.getId().getPath() == null) {
                     childUUID = childInfo.getId().getUUID();
                 }
                 childNodeEntries.add(new CNE(childInfo.getQName(), childUUID));
@@ -241,7 +242,7 @@
 
             // build the PropertyState
             PropertyState state = new PropertyState(info.getQName(), parent,
-                def, ItemState.STATUS_EXISTING, service.getIdFactory());
+                def, Status.EXISTING, service.getIdFactory(), true);
 
             QValue[] qValues;
             if (info.getType() == PropertyType.BINARY) {

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateManager.java?view=diff&rev=454423&r1=454422&r2=454423
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateManager.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateManager.java Mon Oct  9 09:46:16 2006
@@ -127,6 +127,10 @@
                         log.error("Unexpected error while updating modified property state.", e);
                     }
                 }
+                // TODO: check again. parent must be notified if mixintypes or jcr:uuid prop is changed.
+                if (parent != null) {
+                    parent.refresh(event, changeLog);
+                }
             } else {
                 // should never occur
                 throw new IllegalArgumentException("Invalid event type: " + event.getType());

Added: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/ChildItemReference.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/ChildItemReference.java?view=auto&rev=454423
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/ChildItemReference.java (added)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/ChildItemReference.java Mon Oct  9 09:46:16 2006
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.jcr2spi.state.entry;
+
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.jcr2spi.state.NodeState;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateFactory;
+import org.apache.jackrabbit.jcr2spi.state.ItemState;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateException;
+import org.apache.jackrabbit.jcr2spi.state.NoSuchItemStateException;
+
+import java.lang.ref.WeakReference;
+
+/**
+ * <code>ChildItemReference</code> implements base functionality for child node
+ * and property references.
+ * @see ChildNodeReference
+ * @see PropertyReference
+ */
+abstract class ChildItemReference {
+
+    /**
+     * Cached weak reference to the target NodeState.
+     */
+    private WeakReference target;
+
+    /**
+     * The parent that owns this <code>ChildItemReference</code>.
+     */
+    protected final NodeState parent;
+
+    /**
+     * The name of the target item state.
+     */
+    protected final QName name;
+
+    /**
+     * The item state factory to create the the item state.
+     */
+    protected final ItemStateFactory isf;
+
+    /**
+     * Creates a new <code>ChildItemReference</code> with the given parent
+     * <code>NodeState</code>.
+     *
+     * @param parent the <code>NodeState</code> that owns this child node
+     *               reference.
+     * @param name   the name of the child item.
+     * @param isf    the item state factory to create the item state.
+     */
+    public ChildItemReference(NodeState parent, QName name, ItemStateFactory isf) {
+        this.parent = parent;
+        this.name = name;
+        this.isf = isf;
+    }
+
+    /**
+     * Creates a new <code>ChildItemReference</code> with the given parent
+     * <code>NodeState</code> and an already initialized child item state.
+     *
+     * @param parent the <code>NodeState</code> that owns this child node
+     *               reference.
+     * @param child  the child item state.
+     * @param name   the name of the child item.
+     * @param isf    the item state factory to re-create the item state.
+     */
+    public ChildItemReference(NodeState parent, ItemState child, QName name, ItemStateFactory isf) {
+        this.parent = parent;
+        this.name = name;
+        this.isf = isf;
+        this.target = new WeakReference(child);
+    }
+
+    /**
+     * Resolves this <code>ChildItemReference</code> and returns the target
+     * <code>ItemState</code> of this reference. This method may return a
+     * cached <code>ItemState</code> if this method was called before already
+     * otherwise this method will forward the call to {@link #doResolve()}
+     * and cache its return value.
+     *
+     * @return the <code>ItemState</code> where this reference points to.
+     * @throws NoSuchItemStateException if the referenced <code>ItemState</code>
+     *                                  does not exist.
+     * @throws ItemStateException       if an error occurs.
+     */
+    public ItemState resolve()
+            throws NoSuchItemStateException, ItemStateException {
+        // check if cached
+        if (target != null) {
+            ItemState state = (ItemState) target.get();
+            if (state != null) {
+                return state;
+            }
+        }
+        // not cached. retrieve and keep weak reference to state
+        ItemState state = doResolve();
+        target = new WeakReference(state);
+        return state;
+    }
+
+    /**
+     * Returns the parent <code>NodeState</code>. This is the source of this
+     * <code>ChildItemReference</code>.
+     *
+     * @return the parent <code>NodeState</code>.
+     */
+    public NodeState getParent() {
+        return parent;
+    }
+
+    /**
+     * @return <code>true</code> if this reference is resolved;
+     *         <code>false</code> otherwise.
+     */
+    protected boolean isResolved() {
+        ItemState state = null;
+        if (target != null) {
+            state = (ItemState) target.get();
+        }
+        return state != null;
+    }
+
+    /**
+     * Resolves this <code>ChildItemReference</code> and returns the target
+     * <code>ItemState</code> of this reference.
+     *
+     * @return the <code>ItemState</code> where this reference points to.
+     * @throws NoSuchItemStateException if the referenced <code>ItemState</code>
+     *                                  does not exist.
+     * @throws ItemStateException       if an error occurs.
+     */
+    protected abstract ItemState doResolve()
+            throws NoSuchItemStateException, ItemStateException;
+}

Propchange: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/ChildItemReference.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/ChildItemReference.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/ChildNodeEntry.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/ChildNodeEntry.java?view=auto&rev=454423
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/ChildNodeEntry.java (added)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/ChildNodeEntry.java Mon Oct  9 09:46:16 2006
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.jcr2spi.state.entry;
+
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.jcr2spi.state.NodeState;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateException;
+import org.apache.jackrabbit.jcr2spi.state.NoSuchItemStateException;
+
+/**
+ * <code>ChildNodeEntry</code> specifies the name, index (in the case of
+ * same-name siblings) and the UUID of a child node entry.
+ */
+public interface ChildNodeEntry {
+
+    /**
+     * @return the <code>NodeId</code> of this child node entry.
+     */
+    public NodeId getId();
+
+    /**
+     * @return the name of this child node entry.
+     */
+    public QName getName();
+
+    /**
+     * @return the UUID of the node state which is referenced by this child node
+     * entry or <code>null</code> if the node state cannot be identified with a
+     * UUID.
+     */
+    public String getUUID();
+
+    /**
+     * @return the index of this child node entry to suppport same-name siblings.
+     */
+    public int getIndex();
+
+    /**
+     * @return the referenced <code>NodeState</code>.
+     * @throws NoSuchItemStateException if the <code>NodeState</code> does not
+     *                                  exist anymore.
+     * @throws ItemStateException       if an error occurs while retrieving the
+     *                                  <code>NodeState</code>.
+     */
+    public NodeState getNodeState()
+            throws NoSuchItemStateException, ItemStateException;
+
+    /**
+     * Returns <code>true</code> if the referenced <code>NodeState</code> is
+     * available. That is, the referenced <code>NodeState</code> is already
+     * cached and ready to be returned by {@link #getNodeState()}.
+     *
+     * @return <code>true</code> if the <code>NodeState</code> is available;
+     *         otherwise <code>false</code>.
+     */
+    public boolean isAvailable();
+}

Propchange: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/ChildNodeEntry.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/ChildNodeEntry.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/ChildNodeReference.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/ChildNodeReference.java?view=auto&rev=454423
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/ChildNodeReference.java (added)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/ChildNodeReference.java Mon Oct  9 09:46:16 2006
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.jcr2spi.state.entry;
+
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.IdFactory;
+import org.apache.jackrabbit.jcr2spi.state.NodeState;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateFactory;
+import org.apache.jackrabbit.jcr2spi.state.NoSuchItemStateException;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateException;
+
+/**
+ * <code>ChildNodeReference</code> implements common functionality for child
+ * node entry implementations.
+ */
+public abstract class ChildNodeReference extends ChildItemReference implements ChildNodeEntry {
+
+    /**
+     * Creates a new <code>ChildNodeEntry</code> for an already initialized
+     * child node state. The child node must already be attached to its parent.
+     *
+     * @param child     the child node state.
+     * @param isf       the item state factory to re-create node states.
+     * @param idFactory the <code>IdFactory</code> to create new ItemIds
+     * @return
+     */
+    public static ChildNodeEntry create(NodeState child, ItemStateFactory isf,
+                                        IdFactory idFactory) {
+        ChildNodeEntry cne;
+        if (child.getUUID() == null) {
+            cne = new PathElementReference(child, isf, idFactory);
+        } else {
+            cne = new UUIDReference(child, isf);
+        }
+        return cne;
+    }
+
+    /**
+     * Creates a <code>ChildNodeEntry</code> instance based on
+     *  <code>nodeName</code> and an optional <code>uuid</code>.
+     *
+     * @param parent
+     * @param childName
+     * @param childUUID
+     * @param isf
+     * @param idFactory
+     * @return
+     */
+    public static ChildNodeEntry create(NodeState parent, QName childName,
+                                        String childUUID, ItemStateFactory isf,
+                                        IdFactory idFactory) {
+        if (childUUID == null) {
+            return new PathElementReference(parent, childName, isf, idFactory);
+        } else {
+            return new UUIDReference(parent, idFactory.createNodeId(childUUID), isf, childName);
+        }
+    }
+
+    /**
+     * Creates a new <code>ChildNodeReference</code> with the given parent
+     * <code>NodeState</code>.
+     *
+     * @param parent the <code>NodeState</code> that owns this child node
+     *               reference.
+     * @param name   the name of the child item.
+     * @param isf    the item state factory to create the item state.
+     */
+    ChildNodeReference(NodeState parent, QName name, ItemStateFactory isf) {
+        super(parent, name, isf);
+    }
+
+
+    /**
+     * Creates a new <code>ChildNodeReference</code> with the given parent
+     * <code>NodeState</code> and an already initialized child node state.
+     *
+     * @param child  the child node state.
+     * @param isf    the item state factory to re-create the node state.
+     */
+    ChildNodeReference(NodeState child, ItemStateFactory isf) {
+        super(child.getParent(), child, child.getQName(), isf);
+    }
+
+    /**
+     * @inheritDoc
+     * @see ChildNodeEntry#getIndex()
+     */
+    public int getIndex() {
+        return parent.getChildNodeIndex(getName(), this);
+    }
+
+    /**
+     * @inheritDoc
+     * @see ChildNodeEntry#getName()
+     */
+    public QName getName() {
+        return name;
+    }
+
+    /**
+     * @inheritDoc
+     * @see ChildNodeEntry#getNodeState()
+     */
+    public NodeState getNodeState()
+            throws NoSuchItemStateException, ItemStateException {
+        return (NodeState) resolve();
+    }
+
+    /**
+     * @inheritDoc
+     * @see ChildNodeEntry#isAvailable()
+     */
+    public boolean isAvailable() {
+        return isResolved();
+    }
+}

Propchange: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/ChildNodeReference.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/ChildNodeReference.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/ChildPropertyEntry.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/ChildPropertyEntry.java?view=auto&rev=454423
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/ChildPropertyEntry.java (added)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/ChildPropertyEntry.java Mon Oct  9 09:46:16 2006
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.jcr2spi.state.entry;
+
+import org.apache.jackrabbit.spi.PropertyId;
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateException;
+import org.apache.jackrabbit.jcr2spi.state.NoSuchItemStateException;
+import org.apache.jackrabbit.jcr2spi.state.PropertyState;
+
+/**
+ * <code>ChildPropertyEntry</code>...
+ */
+public interface ChildPropertyEntry {
+
+    /**
+     * @return the <code>NodeId</code> of this child node entry.
+     */
+    public PropertyId getId();
+
+    /**
+     * @return the name of this child node entry.
+     */
+    public QName getName();
+
+    /**
+     * @return the referenced <code>PropertyState</code>.
+     * @throws NoSuchItemStateException if the <code>PropertyState</code> does not
+     * exist anymore.
+     * @throws ItemStateException if an error occurs while retrieving the
+     * <code>PropertyState</code>.
+     */
+    public PropertyState getPropertyState() throws NoSuchItemStateException, ItemStateException;
+
+    /**
+     * Returns <code>true</code> if the referenced <code>PropertyState</code> is
+     * available. That is, the referenced <code>PropertyState</code> is already
+     * cached and ready to be returned by {@link #getPropertyState()}.
+     *
+     * @return <code>true</code> if the <code>PropertyState</code> is available;
+     *         otherwise <code>false</code>.
+     */
+    public boolean isAvailable();
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/ChildPropertyEntry.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/ChildPropertyEntry.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/PathElementReference.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/PathElementReference.java?view=auto&rev=454423
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/PathElementReference.java (added)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/PathElementReference.java Mon Oct  9 09:46:16 2006
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.jcr2spi.state.entry;
+
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.name.Path;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.IdFactory;
+import org.apache.jackrabbit.jcr2spi.state.NodeState;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateFactory;
+import org.apache.jackrabbit.jcr2spi.state.ItemState;
+import org.apache.jackrabbit.jcr2spi.state.NoSuchItemStateException;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateException;
+
+/**
+ * <code>PathElementReference</code> implements a {@link ChildNodeEntry} based
+ * on a {@link Path.PathElement}.
+ */
+class PathElementReference extends ChildNodeReference implements ChildNodeEntry {
+
+    /**
+     * IdFactory to create an ItemId based on the parent NodeId
+     */
+    private final IdFactory idFactory;
+
+    /**
+     * Creates a new <code>PathElementReference</code>
+     *
+     * @param parent    the <code>ItemState</code> that owns this child item
+     *                  reference.
+     * @param name      the name of the child node.
+     * @param isf       the item state factory to create the node state.
+     * @param idFactory the <code>IdFactory</code> to create new ItemIds
+     */
+    PathElementReference(NodeState parent, QName name,
+                         ItemStateFactory isf, IdFactory idFactory) {
+        super(parent, name, isf);
+        this.idFactory = idFactory;
+    }
+
+    /**
+     * Creates a new <code>PathElementReference</code> with the given parent
+     * <code>NodeState</code> and an already initialized child node state.
+     *
+     * @param child  the child node state.
+     * @param isf    the item state factory to re-create the node state.
+     * @param idFactory the <code>IdFactory</code> to create new ItemIds
+     */
+    PathElementReference(NodeState child, ItemStateFactory isf,
+                         IdFactory idFactory) {
+        super(child, isf);
+        this.idFactory = idFactory;
+    }
+
+    /**
+     * @inheritDoc
+     * @see ChildItemReference#doResolve()
+     * <p/>
+     * Returns a <code>NodeState</code>.
+     */
+    protected ItemState doResolve()
+            throws NoSuchItemStateException, ItemStateException {
+        return isf.createNodeState(getId(), getParent());
+    }
+
+    /**
+     * @inheritDoc
+     * @see ChildNodeEntry#getId()
+     */
+    public NodeId getId() {
+        return idFactory.createNodeId(parent.getNodeId(), Path.create(getName(), getIndex()));
+    }
+
+    /**
+     * This implementation always returns <code>null</code>.
+     * @inheritDoc
+     * @see ChildNodeEntry#getUUID()
+     */
+    public String getUUID() {
+        return null;
+    }
+}

Propchange: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/PathElementReference.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/PathElementReference.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/PropertyReference.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/PropertyReference.java?view=auto&rev=454423
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/PropertyReference.java (added)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/PropertyReference.java Mon Oct  9 09:46:16 2006
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.jcr2spi.state.entry;
+
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.IdFactory;
+import org.apache.jackrabbit.spi.PropertyId;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateFactory;
+import org.apache.jackrabbit.jcr2spi.state.NodeState;
+import org.apache.jackrabbit.jcr2spi.state.PropertyState;
+import org.apache.jackrabbit.jcr2spi.state.NoSuchItemStateException;
+import org.apache.jackrabbit.jcr2spi.state.ItemState;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateException;
+
+/**
+ * <code>PropertyReference</code> implements a reference to a property state.
+ */
+public class PropertyReference extends ChildItemReference implements ChildPropertyEntry {
+
+    /**
+     * IdFactory to create an ItemId based on the parent NodeId
+     */
+    private final IdFactory idFactory;
+
+    /**
+     * Creates a new <code>ChildPropertyEntry</code>.
+     *
+     * @param parent
+     * @param name
+     * @param isf
+     * @param idFactory
+     * @return new <code>ChildPropertyEntry</code>
+     */
+    public static ChildPropertyEntry create(NodeState parent, QName name, ItemStateFactory isf, IdFactory idFactory) {
+        return new PropertyReference(parent, name, isf, idFactory);
+    }
+
+    /**
+     * Creates a new <code>ChildPropertyEntry</code> for an property state that
+     * already exists.
+     *
+     * @param propState
+     * @param isf
+     * @param idFactory
+     * @return new <code>ChildPropertyEntry</code>
+     */
+    public static ChildPropertyEntry create(PropertyState propState, ItemStateFactory isf, IdFactory idFactory) {
+        return new PropertyReference(propState, isf, idFactory);
+    }
+
+    /**
+     * Creates a new <code>PropertyReference</code>.
+     *
+     * @param parent    the parent <code>NodeState</code> where the property
+     *                  belongs to.
+     * @param name      the name of the property.
+     * @param isf       the item state factory to create the property state.
+     * @param idFactory the id factory to create new ids.
+     */
+    private PropertyReference(NodeState parent, QName name, ItemStateFactory isf, IdFactory idFactory) {
+        super(parent, name, isf);
+        this.idFactory = idFactory;
+    }
+
+    /**
+     * Creates a new <code>PropertyReference</code> for an property state that
+     * already exists.
+     *
+     * @param propState the property state.
+     * @param isf       the item state factory to re-create the property state.
+     * @param idFactory the id factory to create new ids.
+     */
+    private PropertyReference(PropertyState propState, ItemStateFactory isf, IdFactory idFactory) {
+        super(propState.getParent(), propState, propState.getQName(), isf);
+        this.idFactory = idFactory;
+    }
+
+    /**
+     * @inheritDoc
+     * @see ChildItemReference#doResolve()
+     * <p/>
+     * Returns a <code>PropertyState</code>.
+     */
+    protected ItemState doResolve()
+            throws NoSuchItemStateException, ItemStateException {
+        return isf.createPropertyState(getId(), getParent());
+    }
+
+    //-------------------------------------------------< ChildPropertyEntry >---
+    /**
+     * @inheritDoc
+     */
+    public PropertyId getId() {
+        return idFactory.createPropertyId(parent.getNodeId(), name);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public QName getName() {
+        return name;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public PropertyState getPropertyState() throws NoSuchItemStateException, ItemStateException {
+        return (PropertyState) resolve();
+    }
+
+    /**
+     * @inheritDoc
+     * @see ChildPropertyEntry#isAvailable()
+     */
+    public boolean isAvailable() {
+        return isResolved();
+    }
+}

Propchange: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/PropertyReference.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/PropertyReference.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/UUIDReference.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/UUIDReference.java?view=auto&rev=454423
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/UUIDReference.java (added)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/UUIDReference.java Mon Oct  9 09:46:16 2006
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.jcr2spi.state.entry;
+
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.jcr2spi.state.NodeState;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateFactory;
+import org.apache.jackrabbit.jcr2spi.state.ItemState;
+import org.apache.jackrabbit.jcr2spi.state.NoSuchItemStateException;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateException;
+
+/**
+ * <code>UUIDReference</code> implements a {@link ChildNodeEntry} based on a
+ * <code>NodeId</code> with just a UUID and no relative path component.
+ */
+class UUIDReference extends ChildNodeReference implements ChildNodeEntry {
+
+    /**
+     * The <code>NodeId</code> with just a UUID that references the child node.
+     */
+    private final NodeId childId;
+
+    /**
+     * Creates a new <code>UUIDReference</code>.
+     *
+     * @param parent  the <code>NodeState</code> that owns this child node
+     *                reference.
+     * @param childId the id of the referenced <code>NodeState</code>. This id
+     *                must not have a relative path component.
+     * @param name    the name of the child node.
+     * @param isf     the item state factory to create the node state.
+     * @throws IllegalArgumentException if <code>childId</code> has a relative
+     *                                  path component.
+     */
+    UUIDReference(NodeState parent, NodeId childId, ItemStateFactory isf, QName name) {
+        super(parent, name, isf);
+        if (childId.getPath() != null) {
+            throw new IllegalArgumentException("childId must not contain a relative path");
+        }
+        this.childId = childId;
+    }
+
+    /**
+     * Creates a new <code>UUIDReference</code> with the given parent
+     * <code>NodeState</code> and an already initialized child node state.
+     *
+     * @param child     the child node state.
+     * @param isf       the item state factory to re-create the node state.
+     * @throws IllegalArgumentException if the id of <code>child</code> has a
+     *                                  relative path component.
+     */
+    UUIDReference(NodeState child, ItemStateFactory isf) {
+        super(child, isf);
+        this.childId = child.getNodeId();
+        if (childId.getPath() == null) {
+            throw new IllegalArgumentException("id of child must not contain a relative path");
+        }
+    }
+
+    /**
+     * @inheritDoc
+     * @see ChildItemReference#doResolve()
+     * <p/>
+     * Returns a <code>NodeState</code>.
+     */
+    protected ItemState doResolve()
+            throws NoSuchItemStateException, ItemStateException {
+        return isf.createNodeState(childId, getParent());
+    }
+
+    /**
+     * @inheritDoc
+     * @see ChildNodeEntry#getId()
+     */
+    public NodeId getId() {
+        return childId;
+    }
+
+    /**
+     * This implementation always returns a non-null value.
+     * @inheritDoc
+     * @see ChildNodeEntry#getUUID()
+     */
+    public String getUUID() {
+        return childId.getUUID();
+    }
+}

Propchange: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/UUIDReference.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/entry/UUIDReference.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java?view=diff&rev=454423&r1=454422&r2=454423
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java Mon Oct  9 09:46:16 2006
@@ -25,7 +25,7 @@
 import org.apache.jackrabbit.jcr2spi.LazyItemIterator;
 import org.apache.jackrabbit.jcr2spi.state.NodeState;
 import org.apache.jackrabbit.jcr2spi.state.ItemStateException;
-import org.apache.jackrabbit.jcr2spi.state.ChildNodeEntry;
+import org.apache.jackrabbit.jcr2spi.state.entry.ChildNodeEntry;
 import org.apache.jackrabbit.jcr2spi.state.PropertyState;
 import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.name.NameException;

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java?view=diff&rev=454423&r1=454422&r2=454423
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java Mon Oct  9 09:46:16 2006
@@ -19,8 +19,8 @@
 import org.apache.jackrabbit.jcr2spi.state.NodeState;
 import org.apache.jackrabbit.jcr2spi.state.PropertyState;
 import org.apache.jackrabbit.jcr2spi.state.ItemStateException;
-import org.apache.jackrabbit.jcr2spi.state.ItemState;
 import org.apache.jackrabbit.jcr2spi.state.ChangeLog;
+import org.apache.jackrabbit.jcr2spi.state.Status;
 import org.apache.jackrabbit.jcr2spi.observation.InternalEventListener;
 import org.apache.jackrabbit.jcr2spi.operation.Operation;
 import org.apache.jackrabbit.jcr2spi.operation.Checkout;
@@ -82,7 +82,7 @@
      */
     public boolean isCheckedOut(NodeState nodeState) throws RepositoryException {
         // shortcut: if state is new, its ancestor must be checkout
-        if (nodeState.getStatus() == ItemState.STATUS_NEW) {
+        if (nodeState.getStatus() == Status.NEW) {
             return true;
         }
 
@@ -195,12 +195,6 @@
      * an overlayed state.
      */
     private NodeState getWorkspaceState(NodeState nodeState) {
-        if (nodeState.hasOverlayedState()) {
-            // nodestate has been obtained from  Session-ISM
-            return (NodeState) nodeState.getOverlayedState();
-        } else {
-            // nodestate has been obtained from Workspace-ISM already
-            return nodeState;
-        }
+        return (NodeState) nodeState.getWorkspaceState();
     }
 }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java?view=diff&rev=454423&r1=454422&r2=454423
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java Mon Oct  9 09:46:16 2006
@@ -20,10 +20,11 @@
 import org.apache.jackrabbit.jcr2spi.state.PropertyState;
 import org.apache.jackrabbit.jcr2spi.state.ItemState;
 import org.apache.jackrabbit.jcr2spi.state.SessionItemStateManager;
-import org.apache.jackrabbit.jcr2spi.state.ChildNodeEntry;
+import org.apache.jackrabbit.jcr2spi.state.entry.ChildNodeEntry;
 import org.apache.jackrabbit.jcr2spi.state.ItemStateException;
 import org.apache.jackrabbit.jcr2spi.state.NoSuchItemStateException;
 import org.apache.jackrabbit.jcr2spi.state.ItemStateValidator;
+import org.apache.jackrabbit.jcr2spi.state.Status;
 import org.apache.jackrabbit.jcr2spi.SessionImpl;
 import org.apache.jackrabbit.jcr2spi.SessionListener;
 import org.apache.jackrabbit.jcr2spi.util.ReferenceChangeTracker;
@@ -403,7 +404,7 @@
              */
             try {
                 PropertyState conflicting = parent.getPropertyState(nodeInfo.getName());
-                if (conflicting.getStatus() == ItemState.STATUS_NEW) {
+                if (conflicting.getStatus() == Status.NEW) {
                     // assume this property has been imported as well;
                     // rename conflicting property
                     // TODO: use better reversible escaping scheme to create unique name

Modified: jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/IdFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/IdFactory.java?view=diff&rev=454423&r1=454422&r2=454423
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/IdFactory.java (original)
+++ jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/IdFactory.java Mon Oct  9 09:46:16 2006
@@ -26,9 +26,9 @@
 
     public PropertyId createPropertyId(NodeId parentId, QName propertyName);
 
-    public NodeId createNodeId(NodeId parentId, Path relativePath);
+    public NodeId createNodeId(NodeId parentId, Path path);
 
-    public NodeId createNodeId(String uuid, Path relativePath);
+    public NodeId createNodeId(String uuid, Path path);
 
     public NodeId createNodeId(String uuid);
 }

Modified: jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/ItemId.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/ItemId.java?view=diff&rev=454423&r1=454422&r2=454423
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/ItemId.java (original)
+++ jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/ItemId.java Mon Oct  9 09:46:16 2006
@@ -20,26 +20,23 @@
 
 /**
  * An <code>ItemId</code> identifies an item using a combination of UUID and
- * relative path. There are three basic forms of an ItemId. The following
+ * path. There are three basic forms of an ItemId. The following
  * table shows each of the allowed combinations where an <b>X</b> in
  * the column indicates that a value is set and a <b>-</b> indicates
  * that the value is <code>null</code>:
  * <table>
  * <tr><th>UUID</th><th>relative Path</th><th>Usage</th></tr>
- * <tr><td align="center"><b>X</b></td><td align="center"><b>-</b></td>
+ * <tr valign="top"><td align="center"><b>X</b></td><td align="center"><b>-</b></td>
  *   <td>The item can be identified with a UUID. In most cases such an item
  *   is also mix:referenceable but there is no restriction in that respect. An
  *   SPI implementation may also use a UUID to identify non-referenceable nodes.
  *   Whether a node is referenceable is purely governed by its node type or
  *   the assigned mixin types.</td></tr>
- * <tr><td align="center"><b>-</b></td><td align="center"><b>X</b></td>
+ * <tr valign="top"><td align="center"><b>-</b></td><td align="center"><b>X</b></td>
  *   <td>The item can not be identified with a UUID and none of its ancestors
- *   can be identified with a UUID. The item is identified by a relative path
- *   starting from the root node of the workspace as if calling
- *   {@link javax.jcr.Session#getRootNode() Session.getRootNode()}{@link
- *   javax.jcr.Node#getNode(String) .getNode(relPath)}.
+ *   can be identified with a UUID. The item is identified by an absolute path.
  *   </td></tr>
- * <tr><td align="center"><b>X</b></td><td align="center"><b>X</b></td>
+ * <tr valign="top"><td align="center"><b>X</b></td><td align="center"><b>X</b></td>
  *   <td>The item can not be identified with a UUID but one of its ancestors
  *   can. {@link #getUUID} returns the UUID of the nearest ancestor, which
  *   can be identified with a UUID. The relative path provides a navigation
@@ -64,8 +61,8 @@
     public String getUUID();
 
     /**
-     * @return the relative path part of this item id. Returns <code>null</code>
+     * @return the path part of this item id. Returns <code>null</code>
      *         if this item can be identified solely with a UUID.
      */
-    public Path getRelativePath();
+    public Path getPath();
 }

Modified: jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java?view=diff&rev=454423&r1=454422&r2=454423
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java (original)
+++ jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java Mon Oct  9 09:46:16 2006
@@ -61,15 +61,12 @@
      */
     public Properties getRepositoryDescriptors() throws RepositoryException;
 
-    //------------------------------------------------------< Initial login >---
-
+    //-----------------------------------< SessionInfo creation and release >---
     /**
-     * Authenticates the user using the supplied <code>credentials</code>. If
-     * <code>credentials</code> is <code>null</code> an implementation will use
-     * the current security context to obtain the {@link
-     * javax.security.auth.Subject}. If <code>credentials</code> is
-     * <code>null</code> and there is no <code>Subject</code> present in the
-     * current security context a <code>RepositoryException</code> is thrown.
+     * Returns a <code>SessionInfo</code> that will be used by other methods
+     * on the <code>RepositoryService</code>.
+     * An implementation may choose to authenticate the user using the supplied
+     * <code>credentials</code>.
      *
      * @param credentials the credentials of the user.
      * @return a <code>SessionInfo</code> if authentication was successful.
@@ -78,9 +75,17 @@
      *                                  is not recognized.
      * @throws RepositoryException      if an error occurs.
      */
-    public SessionInfo login(Credentials credentials, String workspaceName)
+    public SessionInfo obtain(Credentials credentials, String workspaceName)
             throws LoginException, NoSuchWorkspaceException, RepositoryException;
 
+    /**
+     * Indicates to the <code>RepositoryService</code>, that the given SessionInfo
+     * will not be used any more.
+     *
+     * @param sessionInfo
+     */
+    public void dispose(SessionInfo sessionInfo) throws RepositoryException;
+
     //--------------------------------------------------------------------------
     /**
      * @param sessionInfo
@@ -110,10 +115,10 @@
     /**
      * The <code>NodeId</code> of the root node may basically have two
      * characteristics. If the root node can be identified with a UUID the
-     * returned <code>NodeId</code> simply has a UUID part and the relative path
+     * returned <code>NodeId</code> simply has a UUID part and the path
      * part is <code>null</code>. If the root node cannot be identified with a
-     * UUID the UUID part is <code>null</code> and the relative path will be set
-     * to '.' (current element).
+     * UUID the UUID part is <code>null</code> and the path part will be set
+     * to "/".
      *
      * @param sessionInfo
      * @return

Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/IdFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/IdFactoryImpl.java?view=diff&rev=454423&r1=454422&r2=454423
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/IdFactoryImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/IdFactoryImpl.java Mon Oct  9 09:46:16 2006
@@ -49,16 +49,16 @@
         }
     }
 
-    public NodeId createNodeId(NodeId parentId, Path relativePath) {
+    public NodeId createNodeId(NodeId parentId, Path path) {
         try {
-            return new NodeIdImpl(parentId, relativePath);
+            return new NodeIdImpl(parentId, path);
         } catch (MalformedPathException e) {
             throw new IllegalArgumentException(e.getMessage());
         }
     }
 
-    public NodeId createNodeId(String uuid, Path relativePath) {
-        return new NodeIdImpl(uuid, relativePath);
+    public NodeId createNodeId(String uuid, Path path) {
+        return new NodeIdImpl(uuid, path);
     }
 
     public NodeId createNodeId(String uuid) {
@@ -69,16 +69,16 @@
     private abstract class ItemIdImpl implements ItemId {
 
         private final String uuid;
-        private final Path relativePath;
+        private final Path path;
 
         private int hashCode = 0;
 
-        private ItemIdImpl(String uuid, Path relativePath) {
-            if (uuid == null && relativePath == null) {
+        private ItemIdImpl(String uuid, Path path) {
+            if (uuid == null && path == null) {
                 throw new IllegalArgumentException("Only uuid or relative path might be null.");
             }
             this.uuid = uuid;
-            this.relativePath = relativePath;
+            this.path = path;
         }
 
         private ItemIdImpl(NodeId parentId, QName name) throws MalformedPathException {
@@ -86,11 +86,11 @@
                 throw new IllegalArgumentException("Invalid ItemIdImpl: parentId and name must not be null.");
             }
             this.uuid = parentId.getUUID();
-            Path parent = parentId.getRelativePath();
-            if (parent != null) {
-                this.relativePath = Path.create(parent, name, true);
+            Path parentPath = parentId.getPath();
+            if (parentPath != null) {
+                this.path = Path.create(parentPath, name, true);
             } else {
-                this.relativePath = Path.create(name, Path.INDEX_UNDEFINED);
+                this.path = Path.create(name, Path.INDEX_UNDEFINED);
             }
         }
 
@@ -100,8 +100,8 @@
             return uuid;
         }
 
-        public Path getRelativePath() {
-            return relativePath;
+        public Path getPath() {
+            return path;
         }
 
         /**
@@ -123,11 +123,11 @@
 
         boolean equals(ItemId other) {
             return (uuid == null) ? other.getUUID() == null : uuid.equals(other.getUUID())
-                && (relativePath == null) ? other.getRelativePath() == null : relativePath.equals(other.getRelativePath());
+                && (path == null) ? other.getPath() == null : path.equals(other.getPath());
         }
 
         /**
-         * Returns the hash code of the uuid and the relativePath. The computed hash code
+         * Returns the hash code of the uuid and the path. The computed hash code
          * is memorized for better performance.
          *
          * @return hash code
@@ -151,8 +151,8 @@
             if (uuid != null) {
                 b.append(uuid);
             }
-            if (relativePath != null) {
-                b.append(relativePath.toString());
+            if (path != null) {
+                b.append(path.toString());
             }
             return b.toString();
         }
@@ -164,12 +164,12 @@
             super(uuid, null);
         }
 
-        public NodeIdImpl(String uuid, Path relativePath) {
-            super(uuid, relativePath);
+        public NodeIdImpl(String uuid, Path path) {
+            super(uuid, path);
         }
 
-        public NodeIdImpl(NodeId parentId, Path relativePath) throws MalformedPathException {
-            super(parentId.getUUID(), (parentId.getRelativePath() != null) ? Path.create(parentId.getRelativePath(), relativePath, true) : relativePath);
+        public NodeIdImpl(NodeId parentId, Path path) throws MalformedPathException {
+            super(parentId.getUUID(), (parentId.getPath() != null) ? Path.create(parentId.getPath(), path, true) : path);
         }
 
         public boolean denotesNode() {
@@ -205,7 +205,7 @@
         }
 
         public QName getQName() {
-            return getRelativePath().getNameElement().getName();
+            return getPath().getNameElement().getName();
         }
 
         public boolean equals(Object obj) {

Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/NodeInfoImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/NodeInfoImpl.java?view=diff&rev=454423&r1=454422&r2=454423
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/NodeInfoImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/NodeInfoImpl.java Mon Oct  9 09:46:16 2006
@@ -64,7 +64,7 @@
         this.id = id;
 
         // retrieve name
-        if (id.getRelativePath() == null) {
+        if (id.getPath() == null) {
             DavProperty nameProp = propSet.get(ItemResourceConstants.JCR_NAME);
             if (nameProp != null && nameProp.getValue() != null) {
                 // not root node
@@ -81,8 +81,8 @@
                 qName = QName.ROOT;
             }
         } else {
-            Path.PathElement el = id.getRelativePath().getNameElement();
-            qName = (Path.CURRENT_ELEMENT == el) ? QName.ROOT : el.getName();
+            Path.PathElement el = id.getPath().getNameElement();
+            qName = (Path.ROOT_ELEMENT == el) ? QName.ROOT : el.getName();
         }
 
 

Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java?view=diff&rev=454423&r1=454422&r2=454423
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java Mon Oct  9 09:46:16 2006
@@ -373,10 +373,10 @@
 
     /**
      * TODO: handle impersonation
-     * @see RepositoryService#login(Credentials, String)
+     *
+     * @see RepositoryService#obtain(Credentials, String)
      */
-    public SessionInfo login(Credentials credentials, String workspaceName)
-            throws LoginException, NoSuchWorkspaceException, RepositoryException {
+    public SessionInfo obtain(Credentials credentials, String workspaceName) throws LoginException, NoSuchWorkspaceException, RepositoryException {
         // check if the workspace with the given name is accessible
         PropFindMethod method = null;
         try {
@@ -413,6 +413,12 @@
         }
     }
 
+    public void dispose(SessionInfo sessionInfo) throws RepositoryException {
+        checkSessionInfo(sessionInfo);
+        SubscriptionManager sMgr = ((SessionInfoImpl)sessionInfo).getSubscriptionManager();
+        sMgr.dispose();
+    }
+
     /**
      * @see RepositoryService#getWorkspaceNames(SessionInfo)
      */
@@ -844,6 +850,8 @@
         try {
             String uri = getItemUri(nodeId, sessionInfo);
             method = new PropFindMethod(uri, nameSet, DEPTH_0);
+            initMethod(method, sessionInfo, true);
+
             getClient(sessionInfo).executeMethod(method);
             method.checkSuccess();
 
@@ -877,7 +885,8 @@
     public EventIterator lock(SessionInfo sessionInfo, NodeId nodeId, boolean deep) throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, InvalidItemStateException, RepositoryException {
         try {
             String uri = getItemUri(nodeId, sessionInfo);
-            LockMethod method = new LockMethod(uri, Scope.EXCLUSIVE, Type.WRITE, null, DavConstants.INFINITE_TIMEOUT, true);
+            LockMethod method = new LockMethod(uri, Scope.EXCLUSIVE, Type.WRITE,
+                sessionInfo.getUserID(), DavConstants.INFINITE_TIMEOUT, deep);
             EventIterator events = execute(method, sessionInfo);
 
             String lockToken = method.getLockToken();
@@ -1868,6 +1877,16 @@
                 subscriptions.remove(listener);
                 currentSubscriptions = null;
                 if (subscriptions.isEmpty()) {
+                    stopPolling();
+                }
+            }
+        }
+
+        public void dispose() {
+            synchronized (subscriptionsLock) {
+                if (!subscriptions.isEmpty()) {
+                    subscriptions.clear();
+                    currentSubscriptions = null;
                     stopPolling();
                 }
             }

Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/SubscriptionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/SubscriptionManager.java?view=diff&rev=454423&r1=454422&r2=454423
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/SubscriptionManager.java (original)
+++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/SubscriptionManager.java Mon Oct  9 09:46:16 2006
@@ -26,11 +26,13 @@
 
     public void setSessionInfo(SessionInfo sessionInfo);
 
-        public boolean subscriptionExists(EventListener listener);
+    public boolean subscriptionExists(EventListener listener);
 
-        public String getSubscriptionId(EventListener listener);
+    public String getSubscriptionId(EventListener listener);
 
-        public void addSubscription(String uri, String subscriptionId, EventListener listener);
+    public void addSubscription(String uri, String subscriptionId, EventListener listener);
 
-        public void removeSubscription(EventListener listener);
+    public void removeSubscription(EventListener listener);
+
+    public void dispose();
 }

Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolverImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolverImpl.java?view=diff&rev=454423&r1=454422&r2=454423
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolverImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolverImpl.java Mon Oct  9 09:46:16 2006
@@ -115,13 +115,13 @@
         } else {
             StringBuffer uriBuffer = new StringBuffer();
 
-            Path relativePath = itemId.getRelativePath();
+            Path path = itemId.getPath();
             String uuid = itemId.getUUID();
 
             // resolver uuid part
             if (uuid != null) {
-                ItemId uuidId = (relativePath == null) ? itemId : service.getIdFactory().createNodeId(uuid);
-                if (relativePath != null & cache.containsItemId(uuidId)) {
+                ItemId uuidId = (path == null) ? itemId : service.getIdFactory().createNodeId(uuid);
+                if (path != null & cache.containsItemId(uuidId)) {
                     // append uri of parent node, that is already cached
                     uriBuffer.append(cache.getUri(uuidId));
                 } else {
@@ -159,13 +159,10 @@
                 uriBuffer.append(getRootItemUri(workspaceName));
             }
             // resolve relative-path part unless it denotes the root-item
-            if (relativePath != null && !relativePath.denotesRoot()) {
+            if (path != null && !path.denotesRoot()) {
                 try {
-                    String jcrPath = PathFormat.format(relativePath, nsResolver);
-                    // TODO: TOBEFIXED rootId is currently build from absolute path and not
-                    // from '.' as description in RS.getRootId defines. similarly
-                    // the PathResolver does not accept a non-normalized root-path.
-                    if (relativePath.isAbsolute()) {
+                    String jcrPath = PathFormat.format(path, nsResolver);
+                    if (path.isAbsolute()) {
                         jcrPath = jcrPath.substring(1);
                     }
                     uriBuffer.append(Text.escapePath(jcrPath));