jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r431352 - in /jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: ./ operation/ security/ state/ version/
Date Mon, 14 Aug 2006 14:16:04 GMT
Author: angela
Date: Mon Aug 14 07:16:02 2006
New Revision: 431352

URL: http://svn.apache.org/viewvc?rev=431352&view=rev
Log:
div

- get rid of rootId stored with ISM, HierarchyManagers etc.
- remove corresponding method with WorkspaceManager and WorkspaceImpl

jcr2spi/state/ItemState

- move parent field from Node/PropertyState to ItemState
- move idFactory field from NodeState to ItemState
- let PropertyState build its id instead of calling parentstate method.
- minor reordering of status related methods
- remove modCount and its usage

jcr2spi/state/ItemStateManager

- add method getRootNode()

jcr2spi/security/AccessManager

- replace ItemId by ItemState

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/ItemManager.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/SessionImpl.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.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/operation/AbstractOperation.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/security/AccessManager.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/CachingItemStateManager.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/ItemStateManager.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/WorkspaceItemStateFactory.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionImpl.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=431352&r1=431351&r2=431352&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 14 07:16:02 2006
@@ -43,17 +43,12 @@
 
     private static Logger log = LoggerFactory.getLogger(HierarchyManagerImpl.class);
 
-    // TODO: TO-BE-FIXED. With SPI_ItemId rootId must not be stored separately
-    protected final NodeId rootNodeId;
-
     protected final ItemStateManager itemStateManager;
     // used for outputting user-friendly paths and names
     protected final NamespaceResolver nsResolver;
 
-    public HierarchyManagerImpl(NodeId rootNodeId,
-                                ItemStateManager itemStateManager,
+    public HierarchyManagerImpl(ItemStateManager itemStateManager,
                                 NamespaceResolver nsResolver) {
-        this.rootNodeId = rootNodeId;
         this.itemStateManager = itemStateManager;
         this.nsResolver = nsResolver;
     }
@@ -191,18 +186,11 @@
      */
     protected void buildPath(Path.PathBuilder builder, ItemState state)
             throws ItemStateException, RepositoryException {
-        // shortcut
-        if (state.getParent() == null) {
-            builder.addRoot();
-            return;
-        }
-
         NodeState parentState = state.getParent();
+        // shortcut for root state
         if (parentState == null) {
-            String msg = "failed to build path of " + state.getId()
-                    + ": orphaned item";
-            log.debug(msg);
-            throw new ItemNotFoundException(msg);
+            builder.addRoot();
+            return;
         }
 
         // recursively build path of parent
@@ -239,7 +227,8 @@
      */
     public ItemState getItemState(Path qPath) throws PathNotFoundException, RepositoryException {
         try {
-            ItemState rootState = itemStateManager.getItemState(rootNodeId);
+            // retrieve root state first
+            NodeState rootState = itemStateManager.getRootState();
             // shortcut
             if (qPath.denotesRoot()) {
                 return rootState;
@@ -251,9 +240,9 @@
                 throw new RepositoryException(msg);
             }
 
-            return resolvePath(qPath, rootState, 1);
+            return resolvePath(qPath, rootState, Path.INDEX_DEFAULT);
         } catch (ItemStateException e) {
-            // should never occur
+            // should not occur
             throw new RepositoryException(e);
         }
     }
@@ -262,9 +251,14 @@
      * @see HierarchyManager#getQPath(ItemState)
      */
     public Path getQPath(ItemState itemState) throws ItemNotFoundException, RepositoryException {
+        // shortcut for root state
+        if (itemState.getParent() == null) {
+            return Path.ROOT;
+        }
 
-        Path.PathBuilder builder = new Path.PathBuilder();
+        // build path otherwise
         try {
+            Path.PathBuilder builder = new Path.PathBuilder();
             buildPath(builder, itemState);
             return builder.getPath();
         } catch (NoSuchItemStateException e) {

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=431352&r1=431351&r2=431352&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 14 07:16:02 2006
@@ -208,7 +208,7 @@
                 // any transient modifications.
                 // TODO: TO_BE_FIXED check if this is sufficient check (SPI-id)
                 ItemId thisId = (state.hasOverlayedState()) ? state.getOverlayedState().getId() : state.getId();
-                ItemId otherId = (other.getItemState().hasOverlayedState()) ? other.getItemState().getOverlayedState().getId() : other.getId();
+                ItemId otherId = (other.getItemState().hasOverlayedState()) ? other.getItemState().getOverlayedState().getId() : other.getItemState().getId();
                 return thisId.equals(otherId);
             }
         }
@@ -290,7 +290,7 @@
         session.getSessionItemStateManager().execute(rm);
     }
 
-    //-----------------------------------------------------< ItemStateListener >
+    //--------------------------------------------------< ItemStateListener >---
     /**
      * {@inheritDoc}
      */
@@ -553,15 +553,6 @@
 
     //------------------------------------< Implementation specific methods >---
     /**
-     * Return the id of this <code>Item</code>.
-     *
-     * @return the id of this <code>Item</code>
-     */
-    public ItemId getId() {
-        return getItemState().getId();
-    }
-
-    /**
      * Same as <code>{@link Item#getName()}</code> except that
      * this method returns a <code>QName</code> instead of a
      * <code>String</code>.
@@ -571,7 +562,6 @@
      */
     abstract QName getQName() throws RepositoryException;
 
-    // DIFF JR: getPrimaryPath
     /**
      * Returns the primary path to this <code>Item</code>.
      *

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManager.java?rev=431352&r1=431351&r2=431352&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManager.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManager.java Mon Aug 14 07:16:02 2006
@@ -33,8 +33,6 @@
  */
 public interface ItemManager extends ItemLifeCycleListener {
 
-    // DIFF JR: removed 'getRootNode' shortcut
-
     /**
      * Disposes this <code>ItemManager</code> and frees resources.
      */

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=431352&r1=431351&r2=431352&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 14 07:16:02 2006
@@ -21,15 +21,13 @@
 import org.apache.jackrabbit.jcr2spi.state.PropertyState;
 import org.apache.jackrabbit.jcr2spi.state.ChildNodeEntry;
 import org.apache.jackrabbit.jcr2spi.state.ChildPropertyEntry;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateException;
 import org.apache.jackrabbit.jcr2spi.util.Dumpable;
 import org.apache.jackrabbit.jcr2spi.util.LogUtil;
 import org.apache.jackrabbit.jcr2spi.version.VersionHistoryImpl;
 import org.apache.jackrabbit.jcr2spi.version.VersionImpl;
 import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.name.Path;
-import org.apache.jackrabbit.spi.NodeId;
-import org.apache.jackrabbit.spi.ItemId;
-import org.apache.jackrabbit.spi.PropertyId;
 import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.commons.collections.map.ReferenceMap;
@@ -82,7 +80,7 @@
 
     /**
      * A cache for item instances created by this <code>ItemManagerImpl</code>.
-     * // DIFF JR:
+     * 
      * The <code>ItemState</code>s act as keys for the map. In contrast to
      * o.a.j.core the item state are copied to transient space for reading and
      * will therefor not change upon transient modifications.
@@ -194,11 +192,15 @@
 
         Iterator iter = parentState.getChildNodeEntries().iterator();
         while (iter.hasNext()) {
-            ChildNodeEntry entry = (ChildNodeEntry) iter.next();
-            NodeId id = entry.getId();
-            // check read access
-            if (session.getAccessManager().canRead(id)) {
-                return true;
+            try {
+                // check read access
+                ChildNodeEntry entry = (ChildNodeEntry) iter.next();
+                if (session.getAccessManager().canRead(entry.getNodeState())) {
+                    return true;
+                }
+            } catch (ItemStateException e) {
+                // should not occur. ignore
+                log.debug("Failed to access node state.", e);
             }
         }
         return false;
@@ -227,14 +229,17 @@
 
         Iterator iter = parentState.getPropertyEntries().iterator();
         while (iter.hasNext()) {
-            ChildPropertyEntry entry = (ChildPropertyEntry) iter.next();
-            PropertyId id = entry.getId();
-            // check read access
-            if (session.getAccessManager().canRead(id)) {
-                return true;
+            try {
+                ChildPropertyEntry entry = (ChildPropertyEntry) iter.next();
+                // check read access
+                if (session.getAccessManager().canRead(entry.getPropertyState())) {
+                    return true;
+                }
+            } catch (ItemStateException e) {
+                // should not occur. ignore
+                log.debug("Failed to access node state.", e);
             }
         }
-
         return false;
     }
 
@@ -336,8 +341,7 @@
      */
     private void checkAccess(ItemState state, boolean removeFromCache) throws RepositoryException {
         // check privileges
-        ItemId id = state.getId();
-        if (!session.getAccessManager().canRead(id)) {
+        if (!session.getAccessManager().canRead(state)) {
             if (removeFromCache) {
                 // clear cache
                 Item item = retrieveItem(state);
@@ -345,7 +349,7 @@
                     evictItem(state);
                 }
             }
-            throw new AccessDeniedException("cannot read item " + id);
+            throw new AccessDeniedException("cannot read item " + state.getId());
         }
     }
 

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=431352&r1=431351&r2=431352&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 14 07:16:02 2006
@@ -146,8 +146,9 @@
      */
     public Node getParent() throws ItemNotFoundException, AccessDeniedException, RepositoryException {
         checkStatus();
-        // check if root node
+
         NodeState parentState = getItemState().getParent();
+        // special treatment for root node
         if (parentState == null) {
             String msg = "Root node doesn't have a parent.";
             log.debug(msg);
@@ -534,7 +535,7 @@
             throw new UnsupportedRepositoryOperationException();
         }
         // Node is referenceable -> NodeId must contain a UUID part
-        return getNodeState().getNodeId().getUUID();
+        return getNodeId().getUUID();
     }
 
     /**
@@ -542,12 +543,14 @@
      */
     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
             return Path.INDEX_DEFAULT;
         }
+
         ChildNodeEntry parentEntry = parentState.getChildNodeEntry(getNodeId());
         return parentEntry.getIndex();
     }
