jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r124539 - incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence
Date Fri, 07 Jan 2005 16:56:12 GMT
Author: tripod
Date: Fri Jan  7 08:56:10 2005
New Revision: 124539

URL: http://svn.apache.org/viewcvs?view=rev&rev=124539
Log:
- fixing some versioning persistence problems
Modified:
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalFrozenNodeImpl.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalVersionHistoryImpl.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalVersionImpl.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativePVM.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/PersistentNode.java

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&rev=124539&p1=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalFrozenNodeImpl.java&r1=124538&p2=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalFrozenNodeImpl.java&r2=124539
==============================================================================
--- 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 Jan  7 08:56:10 2005
@@ -304,7 +304,6 @@
                 }
             }
         }
-        parent.store();
         return node;
     }
 

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&rev=124539&p1=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalVersionHistoryImpl.java&r1=124538&p2=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalVersionHistoryImpl.java&r2=124539
==============================================================================
--- 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 Jan  7 08:56:10 2005
@@ -239,6 +239,7 @@
         try {
             // remove from persistance state
             node.removeNode(versionName);
+            node.store();
 
             // unregister from labels
             String[] labels = v.internalGetLabels();
@@ -253,7 +254,6 @@
 
             // and remove from history
             versionCache.remove(v.getId());
-            store();
         } catch (RepositoryException e) {
             throw new VersionException("error while storing modifications", e);
         }
@@ -354,7 +354,7 @@
         InternalFrozenNodeImpl.checkin(vNode, VersionManager.NODENAME_FROZEN, src, false,
false);
 
         // and store
-        store();
+        node.store();
 
         // update version graph
         InternalVersionImpl version = new InternalVersionImpl(this, vNode);
@@ -364,26 +364,6 @@
         versionCache.put(version.getId(), version);
 
         return version;
-    }
-
-
-    /**
-     * Stores the changes made to this version history
-     *
-     * @throws RepositoryException
-     */
-    protected void store() throws RepositoryException {
-        node.store();
-    }
-
-    /**
-     * discards the changes made to this version history
-     *
-     * @throws RepositoryException
-     */
-    protected void reload() throws RepositoryException {
-        node.reload();
-        init();
     }
 
     /**

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&rev=124539&p1=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalVersionImpl.java&r1=124538&p2=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalVersionImpl.java&r2=124539
==============================================================================
--- 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 Jan  7 08:56:10 2005
@@ -19,6 +19,7 @@
 import org.apache.jackrabbit.core.version.*;
 import org.apache.jackrabbit.core.QName;
 import org.apache.jackrabbit.core.InternalValue;
+import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.util.uuid.UUID;
 
 import javax.jcr.RepositoryException;
@@ -140,13 +141,14 @@
     public InternalFrozenNode getFrozenNode() {
         // get frozen node
         try {
-            // assuming only child
-            PersistentNode[] nodes = node.getChildNodes();
-            return nodes.length==0 ? null : (InternalFrozenNode) getVersionManager().getItemByInternal(nodes[0].getUUID());
+            NodeState.ChildNodeEntry entry = node.getState().getChildNodeEntry(VersionManager.NODENAME_FROZEN,
1);
+            if (entry==null) {
+                throw new IllegalStateException("version has no frozen node: " + getId());
+            }
+            return (InternalFrozenNode) getVersionManager().getItemByInternal(entry.getUUID());
         } catch (RepositoryException e) {
-            // ignore
+            throw new IllegalStateException("unable to retrieve frozen node: " + e);
         }
-        return null;
     }
 
     /**

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&rev=124539&p1=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativePVM.java&r1=124538&p2=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativePVM.java&r2=124539
==============================================================================
--- 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 Jan  7 08:56:10 2005
@@ -188,7 +188,7 @@
             initVirtualIds(historyRoot.getState());
             log.info("loaded " + idsByExternal.size() + " virtual ids.");
         } catch (ItemStateException e) {
-            throw new RepositoryException("Unable to initialize PersistentVersionManager:
" + e.toString());
+            throw new RepositoryException("Unable to initialize PersistentVersionManager:
" + e.toString(), e);
         }
     }
 
@@ -274,6 +274,12 @@
     public InternalVersionHistory createVersionHistory(NodeImpl node)
             throws RepositoryException {
 
+        // check if version history for that node already exists
+        InternalVersionHistoryImpl hist = (InternalVersionHistoryImpl) getVersionHistory(node.internalGetUUID());
+        if (hist!=null) {
+            return hist;
+        }
+
         // create deep path
         String uuid = UUID.randomUUID().toString();
         PersistentNode root = historyRoot;
@@ -288,7 +294,7 @@
         QName historyNodeName = new QName(NamespaceRegistryImpl.NS_DEFAULT_URI, uuid);
 
         // create new history node in the persistent state
-        InternalVersionHistoryImpl hist = InternalVersionHistoryImpl.create(this, root, uuid,
historyNodeName, node);
+        hist = InternalVersionHistoryImpl.create(this, root, uuid, historyNodeName, node);
         try {
             initVirtualIds(hist.getId(), hist.getNode().getState());
         } catch (ItemStateException e) {

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&rev=124539&p1=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/PersistentNode.java&r1=124538&p2=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/PersistentNode.java&r2=124539
==============================================================================
--- 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 Jan  7 08:56:10 2005
@@ -228,6 +228,10 @@
                 PersistentPropertyState propState = (PersistentPropertyState) stateMgr.getItemState(propId);
                 // someone calling this method will always alter the property state, so set
status to modified
                 propState.setStatus(ItemState.STATUS_EXISTING_MODIFIED);
+                // although this is not quite correct, we mark node as modified aswell
+                if (nodeState.getStatus()==ItemState.STATUS_EXISTING) {
+                    nodeState.setStatus(ItemState.STATUS_EXISTING_MODIFIED);
+                }
                 return propState;
             } catch (ItemStateException e) {
                 throw new RepositoryException("Unable to create property: " + e.toString());
@@ -242,7 +246,9 @@
 
                 // need to store nodestate
                 nodeState.addPropertyEntry(name);
-                nodeState.setStatus(ItemState.STATUS_EXISTING_MODIFIED);
+                if (nodeState.getStatus()==ItemState.STATUS_EXISTING) {
+                    nodeState.setStatus(ItemState.STATUS_EXISTING_MODIFIED);
+                }
                 return propState;
             } catch (ItemStateException e) {
                 throw new RepositoryException("Unable to store property: " + e.toString());
@@ -333,7 +339,9 @@
      */
     protected boolean removeNode(QName name, int index) throws RepositoryException {
         if (nodeState.removeChildNodeEntry(name, index)) {
-            nodeState.setStatus(ItemState.STATUS_EXISTING_MODIFIED);
+            if (nodeState.getStatus()==ItemState.STATUS_EXISTING) {
+                nodeState.setStatus(ItemState.STATUS_EXISTING_MODIFIED);
+            }
             return true;
         } else {
             return false;
@@ -441,7 +449,9 @@
         PersistentNode node = new PersistentNode(stateMgr, ntMgr, state);
         // add new child node entry
         nodeState.addChildNodeEntry(name, state.getUUID());
-        nodeState.setStatus(ItemState.STATUS_EXISTING_MODIFIED);
+        if (nodeState.getStatus()==ItemState.STATUS_EXISTING) {
+            nodeState.setStatus(ItemState.STATUS_EXISTING_MODIFIED);
+        }
 
         // add 'auto-create' properties defined in node type
         PropertyDef[] pda = nodeType.getAutoCreatePropertyDefs();

Mime
View raw message