jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r449672 - in /jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: NodeImpl.java state/NodeState.java
Date Mon, 25 Sep 2006 13:00:21 GMT
Author: angela
Date: Mon Sep 25 06:00:20 2006
New Revision: 449672

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

- Node.getIndex() always returns 1.
  It's the definition of the node that determines if SNS are allowed and not
  the definition of the parent -> moving check from NodeState.getChildIndex to NodeImpl

Modified:
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java?view=diff&rev=449672&r1=449671&r2=449672
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
Mon Sep 25 06:00:20 2006
@@ -549,19 +549,22 @@
     public int getIndex() throws RepositoryException {
         checkStatus();
 
-        NodeState parentState = getItemState().getParent();
-        if (parentState == null) {
-            // the root node cannot have same-name siblings; always return the
-            // default index
+        if (getNodeState().getDefinition().allowsSameNameSiblings()) {
+            NodeState parentState = getItemState().getParent();
+            if (parentState == null) {
+                // the root node cannot have same-name siblings; always return the
+                // default index
+                return Path.INDEX_DEFAULT;
+            }
+            ChildNodeEntry entry = parentState.getChildNodeEntry(getNodeState());
+            if (entry == null) {
+                String msg = "Unable to retrieve index for: " + safeGetJCRPath();
+                throw new RepositoryException(msg);
+            }
+            return entry.getIndex();
+        } else {
             return Path.INDEX_DEFAULT;
         }
-
-        ChildNodeEntry parentEntry = parentState.getChildNodeEntry(getNodeState());
-        if (parentEntry == null) {
-            String msg = "Unable to retrieve index for: " + safeGetJCRPath();
-            throw new RepositoryException(msg);
-        }
-        return parentEntry.getIndex();
     }
 
     /**

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java?view=diff&rev=449672&r1=449671&r2=449672
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
Mon Sep 25 06:00:20 2006
@@ -1019,9 +1019,6 @@
      *         found in this <code>NodeState</code>.
      */
     int getChildNodeIndex(QName name, ChildNodeEntry cne) {
-        if (!this.getDefinition().allowsSameNameSiblings()) {
-            return Path.INDEX_DEFAULT;
-        }
         List sns = childNodeEntries.get(name);
         // index is one based
         int index = 1;
@@ -1040,7 +1037,7 @@
             }
         }
         // not found
-        return 0;
+        return Path.INDEX_UNDEFINED;
     }
 
     //-------------------------------< internal >-------------------------------



Mime
View raw message