@@ -834,7 +837,8 @@
         }
 
         if (version instanceof VersionImpl) {
-            session.getVersionManager().resolveMergeConflict(getNodeId(), (NodeId) ((VersionImpl)version).getId(), done);
+            NodeId versionId = ((VersionImpl)version).getNodeId();
+            session.getVersionManager().resolveMergeConflict(getNodeId(), versionId, done);
         } else {
             throw new RepositoryException("Incompatible Version object :" + version);
         }
@@ -1053,7 +1057,8 @@
      */
     private void restore(NodeId nodeId, Version version, boolean removeExisting) throws PathNotFoundException, ItemExistsException, VersionException, ConstraintViolationException, UnsupportedRepositoryOperationException, LockException, InvalidItemStateException, RepositoryException {
         if (version instanceof VersionImpl) {
-            session.getVersionManager().restore(nodeId, (NodeId) ((VersionImpl)version).getId(), removeExisting);
+            NodeId versionId = ((VersionImpl)version).getNodeId();
+            session.getVersionManager().restore(nodeId, versionId, removeExisting);
         } else {
             throw new RepositoryException("Unexpected error: Failed to retrieve a valid ID for the given version " + version.getPath());
         }
@@ -1185,10 +1190,9 @@
             return QName.ROOT;
         }
 
-        NodeId nodeId = getNodeState().getNodeId();
-        ChildNodeEntry entry = parentState.getChildNodeEntry(nodeId);
+        ChildNodeEntry entry = parentState.getChildNodeEntry(getNodeId());
         if (entry == null) {
-            String msg = "Failed to retrieve qualified name of Node " + nodeId;
+            String msg = "Failed to retrieve qualified name of Node " + getNodeId();
             log.debug(msg);
             throw new RepositoryException(msg);
         }
@@ -1491,11 +1495,12 @@
     }
 
     /**
-     * Return the id of this <code>Node</code>.
+     * Return the id of this <code>Node</code>. Protected for usage within
+     * <code>VersionImpl</code> and <code>VersionHistoryImpl</code>.
      *
      * @return the id of this <code>Node</code>
      */
