You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by st...@apache.org on 2005/02/04 18:44:02 UTC

svn commit: r151380 [2/2] - in incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core: ./ state/ state/mem/ state/obj/ state/xml/ version/ version/persistence/

Added: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/TransactionalItemStateManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/TransactionalItemStateManager.java?view=auto&rev=151380
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/TransactionalItemStateManager.java (added)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/TransactionalItemStateManager.java Fri Feb  4 09:43:55 2005
@@ -0,0 +1,180 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.core.state;
+
+import org.apache.jackrabbit.core.ItemId;
+import org.apache.log4j.Logger;
+
+/**
+ * Extension to <code>LocalItemStateManager</code> that remembers changes on
+ * multiple save() requests and commits them only when an associated transaction
+ * is itself committed.
+ */
+public class TransactionalItemStateManager extends LocalItemStateManager
+        implements TransactionListener {
+
+    /**
+     * Logger instance
+     */
+    private static Logger log = Logger.getLogger(TransactionalItemStateManager.class);
+
+    /**
+     * Known attribute name
+     */
+    private static final String ATTRIBUTE_CHANGE_LOG = "ChangeLog";
+
+    /**
+     * Currently associated transaction
+     */
+    private transient TransactionContext tx;
+
+    /**
+     * Current change log
+     */
+    private transient ChangeLog changeLog;
+
+    /**
+     * Creates a new <code>LocalItemStateManager</code> instance.
+     *
+     * @param sharedStateMgr shared state manager
+     */
+    public TransactionalItemStateManager(SharedItemStateManager sharedStateMgr) {
+        super(sharedStateMgr);
+    }
+
+    /**
+     * Set transaction context.
+     * @param tx transaction context.
+     */
+    public void setTransactionContext(TransactionContext tx) {
+        if (tx != null) {
+            changeLog = (ChangeLog) tx.getAttribute(ATTRIBUTE_CHANGE_LOG);
+            if (changeLog == null) {
+                changeLog = new ChangeLog();
+                tx.setAttribute(ATTRIBUTE_CHANGE_LOG, changeLog);
+                tx.addListener(this);
+            }
+        }
+        this.tx = tx;
+    }
+
+    //-----------------------------------------------------< ItemStateManager >
+
+    /**
+     * @see ItemStateManager#getItemState(org.apache.jackrabbit.core.ItemId)
+     *
+     * If associated to a transaction, check our transactional
+     * change log first.
+     */
+    public ItemState getItemState(ItemId id)
+            throws NoSuchItemStateException, ItemStateException {
+
+        if (tx != null) {
+            // check items in change log
+            ItemState state = changeLog.get(id);
+            if (state != null) {
+                return state;
+            }
+        }
+        return super.getItemState(id);
+    }
+
+    /**
+     * @see ItemStateManager#hasItemState(org.apache.jackrabbit.core.ItemId)
+     *
+     * If associated to a transaction, check our transactional
+     * change log first.
+     */
+    public boolean hasItemState(ItemId id) {
+        if (tx != null) {
+            // check items in change log
+            try {
+                ItemState state = changeLog.get(id);
+                if (state != null) {
+                    return true;
+                }
+            } catch (NoSuchItemStateException e) {
+                return false;
+            }
+        }
+        return super.hasItemState(id);
+    }
+
+    /**
+     * @see ItemStateManager#getNodeReferences
+     *
+     * If associated to a transaction, check our transactional
+     * change log first.
+     */
+    public NodeReferences getNodeReferences(NodeReferencesId id)
+            throws NoSuchItemStateException, ItemStateException {
+
+        if (tx != null) {
+            // check change log
+            NodeReferences refs = changeLog.get(id);
+            if (refs != null) {
+                return refs;
+            }
+        }
+        return super.getNodeReferences(id);
+    }
+
+    /**
+     * @see LocalItemStateManager#update
+     *
+     * If associated to a transaction, simply merge the changes given to
+     * the ones already known (removing items that were first added and
+     * then again deleted).
+     */
+    protected void update(ChangeLog changeLog) throws ItemStateException {
+        if (tx != null) {
+            this.changeLog.merge(changeLog);
+        } else {
+            super.update(changeLog);
+        }
+    }
+
+
+    //--------------------------------------------------< TransactionListener >
+
+    /**
+     * @see TransactionListener#transactionCommitted
+     */
+    public void transactionCommitted(TransactionContext tx)
+            throws TransactionException {
+
+        ChangeLog changeLog = (ChangeLog) tx.getAttribute(ATTRIBUTE_CHANGE_LOG);
+        if (changeLog != null) {
+            try {
+                super.update(changeLog);
+                changeLog.reset();
+            } catch (ItemStateException e) {
+                throw new TransactionException("Unable to end update.", e);
+            }
+        }
+    }
+
+    /**
+     * @see TransactionListener#transactionRolledBack
+     */
+    public void transactionRolledBack(TransactionContext tx) {
+        ChangeLog changeLog = (ChangeLog) tx.getAttribute(ATTRIBUTE_CHANGE_LOG);
+        if (changeLog != null) {
+            changeLog.undo(sharedStateMgr);
+        }
+    }
+}

Propchange: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/TransactionalItemStateManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/TransientItemStateManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/TransientItemStateManager.java?view=diff&r1=151379&r2=151380
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/TransientItemStateManager.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/TransientItemStateManager.java Fri Feb  4 09:43:55 2005
@@ -84,19 +84,12 @@
     /**
      * @see ItemStateManager#getNodeReferences
      */
-    public NodeReferences getNodeReferences(NodeId targetId)
+    public NodeReferences getNodeReferences(NodeReferencesId id)
             throws NoSuchItemStateException, ItemStateException {
 
         throw new ItemStateException("getNodeReferences() not implemented");
     }
 
-    /**
-     * @see ItemStateManager#beginUpdate
-     */
-    public UpdateOperation beginUpdate() throws ItemStateException {
-        throw new ItemStateException("beginUpdate() not implemented");
-    }
-
     //------------------< methods for listing & querying state of cache/attic >
 
     /**
@@ -337,17 +330,10 @@
         /**
          * @see ItemStateManager#getNodeReferences
          */
-        public NodeReferences getNodeReferences(NodeId targetId)
+        public NodeReferences getNodeReferences(NodeReferencesId id)
                 throws NoSuchItemStateException, ItemStateException {
 
             throw new ItemStateException("getNodeReferences() not implemented");
-        }
-
-        /**
-         * @see ItemStateManager#beginUpdate
-         */
-        public UpdateOperation beginUpdate() throws ItemStateException {
-            throw new ItemStateException("beginUpdate() not implemented");
         }
     }
 }

Added: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/UpdatableItemStateManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/UpdatableItemStateManager.java?view=auto&rev=151380
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/UpdatableItemStateManager.java (added)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/UpdatableItemStateManager.java Fri Feb  4 09:43:55 2005
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.core.state;
+
+import org.apache.jackrabbit.core.QName;
+
+/**
+ * Identifies an <code>ItemStateManager</code> that allows updating
+ * items.
+ */
+public interface UpdatableItemStateManager extends ItemStateManager {
+
+    /**
+     * Start an edit operation on items inside this manager. This
+     * allows calling the operations defined below. At the end of
+     * this operation, either {@link #update} or {@link #cancel}
+     * must be invoked.
+     * @throws ItemStateException if the manager is already inside
+     *         edit mode.
+     */
+    public void edit() throws ItemStateException;
+
+    /**
+     * Creates a {@link NodeState} instance representing new,
+     * i.e. not yet existing state. Call {@link #store}
+     * on the returned object to make it persistent.
+     *
+     * @param uuid         node UUID
+     * @param nodeTypeName qualified node type name
+     * @param parentUUID   parent node's UUID
+     * @return a node state
+     */
+    public NodeState createNew(String uuid, QName nodeTypeName,
+                               String parentUUID);
+
+    /**
+     * Creates a {@link PropertyState} instance representing new,
+     * i.e. not yet existing state. Call {@link #store}
+     * on the returned object to make it persistent.
+     *
+     * @param propName   qualified property name
+     * @param parentUUID parent node UUID
+     * @return a property state
+     */
+    public PropertyState createNew(QName propName, String parentUUID);
+
+    /**
+     * Store an item state.
+     * @param state item state that should be stored
+      */
+    public void store(ItemState state);
+
+    /**
+     * Store a node references object
+     * @param refs node references object that should be stored
+     */
+    public void store(NodeReferences refs);
+
+    /**
+     * Destroy an item state.
+     * @param state item state that should be destroyed
+      */
+    public void destroy(ItemState state);
+
+    /**
+     * Cancel an update operation. This will undo all changes
+     * made to objects inside this item state manager.
+     */
+    public void cancel();
+
+    /**
+     * End an update operation. This will save all items
+     * added to this update operation in a single step.
+     * If this operation fails, no item will have been saved.
+     * @throws ItemStateException if the operation failed
+     */
+    public void update() throws ItemStateException;
+}

