jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r448191 - in /jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: ./ state/ util/ xml/
Date Wed, 20 Sep 2006 12:43:40 GMT
Author: angela
Date: Wed Sep 20 05:43:39 2006
New Revision: 448191

URL: http://svn.apache.org/viewvc?view=rev&rev=448191
Log:
work in progress

- move getPath from HierarchyManager to ItemState
- remove unused ZombieHierarchyManager
- remove protected methods in HierarchyManagerImpl, that were used by Zombie-HM.
- ItemStateFactory: add method createRootState(ItemStateManager)

Removed:
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ZombieHierarchyManager.java
Modified:
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/HierarchyManager.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/HierarchyManagerImpl.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/CachingItemStateManager.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateFactory.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/util/LogUtil.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/HierarchyManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/HierarchyManager.java?view=diff&rev=448191&r1=448190&r2=448191
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/HierarchyManager.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/HierarchyManager.java
Wed Sep 20 05:43:39 2006
@@ -40,16 +40,6 @@
     ItemState getItemState(Path qPath) throws PathNotFoundException, RepositoryException;
 
     /**
-     * Returns the path to the item represented by the given state object.
-     *
-     * @param itemState
-     * @return
-     * @throws ItemNotFoundException
-     * @throws RepositoryException
-     */
-    Path getQPath(ItemState itemState) throws ItemNotFoundException, RepositoryException;
-
-    /**
      * Returns the depth of the specified item which is equivalent to
      * <code>getQPath(id).getAncestorCount()</code>. The depth reflects the
      * absolute hierarchy level.

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/HierarchyManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/HierarchyManagerImpl.java?view=diff&rev=448191&r1=448190&r2=448191
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/HierarchyManagerImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/HierarchyManagerImpl.java
Wed Sep 20 05:43:39 2006
@@ -19,15 +19,12 @@
 import org.apache.jackrabbit.jcr2spi.state.ItemState;
 import org.apache.jackrabbit.jcr2spi.state.ItemStateException;
 import org.apache.jackrabbit.jcr2spi.state.ItemStateManager;
-import org.apache.jackrabbit.jcr2spi.state.NoSuchItemStateException;
 import org.apache.jackrabbit.jcr2spi.state.NodeState;
-import org.apache.jackrabbit.jcr2spi.state.PropertyState;
 import org.apache.jackrabbit.jcr2spi.state.ChildNodeEntry;
 import org.apache.jackrabbit.jcr2spi.util.LogUtil;
 import org.apache.jackrabbit.name.NamespaceResolver;
 import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.name.Path;
-import org.apache.jackrabbit.name.MalformedPathException;
 import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
 
@@ -52,58 +49,7 @@
         this.nsResolver = nsResolver;
     }
 
-    //-------------------------------------------------------< overridables >---
-
-    // TODO: review the overridables as soon as status of ZombiHierarchyManager is clear
-    /**
-     *
-     * @param state
-     * @return
-     */
-    protected NodeState getParentState(ItemState state) {
-        return state.getParent();
-    }
-
-    // TODO: review the overridables as soon as status of ZombiHierarchyManager is clear
-    /**
-     * Returns the <code>ChildNodeEntry</code> of <code>parent</code>
with the
-     * specified <code>uuid</code> or <code>null</code> if there's
no such entry.
-     * <p/>
-     * Low-level hook provided for specialized derived classes.
-     *
-     * @param parent node state
-     * @param state  child state
-     * @return the <code>ChildNodeEntry</code> of <code>parent</code>
with
-     *         the specified <code>uuid</code> or <code>null</code>
if there's
-     *         no such entry.
-     * @see ZombieHierarchyManager#getChildNodeEntry(NodeState, NodeState)
-     */
-    protected ChildNodeEntry getChildNodeEntry(NodeState parent,
-                                               NodeState state) {
-        return parent.getChildNodeEntry(state);
-    }
-
-    // TODO: review the overridables as soon as status of ZombiHierarchyManager is clear
-    /**
-     * Returns the <code>ChildNodeEntry</code> of <code>parent</code>
with the
-     * specified <code>name</code> and <code>index</code> or <code>null</code>
-     * if there's no such entry.
-     * <p/>
-     * Low-level hook provided for specialized derived classes.
-     *
-     * @param parent node state
-     * @param name   name of child node entry
-     * @param index  index of child node entry
-     * @return the <code>ChildNodeEntry</code> of <code>parent</code>
with
-     *         the specified <code>name</code> and <code>index</code>
or
-     *         <code>null</code> if there's no such entry.
-     * @see ZombieHierarchyManager#getChildNodeEntry(NodeState, QName, int)
-     */
-    protected ChildNodeEntry getChildNodeEntry(NodeState parent,
-                                               QName name,
-                                               int index) {
-        return parent.getChildNodeEntry(name, index);
-    }
+    //------------------------------------------------------------< private >---
 
     /**
      * Resolve a path into an item state. Recursively invoked method that may be
@@ -115,7 +61,7 @@
      * @param next  next path element index to resolve
      * @return the state of the item denoted by <code>path</code>
      */
