jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r429288 - in /jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: ./ lock/ operation/ state/ version/ xml/
Date Mon, 07 Aug 2006 09:52:37 GMT
Author: angela
Date: Mon Aug  7 02:52:34 2006
New Revision: 429288

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

- replace ItemState.getParentId by ItemState.getParentState

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/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/NodeImpl.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/PropertyImpl.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/ZombieHierarchyManager.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Remove.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/ItemStateValidator.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/PropertyState.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/TransientChangeLog.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/version/VersionManagerImpl.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/ImporterImpl.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=429288&r1=429287&r2=429288&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
Mon Aug  7 02:52:34 2006
@@ -112,7 +112,7 @@
      * @see ZombieHierarchyManager#getParentId(ItemState)
      */
     protected NodeId getParentId(ItemState state) {
-        return state.getParentId();
+        return state.getParentState().getNodeId();
     }
 
     /**
@@ -244,25 +244,24 @@
             return;
         }
 
-        NodeId parentId = state.getParentId();
-        if (parentId == null) {
+        NodeState parentState = state.getParentState();
+        if (parentState == null) {
             String msg = "failed to build path of " + state.getId()
                     + ": orphaned item";
             log.debug(msg);
             throw new ItemNotFoundException(msg);
         }
 
-        NodeState parent = (NodeState) getItemState(parentId);
         // recursively build path of parent
-        buildPath(builder, parent);
+        buildPath(builder, parentState);
 
         if (state.isNode()) {
             NodeState nodeState = (NodeState) state;
             NodeId id = nodeState.getNodeId();
-            ChildNodeEntry entry = getChildNodeEntry(parent, id);
+            ChildNodeEntry entry = getChildNodeEntry(parentState, id);
             if (entry == null) {
                 String msg = "failed to build path of " + state.getId() + ": "
-                        + parent.getNodeId() + " has no child entry for "
+                        + parentState.getNodeId() + " has no child entry for "
                         + id;
                 log.debug(msg);
                 throw new ItemNotFoundException(msg);

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?rev=429288&r1=429287&r2=429288&view=diff
==============================================================================
--- 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
Mon Aug  7 02:52:34 2006
@@ -158,11 +158,11 @@
      */
     public int getDepth() throws RepositoryException {
         checkStatus();
-        if (state.getParentId() == null) {
+        if (state.getParentState() == null) {
             // shortcut
             return Path.ROOT_DEPTH;
         }
-        return session.getHierarchyManager().getDepth(id);
+        return session.getHierarchyManager().getDepth(state.getParentState().getId());
     }
 
     /**

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?rev=429288&r1=429287&r2=429288&view=diff
==============================================================================
--- 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
Mon Aug  7 02:52:34 2006
@@ -102,12 +102,7 @@
 
     private NodeDefinition getDefinition(NodeState state)
             throws RepositoryException {
-        NodeId parentId = state.getParentId();
-        NodeState parentState = null;
-        if (parentId != null) {
-            NodeImpl parent = (NodeImpl) getItem(parentId);
-            parentState = (NodeState) parent.getItemState();
-        }
+        NodeState parentState = state.getParentState();
         NodeDefinition def = session.getItemDefinitionManager().getNodeDefinition(state,
parentState);
         return def;
     }
@@ -115,9 +110,7 @@
     private PropertyDefinition getDefinition(PropertyState state)
         throws RepositoryException {
         // fallback: try finding applicable definition
-        NodeId parentId = state.getParentId();
-        NodeImpl parent = (NodeImpl) getItem(parentId);
-        NodeState parentState = (NodeState) parent.getItemState();
+        NodeState parentState = state.getParentState();
         PropertyDefinition def = session.getItemDefinitionManager().getPropertyDefinition(state,
parentState);
         return def;
     }

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=429288&r1=429287&r2=429288&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
Mon Aug  7 02:52:34 2006
@@ -144,14 +144,14 @@
     public Node getParent() throws ItemNotFoundException, AccessDeniedException, RepositoryException
{
         checkStatus();
         // check if root node
-        NodeId parentId = getItemState().getParentId();
-        if (parentId == null) {
+        NodeState parentState = getItemState().getParentState();
+        if (parentState == null) {
             String msg = "root node doesn't have a parent";
             log.debug(msg);
             throw new ItemNotFoundException(msg);
         }
 
-        return (Node) itemMgr.getItem(parentId);
+        return (Node) itemMgr.getItem(parentState.getNodeId());
     }
 
     /**
@@ -537,22 +537,14 @@
      */
     public int getIndex() throws RepositoryException {
         checkStatus();
-        NodeId parentId = getItemState().getParentId();
-        if (parentId == null) {
+        NodeState parentState = getItemState().getParentState();
+        if (parentState == null) {
             // the root node cannot have same-name siblings; always return the
             // default index
             return Path.INDEX_DEFAULT;
         }
-        try {
-            NodeState parent = (NodeState) itemStateMgr.getItemState(parentId);
-            ChildNodeEntry parentEntry = parent.getChildNodeEntry(getNodeId());
-            return parentEntry.getIndex();
-        } catch (ItemStateException ise) {
-            // should never get here...
-            String msg = "internal error: failed to determine index";
-            log.error(msg, ise);
-            throw new RepositoryException(msg, ise);
-        }
+        ChildNodeEntry parentEntry = parentState.getChildNodeEntry(getNodeId());
+        return parentEntry.getIndex();
     }
 
     /**

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/PropertyImpl.java?rev=429288&r1=429287&r2=429288&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/PropertyImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/PropertyImpl.java
Mon Aug  7 02:52:34 2006
@@ -88,7 +88,7 @@
      */
     public Node getParent() throws ItemNotFoundException, AccessDeniedException, RepositoryException
{
         checkStatus();
-        return (Node) itemMgr.getItem(getItemState().getParentId());
+        return (Node) itemMgr.getItem(getItemState().getParentState().getId());
     }
 
     /**

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=429288&r1=429287&r2=429288&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
Mon Aug  7 02:52:34 2006
@@ -603,7 +603,7 @@
             // build the PropertyState
             // NOTE: unable to retrieve definitionId -> needs to be retrieved
             // by the itemManager upon Property creation.
-            PropertyState state = new PropertyState(info.getId(), ItemState.STATUS_EXISTING,
false);
+            PropertyState state = new PropertyState(info.getId(), parent, ItemState.STATUS_EXISTING,
false);
             state.setMultiValued(info.isMultiValued());
             state.setType(info.getType());
             QValue[] qValues;

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=429288&r1=429287&r2=429288&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
Mon Aug  7 02:52:34 2006
@@ -87,7 +87,7 @@
     protected NodeId getParentId(ItemState state) {
         if (state.hasOverlayedState()) {
             // use 'old' parent in case item has been removed
-            return state.getOverlayedState().getParentId();
+            return state.getOverlayedState().getParentState().getNodeId();
         }
         // delegate to base class
         return super.getParentId(state);

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java?rev=429288&r1=429287&r2=429288&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java
Mon Aug  7 02:52:34 2006
@@ -299,11 +299,12 @@
              * this would have a negative impact on performance though...
              */
             while (!nodeState.hasPropertyName(QName.JCR_LOCKOWNER)) {
-                if (nodeState.getParentId() == null) {
+                NodeState parentState = nodeState.getParentState();
+                if (parentState == null) {
                     // reached root state without finding a locked node
                     return null;
                 }
-                nodeState = (NodeState) wspManager.getItemState(nodeState.getParentId());
+                nodeState = parentState;
             }
             return nodeState;
         } catch (ItemStateException e) {

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Remove.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Remove.java?rev=429288&r1=429287&r2=429288&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Remove.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Remove.java
Mon Aug  7 02:52:34 2006
@@ -61,7 +61,7 @@
 
     //------------------------------------------------------------< Factory >---
     public static Operation create(ItemState state) {
-        Remove rm = new Remove(state.getId(), state.getParentId());
+        Remove rm = new Remove(state.getId(), state.getParentState().getNodeId());
         return rm;
     }
 }

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?rev=429288&r1=429287&r2=429288&view=diff
==============================================================================
--- 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
Mon Aug  7 02:52:34 2006
@@ -18,7 +18,6 @@
 
 import org.apache.jackrabbit.util.WeakIdentityCollection;
 import org.apache.jackrabbit.spi.ItemId;
-import org.apache.jackrabbit.spi.NodeId;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -357,13 +356,13 @@
     }
 
     /**
-     * Returns the NodeId of the parent <code>NodeState</code> or <code>null</code>
+     * Returns the parent <code>NodeState</code> or <code>null</code>
      * if either this item state represents the root node or this item state is
      * 'free floating', i.e. not attached to the repository's hierarchy.
      *
      * @return the parent <code>NodeState</code>'s Id
      */
-    public abstract NodeId getParentId();
+    public abstract NodeState getParentState();
 
     /**
      * Returns the status of this item.

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?rev=429288&r1=429287&r2=429288&view=diff
==============================================================================
--- 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
Mon Aug  7 02:52:34 2006
@@ -419,7 +419,7 @@
         VersionException, LockException, ItemNotFoundException,
         ItemExistsException, PathNotFoundException, RepositoryException {
 
-        checkWriteProperty(getNodeState(propState.getParentId()), propState.getName(), propState.getDefinition(),
options);
+        checkWriteProperty(propState.getParentState(), propState.getName(), propState.getDefinition(),
options);
     }
 
     /**
@@ -587,14 +587,14 @@
         // NOTE: referencial integrity should be asserted for all child-nodes.
 
         ItemId targetId = targetState.getId();
-        NodeId parentId = targetState.getParentId();
-        if (parentId == null) {
+        NodeState parentState = targetState.getParentState();
+        if (parentState == null) {
             // root or orphaned node
             throw new ConstraintViolationException("Cannot remove root node");
         }
 
         // check parent
-        checkIsWritable(getNodeState(parentId), options);
+        checkIsWritable(parentState, options);
 
         // access rights
         if ((options & CHECK_ACCESS) == CHECK_ACCESS) {
@@ -648,7 +648,7 @@
         if (itemState.getStatus() == ItemState.STATUS_NEW) {
             return;
         }
-        NodeState nodeState = (itemState.isNode()) ? (NodeState)itemState : getNodeState(itemState.getParentId());
+        NodeState nodeState = (itemState.isNode()) ? (NodeState)itemState : itemState.getParentState();
         if (!mgrProvider.getVersionManager().isCheckedOut(nodeState.getNodeId())) {
             throw new VersionException(safeGetJCRPath(nodeState.getNodeId()) + " is checked-in");
         }
@@ -667,8 +667,10 @@
             throws LockException, RepositoryException {
         // make sure there's no foreign lock present the node (or the parent node
         // for properties.
-        NodeId nodeId = (itemState.isNode()) ? ((NodeState)itemState).getNodeId() : itemState.getParentId();
-        mgrProvider.getLockManager().checkLock(nodeId);
+        NodeState nodeState = (itemState.isNode())
+            ? ((NodeState)itemState)
+            : itemState.getParentState();
+        mgrProvider.getLockManager().checkLock(nodeState.getNodeId());
     }
 
     /**

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=429288&r1=429287&r2=429288&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
Mon Aug  7 02:52:34 2006
@@ -62,10 +62,10 @@
     private NodeId id;
 
     /**
-     * The id of the parent <code>NodeState</code> or <code>null</code>
if this
+     * The parent <code>NodeState</code> or <code>null</code> if
this
      * instance represents the root node.
      */
-    private NodeId parentId;
+    private NodeState parent;
     
     /**
      * this node's definition
@@ -127,6 +127,7 @@
                      int initialStatus, boolean isTransient, ItemStateFactory isf) {
         super(initialStatus, isTransient);
         this.id = id;
+        this.parent = parent;
         this.idFactory = parent.idFactory;
         this.nodeTypeName = nodeTypeName;
         this.isf = isf;
@@ -154,15 +155,15 @@
      *
      * @param id            id of this node
      * @param nodeTypeName  node type of this node
-     * @param parentId      id of the parent node
+     * @param parent        the parent node state
      * @param initialStatus the initial status of the node state object
      * @param isTransient   flag indicating whether this state is transient or not
      */
-    public NodeState(NodeId id, QName nodeTypeName, NodeId parentId,
+    public NodeState(NodeId id, QName nodeTypeName, NodeState parent,
                      int initialStatus, boolean isTransient, IdFactory idFactory) {
         super(initialStatus, isTransient);
         this.id = id;
-        this.parentId = parentId;
+        this.parent = parent;
         this.nodeTypeName = nodeTypeName;
         this.idFactory = idFactory;
         // TODO: remove this constructor
@@ -176,7 +177,7 @@
         synchronized (state) {
             NodeState nodeState = (NodeState) state;
             id = nodeState.id;
-            parentId = nodeState.parentId;
+            parent = nodeState.parent;
             nodeTypeName = nodeState.nodeTypeName;
             mixinTypeNames = nodeState.mixinTypeNames;
             def = nodeState.getDefinition();
@@ -200,11 +201,8 @@
         return true;
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public NodeId getParentId() {
-        return parentId;
+    public NodeState getParentState() {
+        return parent;
     }
 
     /**
@@ -225,13 +223,13 @@
     /**
      * Sets the Id of the parent <code>NodeState</code>.
      *
-     * @param parentId the parent <code>NodeState</code>'s Id or <code>null</code>
+     * @param parent the parent <code>NodeState</code> or <code>null</code>
      * if either this node state should represent the root node or this node
      * state should be 'free floating', i.e. detached from the repository's
      * hierarchy.
      */
-    public void setParentId(NodeId parentId) {
-        this.parentId = parentId;
+    public void setParent(NodeState parent) {
+        this.parent = parent;
     }
 
     /**

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java?rev=429288&r1=429287&r2=429288&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java
Mon Aug  7 02:52:34 2006
@@ -22,7 +22,6 @@
 import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.spi.PropertyId;
 import org.apache.jackrabbit.spi.ItemId;
-import org.apache.jackrabbit.spi.NodeId;
 import org.apache.jackrabbit.value.QValue;
 
 /**
@@ -36,6 +35,11 @@
     private PropertyId id;
 
     /**
+     * The parent state
+     */
+    private NodeState parent;
+
+    /**
      * the internal values
      */
     private QValue[] values;
@@ -73,9 +77,10 @@
      * @param initialStatus the initial status of the property state object
      * @param isTransient   flag indicating whether this state is transient or not
      */
-    public PropertyState(PropertyId id, int initialStatus, boolean isTransient) {
+    public PropertyState(PropertyId id, NodeState parent, int initialStatus, boolean isTransient)
{
         super(initialStatus, isTransient);
         this.id = id;
+        this.parent = parent;
         type = PropertyType.UNDEFINED;
         values = QValue.EMPTY_ARRAY;
         multiValued = false;
@@ -88,6 +93,7 @@
         synchronized (state) {
             PropertyState propState = (PropertyState) state;
             id = propState.id;
+            parent = propState.parent;
             type = propState.type;
             def = propState.getDefinition();
             values = propState.values;
@@ -125,8 +131,8 @@
     /**
      * {@inheritDoc}
      */
-    public NodeId getParentId() {
-        return id.getParentId();
+    public NodeState getParentState() {
+        return parent;
     }
 
     /**

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=429288&r1=429287&r2=429288&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
Mon Aug  7 02:52:34 2006
@@ -846,8 +846,9 @@
                 NodeState nodeState = (NodeState) transientState;
                 Set dependentIDs = new HashSet();
                 if (nodeState.hasOverlayedState()) {
-                    NodeId oldParentId = nodeState.getOverlayedState().getParentId();
-                    NodeId newParentId = nodeState.getParentId();
+                    // TODO: review usage of NodeId
+                    NodeId oldParentId = nodeState.getOverlayedState().getParentState().getNodeId();
+                    NodeId newParentId = nodeState.getParentState().getNodeId();
                     if (oldParentId != null) {
                         if (newParentId == null) {
                             // node has been removed, add old parent
@@ -985,7 +986,7 @@
             // remove child node entry from old parent
             srcParent.removeChildNodeEntry(srcName, srcIndex);
             // re-parent target node
-            srcState.setParentId(destParent.getNodeId());
+            srcState.setParent(destParent);
             // add child node entry to new parent
             destParent.addChildNodeEntry(operation.getDestinationName(), srcState.getNodeId());
         }
@@ -1295,7 +1296,7 @@
         // assert transient parent state
         NodeState parentState = create(parent);
         // create property state
-        PropertyState propState = createNew(propertyName, parentState.getNodeId());
+        PropertyState propState = createNew(propertyName, parentState);
         propState.setDefinition(pDef);
 
         // NOTE: callers must make sure, the property type is not 'undefined'
@@ -1339,7 +1340,7 @@
         NodeState parentState = create(parent);
         // ev. create new id
         NodeId newId = (uuid == null) ? idFactory.createNodeId(UUID.randomUUID().toString())
: idFactory.createNodeId(uuid);
-        NodeState nodeState = createNew(newId, nodeTypeName, parentState.getNodeId());
+        NodeState nodeState = createNew(newId, nodeTypeName, parentState);
         nodeState.setDefinition(definition);
 
         // now add new child node entry to parent
@@ -1380,7 +1381,7 @@
         boolean success = false;
         try {
             // assert parent is transient state
-            NodeState parent = create(validator.getNodeState(itemState.getParentId()));
+            NodeState parent = create(itemState.getParentState());
             if (itemState.isNode()) {
                 removeNodeState(parent, (NodeState)itemState);
             } else {
@@ -1479,7 +1480,7 @@
         }
 
         // now actually do unlink target state
-        targetState.setParentId(null);
+        targetState.setParent(null);
         // destroy target state
         // DIFF JR: destroy targetState (not overlayed state)
         destroy(targetState);
@@ -1539,14 +1540,14 @@
      *
      * @param id           the id of the node
      * @param nodeTypeName qualified node type name
-     * @param parentId     parent node's id
+     * @param parent     parent node's id
      * @return a node state
      * @throws IllegalStateException if the manager is not in edit mode.
      */
-    private NodeState createNew(NodeId id, QName nodeTypeName, NodeId parentId)
+    private NodeState createNew(NodeId id, QName nodeTypeName, NodeState parent)
             throws IllegalStateException {
         // DIFF JACKRABBIT: return workspaceItemStateMgr.createNew(id, nodeTypeName, parentId);
-        return transientStateMgr.createNodeState(id, nodeTypeName, parentId);
+        return transientStateMgr.createNodeState(id, nodeTypeName, parent);
     }
 
     /**
@@ -1579,12 +1580,12 @@
      * on the returned object to make it persistent.
      *
      * @param propName   qualified property name
-     * @param parentId   parent node Id
+     * @param parent   parent node state
      * @return a property state
      */
-    private PropertyState createNew(QName propName, NodeId parentId) {
+    private PropertyState createNew(QName propName, NodeState parent) {
         // DIFF JACKRABBIT: return workspaceItemStateMgr.createNew(propName, parentId);
-        return transientStateMgr.createPropertyState(parentId, propName);
+        return transientStateMgr.createPropertyState(parent, propName);
     }
 
     /**

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientChangeLog.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientChangeLog.java?rev=429288&r1=429287&r2=429288&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientChangeLog.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientChangeLog.java
Mon Aug  7 02:52:34 2006
@@ -126,7 +126,7 @@
      */
     public NodeState createNodeState(NodeId id,
                                      QName nodeTypeName,
-                                     NodeId parentId) {
+                                     NodeState parent) {
         // DIFF JACKRABBIT: not needed anymore
         // check map; synchronized to ensure an entry is not created twice.
 //        synchronized (addedStates) {
@@ -143,7 +143,7 @@
 //            return state;
 //        }
 
-        return new NodeState(id, nodeTypeName, parentId, ItemState.STATUS_NEW, true, idFactory);
+        return new NodeState(id, nodeTypeName, parent, ItemState.STATUS_NEW, true, idFactory);
     }
 
     /**
@@ -172,9 +172,9 @@
     /**
      * @inheritDoc
      */
-    public PropertyState createPropertyState(NodeId parentId, QName propName) {
-        PropertyId id = idFactory.createPropertyId(parentId, propName);
-        return new PropertyState(id, ItemState.STATUS_NEW, true);
+    public PropertyState createPropertyState(NodeState parentState, QName propName) {
+        PropertyId id = idFactory.createPropertyId(parentState.getNodeId(), propName);
+        return new PropertyState(id, parentState, ItemState.STATUS_NEW, true);
     }
 
     /**

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=429288&r1=429287&r2=429288&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
Mon Aug  7 02:52:34 2006
@@ -66,11 +66,11 @@
      *
      * @param id the <code>NodeId</code> of the new node state.
      * @param nodeTypeName name of the node type of the new node state.
-     * @param parentId the parent id of the new node state.
+     * @param parent the parent of the new node state.
      * @return a new transient {@link NodeState}.
      */
     NodeState createNodeState(NodeId id, QName nodeTypeName,
-                              NodeId parentId);
+                              NodeState parent);
 
     /**
      * DIFF JACKRABBIT: does not throw ItemStateException
@@ -81,11 +81,11 @@
 
     /**
      * DIFF JACKRABBIT: does not throw ItemStateException
-     * @param parentId
+     * @param parent
      * @param propName
      * @return
      */
-    PropertyState createPropertyState(NodeId parentId, QName propName);
+    PropertyState createPropertyState(NodeState parent, QName propName);
 
     /**
      * DIFF JACKRABBIT: does not throw ItemStateException

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java?rev=429288&r1=429287&r2=429288&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java
Mon Aug  7 02:52:34 2006
@@ -74,11 +74,12 @@
              * this would have a negative impact on performance though...
              */
             while (!nodeState.hasPropertyName(QName.JCR_ISCHECKEDOUT)) {
-                if (nodeState.getParentId() == null) {
+                NodeState parentState = nodeState.getParentState();
+                if (parentState == null) {
                     // reached root state without finding a jcr:isCheckedOut property
                     return true;
                 }
-                nodeState = (NodeState) stateManager.getItemState(nodeState.getParentId());
+                nodeState = parentState;
             }
             PropertyId propId = nodeState.getPropertyState(QName.JCR_ISCHECKEDOUT).getPropertyId();
             PropertyState propState = (PropertyState) stateManager.getItemState(propId);

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/ImporterImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/ImporterImpl.java?rev=429288&r1=429287&r2=429288&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/ImporterImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/ImporterImpl.java
Mon Aug  7 02:52:34 2006
@@ -378,21 +378,14 @@
                 break;
 
             case ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING:
-                NodeId parentId = conflicting.getParentId();
-                if (parentId == null) {
+                // 'replace' current parent with parent of conflicting
+                parent = conflicting.getParentState();
+                if (parent == null) {
                     msg = "Root node cannot be replaced";
                     log.debug(msg);
                     throw new RepositoryException(msg);
                 }
-                // 'replace' current parent with parent of conflicting
-                try {
-                    parent = validator.getNodeState(parentId);
-                } catch (ItemNotFoundException infe) {
-                    // should never get here...
-                    msg = "Internal error: failed to retrieve parent state";
-                    log.error(msg, infe);
-                    throw new RepositoryException(msg, infe);
-                }
+                
                 // do remove conflicting (recursive), including validation checks
                 op = Remove.create(conflicting);
                 stateMgr.execute(op);



Mime
View raw message