jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r515161 - in /jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: NodeImpl.java SessionImpl.java WorkspaceImpl.java
Date Tue, 06 Mar 2007 15:47:59 GMT
Author: angela
Date: Tue Mar  6 07:47:58 2007
New Revision: 515161

URL: http://svn.apache.org/viewvc?view=rev&rev=515161
Log:
assert that versionState used for restore/merge is obtained from the hierarchy belonging to
'this' session.

Modified:
    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

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?view=diff&rev=515161&r1=515160&r2=515161
==============================================================================
--- 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
Tue Mar  6 07:47:58 2007
@@ -45,7 +45,6 @@
 import org.apache.jackrabbit.jcr2spi.operation.Operation;
 import org.apache.jackrabbit.jcr2spi.operation.Update;
 import org.apache.jackrabbit.jcr2spi.lock.LockManager;
-import org.apache.jackrabbit.jcr2spi.version.VersionImpl;
 import org.apache.jackrabbit.jcr2spi.util.LogUtil;
 import org.apache.jackrabbit.jcr2spi.util.StateUtility;
 import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
@@ -867,12 +866,8 @@
             throw new VersionException(msg);
         }
 
-        if (version instanceof VersionImpl) {
-            NodeState versionState = ((NodeImpl)version).getNodeState();
-            session.getVersionManager().resolveMergeConflict(getNodeState(), versionState,
done);
-        } else {
-            throw new RepositoryException("Incompatible Version object: " + version.getPath());
-        }
+        NodeState versionState = session.getVersionState(version);
+        session.getVersionManager().resolveMergeConflict(getNodeState(), versionState, done);
     }
 
     /**
@@ -1106,12 +1101,8 @@
             // NOTE: check for nodetype constraint violation is left to the 'server'
         }
 
-        if (version instanceof VersionImpl) {
-            NodeState versionState = ((NodeImpl)version).getNodeState();
-            session.getVersionManager().restore(targetNode.getNodeState(), relQPath, versionState,
removeExisting);
-        } else {
-            throw new RepositoryException("Incompatible Version object: " + version.getPath());
-        }
+        NodeState versionState = session.getVersionState(version);
+        session.getVersionManager().restore(targetNode.getNodeState(), relQPath, versionState,
removeExisting);
     }
 
     /**

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?view=diff&rev=515161&r1=515160&r2=515161
==============================================================================
--- 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
Tue Mar  6 07:47:58 2007
@@ -81,6 +81,7 @@
 import javax.jcr.lock.LockException;
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.version.VersionException;
+import javax.jcr.version.Version;
 import javax.xml.transform.sax.SAXTransformerFactory;
 import javax.xml.transform.sax.TransformerHandler;
 import javax.xml.transform.stream.StreamResult;
@@ -793,6 +794,25 @@
         }
     }
 
+    /**
+     * Returns the NodeState of the given Node and asserts that the state is
+     * listed in the hierarchy built by this Session. If the version
+     * was obtained from a different session, the 'corresponding' version
+     * state for this session is retrieved.
+     *
+     * @param node
+     * @return
+     */
+    NodeState getVersionState(Version version) throws RepositoryException {
+        ItemState itemState;
+        if (version.getSession() == this) {
+            itemState = ((NodeImpl) version).getItemState();
+        } else {
+            Path p = getQPath(version.getPath());
+            itemState = getHierarchyManager().getItemState(p);
+        }
+        return (NodeState) itemState;
+    }
     //------------------------------------------------------< check methods >---
     /**
      * Performs a sanity check on this session.

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?view=diff&rev=515161&r1=515160&r2=515161
==============================================================================
--- 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
Tue Mar  6 07:47:58 2007
@@ -35,7 +35,6 @@
 import org.apache.jackrabbit.jcr2spi.lock.LockManagerImpl;
 import org.apache.jackrabbit.jcr2spi.version.VersionManager;
 import org.apache.jackrabbit.jcr2spi.version.VersionManagerImpl;
-import org.apache.jackrabbit.jcr2spi.version.VersionImpl;
 import org.apache.jackrabbit.jcr2spi.name.NamespaceRegistryImpl;
 import org.apache.jackrabbit.jcr2spi.observation.ObservationManagerImpl;
 import org.apache.jackrabbit.jcr2spi.xml.WorkspaceContentHandler;
@@ -242,12 +241,7 @@
 
         NodeState[] versionStates = new NodeState[versions.length];
         for (int i = 0; i < versions.length; i++) {
-            if (versions[i] instanceof VersionImpl) {
-                ItemState vState = ((NodeImpl)versions[i]).getItemState();
-                versionStates[i] = (NodeState) vState;
-            } else {
-                throw new RepositoryException("Unexpected error: Failed to retrieve a valid
ID for the given version " + versions[i].getPath());
-            }
+            versionStates[i] = session.getVersionState(versions[i]);
         }
         getVersionManager().restore(versionStates, removeExisting);
     }



Mime
View raw message