-    protected ItemState resolvePath(Path path, ItemState state, int next)
+    private ItemState resolvePath(Path path, ItemState state, int next)
         throws PathNotFoundException, RepositoryException {
 
         Path.PathElement[] elements = path.getElements();
@@ -132,7 +78,7 @@
 
         if (parentState.hasChildNodeEntry(name, index)) {
             // child node
-            ChildNodeEntry nodeEntry = getChildNodeEntry(parentState, name, index);
+            ChildNodeEntry nodeEntry = parentState.getChildNodeEntry(name, index);
             try {
                 childState = nodeEntry.getNodeState();
             } catch (ItemStateException e) {
@@ -161,50 +107,6 @@
         return resolvePath(path, childState, next + 1);
     }
 
-    /**
-     * Adds the path element of an item id to the path currently being built.
-     * Recursively invoked method that may be overridden by some subclass to
-     * either return cached responses or add response to cache. On exit,
-     * <code>builder</code> contains the path of <code>state</code>.
-     *
-     * @param builder builder currently being used
-     * @param state   item to find path of
-     */
-    protected void buildPath(Path.PathBuilder builder, ItemState state)
-            throws ItemStateException, RepositoryException {
-        NodeState parentState = state.getParent();
-        // shortcut for root state
-        if (parentState == null) {
-            builder.addRoot();
-            return;
-        }
-
-        // recursively build path of parent
-        buildPath(builder, parentState);
-
-        if (state.isNode()) {
-            NodeState nodeState = (NodeState) state;
-            ChildNodeEntry entry = getChildNodeEntry(parentState, nodeState);
-            if (entry == null) {
-                String msg = "Failed to build path of " + state + ": "
-                        + LogUtil.safeGetJCRPath(parentState, nsResolver, this) + " has such
child entry.";
-                log.debug(msg);
-                throw new ItemNotFoundException(msg);
-            }
-            // add to path
-            if (entry.getIndex() == Path.INDEX_DEFAULT) {
-                builder.addLast(entry.getName());
-            } else {
-                builder.addLast(entry.getName(), entry.getIndex());
-            }
-        } else {
-            PropertyState propState = (PropertyState) state;
-            QName name = propState.getQName();
-            // add to path
-            builder.addLast(name);
-        }
-    }
-
     //---------------------------------------------------< HierarchyManager >---
     /**
      * @see HierarchyManager#getItemState(Path)
@@ -232,43 +134,15 @@
     }
 
     /**
-     * @see HierarchyManager#getQPath(ItemState)
-     */
-    public Path getQPath(ItemState itemState) throws ItemNotFoundException, RepositoryException
{
-        // shortcut for root state
-        if (itemState.getParent() == null) {
-            return Path.ROOT;
-        }
-
-        // build path otherwise
-        try {
-            Path.PathBuilder builder = new Path.PathBuilder();
-            buildPath(builder, itemState);
-            return builder.getPath();
-        } catch (NoSuchItemStateException e) {
-            String msg = "Failed to build path of " + itemState;
-            log.debug(msg);
-            throw new ItemNotFoundException(msg, e);
-        } catch (ItemStateException e) {
-            String msg = "Failed to build path of " + itemState;
-            log.debug(msg);
-            throw new RepositoryException(msg, e);
-        } catch (MalformedPathException e) {
-            String msg = "Failed to build path of " + itemState;
-            throw new RepositoryException(msg, e);
-        }
-    }
-
-    /**
      * @see HierarchyManager#getDepth(ItemState)
      */
     public int getDepth(ItemState itemState) throws ItemNotFoundException, RepositoryException
{
         int depth = Path.ROOT_DEPTH;
-        NodeState parentState = getParentState(itemState);
+        NodeState parentState = itemState.getParent();
         while (parentState != null) {
             depth++;
             itemState = parentState;
-            parentState = getParentState(itemState);
+            parentState = itemState.getParent();
         }
         return depth;
     }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java?view=diff&rev=448191&r1=448190&r2=448191
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
Wed Sep 20 05:43:39 2006
@@ -495,7 +495,7 @@
      * @return the primary path to this <code>Item</code>
      */
     Path getQPath() throws RepositoryException {
-        return session.getHierarchyManager().getQPath(state);
+        return state.getQPath();
     }
 
     /**
@@ -514,6 +514,6 @@
      * @return JCR path
      */
     String safeGetJCRPath() {
-        return LogUtil.safeGetJCRPath(getItemState(), session.getNamespaceResolver(), session.getHierarchyManager());
+        return LogUtil.safeGetJCRPath(getItemState(), session.getNamespaceResolver());
     }
 }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java?view=diff&rev=448191&r1=448190&r2=448191
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java
Wed Sep 20 05:43:39 2006
@@ -354,7 +354,7 @@
             } else {
                 ps.print("- ");
             }
