jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r431904 - in /jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: HierarchyManagerImpl.java NodeImpl.java WorkspaceManager.java operation/ReorderNodes.java state/NodeState.java state/SessionItemStateManager.java
Date Wed, 16 Aug 2006 13:59:19 GMT
Author: mreutegg
Date: Wed Aug 16 06:59:19 2006
New Revision: 431904

URL: http://svn.apache.org/viewvc?rev=431904&view=rev
Log:
- Replace NodeState.getChildNodeEntry(NodeId) with NodeState.getChildNodeEntry(NodeState)
- Replace NodeState.reorderChildNodeEntries(NodeId, NodeId) with NodeState.reorderChildNodeEntries(NodeState,
NodeState)
- ReorderNodes operation now works with NodeStates instead of NodeIds.
- Simplify NodeImpl.getQName()

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/NodeImpl.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/ReorderNodes.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/SessionItemStateManager.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=431904&r1=431903&r2=431904&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 06:59:19 2006
@@ -80,7 +80,7 @@
      */
     protected ChildNodeEntry getChildNodeEntry(NodeState parent,
                                                NodeState state) {
-        return parent.getChildNodeEntry(state.getNodeId());
+        return parent.getChildNodeEntry(state);
     }
 
     // TODO: review the overridables as soon as status of ZombiHierarchyManager is clear

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?rev=431904&r1=431903&r2=431904&view=diff
==============================================================================
--- 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
Wed Aug 16 06:59:19 2006
@@ -255,7 +255,14 @@
         Path.PathElement srcName = getReorderPath(srcChildRelPath).getNameElement();
         Path.PathElement beforeName = (destChildRelPath == null) ? null : getReorderPath(destChildRelPath).getNameElement();
 
-        Operation op = ReorderNodes.create(getNodeState(), srcName, beforeName);
+        Operation op = null;
+        try {
+            op = ReorderNodes.create(getNodeState(), srcName, beforeName);
+        } catch (NoSuchItemStateException e) {
+            throw new ItemNotFoundException(e.getMessage(), e);
+        } catch (ItemStateException e) {
+            throw new RepositoryException("Unable to reorder nodes: " + e.getMessage(), e);
+        }
         session.getSessionItemStateManager().execute(op);
     }
 
@@ -551,7 +558,11 @@
             return Path.INDEX_DEFAULT;
         }
 
-        ChildNodeEntry parentEntry = parentState.getChildNodeEntry(getNodeId());
+        ChildNodeEntry parentEntry = parentState.getChildNodeEntry(getNodeState());
+        if (parentEntry == null) {
+            String msg = "Unable to retrieve index for: " + safeGetJCRPath();
+            throw new RepositoryException(msg);
+        }
         return parentEntry.getIndex();
     }
 
