jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r432559 - in /jackrabbit/trunk/contrib/spi: client/ jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/
Date Fri, 18 Aug 2006 12:15:05 GMT
Author: mreutegg
Date: Fri Aug 18 05:15:02 2006
New Revision: 432559

URL: http://svn.apache.org/viewvc?rev=432559&view=rev
Log:
- LazyItemIterator is created with either ChildItemReferences or ItemStates but did not handle
ChildItemReferences.
- Temporarily use NodeId(null, "/") as root node id.
- TransientItemStateManager throws exception when root node state is created.
- Incorrect check for path part in UUIDReference.

Modified:
    jackrabbit/trunk/contrib/spi/client/   (props changed)
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LazyItemIterator.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChildItemReference.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PathResolver.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/UUIDReference.java

Propchange: jackrabbit/trunk/contrib/spi/client/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Aug 18 05:15:02 2006
@@ -0,0 +1,2 @@
+target
+*.iml

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LazyItemIterator.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LazyItemIterator.java?rev=432559&r1=432558&r2=432559&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LazyItemIterator.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LazyItemIterator.java
Fri Aug 18 05:15:02 2006
@@ -17,6 +17,8 @@
 package org.apache.jackrabbit.jcr2spi;
 
 import org.apache.jackrabbit.jcr2spi.state.ItemState;
+import org.apache.jackrabbit.jcr2spi.state.ChildItemReference;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateException;
 import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
 
@@ -87,16 +89,29 @@
         // reset
         next = null;
         while (next == null && pos < stateList.size()) {
-            ItemState state = (ItemState) stateList.get(pos);
+            // TODO: make sure only ItemStates or ChildItemReferences are used, not both!
+            // TODO: check constructors of LazyItemIterator
+            Object refOrState = stateList.get(pos);
             try {
+                ItemState state;
+                if (refOrState instanceof ChildItemReference) {
+                    state = ((ChildItemReference) refOrState).resolve();
+                } else {
+                    state = (ItemState) refOrState;
+                }
                 next = itemMgr.getItem(state);
             } catch (ItemNotFoundException e) {
-                log.debug("ignoring nonexistent item " + state);
+                log.debug("ignoring nonexistent item " + refOrState);
                 // remove invalid id
                 stateList.remove(pos);
                 // try next
             } catch (RepositoryException e) {
-                log.error("failed to fetch item " + state + ", skipping...", e);
+                log.error("failed to fetch item " + refOrState + ", skipping...", e);
+                // remove invalid id
+                stateList.remove(pos);
+                // try next
+            } catch (ItemStateException e) {
+                log.debug("ignoring nonexistent item " + refOrState);
                 // remove invalid id
                 stateList.remove(pos);
                 // try next

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChildItemReference.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChildItemReference.java?rev=432559&r1=432558&r2=432559&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChildItemReference.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChildItemReference.java
Fri Aug 18 05:15:02 2006
@@ -26,7 +26,7 @@
  * @see ChildNodeReference
  * @see PropertyReference
  */
-abstract class ChildItemReference {
+public abstract class ChildItemReference {
 
     /**
      * Cached weak reference to the target NodeState.

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?rev=432559&r1=432558&r2=432559&view=diff
==============================================================================
--- 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
Fri Aug 18 05:15:02 2006
@@ -56,7 +56,7 @@
     /**
      * A current element Path instance.
      */
-    private static final Path CURRENT_PATH;
+    public static final Path CURRENT_PATH;
 
     static {
         try {
@@ -166,8 +166,8 @@
                         int initialStatus, boolean isTransient,
                         ItemStateFactory isf, IdFactory idFactory) {
         super(overlayedState, parent, initialStatus, isTransient, idFactory);
-        pull();
         this.isf = isf;
+        pull();
     }
 
     /**
@@ -190,7 +190,7 @@
                 addPropertyName((QName) it.next());
             }
             // re-create child node entries
-            childNodeEntries.clear(); // TODO: any mre cleanup work to do? try some kind
of merging?
+            childNodeEntries.removeAll(); // TODO: any mre cleanup work to do? try some kind
of merging?
             it = nodeState.getChildNodeEntries().iterator();
             while (it.hasNext()) {
                 ChildNodeEntry cne = (ChildNodeEntry) it.next();
@@ -268,7 +268,7 @@
             }
         } else {
             // root node
-            return idFactory.createNodeId((String) null, CURRENT_PATH);
+            return idFactory.createNodeId((String) null, Path.ROOT);
         }
         // TODO: replace with ItemStateException instead of error.
         throw new InternalError("Unable to retrieve NodeId for NodeState");

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PathResolver.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PathResolver.java?rev=432559&r1=432558&r2=432559&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PathResolver.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PathResolver.java
Fri Aug 18 05:15:02 2006
@@ -39,14 +39,11 @@
      *
      * @param start   the starting point.
      * @param relPath the path to resolve.
-     * @throws IllegalArgumentException if relPath is absolute or not normalized
-     *                                  or starts with a parent ('..') path
-     *                                  element.
+     * @throws IllegalArgumentException if not normalized or starts with a
+     *                                  parent ('..') path element.
      */
     private PathResolver(ItemState start, Path relPath) {
-        if (relPath.isAbsolute()
-                || !relPath.isNormalized()
-                || relPath.getElement(0).denotesParent()) {
+        if (!relPath.isNormalized() || relPath.getElement(0).denotesParent()) {
             throw new IllegalArgumentException("path must be relative and must " +
                     "not contain parent path elements");
         }
@@ -110,6 +107,15 @@
         NodeState state = (NodeState) start;
         for (int i = 0; i < relPath.getLength(); i++) {
             Path.PathElement elem = relPath.getElement(i);
+            // check for root element
+            if (elem.denotesRoot()) {
+                if (start.getParent() != null) {
+                    throw new NoSuchItemStateException(relPath.toString());
+                } else {
+                    continue;
+                }
+            }
+
             // first try to resolve node
             if (state.hasChildNodeEntry(elem.getName(), elem.getNormalizedIndex())) {
                 state = state.getChildNodeEntry(elem.getName(),

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?rev=432559&r1=432558&r2=432559&view=diff
==============================================================================
--- 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
Fri Aug 18 05:15:02 2006
@@ -593,8 +593,11 @@
                 throws NoSuchItemStateException, ItemStateException {
             // retrieve state to overlay
             NodeState overlayedState = (NodeState) parent.getItemState(nodeId);
-            NodeId parentId = overlayedState.getParent().getNodeId();
-            NodeState parentState = (NodeState) ism.getItemState(parentId);
+            NodeState overlayedParent = overlayedState.getParent();
+            NodeState parentState = null;
+            if (overlayedParent != null) {
+                parentState = (NodeState) ism.getItemState(overlayedParent.getId());
+            }
             NodeState nodeState = new NodeState(overlayedState, parentState,
                     ItemState.STATUS_EXISTING, true, this, idFactory);
             nodeState.addListener(listener);

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/UUIDReference.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/UUIDReference.java?rev=432559&r1=432558&r2=432559&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/UUIDReference.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/UUIDReference.java
Fri Aug 18 05:15:02 2006
@@ -44,7 +44,7 @@
      */
     UUIDReference(NodeState parent, NodeId childId, ItemStateFactory isf, QName name) {
         super(parent, name, isf);
-        if (childId.getRelativePath() == null) {
+        if (childId.getRelativePath() != null) {
             throw new IllegalArgumentException("childId must not contain a relative path");
         }
         this.childId = childId;



Mime
View raw message