-            ps.println(state + "\t" + LogUtil.safeGetJCRPath(state, session.getNamespaceResolver(),
hierMgr) + " (" + item + ")");
+            ps.println(state + "\t" + LogUtil.safeGetJCRPath(state, session.getNamespaceResolver())
+ " (" + item + ")");
         }
     }
 

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/CachingItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/CachingItemStateManager.java?view=diff&rev=448191&r1=448190&r2=448191
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/CachingItemStateManager.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/CachingItemStateManager.java
Wed Sep 20 05:43:39 2006
@@ -95,7 +95,7 @@
 
     public NodeState getRootState() throws ItemStateException {
         if (root == null) {
-            root = isf.createNodeState(idFactory.createNodeId((String) null, Path.ROOT),
this);
+            root = isf.createRootState(this);
             root.addListener(lifeCycleListener);
         }
         return root;
@@ -183,8 +183,7 @@
         String uuid = id.getUUID();
         Path relPath = id.getRelativePath();
 
-        // start with root node if no uuid part in id
-        NodeState nodeState = getRootState();
+        NodeState nodeState;
         // resolve uuid part
         if (uuid != null) {
             nodeState = (NodeState) uuid2NodeState.get(uuid);
@@ -195,6 +194,9 @@
                 nodeState.addListener(lifeCycleListener);
                 uuid2NodeState.put(uuid, nodeState);
             }
+        } else {
+            // start with root node if no uuid part in id
+            nodeState = getRootState();
         }
 
         ItemState s = nodeState;

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java?view=diff&rev=448191&r1=448190&r2=448191
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java
Wed Sep 20 05:43:39 2006
@@ -19,9 +19,14 @@
 import org.apache.jackrabbit.util.WeakIdentityCollection;
 import org.apache.jackrabbit.spi.ItemId;
 import org.apache.jackrabbit.spi.IdFactory;