Propchange: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/UpdatableItemStateManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/mem/InMemPersistenceManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/mem/InMemPersistenceManager.java?view=diff&r1=151379&r2=151380
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/mem/InMemPersistenceManager.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/mem/InMemPersistenceManager.java Fri Feb  4 09:43:55 2005
@@ -196,7 +196,7 @@
             int n = in.readInt();   // number of entries
             while (n-- > 0) {
                 String s = in.readUTF();    // target id
-                NodeId id = NodeId.valueOf(s);
+                NodeReferencesId id = (NodeReferencesId) NodeReferencesId.valueOf(s);
                 int length = in.readInt();  // data length
                 byte[] data = new byte[length];
                 in.read(data);  // data
@@ -252,7 +252,7 @@
             // entries
             Iterator iterKeys = refsStore.keySet().iterator();
             while (iterKeys.hasNext()) {
-                NodeId id = (NodeId) iterKeys.next();
+                NodeReferencesId id = (NodeReferencesId) iterKeys.next();
                 out.writeUTF(id.toString());    // target id
                 byte[] data = (byte[]) refsStore.get(id);
                 out.writeInt(data.length);  // data length
@@ -380,15 +380,13 @@
     /**
      * @see PersistenceManager#load
      */
-    public synchronized NodeState load(String uuid)
+    public synchronized NodeState load(NodeId id)
             throws NoSuchItemStateException, ItemStateException {
 
         if (!initialized) {
             throw new IllegalStateException("not initialized");
         }
 
-        NodeId id = new NodeId(uuid);
-
         byte[] data = (byte[]) stateStore.get(id);
         if (data == null) {
             throw new NoSuchItemStateException(id.toString());
@@ -396,7 +394,7 @@
 
         ByteArrayInputStream in = new ByteArrayInputStream(data);
         try {
-            NodeState state = createNew(uuid, null, null);
+            NodeState state = createNew(id);
             ObjectPersistenceManager.deserialize(state, in);
             return state;
         } catch (Exception e) {
@@ -409,15 +407,13 @@
     /**
      * @see PersistenceManager#load
      */
-    public synchronized PropertyState load(QName name, String parentUUID)
+    public synchronized PropertyState load(PropertyId id)
             throws NoSuchItemStateException, ItemStateException {
 
         if (!initialized) {
             throw new IllegalStateException("not initialized");
         }
 
-        PropertyId id = new PropertyId(parentUUID, name);
-
         byte[] data = (byte[]) stateStore.get(id);
         if (data == null) {
             throw new NoSuchItemStateException(id.toString());
@@ -425,7 +421,7 @@
 
         ByteArrayInputStream in = new ByteArrayInputStream(data);
         try {
-            PropertyState state = createNew(name, parentUUID);
+            PropertyState state = createNew(id);
             ObjectPersistenceManager.deserialize(state, in, this);
             return state;
         } catch (Exception e) {
@@ -525,25 +521,25 @@
     /**
      * @see PersistenceManager#load
      */
-    public synchronized NodeReferences load(NodeId targetId)
+    public synchronized NodeReferences load(NodeReferencesId id)
             throws NoSuchItemStateException, ItemStateException {
 
         if (!initialized) {
             throw new IllegalStateException("not initialized");
         }
 
-        byte[] data = (byte[]) refsStore.get(targetId);
+        byte[] data = (byte[]) refsStore.get(id);
         if (data == null) {
-            throw new NoSuchItemStateException(targetId.toString());
+            throw new NoSuchItemStateException(id.getUUID());
         }
 
         ByteArrayInputStream in = new ByteArrayInputStream(data);
         try {
-            NodeReferences refs = new NodeReferences(targetId);
+            NodeReferences refs = new NodeReferences(id);
             ObjectPersistenceManager.deserialize(refs, in);
             return refs;
         } catch (Exception e) {
-            String msg = "failed to load references: " + targetId;
+            String msg = "failed to load references: " + id.getUUID();
             log.debug(msg);
             throw new ItemStateException(msg, e);
         }
@@ -586,24 +582,32 @@
     }
 
     /**
-     * @see PersistenceManager#exists(ItemId id)
+     * @see PersistenceManager#exists(PropertyId id)
      */
-    public boolean exists(ItemId id) throws ItemStateException {
+    public boolean exists(PropertyId id) throws ItemStateException {
         if (!initialized) {
             throw new IllegalStateException("not initialized");
         }
-
         return stateStore.containsKey(id);
     }
 
     /**
-     * @see PersistenceManager#referencesExist(NodeId targetId)
+     * @see PersistenceManager#exists(PropertyId id)
      */
-    public boolean referencesExist(NodeId targetId) throws ItemStateException {
+    public boolean exists(NodeId id) throws ItemStateException {
         if (!initialized) {
             throw new IllegalStateException("not initialized");
         }
+        return stateStore.containsKey(id);
+    }
 
-        return refsStore.containsKey(targetId);
+    /**
+     * @see PersistenceManager#exists(NodeReferencesId targetId)
+     */
+    public boolean exists(NodeReferencesId id) throws ItemStateException {
+        if (!initialized) {
+            throw new IllegalStateException("not initialized");
+        }
+        return refsStore.containsKey(id);
     }
 }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/obj/ObjectPersistenceManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/obj/ObjectPersistenceManager.java?view=diff&r1=151379&r2=151380
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/obj/ObjectPersistenceManager.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/obj/ObjectPersistenceManager.java Fri Feb  4 09:43:55 2005
@@ -466,13 +466,13 @@
     /**
      * @see PersistenceManager#load
      */
-    public synchronized NodeState load(String uuid)
+    public synchronized NodeState load(NodeId id)
             throws NoSuchItemStateException, ItemStateException {
         if (!initialized) {
             throw new IllegalStateException("not initialized");
         }
 
-        String nodeFilePath = buildNodeFilePath(uuid);
+        String nodeFilePath = buildNodeFilePath(id.getUUID());
 
         try {
             if (!itemStateFS.isFile(nodeFilePath)) {
@@ -488,11 +488,11 @@
             BufferedInputStream in =
                     new BufferedInputStream(itemStateFS.getInputStream(nodeFilePath));
             try {
-                NodeState state = createNew(uuid, null, null);
+                NodeState state = createNew(id);
                 deserialize(state, in);
                 return state;
             } catch (Exception e) {
-                String msg = "failed to read node state: " + uuid;
+                String msg = "failed to read node state: " + id.getUUID();
                 log.debug(msg);
                 throw new ItemStateException(msg, e);
             } finally {
@@ -508,13 +508,14 @@
     /**
      * @see PersistenceManager#load
      */
-    public synchronized PropertyState load(QName name, String parentUUID)
+    public synchronized PropertyState load(PropertyId id)
             throws NoSuchItemStateException, ItemStateException {
         if (!initialized) {
             throw new IllegalStateException("not initialized");
         }
 
-        String propFilePath = buildPropFilePath(parentUUID, name);
+        String propFilePath = buildPropFilePath(
+                id.getParentUUID(), id.getName());
 
         try {
             if (!itemStateFS.isFile(propFilePath)) {
@@ -530,7 +531,7 @@
             BufferedInputStream in =
                     new BufferedInputStream(itemStateFS.getInputStream(propFilePath));
             try {
-                PropertyState state = createNew(name, parentUUID);
+                PropertyState state = createNew(id);
                 deserialize(state, in, this);
                 return state;
             } finally {
@@ -546,20 +547,21 @@
     /**
      * @see PersistenceManager#load
      */
-    public synchronized NodeReferences load(NodeId targetId)
+    public synchronized NodeReferences load(NodeReferencesId id)
             throws NoSuchItemStateException, ItemStateException {
+
         if (!initialized) {
             throw new IllegalStateException("not initialized");
         }
 
-        String refsFilePath = buildNodeReferencesFilePath(targetId.getUUID());
+        String refsFilePath = buildNodeReferencesFilePath(id.getUUID());
 
         try {
             if (!itemStateFS.isFile(refsFilePath)) {
-                throw new NoSuchItemStateException(targetId.toString());
+                throw new NoSuchItemStateException(id.toString());
             }
         } catch (FileSystemException fse) {
-            String msg = "failed to load references: " + targetId;
+            String msg = "failed to load references: " + id;
             log.debug(msg);
             throw new ItemStateException(msg, fse);
         }
@@ -568,14 +570,14 @@
             BufferedInputStream in =
                     new BufferedInputStream(itemStateFS.getInputStream(refsFilePath));
             try {
-                NodeReferences refs = new NodeReferences(targetId);
+                NodeReferences refs = new NodeReferences(id);
                 deserialize(refs, in);
                 return refs;
             } finally {
                 in.close();
             }
         } catch (Exception e) {
-            String msg = "failed to load references: " + targetId;
+            String msg = "failed to load references: " + id;
             log.debug(msg);
             throw new ItemStateException(msg, e);
         }
@@ -746,25 +748,17 @@
     }
 
     /**
-     * @see PersistenceManager#exists(ItemId id)
+     * @see PersistenceManager#exists(PropertyId id)
      */
-    public synchronized boolean exists(ItemId id) throws ItemStateException {
+    public synchronized boolean exists(PropertyId id) throws ItemStateException {
         if (!initialized) {
             throw new IllegalStateException("not initialized");
         }
 
         try {
-            if (id.denotesNode()) {
-                NodeId nodeId = (NodeId) id;
-                String nodeFilePath = buildNodeFilePath(nodeId.getUUID());
-                FileSystemResource nodeFile = new FileSystemResource(itemStateFS, nodeFilePath);
-                return nodeFile.exists();
-            } else {
-                PropertyId propId = (PropertyId) id;
-                String propFilePath = buildPropFilePath(propId.getParentUUID(), propId.getName());
-                FileSystemResource propFile = new FileSystemResource(itemStateFS, propFilePath);
-                return propFile.exists();
-            }
+            String propFilePath = buildPropFilePath(id.getParentUUID(), id.getName());
+            FileSystemResource propFile = new FileSystemResource(itemStateFS, propFilePath);
+            return propFile.exists();
         } catch (FileSystemException fse) {
             String msg = "failed to check existence of item state: " + id;
             log.debug(msg);
@@ -773,20 +767,41 @@
     }
 
     /**
-     * @see PersistenceManager#referencesExist(NodeId targetId)
+     * @see PersistenceManager#exists(NodeId)
      */
-    public synchronized boolean referencesExist(NodeId targetId) throws ItemStateException {
+    public synchronized boolean exists(NodeId id) throws ItemStateException {
+        if (!initialized) {
+            throw new IllegalStateException("not initialized");
+        }
+
+        try {
+            String nodeFilePath = buildNodeFilePath(id.getUUID());
+            FileSystemResource nodeFile = new FileSystemResource(itemStateFS, nodeFilePath);
+            return nodeFile.exists();
+        } catch (FileSystemException fse) {
+            String msg = "failed to check existence of item state: " + id;
+            log.error(msg, fse);
+            throw new ItemStateException(msg, fse);
+        }
+    }
+
+    /**
+     * @see PersistenceManager#exists(NodeReferencesId)
+     */
+    public synchronized boolean exists(NodeReferencesId id)
+            throws ItemStateException {
+
         if (!initialized) {
             throw new IllegalStateException("not initialized");
         }
 
         try {
-            String uuid = targetId.getUUID();
+            String uuid = id.getUUID();
             String refsFilePath = buildNodeReferencesFilePath(uuid);
             FileSystemResource refsFile = new FileSystemResource(itemStateFS, refsFilePath);
             return refsFile.exists();
         } catch (FileSystemException fse) {
-            String msg = "failed to check existence of references: " + targetId;
+            String msg = "failed to check existence of references: " + id;
             log.debug(msg);
             throw new ItemStateException(msg, fse);
         }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/xml/XMLPersistenceManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/xml/XMLPersistenceManager.java?view=diff&r1=151379&r2=151380
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/xml/XMLPersistenceManager.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/xml/XMLPersistenceManager.java Fri Feb  4 09:43:55 2005
@@ -320,7 +320,7 @@
             throw new ItemStateException(msg);
         }
         // check targetId
-        if (!refs.getTargetId().equals(NodeId.valueOf(refsElement.getAttributeValue(TARGETID_ATTRIBUTE)))) {
+        if (!refs.getTargetId().equals(NodeReferencesId.valueOf(refsElement.getAttributeValue(TARGETID_ATTRIBUTE)))) {
             String msg = "invalid serialized state: targetId  mismatch";
             log.debug(msg);
             throw new ItemStateException(msg);
@@ -389,7 +389,7 @@
     /**
      * @see PersistenceManager#load
      */
-    public synchronized NodeState load(String uuid)
+    public synchronized NodeState load(NodeId id)
             throws NoSuchItemStateException, ItemStateException {
 
         if (!initialized) {
@@ -397,11 +397,11 @@
         }
 
         Exception e = null;
-        String nodeFilePath = buildNodeFilePath(uuid);
+        String nodeFilePath = buildNodeFilePath(id.getUUID());
 
         try {
             if (!itemStateStore.isFile(nodeFilePath)) {
-                throw new NoSuchItemStateException(uuid);
+                throw new NoSuchItemStateException(id.toString());
             }
             InputStream in = itemStateStore.getInputStream(nodeFilePath);
 
@@ -410,7 +410,7 @@
                 Element rootElement = builder.build(in).getRootElement();
                 String ntName = rootElement.getAttributeValue(NODETYPE_ATTRIBUTE);
 
-                NodeState state = createNew(uuid, null, null);
+                NodeState state = createNew(id);
                 state.setNodeTypeName(QName.valueOf(ntName));
                 readState(rootElement, state);
                 return state;
@@ -427,7 +427,7 @@
             e = fse;
             // fall through
         }
-        String msg = "failed to read node state: " + uuid;
+        String msg = "failed to read node state: " + id;
         log.debug(msg);
         throw new ItemStateException(msg, e);
     }
@@ -435,7 +435,7 @@
     /**
      * @see PersistenceManager#load
      */
-    public synchronized PropertyState load(QName name, String parentUUID)
+    public synchronized PropertyState load(PropertyId id)
             throws NoSuchItemStateException, ItemStateException {
 
         if (!initialized) {
@@ -443,18 +443,18 @@
         }
 
         Exception e = null;
-        String propFilePath = buildPropFilePath(parentUUID, name);
+        String propFilePath = buildPropFilePath(id.getParentUUID(), id.getName());
 
         try {
             if (!itemStateStore.isFile(propFilePath)) {
-                throw new NoSuchItemStateException(parentUUID + "/" + name);
+                throw new NoSuchItemStateException(id.toString());
             }
             InputStream in = itemStateStore.getInputStream(propFilePath);
             try {
                 SAXBuilder builder = new SAXBuilder();
                 Element rootElement = builder.build(in).getRootElement();
 
-                PropertyState state = createNew(name, parentUUID);
+                PropertyState state = createNew(id);
                 readState(rootElement, state);
                 return state;
             } finally {
@@ -470,7 +470,7 @@
             e = fse;
             // fall through
         }
-        String msg = "failed to read property state: " + parentUUID + "/" + name;
+        String msg = "failed to read property state: " + id.toString();
         log.debug(msg);
         throw new ItemStateException(msg, e);
     }
@@ -737,7 +737,7 @@
     /**
      * @see PersistenceManager#load
      */
-    public synchronized NodeReferences load(NodeId targetId)
+    public synchronized NodeReferences load(NodeReferencesId id)
             throws NoSuchItemStateException, ItemStateException {
 
         if (!initialized) {
@@ -745,7 +745,7 @@
         }
 
         Exception e = null;
-        String uuid = targetId.getUUID();
+        String uuid = id.getUUID();
 
         String refsFilePath = buildNodeReferencesFilePath(uuid);
         try {
@@ -759,7 +759,7 @@
                 SAXBuilder builder = new SAXBuilder();
                 Element rootElement = builder.build(in).getRootElement();
 
-                NodeReferences refs = new NodeReferences(targetId);
+                NodeReferences refs = new NodeReferences(id);
                 readState(rootElement, refs);
                 return refs;
             } finally {
@@ -788,7 +788,7 @@
             throw new IllegalStateException("not initialized");
         }
 
-        String uuid = refs.getTargetId().getUUID();
+        String uuid = refs.getUUID();
         String refsFilePath = buildNodeReferencesFilePath(uuid);
         FileSystemResource refsFile = new FileSystemResource(itemStateStore, refsFilePath);
         try {
@@ -834,7 +834,7 @@
             throw new IllegalStateException("not initialized");
         }
 
-        String uuid = refs.getTargetId().getUUID();
+        String uuid = refs.getUUID();
         String refsFilePath = buildNodeReferencesFilePath(uuid);
         FileSystemResource refsFile = new FileSystemResource(itemStateStore, refsFilePath);
         try {
@@ -850,25 +850,18 @@
     }
 
     /**
-     * @see PersistenceManager#exists(ItemId id)
+     * @see PersistenceManager#exists(NodeId)
      */
-    public synchronized boolean exists(ItemId id) throws ItemStateException {
+    public synchronized boolean exists(NodeId id) throws ItemStateException {
         if (!initialized) {
             throw new IllegalStateException("not initialized");
         }
 
         try {
-            if (id.denotesNode()) {
-                NodeId nodeId = (NodeId) id;
-                String nodeFilePath = buildNodeFilePath(nodeId.getUUID());
-                FileSystemResource nodeFile = new FileSystemResource(itemStateStore, nodeFilePath);
-                return nodeFile.exists();
-            } else {
-                PropertyId propId = (PropertyId) id;
-                String propFilePath = buildPropFilePath(propId.getParentUUID(), propId.getName());
-                FileSystemResource propFile = new FileSystemResource(itemStateStore, propFilePath);
-                return propFile.exists();
-            }
+            NodeId nodeId = (NodeId) id;
+            String nodeFilePath = buildNodeFilePath(nodeId.getUUID());
+            FileSystemResource nodeFile = new FileSystemResource(itemStateStore, nodeFilePath);
+            return nodeFile.exists();
         } catch (FileSystemException fse) {
             String msg = "failed to check existence of item state: " + id;
             log.debug(msg);
@@ -877,20 +870,41 @@
     }
 
     /**
-     * @see PersistenceManager#referencesExist(NodeId targetId)
+     * @see PersistenceManager#exists(PropertyId)
      */
-    public synchronized boolean referencesExist(NodeId targetId) throws ItemStateException {
+    public synchronized boolean exists(PropertyId id) throws ItemStateException {
+        if (!initialized) {
+            throw new IllegalStateException("not initialized");
+        }
+
+        try {
+            String propFilePath = buildPropFilePath(id.getParentUUID(), id.getName());
+            FileSystemResource propFile = new FileSystemResource(itemStateStore, propFilePath);
+            return propFile.exists();
+        } catch (FileSystemException fse) {
+            String msg = "failed to check existence of item state: " + id;
+            log.error(msg, fse);
+            throw new ItemStateException(msg, fse);
+        }
+    }
+
+    /**
+     * @see PersistenceManager#exists(NodeReferencesId id)
+     */
+    public synchronized boolean exists(NodeReferencesId id)
+            throws ItemStateException {
+
         if (!initialized) {
             throw new IllegalStateException("not initialized");
         }
 
         try {
-            String uuid = targetId.getUUID();
+            String uuid = id.getUUID();
             String refsFilePath = buildNodeReferencesFilePath(uuid);
             FileSystemResource refsFile = new FileSystemResource(itemStateStore, refsFilePath);
             return refsFile.exists();
         } catch (FileSystemException fse) {
-            String msg = "failed to check existence of references: " + targetId;
+            String msg = "failed to check existence of references: " + id;
             log.debug(msg);
             throw new ItemStateException(msg, fse);
         }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/PersistentVersionManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/PersistentVersionManager.java?view=diff&r1=151379&r2=151380
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/PersistentVersionManager.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/PersistentVersionManager.java Fri Feb  4 09:43:55 2005
@@ -18,6 +18,7 @@
 
 import org.apache.jackrabbit.core.NodeImpl;
 import org.apache.jackrabbit.core.QName;
+import org.apache.jackrabbit.core.state.UpdatableItemStateManager;
 
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
@@ -142,29 +143,8 @@
     public InternalVersion checkin(NodeImpl node) throws RepositoryException;
 
     /**
-     *
-     * @param history
-     * @param versionName
-     * @throws VersionException
-     */
-    public void removeVersion(InternalVersionHistory history, QName versionName) throws VersionException;
-
-
-    /**
-     *
-     * @param versionName
-     * @param label
-     * @param move
-     * @return
-     * @throws VersionException
-     */
-    public InternalVersion addVersionLabel(InternalVersionHistory history, QName versionName, String label, boolean move) throws VersionException;
-
-    /**
-     *
-     * @param label
-     * @return
-     * @throws VersionException
+     * Return the item state manager of this version manager
+     * @return item state manager
      */
-    public InternalVersion removeVersionLabel(InternalVersionHistory history, String label) throws VersionException;
+    public UpdatableItemStateManager getItemStateMgr();
 }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java?view=diff&r1=151379&r2=151380
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java Fri Feb  4 09:43:55 2005
@@ -114,20 +114,13 @@
     }
 
     /**
-     * @see ItemStateManager#getNodeReferences(NodeId)
+     * @see ItemStateManager#getNodeReferences(NodeReferencesId)
      */
-    public NodeReferences getNodeReferences(NodeId targetId)
+    public NodeReferences getNodeReferences(NodeReferencesId id)
             throws NoSuchItemStateException, ItemStateException {
 
         //@todo return node references
-        throw new NoSuchItemStateException(targetId.getUUID());
-    }
-
-    /**
-     * @see ItemStateManager#beginUpdate
-     */
-    public UpdateOperation beginUpdate() throws ItemStateException {
-        throw new ItemStateException("Update not available");
+        throw new NoSuchItemStateException(id.getUUID());
     }
 
     //-------------------------------------------< VirtualItemStateProvider >---

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalFrozenNodeImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalFrozenNodeImpl.java?view=diff&r1=151379&r2=151380
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalFrozenNodeImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalFrozenNodeImpl.java Fri Feb  4 09:43:55 2005
@@ -23,7 +23,6 @@
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.state.PropertyState;
 import org.apache.jackrabbit.core.state.ItemStateException;
-import org.apache.jackrabbit.core.state.UpdateOperation;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.PropertyType;
@@ -234,8 +233,7 @@
      * @return
      * @throws RepositoryException
      */
-    protected static PersistentNode checkin(UpdateOperation upd,
-                                            PersistentNode parent, QName name,
+    protected static PersistentNode checkin(PersistentNode parent, QName name,
                                             NodeImpl src, boolean initOnly,
                                             boolean forceCopy)
             throws RepositoryException {
@@ -243,14 +241,14 @@
         PersistentNode node;
 
         // create new node
-        node = parent.addNode(upd, name, NativePVM.NT_REP_FROZEN);
+        node = parent.addNode(name, NativePVM.NT_REP_FROZEN);
 
         // initialize the internal properties
         if (src.isNodeType(NodeTypeRegistry.MIX_REFERENCEABLE)) {
-            node.setPropertyValue(upd, VersionManager.PROPNAME_FROZEN_UUID, InternalValue.create(src.getUUID()));
+            node.setPropertyValue(VersionManager.PROPNAME_FROZEN_UUID, InternalValue.create(src.getUUID()));
         }
 
-        node.setPropertyValue(upd, VersionManager.PROPNAME_FROZEN_PRIMARY_TYPE,
+        node.setPropertyValue(VersionManager.PROPNAME_FROZEN_PRIMARY_TYPE,
                 InternalValue.create(((NodeTypeImpl) src.getPrimaryNodeType()).getQName()));
 
         if (src.hasProperty(NodeImpl.PROPNAME_MIXINTYPES)) {
@@ -259,7 +257,7 @@
             for (int i = 0; i < mixins.length; i++) {
                 ivalues[i] = InternalValue.create(((NodeTypeImpl) mixins[i]).getQName());
             }
-            node.setPropertyValues(upd, VersionManager.PROPNAME_FROZEN_MIXIN_TYPES, PropertyType.NAME, ivalues);
+            node.setPropertyValues(VersionManager.PROPNAME_FROZEN_MIXIN_TYPES, PropertyType.NAME, ivalues);
         }
 
         if (!initOnly) {
@@ -278,7 +276,7 @@
                         break;
                     case OnParentVersionAction.VERSION:
                     case OnParentVersionAction.COPY:
-                        node.copyFrom(upd, prop);
+                        node.copyFrom(prop);
                         break;
                 }
             }
@@ -299,16 +297,16 @@
                     case OnParentVersionAction.VERSION:
                         if (child.isNodeType(NodeTypeRegistry.MIX_VERSIONABLE)) {
                             // create frozen versionable child
-                            PersistentNode newChild = node.addNode(upd, child.getQName(), NativePVM.NT_REP_FROZEN_HISTORY);
-                            newChild.setPropertyValue(upd, VersionManager.PROPNAME_VERSION_HISTORY,
+                            PersistentNode newChild = node.addNode(child.getQName(), NativePVM.NT_REP_FROZEN_HISTORY);
+                            newChild.setPropertyValue(VersionManager.PROPNAME_VERSION_HISTORY,
                                     InternalValue.create(child.getVersionHistory().getUUID()));
-                            newChild.setPropertyValue(upd, VersionManager.PROPNAME_BASE_VERSION,
+                            newChild.setPropertyValue(VersionManager.PROPNAME_BASE_VERSION,
                                     InternalValue.create(child.getBaseVersion().getUUID()));
                             break;
                         }
                         // else copy
                     case OnParentVersionAction.COPY:
-                        checkin(upd, node, child.getQName(), child, false, true);
+                        checkin(node, child.getQName(), child, false, true);
                         break;
                 }
             }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalVersionHistoryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalVersionHistoryImpl.java?view=diff&r1=151379&r2=151380
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalVersionHistoryImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalVersionHistoryImpl.java Fri Feb  4 09:43:55 2005
@@ -20,7 +20,8 @@
 import org.apache.jackrabbit.core.NamespaceRegistryImpl;
 import org.apache.jackrabbit.core.NodeImpl;
 import org.apache.jackrabbit.core.QName;
-import org.apache.jackrabbit.core.state.UpdateOperation;
+import org.apache.jackrabbit.core.state.UpdatableItemStateManager;
+import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.util.Text;
 import org.apache.jackrabbit.core.util.uuid.UUID;
@@ -237,22 +238,6 @@
      * @throws VersionException
      */
     public void removeVersion(QName versionName) throws VersionException {
-        getVersionManager().removeVersion(this, versionName);
-    }
-
-    /**
-     * Removes the indicated version from this VersionHistory. If the specified
-     * vesion does not exist, if it specifies the root version or if it is
-     * referenced by any node e.g. as base version, a VersionException is thrown.
-     * <p/>
-     * all successors of the removed version become successors of the
-     * predecessors of the removed version and vice versa. then, the entire
-     * version node and all its subnodes are removed.
-     *
-     * @param versionName
-     * @throws VersionException
-     */
-    protected void removeVersion(UpdateOperation upd, QName versionName) throws VersionException {
 
         try {
             InternalVersionImpl v = (InternalVersionImpl) getVersion(versionName);
@@ -262,24 +247,31 @@
                 throw new VersionException(msg);
             }
 
+            UpdatableItemStateManager stateMgr = getVersionManager().getItemStateMgr();
+            stateMgr.edit();
+
             // remove from persistance state
-            node.removeNode(upd, v.getName());
+            node.removeNode(v.getName());
 
             // unregister from labels
             String[] labels = v.internalGetLabels();
             for (int i = 0; i < labels.length; i++) {
                 v.internalRemoveLabel(labels[i]);
                 QName name = new QName("", Text.md5(labels[i]));
-                labelNode.removeNode(upd, name);
+                labelNode.removeNode(name);
             }
             // detach from the version graph
-            v.internalDetach(upd);
+            v.internalDetach();
 
             // and remove from history
             versionCache.remove(v.getId());
 
             // store changes
-            node.store(upd);
+            node.store();
+
+            stateMgr.update();
+        } catch (ItemStateException e) {
+            throw new VersionException("Unable to store modifications", e);
         } catch (RepositoryException e) {
             throw new VersionException("error while storing modifications", e);
         }
@@ -290,14 +282,6 @@
      */
     public InternalVersion addVersionLabel(QName versionName, String label, boolean move)
             throws VersionException {
-        return getVersionManager().addVersionLabel(this, versionName, label, move);
-    }
-
-    /**
-     * @see InternalVersionHistory#addVersionLabel(org.apache.jackrabbit.core.QName, String, boolean)
-     */
-    protected InternalVersion addVersionLabel(UpdateOperation upd, QName versionName, String label, boolean move)
-            throws VersionException {
 
         InternalVersion version = getVersion(versionName);
         if (version == null) {
@@ -319,10 +303,17 @@
         ((InternalVersionImpl) version).internalAddLabel(label);
         QName name = new QName("", Text.md5(label));
         try {
-            PersistentNode lNode = labelNode.addNode(upd, name, NodeTypeRegistry.NT_UNSTRUCTURED);
-            lNode.setPropertyValue(upd, NativePVM.PROPNAME_NAME, InternalValue.create(label));
-            lNode.setPropertyValue(upd, NativePVM.PROPNAME_VERSION, InternalValue.create(version.getId()));
-            labelNode.store(upd);
+            UpdatableItemStateManager stateMgr = getVersionManager().getItemStateMgr();
+            stateMgr.edit();
+
+            PersistentNode lNode = labelNode.addNode(name, NodeTypeRegistry.NT_UNSTRUCTURED);
+            lNode.setPropertyValue(NativePVM.PROPNAME_NAME, InternalValue.create(label));
+            lNode.setPropertyValue(NativePVM.PROPNAME_VERSION, InternalValue.create(version.getId()));
+            labelNode.store();
+
+            stateMgr.update();
+        } catch (ItemStateException e) {
+            throw new VersionException("Error while storing modifications", e);
         } catch (RepositoryException e) {
             throw new VersionException("Error while storing modifications", e);
         }
@@ -333,13 +324,8 @@
      * @see InternalVersionHistory#removeVersionLabel(String)
      */
     public InternalVersion removeVersionLabel(String label) throws VersionException {
-        return getVersionManager().removeVersionLabel(this, label);
-    }
 
-    /**
-     * @see InternalVersionHistory#removeVersionLabel(String)
-     */
-    protected InternalVersion removeVersionLabel(UpdateOperation upd, String label) throws VersionException {
+
         InternalVersionImpl v = (InternalVersionImpl) labelCache.remove(label);
         if (v == null) {
             throw new VersionException("Version label " + label + " is not in version history.");
@@ -348,8 +334,13 @@
         QName name = new QName("", Text.md5(label));
 
         try {
-            labelNode.removeNode(upd, name);
-            labelNode.store(upd);
+            UpdatableItemStateManager stateMgr = getVersionManager().getItemStateMgr();
+            stateMgr.edit();
+            labelNode.removeNode(name);
+            labelNode.store();
+            stateMgr.update();
+        } catch (ItemStateException e) {
+            throw new VersionException("Unable to store modifications", e);
         } catch (RepositoryException e) {
             throw new VersionException("Unable to store modifications", e);
         }
@@ -366,7 +357,7 @@
      * @return
      * @throws RepositoryException
      */
-    protected InternalVersionImpl checkin(UpdateOperation upd, QName name, NodeImpl src)
+    protected InternalVersionImpl checkin(QName name, NodeImpl src)
             throws RepositoryException {
 
         // copy predecessors from src node
@@ -383,19 +374,19 @@
 
         String versionId = UUID.randomUUID().toString();
         QName nodeName = new QName(NamespaceRegistryImpl.NS_DEFAULT_URI, versionId);
-        PersistentNode vNode = node.addNode(upd, nodeName, NativePVM.NT_REP_VERSION);
-        vNode.setPropertyValue(upd, NativePVM.PROPNAME_VERSION_ID, InternalValue.create(versionId));
-        vNode.setPropertyValue(upd, NativePVM.PROPNAME_VERSION_NAME, InternalValue.create(name));
+        PersistentNode vNode = node.addNode(nodeName, NativePVM.NT_REP_VERSION);
+        vNode.setPropertyValue(NativePVM.PROPNAME_VERSION_ID, InternalValue.create(versionId));
+        vNode.setPropertyValue(NativePVM.PROPNAME_VERSION_NAME, InternalValue.create(name));
 
         // initialize 'created' and 'predecessors'
-        vNode.setPropertyValue(upd, VersionManager.PROPNAME_CREATED, InternalValue.create(Calendar.getInstance()));
-        vNode.setPropertyValues(upd, VersionManager.PROPNAME_PREDECESSORS, PropertyType.STRING, predecessors);
+        vNode.setPropertyValue(VersionManager.PROPNAME_CREATED, InternalValue.create(Calendar.getInstance()));
+        vNode.setPropertyValues(VersionManager.PROPNAME_PREDECESSORS, PropertyType.STRING, predecessors);
 
         // checkin source node
-        InternalFrozenNodeImpl.checkin(upd, vNode, VersionManager.NODENAME_FROZEN, src, false, false);
+        InternalFrozenNodeImpl.checkin(vNode, VersionManager.NODENAME_FROZEN, src, false, false);
 
         // and store
-        node.store(upd);
+        node.store();
 
         // update version graph
         InternalVersionImpl version = new InternalVersionImpl(this, vNode);
@@ -456,35 +447,35 @@
      * @return
      * @throws RepositoryException
      */
-    protected static InternalVersionHistoryImpl create(UpdateOperation upd, PersistentVersionManager vMgr, PersistentNode parent, String historyId, QName name, NodeImpl src)
+    protected static InternalVersionHistoryImpl create(PersistentVersionManager vMgr, PersistentNode parent, String historyId, QName name, NodeImpl src)
             throws RepositoryException {
 
         // create history node
-        PersistentNode pNode = parent.addNode(upd, name, NativePVM.NT_REP_VERSION_HISTORY);
-        pNode.setPropertyValue(upd, NativePVM.PROPNAME_HISTORY_ID, InternalValue.create(historyId));
+        PersistentNode pNode = parent.addNode(name, NativePVM.NT_REP_VERSION_HISTORY);
+        pNode.setPropertyValue(NativePVM.PROPNAME_HISTORY_ID, InternalValue.create(historyId));
 
         // set the versionable uuid
-        pNode.setPropertyValue(upd, NativePVM.PROPNAME_VERSIONABLE_ID, InternalValue.create(src.internalGetUUID()));
+        pNode.setPropertyValue(NativePVM.PROPNAME_VERSIONABLE_ID, InternalValue.create(src.internalGetUUID()));
 
         // create label node
-        pNode.addNode(upd, NativePVM.NODENAME_VERSION_LABELS, NodeTypeRegistry.NT_UNSTRUCTURED);
+        pNode.addNode(NativePVM.NODENAME_VERSION_LABELS, NodeTypeRegistry.NT_UNSTRUCTURED);
 
         // create root version
         String versionId = UUID.randomUUID().toString();
         QName nodeName = new QName(NamespaceRegistryImpl.NS_DEFAULT_URI, versionId);
 
-        PersistentNode vNode = pNode.addNode(upd, nodeName, NativePVM.NT_REP_VERSION);
-        vNode.setPropertyValue(upd, NativePVM.PROPNAME_VERSION_ID, InternalValue.create(versionId));
-        vNode.setPropertyValue(upd, NativePVM.PROPNAME_VERSION_NAME, InternalValue.create(VersionManager.NODENAME_ROOTVERSION));
+        PersistentNode vNode = pNode.addNode(nodeName, NativePVM.NT_REP_VERSION);
+        vNode.setPropertyValue(NativePVM.PROPNAME_VERSION_ID, InternalValue.create(versionId));
+        vNode.setPropertyValue(NativePVM.PROPNAME_VERSION_NAME, InternalValue.create(VersionManager.NODENAME_ROOTVERSION));
 
         // initialize 'created' and 'predecessors'
-        vNode.setPropertyValue(upd, VersionManager.PROPNAME_CREATED, InternalValue.create(Calendar.getInstance()));
-        vNode.setPropertyValues(upd, VersionManager.PROPNAME_PREDECESSORS, PropertyType.REFERENCE, new InternalValue[0]);
+        vNode.setPropertyValue(VersionManager.PROPNAME_CREATED, InternalValue.create(Calendar.getInstance()));
+        vNode.setPropertyValues(VersionManager.PROPNAME_PREDECESSORS, PropertyType.REFERENCE, new InternalValue[0]);
 
         // add also an empty frozen node to the root version
-        InternalFrozenNodeImpl.checkin(upd, vNode, VersionManager.NODENAME_FROZEN, src, true, false);
+        InternalFrozenNodeImpl.checkin(vNode, VersionManager.NODENAME_FROZEN, src, true, false);
 
-        parent.store(upd);
+        parent.store();
         return new InternalVersionHistoryImpl(vMgr, pNode);
     }
 }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalVersionImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalVersionImpl.java?view=diff&r1=151379&r2=151380
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalVersionImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalVersionImpl.java Fri Feb  4 09:43:55 2005
@@ -19,7 +19,6 @@
 import org.apache.jackrabbit.core.InternalValue;
 import org.apache.jackrabbit.core.QName;
 import org.apache.jackrabbit.core.state.NodeState;
-import org.apache.jackrabbit.core.state.UpdateOperation;
 import org.apache.jackrabbit.core.util.uuid.UUID;
 import org.apache.jackrabbit.core.version.*;
 
@@ -202,12 +201,12 @@
      *
      * @throws RepositoryException
      */
-    private void storePredecessors(UpdateOperation upd) throws RepositoryException {
+    private void storePredecessors() throws RepositoryException {
         InternalValue[] values = new InternalValue[predecessors.size()];
         for (int i = 0; i < values.length; i++) {
             values[i] = InternalValue.create(new UUID(((InternalVersion) predecessors.get(i)).getId()));
         }
-        node.setPropertyValues(upd, VersionManager.PROPNAME_PREDECESSORS, PropertyType.STRING, values);
+        node.setPropertyValues(VersionManager.PROPNAME_PREDECESSORS, PropertyType.STRING, values);
     }
 
     /**
@@ -215,18 +214,18 @@
      *
      * @throws RepositoryException
      */
-    void internalDetach(UpdateOperation upd) throws RepositoryException {
+    void internalDetach() throws RepositoryException {
         // detach this from all successors
         InternalVersionImpl[] succ = (InternalVersionImpl[]) getSuccessors();
         for (int i = 0; i < succ.length; i++) {
-            succ[i].internalDetachPredecessor(upd, this);
+            succ[i].internalDetachPredecessor(this);
         }
 
         // clear properties
         successors.clear();
         predecessors.clear();
         labelCache = null;
-        storePredecessors(upd);
+        storePredecessors();
     }
 
     /**
@@ -237,7 +236,7 @@
      *
      * @param v the successor to detach
      */
-    private void internalDetachPredecessor(UpdateOperation upd, InternalVersion v) throws RepositoryException {
+    private void internalDetachPredecessor(InternalVersion v) throws RepositoryException {
         // remove 'v' from predecessor list
         for (int i = 0; i < predecessors.size(); i++) {
             if (predecessors.get(i).equals(v)) {
@@ -248,7 +247,7 @@
         // attach v's successors
         predecessors.clear();
         predecessors.addAll(Arrays.asList(v.getPredecessors()));
-        storePredecessors(upd);
+        storePredecessors();
     }
 
     /**

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativeItemStateManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativeItemStateManager.java?view=diff&r1=151379&r2=151380
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativeItemStateManager.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativeItemStateManager.java Fri Feb  4 09:43:55 2005
@@ -22,12 +22,9 @@
 import org.apache.jackrabbit.core.nodetype.PropDefId;
 import org.apache.jackrabbit.core.*;
 import org.apache.log4j.Logger;
-import org.apache.commons.collections.ReferenceMap;
 
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.PropertyType;
-import java.util.*;
-import java.io.PrintStream;
 
 /**
  * This Class implements...
@@ -36,7 +33,7 @@
  * @version $Revision:$, $Date:$
  */
 public class NativeItemStateManager extends ItemStateCache
-        implements ItemStateManager, ItemStateListener {
+        implements UpdatableItemStateManager, ItemStateListener {
 
     /**
      * Logger instance
@@ -54,9 +51,14 @@
     private NodeState root;
 
     /**
-     * A cache for <code>NodeReferences</code> objects.
+     * Flag indicating whether this item state manager is in edit mode
      */
-    private Map refsCache = new ReferenceMap(ReferenceMap.HARD, ReferenceMap.SOFT);
+    private boolean editMode;
+
+    /**
+     * Change log
+     */
+    private ChangeLog changeLog;
 
     /**
      * Creates a new <code>DefaultItemStateManager</code> instance.
@@ -119,12 +121,10 @@
         prop.setMultiValued(false);
         prop.setDefinitionId(propDefId);
 
-        ArrayList states = new ArrayList();
-        states.add(rootState);
-        states.add(prop);
-
-        // do persist root node (incl. properties)
-        store(states, Collections.EMPTY_LIST);
+        ChangeLog changeLog = new ChangeLog();
+        changeLog.added(rootState);
+        changeLog.added(prop);
+        store(changeLog);
 
         return rootState;
     }
@@ -144,7 +144,7 @@
         }
 
         // load from persisted state
-        NodeState state = persistMgr.load(id.getUUID());
+        NodeState state = persistMgr.load(id);
         state.setStatus(ItemState.STATUS_EXISTING);
 
         // put it in cache
@@ -170,7 +170,7 @@
         }
 
         // load from persisted state
-        PropertyState state = persistMgr.load(id.getName(), id.getParentUUID());
+        PropertyState state = persistMgr.load(id);
         state.setStatus(ItemState.STATUS_EXISTING);
 
         // put it in cache
@@ -205,7 +205,11 @@
         }
 
         try {
-            return persistMgr.exists(id);
+            if (id.denotesNode()) {
+                return persistMgr.exists((NodeId) id);
+            } else {
+                return persistMgr.exists((PropertyId) id);
+            }
         } catch (ItemStateException ise) {
             return false;
         }
@@ -214,30 +218,100 @@
     /**
      * @see ItemStateManager#getNodeReferences
      */
-    public synchronized NodeReferences getNodeReferences(NodeId targetId)
+    public synchronized NodeReferences getNodeReferences(NodeReferencesId id)
             throws NoSuchItemStateException, ItemStateException {
 
-        if (refsCache.containsKey(targetId)) {
-            return (NodeReferences) refsCache.get(targetId);
-        }
-
         NodeReferences refs;
 
         try {
-            refs = persistMgr.load(targetId);
+            refs = persistMgr.load(id);
         } catch (NoSuchItemStateException nsise) {
-            refs = new NodeReferences(targetId);
+            refs = new NodeReferences(id);
         }
 
-        refsCache.put(targetId, refs);
         return refs;
     }
 
     /**
-     * @see ItemStateManager#beginUpdate
+     * @see UpdatableItemStateManager#edit
+     */
+    public void edit() throws ItemStateException {
+        if (editMode) {
+            throw new ItemStateException("Already in edit mode.");
+        }
+        editMode = true;
+
+        changeLog = new ChangeLog();
+    }
+
+    /**
+     * @see UpdatableItemStateManager#createNew
+     */
+    public NodeState createNew(String uuid, QName nodeTypeName,
+                               String parentUUID) {
+
+        if (!editMode) {
+            throw new IllegalStateException("Not in edit mode");
+        }
+        return createInstance(uuid, nodeTypeName, parentUUID);
+    }
+
+    /**
+     * @see UpdatableItemStateManager#createNew
+     */
+    public PropertyState createNew(QName propName, String parentUUID) {
+        if (!editMode) {
+            throw new IllegalStateException("Not in edit mode");
+        }
+        return createInstance(propName, parentUUID);
+    }
+
+    /**
+     * @see UpdatableItemStateManager#store
      */
-    public UpdateOperation beginUpdate() throws ItemStateException {
-        return new Update();
+    public void store(ItemState state) {
+        if (!editMode) {
+            throw new IllegalStateException("Not in edit mode");
+        }
+        changeLog.modified(state);
+    }
+
+    /**
+     * @see UpdatableItemStateManager#store
+     */
+    public void store(NodeReferences refs) {
+        if (!editMode) {
+            throw new IllegalStateException("Not in edit mode");
+        }
+        changeLog.modified(refs);
+    }
+
+    /**
+     * @see UpdatableItemStateManager#destroy
+     */
+    public void destroy(ItemState state) {
+        if (!editMode) {
+            throw new IllegalStateException("Not in edit mode");
+        }
+        changeLog.deleted(state);
+    }
+
+    /**
+     * @see UpdatableItemStateManager#cancel
+     */
+    public void cancel() {
+        editMode = false;
+
+        changeLog.discard();
+    }
+
+    /**
+     * @see UpdatableItemStateManager#update
+     */
+    public void update() throws ItemStateException {
+        store(changeLog);
+
+        editMode = false;
     }
 
     //-------------------------------------------------------- other operations
@@ -253,7 +327,9 @@
     private NodeState createInstance(String uuid, QName nodeTypeName,
                              String parentUUID) {
 
-        NodeState state = persistMgr.createNew(uuid, nodeTypeName, parentUUID);
+        NodeState state = persistMgr.createNew(new NodeId(uuid));
+        state.setNodeTypeName(nodeTypeName);
+        state.setParentUUID(parentUUID);
         state.setStatus(ItemState.STATUS_NEW);
         state.addListener(this);
         cache(state);
@@ -268,7 +344,7 @@
      * @return new property state instance
      */
     private PropertyState createInstance(QName propName, String parentUUID) {
-        PropertyState state = persistMgr.createNew(propName, parentUUID);
+        PropertyState state = persistMgr.createNew(new PropertyId(parentUUID, propName));
         state.setStatus(ItemState.STATUS_NEW);
         state.addListener(this);
         cache(state);
@@ -276,39 +352,15 @@
     }
 
     /**
-     * Store modified states and node references, atomically.
-     *
-     * @param states         states that have been modified
-     * @param refsCollection collection of refs to store
+     * Save all states and node references, atomically.
+     * @param changeLog change log containing states that were changed
      * @throws ItemStateException if an error occurs
      */
-    private void store(Collection states, Collection refsCollection)
+    private synchronized void store(ChangeLog changeLog)
             throws ItemStateException {
 
-        persistMgr.store(states.iterator(), refsCollection.iterator());
-
-        Iterator iter = states.iterator();
-        while (iter.hasNext()) {
-            ItemState state = (ItemState) iter.next();
-            int status = state.getStatus();
-
-            switch (status) {
-                case ItemState.STATUS_NEW:
-                    //state.notifyStateCreated();
-                    state.setStatus(ItemState.STATUS_EXISTING);
-                    break;
-
-                case ItemState.STATUS_EXISTING_REMOVED:
-                    //state.notifyStateDestroyed();
-                    state.discard();
-                    break;
-
-                default:
-                    //state.notifyStateUpdated();
-                    state.setStatus(ItemState.STATUS_EXISTING);
-                    break;
-            }
-        }
+        persistMgr.store(changeLog);
+        changeLog.persisted();
     }
 
 
@@ -343,63 +395,4 @@
         discarded.removeListener(this);
         evict(discarded.getId());
     }
-
-
-    class Update implements UpdateOperation {
-
-        /**
-         * Modified states
-         */
-        private final List states = new ArrayList();
-
-        /**
-         * Modified references
-         */
-        private final List refsCollection = new ArrayList();
-
-        /**
-         * @see UpdateOperation#createNew
-         */
-        public NodeState createNew(String uuid, QName nodeTypeName,
-                                   String parentUUID) {
-            return createInstance(uuid, nodeTypeName, parentUUID);
-        }
-
-        /**
-         * @see UpdateOperation#createNew
-         */
-        public PropertyState createNew(QName propName, String parentUUID) {
-            return createInstance(propName, parentUUID);
-        }
-
-        /**
-         * @see UpdateOperation#store
-         */
-        public void store(ItemState state) {
-            states.add(state);
-        }
-
-        /**
-         * @see UpdateOperation#store
-         */
-        public void store(NodeReferences refs) {
-            refsCollection.add(refs);
-        }
-
-        /**
-         * @see UpdateOperation#destroy
-         */
-        public void destroy(ItemState state) {
-            state.setStatus(ItemState.STATUS_EXISTING_REMOVED);
-            states.add(state);
-        }
-
-        /**
-         * @see UpdateOperation#end
-         */
-        public void end() throws ItemStateException {
-            NativeItemStateManager.this.store(states, refsCollection);
-        }
-    }
-
 }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativePVM.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativePVM.java?view=diff&r1=151379&r2=151380
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativePVM.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativePVM.java Fri Feb  4 09:43:55 2005
@@ -267,7 +267,7 @@
         }
 
         try {
-            UpdateOperation upd = stateMgr.beginUpdate();
+            stateMgr.edit();
 
             // create deep path
             String uuid = UUID.randomUUID().toString();
@@ -275,18 +275,18 @@
             for (int i=0; i<3; i++) {
                 QName name = new QName(NamespaceRegistryImpl.NS_DEFAULT_URI, uuid.substring(i*2, i*2+2));
                 if (!root.hasNode(name)) {
-                    root.addNode(upd, name, NodeTypeRegistry.NT_UNSTRUCTURED);
-                    root.store(upd);
+                    root.addNode(name, NodeTypeRegistry.NT_UNSTRUCTURED);
+                    root.store();
                 }
                 root = root.getNode(name, 1);
             }
             QName historyNodeName = new QName(NamespaceRegistryImpl.NS_DEFAULT_URI, uuid);
 
             // create new history node in the persistent state
-            hist = InternalVersionHistoryImpl.create(upd, this, root, uuid, historyNodeName, node);
+            hist = InternalVersionHistoryImpl.create(this, root, uuid, historyNodeName, node);
 
             // end update
-            upd.end();
+            stateMgr.update();
 
             initVirtualIds(hist.getId(), hist.getNode().getState());
         } catch (ItemStateException e) {
@@ -496,9 +496,9 @@
         }
 
         try {
-            UpdateOperation upd = stateMgr.beginUpdate();
-            InternalVersionImpl v = history.checkin(upd, new QName("", versionName), node);
-            upd.end();
+            stateMgr.edit();
+            InternalVersionImpl v = history.checkin(new QName("", versionName), node);
+            stateMgr.update();
 
             initVirtualIds(v.getId(), v.getNode().getState());
 
@@ -508,39 +508,11 @@
         }
     }
 
-    public void removeVersion(InternalVersionHistory hist, QName name) throws VersionException {
-        try {
-            UpdateOperation upd = stateMgr.beginUpdate();
-            ((InternalVersionHistoryImpl) hist).removeVersion(upd, name);
-            upd.end();
-        } catch (ItemStateException e) {
-            throw new VersionException(e);
-        }
-
-    }
-
-    public InternalVersion addVersionLabel(InternalVersionHistory hist, QName versionName, String label, boolean move) throws VersionException {
-        try {
-            UpdateOperation upd = stateMgr.beginUpdate();
-            InternalVersion v =
-                    ((InternalVersionHistoryImpl) hist).addVersionLabel(upd, versionName, label, move);
-            upd.end();
-            return v;
-        } catch (ItemStateException e) {
-            throw new VersionException(e);
-        }
-    }
-
-    public InternalVersion removeVersionLabel(InternalVersionHistory hist, String label) throws VersionException {
-        try {
-            UpdateOperation upd = stateMgr.beginUpdate();
-            InternalVersion v =
-                    ((InternalVersionHistoryImpl) hist).removeVersionLabel(upd, label);
-            upd.end();
-            return v;
-        } catch (ItemStateException e) {
-            throw new VersionException(e);
-        }
+    /**
+     * @see PersistentVersionManager#getItemStateMgr()
+     */
+    public UpdatableItemStateManager getItemStateMgr() {
+        return stateMgr;
     }
 
     /**

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/PersistentNode.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/PersistentNode.java?view=diff&r1=151379&r2=151380
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/PersistentNode.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/PersistentNode.java Fri Feb  4 09:43:55 2005
@@ -39,7 +39,7 @@
     /**
      * the state manager
      */
-    private final ItemStateManager stateMgr;
+    private final UpdatableItemStateManager stateMgr;
 
     /**
      * the cached name
@@ -52,7 +52,7 @@
      * @param stateMgr
      * @param nodeState
      */
-    protected PersistentNode(ItemStateManager stateMgr,
+    protected PersistentNode(UpdatableItemStateManager stateMgr,
                              NodeState nodeState) {
         this.nodeState = nodeState;
         this.stateMgr = stateMgr;
@@ -161,9 +161,9 @@
      * @param value
      * @throws RepositoryException
      */
-    protected void setPropertyValue(UpdateOperation upd, QName name, InternalValue value)
+    protected void setPropertyValue(QName name, InternalValue value)
             throws RepositoryException {
-        setPropertyValues(upd, name, value.getType(), new InternalValue[]{value}, false);
+        setPropertyValues(name, value.getType(), new InternalValue[]{value}, false);
     }
 
     /**
@@ -174,9 +174,9 @@
      * @param values
      * @throws RepositoryException
      */
-    protected void setPropertyValues(UpdateOperation upd, QName name, int type, InternalValue[] values)
+    protected void setPropertyValues(QName name, int type, InternalValue[] values)
             throws RepositoryException {
-        setPropertyValues(upd, name, type, values, true);
+        setPropertyValues(name, type, values, true);
     }
 
     /**
@@ -187,10 +187,10 @@
      * @param values
      * @throws RepositoryException
      */
-    protected void setPropertyValues(UpdateOperation upd, QName name, int type, InternalValue[] values, boolean multiple)
+    protected void setPropertyValues(QName name, int type, InternalValue[] values, boolean multiple)
             throws RepositoryException {
 
-        PropertyState prop = getOrCreatePropertyState(upd, name, type, multiple);
+        PropertyState prop = getOrCreatePropertyState(name, type, multiple);
         prop.setValues(values);
     }
 
@@ -204,7 +204,7 @@
      * @return
      * @throws RepositoryException
      */
-    private PropertyState getOrCreatePropertyState(UpdateOperation upd, QName name, int type, boolean multiValued)
+    private PropertyState getOrCreatePropertyState(QName name, int type, boolean multiValued)
             throws RepositoryException {
 
         PropertyId propId = new PropertyId(nodeState.getUUID(), name);
@@ -224,7 +224,7 @@
                 throw new RepositoryException("Unable to create property: " + e.toString());
             }
         } else {
-            PropertyState propState = upd.createNew(name, nodeState.getUUID());
+            PropertyState propState = stateMgr.createNew(name, nodeState.getUUID());
             propState.setType(type);
             propState.setMultiValued(multiValued);
             propState.setDefinitionId(PropDefId.valueOf("0"));
@@ -254,8 +254,8 @@
      * @return
      * @throws RepositoryException
      */
-    protected boolean removeNode(UpdateOperation upd, QName name) throws RepositoryException {
-        return removeNode(upd, name, 1);
+    protected boolean removeNode(QName name) throws RepositoryException {
+        return removeNode(name, 1);
     }
 
     /**
@@ -266,14 +266,14 @@
      * @return
      * @throws RepositoryException
      */
-    protected boolean removeNode(UpdateOperation upd, QName name, int index) throws RepositoryException {
+    protected boolean removeNode(QName name, int index) throws RepositoryException {
         try {
             NodeState.ChildNodeEntry entry = nodeState.getChildNodeEntry(name, index);
             if (entry == null) {
                 return false;
             } else {
                 ItemState state = stateMgr.getItemState(new NodeId(entry.getUUID()));
-                upd.destroy(state);
+                stateMgr.destroy(state);
                 nodeState.removeChildNodeEntry(name, index);
                 nodeState.setStatus(ItemState.STATUS_EXISTING_MODIFIED);
                 return true;
@@ -331,9 +331,10 @@
      * @throws ConstraintViolationException
      * @throws RepositoryException
      */
-    protected PersistentNode addNode(UpdateOperation upd, QName nodeName, QName nodeTypeName)
+    protected PersistentNode addNode(QName nodeName, QName nodeTypeName)
             throws NoSuchNodeTypeException, ConstraintViolationException, RepositoryException {
-        return createChildNode(upd, nodeName, nodeTypeName, null);
+
+        return createChildNode(nodeName, nodeTypeName, null);
     }
 
     /**
@@ -343,14 +344,13 @@
      * @param uuid
      * @return
      */
-    private PersistentNode createChildNode(UpdateOperation upd, QName name, QName nodeTypeName, String uuid) {
-
+    private PersistentNode createChildNode(QName name, QName nodeTypeName, String uuid) {
         String parentUUID = nodeState.getUUID();
         // create a new node state
         if (uuid == null) {
             uuid = UUID.randomUUID().toString();	// version 4 uuid
         }
-        NodeState state = upd.createNew(uuid, nodeTypeName, parentUUID);
+        NodeState state = stateMgr.createNew(uuid, nodeTypeName, parentUUID);
         state.setDefinitionId(NodeDefId.valueOf("0"));
 
         // create Node instance wrapping new node state
@@ -389,9 +389,9 @@
      *
      * @throws RepositoryException
      */
-    protected void store(UpdateOperation upd) throws RepositoryException {
+    protected void store() throws RepositoryException {
         try {
-            store(upd, nodeState);
+            store(nodeState);
         } catch (ItemStateException e) {
             throw new RepositoryException(e);
         }
@@ -401,10 +401,9 @@
      * stores the given persistent state recursively
      *
      * @param state
-     * @param update update operation
      * @throws ItemStateException
      */
-    private void store(UpdateOperation update, NodeState state)
+    private void store(NodeState state)
             throws ItemStateException {
 
         if (state.getStatus()!=ItemState.STATUS_EXISTING) {
@@ -414,7 +413,7 @@
                 NodeState.PropertyEntry entry = (NodeState.PropertyEntry) props.get(i);
                 PropertyState pstate = (PropertyState) stateMgr.getItemState(new PropertyId(state.getUUID(), entry.getName()));
                 if (pstate.getStatus()!=ItemState.STATUS_EXISTING) {
-                    update.store(pstate);
+                    stateMgr.store(pstate);
                 }
             }
             // now store all child node entries
@@ -422,10 +421,10 @@
             for (int i = 0; i < nodes.size(); i++) {
                 NodeState.ChildNodeEntry entry = (NodeState.ChildNodeEntry) nodes.get(i);
                 NodeState nstate = (NodeState) stateMgr.getItemState(new NodeId(entry.getUUID()));
-                store(update, nstate);
+                store(nstate);
             }
             // and store itself
-            update.store(state);
+            stateMgr.store(state);
         }
     }
 
@@ -479,13 +478,13 @@
      * @param prop
      * @throws RepositoryException
      */
-    protected void copyFrom(UpdateOperation upd, PropertyImpl prop) throws RepositoryException {
+    protected void copyFrom(PropertyImpl prop) throws RepositoryException {
         if (prop.getDefinition().isMultiple()) {
             InternalValue[] values = prop.internalGetValues();
             int type = values.length>0 ? values[0].getType() : prop.getDefinition().getRequiredType();
-            setPropertyValues(upd, prop.getQName(), type, values);
+            setPropertyValues(prop.getQName(), type, values);
         } else {
-            setPropertyValue(upd, prop.getQName(), prop.internalGetValue());
+            setPropertyValue(prop.getQName(), prop.internalGetValue());
         }
     }