@@ -1182,19 +1193,12 @@
      * @see ItemImpl#getQName()
      */
     QName getQName() throws RepositoryException {
-        NodeState parentState = getNodeState().getParent();
-        if (parentState == null) {
+        if (getNodeState().getParent() == null) {
             // shortcut. the given state represents the root or an orphaned node
             return QName.ROOT;
         }
 
-        ChildNodeEntry entry = parentState.getChildNodeEntry(getNodeId());
-        if (entry == null) {
-            String msg = "Failed to retrieve qualified name of Node " + getNodeId();
-            log.debug(msg);
-            throw new RepositoryException(msg);
-        }
-        return entry.getName();
+        return getNodeState().getName();
     }
 
 

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java?rev=431904&r1=431903&r2=431904&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
Wed Aug 16 06:59:19 2006
@@ -657,8 +657,8 @@
 
         public void visit(ReorderNodes operation) throws RepositoryException {
             NodeId parentId = operation.getParentState().getNodeId();
-            NodeId insertId = operation.getInsertNodeId();
-            NodeId beforeId = operation.getBeforeNodeId();
+            NodeId insertId = operation.getInsertNode().getNodeId();
+            NodeId beforeId = operation.getBeforeNode().getNodeId();
             batch.reorderNodes(parentId, insertId, beforeId);
         }
 

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/ReorderNodes.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/ReorderNodes.java?rev=431904&r1=431903&r2=431904&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/ReorderNodes.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/ReorderNodes.java
Wed Aug 16 06:59:19 2006
@@ -17,7 +17,8 @@
 package org.apache.jackrabbit.jcr2spi.operation;
 
 import org.apache.jackrabbit.jcr2spi.state.NodeState;
-import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateException;
+import org.apache.jackrabbit.jcr2spi.state.NoSuchItemStateException;
 import org.apache.jackrabbit.name.Path;
 
 import javax.jcr.nodetype.ConstraintViolationException;
@@ -32,14 +33,18 @@
 public class ReorderNodes extends AbstractOperation {
 
     private final NodeState parentState;
-    private final NodeId insertId;
-    private final NodeId beforeId;
+    private final NodeState insert;
+    private final NodeState before;
 
-    private ReorderNodes(NodeState parentState, NodeId insertId, NodeId beforeId) {
+    private ReorderNodes(NodeState parentState, NodeState insert, NodeState before) {
         this.parentState = parentState;
-        this.insertId = insertId;
-        this.beforeId = beforeId;
+        this.insert = insert;
+        this.before = before;
         addAffectedItemState(parentState);
+        addAffectedItemState(insert);
+        if (before != null) {
+            addAffectedItemState(before);
+        }
     }
 
     //----------------------------------------------------------< Operation >---
@@ -56,21 +61,21 @@
         return parentState;
     }
 
-    public NodeId getInsertNodeId() {
-        return insertId;
+    public NodeState getInsertNode() {
+        return insert;
     }
 
-    public NodeId getBeforeNodeId() {
-        return beforeId;
+    public NodeState getBeforeNode() {
+        return before;
     }
 
     //------------------------------------------------------------< Factory >---
 
     public static Operation create(NodeState parentState, Path.PathElement srcName,
-                                   Path.PathElement beforeName) {
-        NodeId insertId = parentState.getChildNodeEntry(srcName.getName(), srcName.getNormalizedIndex()).getId();
-        NodeId beforeId = (beforeName == null) ? null : parentState.getChildNodeEntry(beforeName.getName(),
beforeName.getNormalizedIndex()).getId();
-        Operation op = new ReorderNodes(parentState, insertId, beforeId);
+                                   Path.PathElement beforeName) throws NoSuchItemStateException,
ItemStateException {
+        NodeState insert = parentState.getChildNodeEntry(srcName.getName(), srcName.getNormalizedIndex()).getNodeState();
+        NodeState before = (beforeName == null) ? null : parentState.getChildNodeEntry(beforeName.getName(),
beforeName.getNormalizedIndex()).getNodeState();
+        Operation op = new ReorderNodes(parentState, insert, before);
         return op;
     }
 }

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=431904&r1=431903&r2=431904&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
Wed Aug 16 06:59:19 2006
@@ -352,9 +352,8 @@
                 def = ntRegistry.getRootNodeDef();
             } else {
                 try {
-                    ChildNodeEntry cne = parentState.getChildNodeEntry(getNodeId());
                     EffectiveNodeType ent = ntRegistry.getEffectiveNodeType(parentState.getNodeTypeNames());
-                    def = ent.getApplicableNodeDefinition(cne.getName(), getNodeTypeName());
+                    def = ent.getApplicableNodeDefinition(getName(), getNodeTypeName());
                 } catch (NodeTypeConflictException e) {
                     String msg = "internal error: failed to build effective node type.";
                     log.debug(msg);
@@ -423,16 +422,18 @@
     }
 
     /**
-     * Returns the <code>ChildNodeEntry</code> with the specified <code>NodeId</code>
or
-     * <code>null</code> if there's no matching entry.
-     *
-     * @param id the id of the child node
-     * @return the <code>ChildNodeEntry</code> with the specified <code>NodeId</code>
or
-     *         <code>null</code> if there's no matching entry.
+     * Returns the <code>ChildNodeEntry</code> with the specified
+     * <code>NodeState</code> or <code>null</code> if there's no
matching
+     * entry.
+     *
+     * @param nodeState the child node state.
+     * @return the <code>ChildNodeEntry</code> with the specified
+     *         <code>NodeState</code> or <code>null</code> if there's
no
+     *         matching entry.
      * @see #addChildNodeEntry
      */
-    public synchronized ChildNodeEntry getChildNodeEntry(NodeId id) {
-        return childNodeEntries.get(id);
+    public synchronized ChildNodeEntry getChildNodeEntry(NodeState nodeState) {
+        return childNodeEntries.get(nodeState);
     }
 
     /**
@@ -762,20 +763,23 @@
 
     /**
      *
-     * @param insertNodeId
-     * @param beforeNodeId
+     * @param insertNode
+     * @param beforeNode
      */
-    synchronized void reorderChildNodeEntries(NodeId insertNodeId, NodeId beforeNodeId)
+    synchronized void reorderChildNodeEntries(NodeState insertNode, NodeState beforeNode)
         throws NoSuchItemStateException {
         // validate existance of child node entries even if this has been
         // checked within NodeImpl.
-        if (childNodeEntries.get(insertNodeId) == null) {
-            throw new NoSuchItemStateException("No such child node entry: " + insertNodeId);
+        if (childNodeEntries.get(insertNode) == null) {
+            throw new NoSuchItemStateException("No such child node entry: " + insertNode.getNodeId());
         }
-        if (beforeNodeId != null && childNodeEntries.get(insertNodeId) == null) {
-            throw new NoSuchItemStateException("No such child node entry: " + beforeNodeId);
+        if (beforeNode != null && childNodeEntries.get(insertNode) == null) {
+            throw new NoSuchItemStateException("No such child node entry: " + beforeNode.getNodeId());
         }
 
+        NodeId insertNodeId = insertNode.getNodeId();
+        NodeId beforeNodeId = (beforeNode != null) ? beforeNode.getNodeId() : null;
+
         // TODO: check again. Reorder with SPI-Id
         ArrayList nodeEntries = new ArrayList(childNodeEntries);
         int srcInd = -1, destInd = -1;
@@ -984,8 +988,8 @@
         // (key=name, value=either a single entry or a list of sns entries)
         private final Map nameMap = new HashMap();
 
-        ChildNodeEntry get(NodeId id) {
-            return (ChildNodeEntry) entries.get(id);
+        ChildNodeEntry get(NodeState nodeState) {
+            return (ChildNodeEntry) entries.get(nodeState.getId());
         }
 
         List get(QName nodeName) {

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?rev=431904&r1=431903&r2=431904&view=diff
==============================================================================
--- 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 Aug 16 06:59:19 2006
@@ -391,7 +391,7 @@
         Set affectedStates = new HashSet();
         Iterator it = new IteratorChain(changeLog.modifiedStates(), changeLog.deletedStates());
         while (it.hasNext()) {
-            affectedStates.add(((ItemState) it.next()));
+            affectedStates.add(it.next());
         }
         collectOperations(affectedStates, changeLog);
 
@@ -658,7 +658,7 @@
             Iterator it = new IteratorChain(changeLog.modifiedStates(), changeLog.deletedStates());
             Set affectedStates = new HashSet();
             while (it.hasNext()) {
-                affectedStates.add((ItemState) it.next());
+                affectedStates.add(it.next());
             }
 
             checkIsSelfContained(affectedStates, changeLog);
@@ -1115,7 +1115,7 @@
         NodeState parent = operation.getParentState();
         // modify the parent node state
         try {
-            parent.reorderChildNodeEntries(operation.getInsertNodeId(), operation.getBeforeNodeId());
+            parent.reorderChildNodeEntries(operation.getInsertNode(), operation.getBeforeNode());
         } catch (NoSuchItemStateException e) {
             // invalid reorder-ids
             throw new ItemNotFoundException(e);



Mime
View raw message