+import org.apache.jackrabbit.name.Path;
+import org.apache.jackrabbit.name.MalformedPathException;
+import org.apache.jackrabbit.name.QName;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.RepositoryException;
 import java.util.Collection;
 import java.util.Set;
 
@@ -316,6 +321,79 @@
      * @return the identifier of this item state..
      */
     public abstract ItemId getId();
+
+    /**
+     * Returns the qualified path of this item state.
+     *
+     * @return qualified path
+     * @throws ItemNotFoundException
+     * @throws RepositoryException
+     */
+    public Path getQPath() throws ItemNotFoundException, RepositoryException {
+        // shortcut for root state
+        if (getParent() == null) {
+            return Path.ROOT;
+        }
+
+        // build path otherwise
+        try {
+            Path.PathBuilder builder = new Path.PathBuilder();
+            buildPath(builder, this);
+            return builder.getPath();
+        } catch (NoSuchItemStateException e) {
+            String msg = "Failed to build path of " + this;
+            log.debug(msg);
+            throw new ItemNotFoundException(msg, e);
+        } catch (ItemStateException e) {
+            String msg = "Failed to build path of " + this;
+            log.debug(msg);
+            throw new RepositoryException(msg, e);
+        } catch (MalformedPathException e) {
+            String msg = "Failed to build path of " + this;
+            throw new RepositoryException(msg, e);
+        }
+    }
+
+    /**
+     * Adds the path element of an item id to the path currently being built.
+     * On exit, <code>builder</code> contains the path of <code>state</code>.
+     *
+     * @param builder builder currently being used
+     * @param state   item to find path of
+     */
+    private void buildPath(Path.PathBuilder builder, ItemState state)
+            throws ItemStateException, RepositoryException {
+        NodeState parentState = state.getParent();
+        // shortcut for root state
+        if (parentState == null) {
+            builder.addRoot();
+            return;
+        }
+
+        // recursively build path of parent
+        buildPath(builder, parentState);
+
+        if (state.isNode()) {
+            NodeState nodeState = (NodeState) state;
+            ChildNodeEntry entry = parentState.getChildNodeEntry(nodeState);
+            if (entry == null) {
+                String msg = "Failed to build path of " + state + ": parent has no such child
entry.";
+                log.debug(msg);
+                throw new ItemNotFoundException(msg);
+            }
+            // add to path
+            if (entry.getIndex() == Path.INDEX_DEFAULT) {
+                builder.addLast(entry.getName());
+            } else {
+                builder.addLast(entry.getName(), entry.getIndex());
+            }
+        } else {
+            PropertyState propState = (PropertyState) state;
+            QName name = propState.getQName();
+            // add to path
+            builder.addLast(name);
+        }
+    }
 
     /**
      * Returns <code>true</code> if this item state represents new or modified

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateFactory.java?view=diff&rev=448191&r1=448190&r2=448191
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateFactory.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateFactory.java
Wed Sep 20 05:43:39 2006
@@ -26,6 +26,8 @@
  */
 public interface ItemStateFactory {
 
+    public NodeState createRootState(ItemStateManager ism) throws ItemStateException;
+
     /**
      * Creates the child <code>NodeState</code> with the given
      * <code>nodeId</code>.

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java?view=diff&rev=448191&r1=448190&r2=448191
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java
Wed Sep 20 05:43:39 2006
@@ -21,7 +21,6 @@
 import org.apache.jackrabbit.jcr2spi.nodetype.ValueConstraint;
 import org.apache.jackrabbit.jcr2spi.nodetype.EffectiveNodeType;
 import org.apache.jackrabbit.jcr2spi.ManagerProvider;
-import org.apache.jackrabbit.jcr2spi.HierarchyManager;
 import org.apache.jackrabbit.jcr2spi.util.LogUtil;
 import org.apache.jackrabbit.jcr2spi.security.AccessManager;
 import org.slf4j.LoggerFactory;
@@ -257,10 +256,10 @@
      *
      * @param itemState
      * @return JCR path
-     * @see LogUtil#safeGetJCRPath(ItemState, NamespaceResolver, HierarchyManager)
+     * @see LogUtil#safeGetJCRPath(ItemState,NamespaceResolver)
      */
     private String safeGetJCRPath(ItemState itemState) {
-        return LogUtil.safeGetJCRPath(itemState, mgrProvider.getNamespaceResolver(), mgrProvider.getHierarchyManager());
+        return LogUtil.safeGetJCRPath(itemState, mgrProvider.getNamespaceResolver());
     }
 
     /**

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java?view=diff&rev=448191&r1=448190&r2=448191
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java
Wed Sep 20 05:43:39 2006
@@ -367,7 +367,7 @@
         switch (state.getStatus()) {
             case ItemState.STATUS_NEW:
                 {
-                    String msg = LogUtil.safeGetJCRPath(state, nsResolver, hierMgr) + ":
cannot save a new item.";
+                    String msg = LogUtil.safeGetJCRPath(state, nsResolver) + ": cannot save
a new item.";
                     log.debug(msg);
                     throw new ItemStateException(msg);
                 }
@@ -376,13 +376,13 @@
             switch (state.getStatus()) {
                 case ItemState.STATUS_STALE_MODIFIED:
                     {
-                        String msg = LogUtil.safeGetJCRPath(state, nsResolver, hierMgr) +
": the item cannot be saved because it has been modified externally.";
+                        String msg = LogUtil.safeGetJCRPath(state, nsResolver) + ": the item
cannot be saved because it has been modified externally.";
                         log.debug(msg);
                         throw new StaleItemStateException(msg);
                     }
                 case ItemState.STATUS_STALE_DESTROYED:
                     {
-                        String msg = LogUtil.safeGetJCRPath(state, nsResolver, hierMgr) +
": the item cannot be saved because it has been deleted externally.";
+                        String msg = LogUtil.safeGetJCRPath(state, nsResolver) + ": the item
cannot be saved because it has been deleted externally.";
                         log.debug(msg);
                         throw new StaleItemStateException(msg);
                     }

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=448191&r1=448190&r2=448191
==============================================================================
--- 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
Wed Sep 20 05:43:39 2006
@@ -94,7 +94,7 @@
      */
     public NodeState getRootState() throws ItemStateException {
         if (rootNodeState == null) {
-            rootNodeState = isf.createNodeState(parent.getRootState().getNodeId(), this);
+            rootNodeState = isf.createRootState(this);
             rootNodeState.addListener(this);
         }
         return rootNodeState;
@@ -433,6 +433,19 @@
             // notify listener that a property state has been created
             listener.statusChanged(propState, ItemState.STATUS_NEW);
             return propState;
+        }
+
+        /**
+         * @inheritDoc
+         * @see ItemStateFactory#createRootState(ItemStateManager)
+         */
+        public NodeState createRootState(ItemStateManager ism) throws ItemStateException
{
+            // retrieve state to overlay
+            NodeState overlayedState = (NodeState) parent.getRootState();
+            NodeState nodeState = new NodeState(overlayedState, null,
+                    ItemState.STATUS_EXISTING, this, idFactory);
+            nodeState.addListener(listener);
+            return nodeState;
         }
 
         /**

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=448191&r1=448190&r2=448191
==============================================================================
--- 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
Wed Sep 20 05:43:39 2006
@@ -63,6 +63,18 @@
     }
 
     /**
+     * @inheritDoc
+     * @see ItemStateFactory#createRootState(ItemStateManager)
+     */
+    public NodeState createRootState(ItemStateManager ism) throws ItemStateException {
+        try {
+            return createNodeState(service.getRootId(sessionInfo), ism);
+        } catch (RepositoryException e) {
+            throw new ItemStateException("Internal error while building root state.");
+        }
+    }
+
+    /**
      * Creates the node with information retrieved from the
      * <code>RepositoryService</code>.
      *

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/util/LogUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/util/LogUtil.java?view=diff&rev=448191&r1=448190&r2=448191
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/util/LogUtil.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/util/LogUtil.java
Wed Sep 20 05:43:39 2006
@@ -24,7 +24,6 @@
 import org.apache.jackrabbit.name.NamespaceResolver;
 import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.name.NameFormat;
-import org.apache.jackrabbit.jcr2spi.HierarchyManager;
 import org.apache.jackrabbit.jcr2spi.state.ItemState;
 import org.apache.jackrabbit.spi.ItemId;
 
@@ -61,13 +60,12 @@
      *
      * @param itemState
      * @param nsResolver
-     * @param hierManager
      * @return JCR path
      */
-    public static String safeGetJCRPath(ItemState itemState, NamespaceResolver nsResolver,
-                                 HierarchyManager hierManager) {
+    public static String safeGetJCRPath(ItemState itemState, NamespaceResolver nsResolver
+    ) {
         try {
-            return safeGetJCRPath(hierManager.getQPath(itemState), nsResolver);
+            return safeGetJCRPath(itemState.getQPath(), nsResolver);
         } catch (RepositoryException e) {
             ItemId id = itemState.getId();
             log.error("failed to convert " + id + " to JCR path.");

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=448191&r1=448190&r2=448191
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java
Wed Sep 20 05:43:39 2006
@@ -186,14 +186,14 @@
                if (def.isProtected() && entExisting.includesNodeType(nodeInfo.getNodeTypeName()))
{
                    // skip protected node
                    parents.push(null); // push null onto stack for skipped node
-                   log.debug("skipping protected node " + LogUtil.safeGetJCRPath(existing,
session.getNamespaceResolver(), session.getHierarchyManager()));
+                   log.debug("skipping protected node " + LogUtil.safeGetJCRPath(existing,
session.getNamespaceResolver()));
                    return;
                }
                if (def.isAutoCreated() && entExisting.includesNodeType(nodeInfo.getNodeTypeName()))
{
                    // this node has already been auto-created, no need to create it
                    nodeState = existing;
                } else {
-                   throw new ItemExistsException(LogUtil.safeGetJCRPath(existing, session.getNamespaceResolver(),
session.getHierarchyManager()));
+                   throw new ItemExistsException(LogUtil.safeGetJCRPath(existing, session.getNamespaceResolver()));
                }
            }
        }
@@ -337,8 +337,8 @@
 
             case ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING:
                 // make sure conflicting node is not importTarget or an ancestor thereof
-                Path p0 = session.getHierarchyManager().getQPath(importTarget);
-                Path p1 = session.getHierarchyManager().getQPath(conflicting);
+                Path p0 = importTarget.getQPath();
+                Path p1 = conflicting.getQPath();
                 try {
                     if (p1.equals(p0) || p1.isAncestorOf(p0)) {
                         msg = "cannot remove ancestor node";
@@ -491,7 +491,7 @@
                 def = existing.getDefinition();
                 if (def.isProtected()) {
                     // skip protected property
-                    log.debug("skipping protected property " + LogUtil.safeGetJCRPath(existing,
session.getNamespaceResolver(), session.getHierarchyManager()));
+                    log.debug("skipping protected property " + LogUtil.safeGetJCRPath(existing,
session.getNamespaceResolver()));
                     return;
                 }
                 if (def.isAutoCreated()
@@ -500,7 +500,7 @@
                     // this property has already been auto-created, no need to create it
                     propState = existing;
                 } else {
-                    throw new ItemExistsException(LogUtil.safeGetJCRPath(existing, session.getNamespaceResolver(),
session.getHierarchyManager()));
+                    throw new ItemExistsException(LogUtil.safeGetJCRPath(existing, session.getNamespaceResolver()));
                 }
             } catch (ItemStateException e) {
                 // should not occur. existance has been checked before



Mime
View raw message