jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r830575 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: RepositoryCopier.java RepositoryImpl.java lock/LockManagerImpl.java
Date Wed, 28 Oct 2009 15:18:53 GMT
Author: jukka
Date: Wed Oct 28 15:18:52 2009
New Revision: 830575

URL: http://svn.apache.org/viewvc?rev=830575&view=rev
Log:
JCR-2367: RepositoryCopier does not copy open-scoped Locks

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryCopier.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryCopier.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryCopier.java?rev=830575&r1=830574&r2=830575&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryCopier.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryCopier.java
Wed Oct 28 15:18:52 2009
@@ -27,6 +27,7 @@
 
 import org.apache.commons.io.FileUtils;
 import org.apache.jackrabbit.core.config.RepositoryConfig;
+import org.apache.jackrabbit.core.lock.LockManagerImpl;
 import org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.persistence.PersistenceCopier;
@@ -262,12 +263,18 @@
                 target.createWorkspace(name);
             }
 
+            // Copy all the workspace content
             PersistenceCopier copier = new PersistenceCopier(
                     source.getWorkspaceInfo(name).getPersistenceManager(),
                     target.getWorkspaceInfo(name).getPersistenceManager(),
                     target.getDataStore());
             copier.excludeNode(RepositoryImpl.SYSTEM_ROOT_NODE_ID);
             copier.copy(RepositoryImpl.ROOT_NODE_ID);
+
+            // Copy all the active open-scoped locks
+            LockManagerImpl sourceLockManager = source.getLockManager(name);
+            LockManagerImpl targetLockManager = target.getLockManager(name);
+            targetLockManager.copyOpenScopedLocksFrom(sourceLockManager);
         }
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java?rev=830575&r1=830574&r2=830575&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
Wed Oct 28 15:18:52 2009
@@ -914,7 +914,7 @@
      * @throws NoSuchWorkspaceException if such a workspace does not exist
      * @throws RepositoryException      if some other error occurs
      */
-    LockManager getLockManager(String workspaceName) throws
+    LockManagerImpl getLockManager(String workspaceName) throws
             NoSuchWorkspaceException, RepositoryException {
         // check sanity of this instance
         sanityCheck();
@@ -1847,7 +1847,7 @@
          * @return the lock manager for this workspace
          * @throws RepositoryException if the lock manager could not be created
          */
-        protected LockManager getLockManager() throws RepositoryException {
+        protected LockManagerImpl getLockManager() throws RepositoryException {
             if (!isInitialized()) {
                 throw new IllegalStateException("workspace '" + getName()
                         + "' not initialized");

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java?rev=830575&r1=830574&r2=830575&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
Wed Oct 28 15:18:52 2009
@@ -490,6 +490,30 @@
     }
 
     /**
+     * Helper method that copies all the active open-scoped locks from the
+     * given source to this lock manager. This method is used when backing
+     * up repositories, and only works correctly when the source lock manager
+     * belongs to the original copy of the workspace being backed up.
+     *
+     * @see org.apache.jackrabbit.core.RepositoryCopier
+     * @param source source lock manager
+     */
+    public void copyOpenScopedLocksFrom(LockManagerImpl source) {
+        source.lockMap.traverse(new PathMap.ElementVisitor<LockInfo>() {
+            public void elementVisited(PathMap.Element<LockInfo> element) {
+                LockInfo info = element.get();
+                if (info.isLive() && !info.isSessionScoped()) {
+                    try {
+                        lockMap.put(element.getPath(), info);
+                    } catch (MalformedPathException e) {
+                        log.warn("Ignoring invalid lock path: " + info, e);
+                    }
+                }
+            }
+        }, false);
+    }
+
+    /**
      * Return the most appropriate lock information for a node. This is either
      * the lock info for the node itself, if it is locked, or a lock info for one
      * of its parents, if that is deep locked.



Mime
View raw message