-    private NodeId getNodeId() {
+    protected NodeId getNodeId() {
         return getNodeState().getNodeId();
     }
 

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java?rev=431352&r1=431351&r2=431352&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java Mon Aug 14 07:16:02 2006
@@ -27,6 +27,7 @@
 import org.apache.jackrabbit.jcr2spi.state.ItemState;
 import org.apache.jackrabbit.jcr2spi.state.NoSuchItemStateException;
 import org.apache.jackrabbit.jcr2spi.state.ItemStateException;
+import org.apache.jackrabbit.jcr2spi.state.NodeState;
 import org.apache.jackrabbit.jcr2spi.xml.DocViewSAXEventGenerator;
 import org.apache.jackrabbit.jcr2spi.xml.SysViewSAXEventGenerator;
 import org.apache.jackrabbit.jcr2spi.xml.ImportHandler;
@@ -48,7 +49,6 @@
 import org.apache.jackrabbit.spi.RepositoryService;
 import org.apache.jackrabbit.spi.SessionInfo;
 import org.apache.jackrabbit.spi.NodeId;
-import org.apache.jackrabbit.spi.ItemId;
 import org.apache.jackrabbit.spi.IdFactory;
 import org.apache.commons.collections.map.ReferenceMap;
 import org.slf4j.LoggerFactory;
@@ -163,7 +163,7 @@
 
         // build the state mananger
         // DIFF JACKRABBIT: itemStateMgr = createSessionItemStateManager(wsp.getSessionItemStateManager());
-        itemStateManager = createSessionItemStateManager(workspace.getRootNodeId(), workspace.getUpdatableItemStateManager(), nsMappings);
+        itemStateManager = createSessionItemStateManager(workspace.getUpdatableItemStateManager(), nsMappings);
 
         // DIFF JACKRABBIT: itemManager = createItemManager(itemStateMgr, hierMgr);
         itemManager = createItemManager(getHierarchyManager());
@@ -242,10 +242,8 @@
     public Node getRootNode() throws RepositoryException {
         checkIsAlive();
         try {
-            ItemState state = getItemStateManager().getItemState(workspace.getRootNodeId());
+            ItemState state = getItemStateManager().getRootState();
             return (Node) itemManager.getItem(state);
-        } catch (NoSuchItemStateException e) {
-            throw new ItemNotFoundException();
         } catch (ItemStateException e) {
             String msg = "Failed to retrieve root node.";
             log.error(msg, e);
@@ -401,25 +399,24 @@
         boolean isGranted;
         if (itemExists(absPath)) {
             ItemState itemState = getHierarchyManager().getItemState(targetPath);
-            isGranted = getAccessManager().isGranted(itemState.getId(), actionsArr);
+            isGranted = getAccessManager().isGranted(itemState, actionsArr);
         } else {
             // TODO: if spi-ids are used, its possible to build an id for a non-existing item (see also Node.restore)
             // The given abs-path may point to a non-existing item
             Path parentPath = targetPath;
-            NodeId parentId = null;
-            while (parentId == null) {
+            NodeState parentState = null;
+            while (parentState == null) {
                 parentPath = parentPath.getAncestor(1);
                 if (itemManager.itemExists(parentPath)) {
-                    ItemId id = getHierarchyManager().getItemState(parentPath).getId();
-                    if (id.denotesNode()) {
-                        parentId = (NodeId) id;
+                    ItemState itemState = getHierarchyManager().getItemState(parentPath);
+                    if (itemState.isNode()) {
+                        parentState = itemState.getParent();
                     }
                 }
             }
-            // TODO build Id instead
             try {
                 Path relPath = parentPath.computeRelativePath(targetPath);
-                isGranted = getAccessManager().isGranted(parentId, relPath, actionsArr);
+                isGranted = getAccessManager().isGranted(parentState, relPath, actionsArr);
                 if (!isGranted) {
                     throw new AccessControlException(actions);
                 }
@@ -706,8 +703,8 @@
         return new WorkspaceImpl(sessionInfo.getWorkspaceName(), this, service, sessionInfo);
     }
 
-    protected SessionItemStateManager createSessionItemStateManager(NodeId rootId, UpdatableItemStateManager workspaceStateManager, NamespaceResolver nsResolver) {
-        return new SessionItemStateManager(rootId, workspaceStateManager, getIdFactory(), getValidator(), nsResolver);
+    protected SessionItemStateManager createSessionItemStateManager(UpdatableItemStateManager workspaceStateManager, NamespaceResolver nsResolver) {
+        return new SessionItemStateManager(workspaceStateManager, getIdFactory(), getValidator(), nsResolver);
     }
 
     protected ItemManager createItemManager(HierarchyManager hierarchyMgr) {

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java?rev=431352&r1=431351&r2=431352&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java Mon Aug 14 07:16:02 2006
@@ -238,7 +238,7 @@
         NodeId[] versionIds = new NodeId[versions.length];
         for (int i = 0; i < versions.length; i++) {
             if (versions[i] instanceof VersionImpl) {
-                versionIds[i] = (NodeId) ((VersionImpl)versions[i]).getId();
+                versionIds[i] = ((VersionImpl)versions[i]).getNodeId();
             } else {
                 throw new RepositoryException("Unexpected error: Failed to retrieve a valid ID for the given version " + versions[i].getPath());
             }
@@ -343,8 +343,7 @@
      */
     public HierarchyManager getHierarchyManager() {
         if (hierManager == null) {
-            hierManager = new HierarchyManagerImpl(getRootNodeId(),
-                getItemStateManager(), getNamespaceResolver());
+            hierManager = new HierarchyManagerImpl(getItemStateManager(), getNamespaceResolver());
         }
         return hierManager;
     }
@@ -388,10 +387,6 @@
         return wspManager.getIdFactory();
     }
 
-    NodeId getRootNodeId() {
-        return wspManager.getRootNodeId();
-    }
-
     NodeTypeRegistry getNodeTypeRegistry() {
         return wspManager.getNodeTypeRegistry();
     }
@@ -406,7 +401,7 @@
      *
      * @return the state manager of this workspace
      */
-    public UpdatableItemStateManager getUpdatableItemStateManager() {
+    UpdatableItemStateManager getUpdatableItemStateManager() {
         return wspManager;
     }
     //-----------------------------------------------------< initialization >---

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=431352&r1=431351&r2=431352&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 14 07:16:02 2006
@@ -31,6 +31,8 @@
 import org.apache.jackrabbit.jcr2spi.state.CachingItemStateManager;
 import org.apache.jackrabbit.jcr2spi.state.ItemStateFactory;
 import org.apache.jackrabbit.jcr2spi.state.WorkspaceItemStateFactory;
+import org.apache.jackrabbit.jcr2spi.state.NodeState;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateManager;
 import org.apache.jackrabbit.jcr2spi.operation.OperationVisitor;
 import org.apache.jackrabbit.jcr2spi.operation.AddNode;
 import org.apache.jackrabbit.jcr2spi.operation.AddProperty;
@@ -56,6 +58,7 @@
 import org.apache.jackrabbit.jcr2spi.security.AccessManager;
 import org.apache.jackrabbit.jcr2spi.observation.InternalEventListener;
 import org.apache.jackrabbit.util.IteratorHelper;
+import org.apache.jackrabbit.name.Path;
 import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.spi.RepositoryService;
 import org.apache.jackrabbit.spi.SessionInfo;
@@ -69,7 +72,6 @@
 import org.apache.jackrabbit.spi.EventIterator;
 import org.apache.jackrabbit.spi.Event;
 import org.apache.jackrabbit.spi.ItemId;
-import org.apache.jackrabbit.name.Path;
 import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 import org.apache.jackrabbit.value.QValue;
 import org.slf4j.LoggerFactory;
@@ -116,9 +118,6 @@
     // TODO: TO-BE-FIXED. Major refactoring of caching mechanism with change to SPI ids
     private final CachingItemStateManager cache;
 
-    // TODO: TO-BE-FIXED. With SPI_ItemId rootId must not be stored separately
-    private final NodeId rootNodeId;
-
     private final NamespaceRegistryImpl nsRegistry;
     private final NodeTypeRegistry ntRegistry;
 
@@ -146,7 +145,6 @@
 
             nsRegistry = createNamespaceRegistry();
             ntRegistry = createNodeTypeRegistry(nsRegistry);
-            rootNodeId = createRootNodeId();
             externalChangeListener = createChangeListener();
         } catch (ItemStateException e) {
             throw new RepositoryException(e);
@@ -161,10 +159,6 @@
         return ntRegistry;
     }
 
-    public NodeId getRootNodeId() {
-        return rootNodeId;
-    }
-
     public String[] getWorkspaceNames() throws RepositoryException {
         // TODO: review
         return service.getWorkspaceNames(sessionInfo);
@@ -297,13 +291,21 @@
         return l;
     }
 
-    private NodeId createRootNodeId() throws RepositoryException {
-        return service.getRootId(sessionInfo);
+    //---------------------------------------------------< ItemStateManager >---
+    /**
+     * @inheritDoc
+     * @see ItemStateManager#getRootState()
+     */
+    public NodeState getRootState() throws ItemStateException {
+        // retrieve through cache
+        synchronized (cache) {
+            return cache.getRootState();
+        }
     }
 
-    //---------------------------------------------------< ItemStateManager >---
     /**
      * @inheritDoc
+     * @see ItemStateManager#getItemState(ItemId)
      */
     public ItemState getItemState(ItemId id) throws NoSuchItemStateException, ItemStateException {
         // retrieve through cache
@@ -314,6 +316,7 @@
 
     /**
      * @inheritDoc
+     * @see ItemStateManager#hasItemState(ItemId)
      */
     public boolean hasItemState(ItemId id) {
         synchronized (cache) {
@@ -323,6 +326,7 @@
 
     /**
      * @inheritDoc
+     * @see ItemStateManager#getNodeReferences(NodeId)
      */
     public NodeReferences getNodeReferences(NodeId id) throws NoSuchItemStateException, ItemStateException {
         synchronized (cache) {
@@ -332,6 +336,7 @@
 
     /**
      * @inheritDoc
+     * @see ItemStateManager#hasNodeReferences(NodeId)
      */
     public boolean hasNodeReferences(NodeId id) {
         synchronized (cache) {
@@ -370,7 +375,7 @@
     public void dispose() {
         if (externalChangeListener != null) {
             try {
-                service.removeEventListener(sessionInfo, rootNodeId, externalChangeListener);
+                service.removeEventListener(sessionInfo, service.getRootId(sessionInfo), externalChangeListener);
             } catch (RepositoryException e) {
                 log.warn("exception while disposing workspace manager: " + e);
             }
@@ -378,25 +383,39 @@
     }
     //------------------------------------------------------< AccessManager >---
 
-    // TODO: method can be removed, if jcr2spi uses spi-ids as well
-    public boolean isGranted(NodeId parentId, Path relPath, String[] actions) throws ItemNotFoundException, RepositoryException {
+    /**
+     * @see AccessManager#isGranted(NodeState, Path, String[])
+     */
+    public boolean isGranted(NodeState parentState, Path relPath, String[] actions) throws ItemNotFoundException, RepositoryException {
         // TODO: 'createNodeId' is basically wrong since isGranted is unspecific for any item.
-        ItemId id = getIdFactory().createNodeId(parentId, relPath);
-        return isGranted(id, actions);
+        ItemId id = getIdFactory().createNodeId(parentState.getNodeId(), relPath);
+        return service.isGranted(sessionInfo, id, actions);
     }
 
-    public boolean isGranted(ItemId id, String[] actions) throws ItemNotFoundException, RepositoryException {
-        return service.isGranted(sessionInfo, id, actions);
+    /**
+     * @see AccessManager#isGranted(ItemState, String[])
+     */
+    public boolean isGranted(ItemState itemState, String[] actions) throws ItemNotFoundException, RepositoryException {
+        return service.isGranted(sessionInfo, itemState.getId(), actions);
     }
 
-    public boolean canRead(ItemId id) throws ItemNotFoundException, RepositoryException {
-        return service.isGranted(sessionInfo, id, AccessManager.READ);
+    /**
+     * @see AccessManager#canRead(ItemState)
+     */
+    public boolean canRead(ItemState itemState) throws ItemNotFoundException, RepositoryException {
+        return service.isGranted(sessionInfo, itemState.getId(), AccessManager.READ);
     }
 
-    public boolean canRemove(ItemId id) throws ItemNotFoundException, RepositoryException {
-        return service.isGranted(sessionInfo, id, AccessManager.REMOVE);
+    /**
+     * @see AccessManager#canRemove(ItemState)
+     */
+    public boolean canRemove(ItemState itemState) throws ItemNotFoundException, RepositoryException {
+        return service.isGranted(sessionInfo, itemState.getId(), AccessManager.REMOVE);
     }
 
+    /**
+     * @see AccessManager#canAccess(String)
+     */
     public boolean canAccess(String workspaceName) throws NoSuchWorkspaceException, RepositoryException {
         String[] wspNames = getWorkspaceNames();
         for (int i = 0; i < wspNames.length; i++) {

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=431352&r1=431351&r2=431352&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 14 07:16:02 2006
@@ -38,11 +38,10 @@
      */
     protected ItemStateManager attic;
 
-    public ZombieHierarchyManager(NodeId rootNodeId,
-                                  ItemStateManager provider,
+    public ZombieHierarchyManager(ItemStateManager itemStateManager,
                                   ItemStateManager attic,
                                   NamespaceResolver nsResolver) {
-        super(rootNodeId, provider, nsResolver);
+        super(itemStateManager, nsResolver);
         this.attic = attic;
     }
 

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AbstractOperation.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AbstractOperation.java?rev=431352&r1=431351&r2=431352&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AbstractOperation.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AbstractOperation.java Mon Aug 14 07:16:02 2006
@@ -66,8 +66,6 @@
         affectedIds.add(affectedId);
     }
 
-    // TODO to be removed after ID refactoring completed
-
     /**
      * 
      * @param nodePath

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/security/AccessManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/security/AccessManager.java?rev=431352&r1=431351&r2=431352&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/security/AccessManager.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/security/AccessManager.java Mon Aug 14 07:16:02 2006
@@ -16,9 +16,9 @@
  */
 package org.apache.jackrabbit.jcr2spi.security;
 
-import org.apache.jackrabbit.spi.ItemId;
-import org.apache.jackrabbit.spi.NodeId;
 import org.apache.jackrabbit.name.Path;
+import org.apache.jackrabbit.jcr2spi.state.ItemState;
+import org.apache.jackrabbit.jcr2spi.state.NodeState;
 
 import javax.jcr.ItemNotFoundException;
 import javax.jcr.NoSuchWorkspaceException;
@@ -46,52 +46,50 @@
      * Determines whether the specified <code>permissions</code> are granted
      * on the item with the specified path.
      *
-     * @param parentId The node id the existing ancestor.
+     * @param parentState The node state of the next existing ancestor.
      * @param relPath The relative path pointing to the non-existing target item.
      * @param actions An array of actions that need to be checked.
      * @return <code>true</code> if the actions are granted; otherwise <code>false</code>
      * @throws ItemNotFoundException if the target item does not exist
      * @throws RepositoryException if another error occurs
      */
-    // TODO: method can be removed, if jcr2spi uses spi-ids as well
-    boolean isGranted(NodeId parentId, Path relPath, String[] actions) throws ItemNotFoundException, RepositoryException;
+    boolean isGranted(NodeState parentState, Path relPath, String[] actions) throws ItemNotFoundException, RepositoryException;
 
     /**
-      * Determines whether the specified <code>permissions</code> are granted
-      * on the item with the specified path.
-      *
-      * @param itemId The id of an existing target item.
-      * @param actions An array of actions that need to be checked.
-      * @return <code>true</code> if the actions are granted; otherwise <code>false</code>
-      * @throws ItemNotFoundException if the target item does not exist
-      * @throws RepositoryException if another error occurs
-      */
-     boolean isGranted(ItemId itemId, String[] actions) throws ItemNotFoundException, RepositoryException;
+     * Determines whether the specified <code>permissions</code> are granted
+     * on the item with the specified path.
+     *
+     * @param itemState
+     * @param actions An array of actions that need to be checked.
+     * @return <code>true</code> if the actions are granted; otherwise <code>false</code>
+     * @throws ItemNotFoundException if the target item does not exist
+     * @throws RepositoryException if another error occurs
+     */
+     boolean isGranted(ItemState itemState, String[] actions) throws ItemNotFoundException, RepositoryException;
 
 
     /**
      * Returns true if the existing item with the given <code>ItemId</code> can
      * be read.
      *
-     * @param id The id of an existing target item.
+     * @param itemState
      * @return
      * @throws ItemNotFoundException
      * @throws RepositoryException
      */
-    boolean canRead(ItemId id) throws ItemNotFoundException, RepositoryException;
+    boolean canRead(ItemState itemState) throws ItemNotFoundException, RepositoryException;
 
     // TODO need for canWrite(ItemId ?)
 
     /**
-     * Returns true if the existing item with the given <code>ItemId</code> can
-     * be removed.
+     * Returns true if the existing item state can be removed.
      *
-     * @param id The id of an existing target item.
+     * @param itemState
      * @return
      * @throws ItemNotFoundException
      * @throws RepositoryException
      */
-    boolean canRemove(ItemId id) throws ItemNotFoundException, RepositoryException;
+    boolean canRemove(ItemState itemState) throws ItemNotFoundException, RepositoryException;
 
     /**
      * Determines whether the subject of the current context is granted access

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/CachingItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/CachingItemStateManager.java?rev=431352&r1=431351&r2=431352&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/CachingItemStateManager.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/CachingItemStateManager.java Mon Aug 14 07:16:02 2006
@@ -92,6 +92,11 @@
     }
 
     //---------------------------------------------------< ItemStateManager >---
+
+    public NodeState getRootState() throws ItemStateException {
+        return root;
+    }
+
     /**
      * @inheritDoc
      * @see ItemStateManager#getItemState(ItemId)

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=431352&r1=431351&r2=431352&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 14 07:16:02 2006
@@ -18,6 +18,7 @@
 
 import org.apache.jackrabbit.util.WeakIdentityCollection;
 import org.apache.jackrabbit.spi.ItemId;
+import org.apache.jackrabbit.spi.IdFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -74,11 +75,6 @@
     protected int status = STATUS_UNDEFINED;
 
     /**
-     * a modification counter used to prevent concurrent modifications
-     */
-    private short modCount;
-
-    /**
      * Flag indicating whether this state is transient
      */
     private final boolean isTransient;
@@ -88,18 +84,33 @@
      */
     private final transient Collection listeners = new WeakIdentityCollection(5);
 
+    // TODO: check again...
+    /**
+     *  IdFactory used to build id of the states
+     */
+    final IdFactory idFactory;
+
+    // DIFF JR
+    /**
+     * The parent <code>NodeState</code> or <code>null</code> if this
+     * instance represents the root node.
+     */
+    NodeState parent;
+
     /**
      * the backing persistent item state (may be null)
      */
-    protected transient ItemState overlayedState;
+    transient ItemState overlayedState;
 
     /**
      * Constructs a new unconnected item state
      *
+     * @param parent
      * @param initialStatus the initial status of the item state object
      * @param isTransient   flag indicating whether this state is transient or not
      */
-    protected ItemState(int initialStatus, boolean isTransient) {
+    protected ItemState(NodeState parent, int initialStatus, boolean isTransient,
+                        IdFactory idFactory) {
         switch (initialStatus) {
             case STATUS_EXISTING:
             case STATUS_NEW:
@@ -110,9 +121,10 @@
                 log.debug(msg);
                 throw new IllegalArgumentException(msg);
         }
-        modCount = 0;
+        this.parent = parent;
         overlayedState = null;
         this.isTransient = isTransient;
+        this.idFactory = idFactory;
     }
 
     /**
@@ -123,7 +135,8 @@
      * @param initialStatus the initial status of the new <code>ItemState</code> instance
      * @param isTransient   flag indicating whether this state is transient or not
      */
-    protected ItemState(ItemState overlayedState, int initialStatus, boolean isTransient) {
+    protected ItemState(ItemState overlayedState, NodeState parent, int initialStatus,
+                        boolean isTransient, IdFactory idFactory) {
         switch (initialStatus) {
             case STATUS_EXISTING:
             case STATUS_EXISTING_MODIFIED:
@@ -136,9 +149,11 @@
                 throw new IllegalArgumentException(msg);
         }
         this.isTransient = isTransient;
+        this.parent = parent;
+        this.idFactory = idFactory;
         connect(overlayedState);
     }
-    
+
     /**
      * Copy state information from another state into this state
      * @param state source state information
@@ -151,8 +166,6 @@
     void pull() {
         if (overlayedState != null) {
             copy(overlayedState);
-            // sync modification count
-            modCount = overlayedState.getModCount();
         }
     }
 
@@ -214,6 +227,19 @@
         }
     }
 
+
+    /**
+     * Discards this instance, i.e. renders it 'invalid'.
+     */
+    protected void discard() {
+        if (status != STATUS_UNDEFINED) {
+            // notify listeners
+            notifyStateDiscarded();
+            // reset status
+            setStatus(STATUS_UNDEFINED);
+        }
+    }
+
     /**
      * Notify the listeners that the persistent state this object is
      * representing has been discarded.
@@ -252,7 +278,7 @@
      * Notify the listeners that the persistent state this object is
      * representing has been updated.
      */
-    public void notifyStateUpdated() {
+    protected void notifyStateUpdated() {
         // copy listeners to array to avoid ConcurrentModificationException
         ItemStateListener[] la;
         synchronized (listeners) {
@@ -269,7 +295,7 @@
      * Notify the listeners that the persistent state this object is
      * representing has been destroyed.
      */
-    public void notifyStateDestroyed() {
+    protected void notifyStateDestroyed() {
         // copy listeners to array to avoid ConcurrentModificationException
         ItemStateListener[] la;
         synchronized (listeners) {
@@ -321,14 +347,13 @@
             case STATUS_EXISTING_REMOVED:
             case STATUS_UNDEFINED:
             default:
-                String msg = "Cannot mark item state with status " +
-                        status + " modified.";
+                String msg = "Cannot mark item state with status " + status + " modified.";
                 throw new IllegalStateException(msg);
         }
     }
 
 
-    //-------------------------------------------------------< public methods >
+    //--------------------< public READ methods and package private Setters >---
     /**
      * Determines if this item state represents a node.
      *
@@ -356,27 +381,15 @@
     }
 
     /**
-     * Determines whether this item state has become stale.
-     * @return true if this item state has become stale, false otherwise.
-     */
-    public boolean isStale() {
-        if (isTransient) {
-            return status == STATUS_STALE_MODIFIED
-                || status == STATUS_STALE_DESTROYED;
-        } else {
-            return overlayedState != null
-                && modCount != overlayedState.getModCount();
-        }
-    }
-
-    /**
      * 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>
      */
-    public abstract NodeState getParent();
+    public NodeState getParent() {
+        return parent;
+    }
 
     /**
      * Returns the status of this item.
@@ -388,13 +401,11 @@
     }
 
     /**
-     * TODO: this method should be at least protected. the outside should not
-     * TODO: control the status of an item state
      * Sets the new status of this item.
      *
      * @param newStatus the new status
      */
-    public void setStatus(int newStatus) {
+    void setStatus(int newStatus) {
         if (status == newStatus) {
             return;
         }
@@ -415,43 +426,6 @@
                 throw new IllegalArgumentException(msg);
         }
         notifyStatusChanged(oldStatus);
-    }
-
-    /**
-     * Returns the modification count.
-     *
-     * @return the modification count.
-     */
-    public short getModCount() {
-        return modCount;
-    }
-
-    /**
-     * Sets the modification count.
-     *
-     * @param modCount the modification count of this item
-     */
-    public void setModCount(short modCount) {
-        this.modCount = modCount;
-    }
-
-    /**
-     * Updates the modification count.
-     */
-    synchronized void touch() {
-        modCount++;
-    }
-
-    /**
-     * Discards this instance, i.e. renders it 'invalid'.
-     */
-    public void discard() {
-        if (status != STATUS_UNDEFINED) {
-            // notify listeners
-            notifyStateDiscarded();
-            // reset status
-            setStatus(STATUS_UNDEFINED);
-        }
     }
 
     /**

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateManager.java?rev=431352&r1=431351&r2=431352&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateManager.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateManager.java Mon Aug 14 07:16:02 2006
@@ -26,7 +26,16 @@
 public interface ItemStateManager {
 
     /**
+     * Returns the <code>NodeState</code> of the root node.
+     *
+     * @return node state of the root node.
+     * @throws ItemStateException
+     */
+    NodeState getRootState() throws ItemStateException;
+
+    /**
      * Return an item state, given its item id.
+     *
      * @param id item id
      * @return item state
      * @throws NoSuchItemStateException if the item does not exist
@@ -37,6 +46,7 @@
     /**
      * Return a flag indicating whether an item state for a given
      * item id exists.
+     *
      * @param id item id
      * @return <code>true</code> if an item state exists,
      *         otherwise <code>false</code>
@@ -45,7 +55,8 @@
 
     // DIFF JR: NodeId param instead of NodeReferenceId
     /**
-     * Return a node references object, given its target id
+     * Return a node references object, given its target id.
+     *
      * @param id target id
      * @return node references object
      * @throws NoSuchItemStateException if the item does not exist
@@ -58,6 +69,7 @@
     /**
      * Return a flag indicating whether a node references object
      * for a given target id exists.
+     *
      * @param id target id
      * @return <code>true</code> if a node reference object exists for the given
      *         id, otherwise <code>false</code>.

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=431352&r1=431351&r2=431352&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 14 07:16:02 2006
@@ -40,7 +40,6 @@
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.QItemDefinition;
 import org.apache.jackrabbit.spi.NodeId;
-import org.apache.jackrabbit.spi.ItemId;
 import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.name.Path;
 import org.apache.jackrabbit.name.NamespaceResolver;
@@ -365,7 +364,7 @@
 
         if ((options & CHECK_ACCESS) == CHECK_ACCESS) {
             // make sure current session is granted read access on parent node
-            if (!mgrProvider.getAccessManager().canRead(parentState.getNodeId())) {
+            if (!mgrProvider.getAccessManager().canRead(parentState)) {
                 throw new ItemNotFoundException(safeGetJCRPath(parentState));
             }
         }
@@ -487,7 +486,7 @@
         if ((options & CHECK_ACCESS) == CHECK_ACCESS) {
             // make sure current session is granted write access on new prop
             Path relPath = Path.create(propertyName, Path.INDEX_UNDEFINED);
-            if (!mgrProvider.getAccessManager().isGranted(parentState.getNodeId(), relPath, new String[] {AccessManager.SET_PROPERTY_ACTION})) {
+            if (!mgrProvider.getAccessManager().isGranted(parentState, relPath, new String[] {AccessManager.SET_PROPERTY_ACTION})) {
                 throw new AccessDeniedException(safeGetJCRPath(parentState) + ": not allowed to create property with name " + propertyName);
             }
         }
@@ -550,7 +549,7 @@
             // make sure current session is granted write access on parent node
             // TODO build Id instead 
             Path relPath = Path.create(nodeName, org.apache.jackrabbit.name.Path.INDEX_UNDEFINED);
-            if (!mgrProvider.getAccessManager().isGranted(parentState.getNodeId(), relPath, new String[] {AccessManager.ADD_NODE_ACTION})) {
+            if (!mgrProvider.getAccessManager().isGranted(parentState, relPath, new String[] {AccessManager.ADD_NODE_ACTION})) {
                 throw new AccessDeniedException(safeGetJCRPath(parentState) + ": not allowed to add child node '" + nodeName +"'");
             }
         }
@@ -602,14 +601,11 @@
 
         // TODO: missing check if all affected child-states can be removed as well
         // NOTE: referencial integrity should be asserted for all child-nodes.
-
-        ItemId targetId = targetState.getId();
         NodeState parentState = targetState.getParent();
         if (parentState == null) {
-            // root or orphaned node
-            throw new ConstraintViolationException("Cannot remove root node");
+            // root node
+            throw new ConstraintViolationException("Cannot remove root node.");
         }
-
         // check parent
         checkIsWritable(parentState, options);
 
@@ -617,11 +613,11 @@
         if ((options & CHECK_ACCESS) == CHECK_ACCESS) {
             try {
                 // make sure current session is granted read access on parent node
-                if (!mgrProvider.getAccessManager().canRead(targetId)) {
+                if (!mgrProvider.getAccessManager().canRead(targetState)) {
                     throw new PathNotFoundException(safeGetJCRPath(targetState));
                 }
                 // make sure current session is allowed to remove target node
-                if (!mgrProvider.getAccessManager().canRemove(targetId)) {
+                if (!mgrProvider.getAccessManager().canRemove(targetState)) {
                     throw new AccessDeniedException(safeGetJCRPath(targetState)
                             + ": not allowed to remove node");
                 }
@@ -683,10 +679,8 @@
     private void checkLock(ItemState itemState)
             throws LockException, RepositoryException {
         // make sure there's no foreign lock present the node (or the parent node
-        // for properties.
-        NodeState nodeState = (itemState.isNode())
-            ? ((NodeState)itemState)
-            : itemState.getParent();
+        // in case the state represents a PropertyState).
+        NodeState nodeState = (itemState.isNode()) ? ((NodeState)itemState) : itemState.getParent();
         mgrProvider.getLockManager().checkLock(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=431352&r1=431351&r2=431352&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 14 07:16:02 2006
@@ -27,7 +27,6 @@
 import org.apache.jackrabbit.name.MalformedPathException;
 import org.apache.jackrabbit.spi.NodeId;
 import org.apache.jackrabbit.spi.ItemId;
-import org.apache.jackrabbit.spi.PropertyId;
 import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeConflictException;
 import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.jcr2spi.nodetype.EffectiveNodeType;
@@ -86,6 +85,8 @@
     private String uuid;
 
     /**
+<<<<<<< .mine
+=======
      * The name of this node
      */
     private QName name;
@@ -97,6 +98,7 @@
     private NodeState parent;
 
     /**
+>>>>>>> .r431350
      * this node's definition
      */
     private QNodeDefinition def;
@@ -118,10 +120,6 @@
      */
     private final transient Collection listeners = new WeakIdentityCollection(3);
 
-    // DIFF JR: limit creation of property-ids to the nodeState
-    // TODO: check again....
-    private final IdFactory idFactory;
-
     /**
      * The <code>ItemStateFactory</code> which is used to create new
      * <code>ItemState</code> instances.
@@ -144,14 +142,12 @@
      * @param idFactory     the <code>IdFactory</code> to create new id
      *                      instance.
      */
-    public NodeState(QName name, String uuid, NodeState parent,
+    protected NodeState(QName name, String uuid, NodeState parent,
                      QName nodeTypeName, int initialStatus, boolean isTransient,
                      ItemStateFactory isf, IdFactory idFactory) {
-        super(initialStatus, isTransient);
+        super(parent, initialStatus, isTransient, idFactory);
         this.name = name;
         this.uuid = uuid;
-        this.parent = parent;
-        this.idFactory = idFactory;
         this.nodeTypeName = nodeTypeName;
         this.isf = isf;
     }
@@ -168,13 +164,11 @@
      * @param idFactory      the <code>IdFactory</code> to create new id
      *                       instance.
      */
-    public NodeState(NodeState overlayedState, NodeState parent,
+    protected NodeState(NodeState overlayedState, NodeState parent,
                      int initialStatus, boolean isTransient,
                      ItemStateFactory isf, IdFactory idFactory) {
-        super(overlayedState, initialStatus, isTransient);
+        super(overlayedState, parent, initialStatus, isTransient, idFactory);
         pull();
-        this.parent = parent;
-        this.idFactory = idFactory;
         this.isf = isf;
     }
 
@@ -206,7 +200,7 @@
         }
     }
 
-    //----------------------< public READ methods and package private WRITE >---
+    //--------------------< public READ methods and package private Setters >---
     /**
      * Determines if this item state represents a node.
      *
@@ -218,13 +212,6 @@
     }
 
     /**
-     * {@inheritDoc}
-     */
-    public NodeState getParent() {
-        return parent;
-    }
-
-    /**
      * Sets the the parent <code>NodeState</code>.
      *
      * @param parent the parent <code>NodeState</code> or <code>null</code>
@@ -232,6 +219,7 @@
      * state should be 'free floating', i.e. detached from the repository's
      * hierarchy.
      */
+    // TODO: change to private and only let new parent node state set the parent.
     void setParent(NodeState parent) {
         this.parent = parent;
     }
@@ -355,21 +343,20 @@
         // make sure the state has the definition set now
         if (def == null) {
             NodeState parentState = getParent();
-            try {
-                if (parentState == null) {
-                    // special case for root state
-                    def = ntRegistry.getRootNodeDef();
-                } else {
+            if (parentState == null) {
+                // special case for root state
+                def = ntRegistry.getRootNodeDef();
+            } else {
+                try {
                     ChildNodeEntry cne = parentState.getChildNodeEntry(getNodeId());
                     EffectiveNodeType ent = ntRegistry.getEffectiveNodeType(parentState.getNodeTypeNames());
-                    setDefinition(ent.getApplicableNodeDefinition(cne.getName(), getNodeTypeName()));
+                    def = ent.getApplicableNodeDefinition(cne.getName(), getNodeTypeName());
+                } catch (NodeTypeConflictException e) {
+                    String msg = "internal error: failed to build effective node type.";
+                    log.debug(msg);
+                    throw new RepositoryException(msg, e);
                 }
-            } catch (NodeTypeConflictException e) {
-                String msg = "internal error: failed to build effective node type.";
-                log.debug(msg);
-                throw new RepositoryException(msg, e);
             }
-
         }
         return def;
     }
@@ -480,7 +467,7 @@
      * @return the newly added <code>ChildNodeEntry</code>
      */
     synchronized ChildNodeEntry addChildNodeEntry(QName nodeName,
-                                                         NodeId id) {
+                                                  NodeId id) {
         ChildNodeEntry entry = childNodeEntries.add(nodeName, id);
         notifyNodeAdded(entry);
         return entry;
@@ -617,18 +604,6 @@
      */
     public synchronized Collection getPropertyEntries() {
         return Collections.unmodifiableCollection(properties.values());
-    }
-
-    /**
-     * Returns the <code>PropertyId</code> for a property with
-     * <code>propertyName</code>. The property does not necessarily have to
-     * exist on <code>this</code> node state.
-     *
-     * @param propertyName the name of a property.
-     * @return the property id.
-     */
-    PropertyId getPropertyId(QName propertyName) {
-        return idFactory.createPropertyId(getNodeId(), propertyName);
     }
 
     /**

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=431352&r1=431351&r2=431352&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 14 07:16:02 2006
@@ -24,6 +24,7 @@
 import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.spi.PropertyId;
 import org.apache.jackrabbit.spi.ItemId;
+import org.apache.jackrabbit.spi.IdFactory;
 import org.apache.jackrabbit.value.QValue;
 import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeConflictException;
 import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeRegistry;
@@ -44,11 +45,6 @@
     private QName name;
 
     /**
-     * The parent state
-     */
-    private NodeState parent;
-
-    /**
      * the internal values
      */
     private QValue[] values;
@@ -73,11 +69,10 @@
      * @param initialStatus  the initial status of the property state object
      * @param isTransient    flag indicating whether this state is transient or not
      */
-    public PropertyState(PropertyState overlayedState, NodeState parent, int initialStatus,
-                         boolean isTransient) {
-        super(overlayedState, initialStatus, isTransient);
+    protected PropertyState(PropertyState overlayedState, NodeState parent, int initialStatus,
+                         boolean isTransient, IdFactory idFactory) {
+        super(overlayedState, parent, initialStatus, isTransient, idFactory);
         pull();
-        this.parent = parent;
     }
 
     /**
@@ -88,10 +83,10 @@
      * @param isTransient   flag indicating whether this state is transient or
      *                      not
      */
-    public PropertyState(QName name, NodeState parent, int initialStatus, boolean isTransient) {
-        super(initialStatus, isTransient);
+    protected PropertyState(QName name, NodeState parent, int initialStatus,
+                            boolean isTransient, IdFactory idFactory) {
+        super(parent, initialStatus, isTransient, idFactory);
         this.name = name;
-        this.parent = parent;
         type = PropertyType.UNDEFINED;
         values = QValue.EMPTY_ARRAY;
         multiValued = false;
@@ -112,9 +107,9 @@
         }
     }
 
-    //----------------------< public READ methods and package private WRITE >---
+    //--------------------< public READ methods and package private Setters >---
     /**
-     * Determines if this item state represents a node.
+     * Always returns false.
      *
      * @return always false
      * @see ItemState#isNode
@@ -122,7 +117,7 @@
     public boolean isNode() {
         return false;
     }
-
+    
     /**
      * {@inheritDoc}
      */
@@ -132,18 +127,11 @@
 
     /**
      * Returns the identifier of this property.
-     * 
+     *
      * @return the id of this property.
      */
     public PropertyId getPropertyId() {
-        return parent.getPropertyId(name);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public NodeState getParent() {
-        return parent;
+        return idFactory.createPropertyId(parent.getNodeId(), getQName());
     }
 
     /**
@@ -225,6 +213,11 @@
         if (def == null) {
             try {
                 NodeState parentState = getParent();
+                if (parentState == null) {
+                    String msg = "Internal error: cannot determine definition for orphaned state.";
+                    log.debug(msg);
+                    throw new RepositoryException(msg);
+                }
                 EffectiveNodeType ent = ntRegistry.getEffectiveNodeType(parentState.getNodeTypeNames());
                 setDefinition(ent.getApplicablePropertyDefinition(getQName(), getType(), isMultiValued()));
             } catch (NodeTypeConflictException e) {

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=431352&r1=431351&r2=431352&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 14 07:16:02 2006
@@ -114,19 +114,13 @@
     private final IdFactory idFactory;
     private final ItemStateValidator validator;
 
-    // DIFF JR: store root id. since 'CachingItemStateManager' not used any more
-    // TODO: TO-BE-FIXED. With SPI_ItemId rootId must not be stored separately
-    private NodeId rootId;
-
     /**
      * Creates a new <code>SessionItemStateManager</code> instance.
      *
-     * @param rootId
      * @param workspaceItemStateMgr
      * @param nsResolver
      */
-    public SessionItemStateManager(NodeId rootId,
-                                   UpdatableItemStateManager workspaceItemStateMgr,
+    public SessionItemStateManager(UpdatableItemStateManager workspaceItemStateMgr,
                                    IdFactory idFactory,
                                    ItemStateValidator validator,
                                    NamespaceResolver nsResolver) {
@@ -139,10 +133,9 @@
         this.idFactory = idFactory;
 
         this.nsResolver = nsResolver;
-        this.rootId = rootId;
 
         // create hierarchy manager
-        hierMgr = new HierarchyManagerImpl(rootId, this, nsResolver);
+        hierMgr = new HierarchyManagerImpl(this, nsResolver);
 
     }
 
@@ -158,6 +151,16 @@
     //---------------------------------------------------< ItemStateManager >---
     /**
      * {@inheritDoc}
+     * @see ItemStateManager#getRootState()
+     */
+    public NodeState getRootState() throws ItemStateException {
+        // TODO
+        return null;
+    }
+
+    /**
+     * {@inheritDoc}
+     * @see ItemStateManager#getItemState(ItemId)
      */
     public ItemState getItemState(ItemId id)
             throws NoSuchItemStateException, ItemStateException {
@@ -189,6 +192,7 @@
 
     /**
      * {@inheritDoc}
+     * @see ItemStateManager#hasItemState(ItemId)
      */
     public boolean hasItemState(ItemId id) {
         // first check if the specified item has been transiently removed
@@ -210,6 +214,7 @@
 
     /**
      * {@inheritDoc}
+     * @see ItemStateManager#getNodeReferences(NodeId)
      */
     public NodeReferences getNodeReferences(NodeId id)
             throws NoSuchItemStateException, ItemStateException {
@@ -219,6 +224,7 @@
 
     /**
      * {@inheritDoc}
+     * @see ItemStateManager#hasNodeReferences(NodeId)
      */
     public boolean hasNodeReferences(NodeId id) {
         return workspaceItemStateMgr.hasNodeReferences(id);
@@ -308,14 +314,14 @@
      * This will undo all changes made to <code>state</code> and descendant
      * items of <code>state</code> inside this item state manager.
      *
-     * @param state the root state of the cancel operation.
+     * @param itemState the root state of the cancel operation.
      * @throws ItemStateException if undoing changes made to <code>state</code>
      *                            and descendant items is not a closed set of
      *                            changes. That is, at least another item needs
      *                            to be canceled as well in another sub-tree.
      */
-    public void undo(ItemState state) throws ItemStateException {
-        if (state.getParent() == null) {
+    public void undo(ItemState itemState) throws ItemStateException {
+        if (itemState.getParent() == null) {
             // optimization for root
             transientStateMgr.disposeAllItemStates();
             return;
@@ -325,23 +331,23 @@
         ChangeLog changeLog = new TransientChangeLog(idFactory, workspaceItemStateMgr);
 
         // check status of current item's state
-        if (state.isTransient()) {
-            switch (state.getStatus()) {
+        if (itemState.isTransient()) {
+            switch (itemState.getStatus()) {
                 case ItemState.STATUS_STALE_MODIFIED:
                 case ItemState.STATUS_STALE_DESTROYED:
                 case ItemState.STATUS_EXISTING_MODIFIED:
                     // add this item's state to the list
-                    changeLog.modified(state);
+                    changeLog.modified(itemState);
                     break;
                 default:
-                    log.debug("unexpected state status (" + state.getStatus() + ")");
+                    log.debug("unexpected state status (" + itemState.getStatus() + ")");
                     // ignore
                     break;
             }
         }
 
-        if (state.isNode()) {
-            NodeState nodeState = (NodeState)state;
+        if (itemState.isNode()) {
+            NodeState nodeState = (NodeState)itemState;
             // build list of 'new', 'modified' or 'stale' descendants
             Iterator iter = getDescendantTransientItemStates(nodeState);
             while (iter.hasNext()) {
@@ -471,7 +477,7 @@
                 // determine relative depth: > 0 means it's a descendant
                 int depth;
                 try {
-                    depth = getHierarchyManager().getRelativeDepth(parent, state);
+                    depth = hierMgr.getRelativeDepth(parent, state);
                 } catch (ItemNotFoundException infe) {
                     /**
                      * one of the parents of the specified item has been
@@ -553,10 +559,7 @@
 
         // use a special attic-aware hierarchy manager
         ZombieHierarchyManager zombieHierMgr =
-                new ZombieHierarchyManager(rootId,
-                        this,
-                        transientStateMgr.getAttic(),
-                        nsResolver);
+                new ZombieHierarchyManager(this, transientStateMgr.getAttic(), nsResolver);
 
         // use an array of lists to group the descendants by relative depth;
         // the depth is used as array index
@@ -713,28 +716,28 @@
 
                 case ItemState.STATUS_NEW:
                     {
-                        String msg = LogUtil.safeGetJCRPath(state, nsResolver, getHierarchyManager()) + ": cannot save a new item.";
+                        String msg = LogUtil.safeGetJCRPath(state, nsResolver, hierMgr) + ": cannot save a new item.";
                         log.debug(msg);
                         throw new ItemStateException(msg);
                     }
 
                 case ItemState.STATUS_STALE_MODIFIED:
                     {
-                        String msg = LogUtil.safeGetJCRPath(state, nsResolver, getHierarchyManager()) + ": the item cannot be saved because it has been modified externally.";
+                        String msg = LogUtil.safeGetJCRPath(state, nsResolver, hierMgr) + ": the item cannot be saved because it has been modified externally.";
                         log.debug(msg);
                         throw new StaleItemStateException(msg);
                     }
 
                 case ItemState.STATUS_STALE_DESTROYED:
                     {
-                        String msg = LogUtil.safeGetJCRPath(state, nsResolver, getHierarchyManager()) + ": the item cannot be saved because it has been deleted externally.";
+                        String msg = LogUtil.safeGetJCRPath(state, nsResolver, hierMgr) + ": the item cannot be saved because it has been deleted externally.";
                         log.debug(msg);
                         throw new StaleItemStateException(msg);
                     }
 
                 case ItemState.STATUS_UNDEFINED:
                     {
-                        String msg = LogUtil.safeGetJCRPath(state, nsResolver, getHierarchyManager()) + ": the item cannot be saved; it seems to have been removed externally.";
+                        String msg = LogUtil.safeGetJCRPath(state, nsResolver, hierMgr) + ": the item cannot be saved; it seems to have been removed externally.";
                         log.debug(msg);
                         throw new StaleItemStateException(msg);
                     }
@@ -957,7 +960,7 @@
         QNodeDefinition newDefinition = validator.getApplicableNodeDefinition(operation.getDestinationName(), srcState.getNodeTypeName(), destParent);
 
         // perform the move (modifying states)
-        // TODO: TO-BE-FIXED. Move with SPI id       
+        // TODO: TO-BE-FIXED. Move with SPI id
         boolean renameOnly = srcParent.getNodeId().equals(destParent.getNodeId());
         ChildNodeEntry cne = srcParent.getChildNodeEntry(srcState.getNodeId());
         if (cne == null) {
@@ -1434,8 +1437,6 @@
             }
         }
 
-        // now actually do unlink target state
-        targetState.setParent(null);
         // destroy target state
         // DIFF JR: destroy targetState (not overlayed state)
         destroy(targetState);

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=431352&r1=431351&r2=431352&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 14 07:16:02 2006
@@ -101,6 +101,19 @@
     //-----------------------< ItemStateManager >-------------------------------
 
     /**
+     * Return the root node state or <code>null</code> if the root state has
+     * not been modified yet.
+     *
+     * @return
+     * @throws ItemStateException
+     * @see ItemStateManager#getRootState()
+     */
+    public NodeState getRootState() throws ItemStateException {
+        // TODO
+        return null;
+    }
+
+    /**
      * Return an item state given its id. Returns <code>null</code>
      * if the item state is neither in the added nor in the modified
      * section. Throws a <code>NoSuchItemStateException</code> if
@@ -358,7 +371,7 @@
      */
     public PropertyState createNewPropertyState(QName name, NodeState parent) {
         PropertyState propState = new PropertyState(name, parent,
-                ItemState.STATUS_NEW, true);
+                ItemState.STATUS_NEW, true, idFactory);
         // get a notification when this item state is saved or invalidated
         propState.addListener(this);
         added(propState);
@@ -407,7 +420,7 @@
         NodeId parentId = overlayedState.getParent().getNodeId();
         NodeState parentState = (NodeState) ism.getItemState(parentId);
         PropertyState propState = new PropertyState(overlayedState, parentState,
-                ItemState.STATUS_EXISTING, true);
+                ItemState.STATUS_EXISTING, true, idFactory);
         propState.addListener(this);
         return propState;
     }
@@ -422,7 +435,7 @@
         // retrieve state to overlay
         PropertyState overlayedState = (PropertyState) parent.getItemState(propertyId);
         PropertyState propState = new PropertyState(overlayedState, parentState,
-                ItemState.STATUS_EXISTING, true);
+                ItemState.STATUS_EXISTING, true, idFactory);
         propState.addListener(this);
         return propState;
     }
@@ -528,6 +541,18 @@
     private class AtticItemStateManager implements ItemStateManager {
 
         AtticItemStateManager() {
+        }
+
+        /**
+         * Since the root node may never be removed, this method always returns
+         * <code>null</code>.
+         *
+         * @return <code>null</code> since the root node cannot be removed.
+         * @throws ItemStateException
+         * @see ItemStateManager#getRootState()
+         */
+        public NodeState getRootState() throws ItemStateException {
+            return null;
         }
 
         /**

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java?rev=431352&r1=431351&r2=431352&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java Mon Aug 14 07:16:02 2006
@@ -201,7 +201,7 @@
             // NOTE: unable to retrieve definitionId -> needs to be retrieved
             // by the itemManager upon Property creation.
             PropertyState state = new PropertyState(info.getQName(), parent,
-                    ItemState.STATUS_EXISTING, false);
+                    ItemState.STATUS_EXISTING, false, service.getIdFactory());
             state.setMultiValued(info.isMultiValued());
             state.setType(info.getType());
             QValue[] qValues;

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java?rev=431352&r1=431351&r2=431352&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java Mon Aug 14 07:16:02 2006
@@ -187,7 +187,7 @@
         QName qLabel = getQLabel(label);
         ChildNodeEntry vEntry = getVersionEntry(versionName);
         // delegate to version manager that operates on workspace directely
-        session.getVersionManager().addVersionLabel(vhState.getNodeId(), vEntry.getId(), qLabel, moveLabel);
+        session.getVersionManager().addVersionLabel(getNodeId(), vEntry.getId(), qLabel, moveLabel);
     }
 
     /**
@@ -202,7 +202,7 @@
         ChildNodeEntry vEntry = getVersionEntryByLabel(getQLabel(label));
 
         // delegate to version manager that operates on workspace directely
-        session.getVersionManager().removeVersionLabel(vhState.getNodeId(), vEntry.getId(), qLabel);
+        session.getVersionManager().removeVersionLabel(getNodeId(), vEntry.getId(), qLabel);
     }
 
     /**
@@ -308,7 +308,7 @@
      */
     public void removeVersion(String versionName) throws RepositoryException {
         ChildNodeEntry vEntry = getVersionEntry(versionName);
-        session.getVersionManager().removeVersion(vEntry.getId(), vhState.getNodeId());
+        session.getVersionManager().removeVersion(vEntry.getId(), getNodeId());
     }
 
     //---------------------------------------------------------------< Item >---
@@ -323,7 +323,7 @@
             // since all version histories are referenceable, protected and live
             // in the same workspace, a simple comparison of the ids is sufficient
             VersionHistoryImpl other = ((VersionHistoryImpl) otherItem);
-            return other.getId().equals(getId());
+            return getNodeId().equals(other.getNodeId());
         }
         return false;
     }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionImpl.java?rev=431352&r1=431351&r2=431352&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionImpl.java Mon Aug 14 07:16:02 2006
@@ -99,7 +99,7 @@
             // since all versions are referenceable, protected and live
             // in the same workspace, a simple comparision of the ids is sufficient
             VersionImpl other = ((VersionImpl) otherItem);
-            return other.getId().equals(getId());
+            return other.getNodeId().equals(other.getNodeId());
         }
         return false;
     }



Mime
View raw message