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/08/16 14:17:44 UTC

svn commit: r431885 - in /jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: HierarchyManagerImpl.java ZombieHierarchyManager.java

Author: angela
Date: Wed Aug 16 05:17:43 2006
New Revision: 431885

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

- hierarchy-managers: remove unused protected method getParentId
- hierarchy-managers: limit usage of itemId

Modified:
    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/ZombieHierarchyManager.java

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?rev=431885&r1=431884&r2=431885&view=diff
==============================================================================
--- 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 Aug 16 05:17:43 2006
@@ -25,7 +25,6 @@
 import org.apache.jackrabbit.jcr2spi.state.ChildNodeEntry;
 import org.apache.jackrabbit.jcr2spi.util.LogUtil;
 import org.apache.jackrabbit.name.NamespaceResolver;
-import org.apache.jackrabbit.spi.NodeId;
 import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.name.Path;
 import org.apache.jackrabbit.name.MalformedPathException;
@@ -53,20 +52,7 @@
         this.nsResolver = nsResolver;
     }
 
-    //---------------------------------------------------------< overridables >
-    // TODO: review the overridables as soon as status of ZombiHierarchyManager is clear
-    /**
-     * Returns the <code>parentUUID</code> of the given item.
-     * <p/>
-     * Low-level hook provided for specialized derived classes.
-     *
-     * @param state item state
-     * @return parent <code>NodeId</code> of the given item state
-     * @see ZombieHierarchyManager#getParentId(ItemState)
-     */
-    protected NodeId getParentId(ItemState state) {
-        return state.getParent().getNodeId();
-    }
+    //-------------------------------------------------------< overridables >---
 
     // TODO: review the overridables as soon as status of ZombiHierarchyManager is clear
     /**
@@ -86,15 +72,15 @@
      * Low-level hook provided for specialized derived classes.
      *
      * @param parent node state
-     * @param id   id of child node entry
+     * @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, NodeId)
+     * @see ZombieHierarchyManager#getChildNodeEntry(NodeState, NodeState)
      */
     protected ChildNodeEntry getChildNodeEntry(NodeState parent,
-                                               NodeId id) {
-        return parent.getChildNodeEntry(id);
+                                               NodeState state) {
+        return parent.getChildNodeEntry(state.getNodeId());
     }
 
     // TODO: review the overridables as soon as status of ZombiHierarchyManager is clear
@@ -198,17 +184,15 @@
 
         if (state.isNode()) {
             NodeState nodeState = (NodeState) state;
-            NodeId id = nodeState.getNodeId();
-            ChildNodeEntry entry = getChildNodeEntry(parentState, id);
+            ChildNodeEntry entry = getChildNodeEntry(parentState, nodeState);
             if (entry == null) {
-                String msg = "failed to build path of " + state.getId() + ": "
-                        + parentState.getNodeId() + " has no child entry for "
-                        + id;
+                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() == org.apache.jackrabbit.name.Path.INDEX_DEFAULT) {
+            if (entry.getIndex() == Path.INDEX_DEFAULT) {
                 builder.addLast(entry.getName());
             } else {
                 builder.addLast(entry.getName(), entry.getIndex());
@@ -262,15 +246,15 @@
             buildPath(builder, itemState);
             return builder.getPath();
         } catch (NoSuchItemStateException e) {
-            String msg = "failed to build path of " + itemState.getId();
+            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.getId();
+            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.getId();
+            String msg = "Failed to build path of " + itemState;
             throw new RepositoryException(msg, e);
         }
     }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ZombieHierarchyManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ZombieHierarchyManager.java?rev=431885&r1=431884&r2=431885&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ZombieHierarchyManager.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ZombieHierarchyManager.java Wed Aug 16 05:17:43 2006
@@ -50,20 +50,6 @@
      * <p/>
      * Also allows for removed items.
      */
-    protected NodeId getParentId(ItemState state) {
-        if (state.hasOverlayedState()) {
-            // use 'old' parent in case item has been removed
-            return state.getOverlayedState().getParent().getNodeId();
-        }
-        // delegate to base class
-        return super.getParentId(state);
-    }
-
-    /**
-     * {@inheritDoc}
-     * <p/>
-     * Also allows for removed items.
-     */
     protected NodeState getParentState(ItemState state) {
         if (state.hasOverlayedState()) {
             // use 'old' parent in case item has been removed
@@ -100,17 +86,19 @@
      * Also allows for removed child node entries.
      */
     protected ChildNodeEntry getChildNodeEntry(NodeState parent,
-                                                         NodeId id) {
+                                               NodeState state) {
         // check removed child node entries first
         Iterator iter = parent.getRemovedChildNodeEntries().iterator();
+        NodeId id = state.getNodeId();
         while (iter.hasNext()) {
             ChildNodeEntry entry = (ChildNodeEntry) iter.next();
+            // TODO: not correct to compare ids
             if (entry.getId().equals(id)) {
                 return entry;
             }
         }
         // no matching removed child node entry found in parent,
         // delegate to base class
-        return super.getChildNodeEntry(parent, id);
+        return super.getChildNodeEntry(parent, state);
     }
 }