jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r1764217 - in /jackrabbit/commons/filevault/trunk/vault-core/src: main/java/org/apache/jackrabbit/vault/fs/impl/io/ test/java/org/apache/jackrabbit/vault/packaging/integration/
Date Tue, 11 Oct 2016 09:27:49 GMT
Author: tripod
Date: Tue Oct 11 09:27:49 2016
New Revision: 1764217

URL: http://svn.apache.org/viewvc?rev=1764217&view=rev
Log:
JCRVLT-128 System maintained cache nodes should be ignored

Modified:
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/ChildNodeStash.java
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/JcrSysViewTransformer.java
    jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestUserContentPackage.java

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/ChildNodeStash.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/ChildNodeStash.java?rev=1764217&r1=1764216&r2=1764217&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/ChildNodeStash.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/ChildNodeStash.java
Tue Oct 11 09:27:49 2016
@@ -16,6 +16,9 @@
  */
 package org.apache.jackrabbit.vault.fs.impl.io;
 
+import java.util.HashSet;
+import java.util.Set;
+
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
 import javax.jcr.RepositoryException;
@@ -39,6 +42,8 @@ public class ChildNodeStash {
 
     private Node tmpNode;
 
+    private final Set<String> excludedNodeName = new HashSet<String>();
+
     /**
      * List of potential roots where the transient temporary node will be created.
      * Note that the node is never persisted.
@@ -75,6 +80,17 @@ public class ChildNodeStash {
     }
 
     /**
+     * Adds the given name to the set of excluded child node names. the nodes that are excluded
are not saved
+     * in the stash.
+     * @param name The name of the node to exclude
+     * @return "this" suitable for chaining.
+     */
+    public ChildNodeStash excludeName(String name) {
+        excludedNodeName.add(name);
+        return this;
+    }
+
+    /**
      * Moves the nodes below the given parent path to a temporary location.
      * @param parentPath the path of the parent node.
      * @throws RepositoryException if an error occurrs
@@ -92,9 +108,14 @@ public class ChildNodeStash {
             NodeIterator iter = parent.getNodes();
             while (iter.hasNext()) {
                 Node child = iter.nextNode();
+                String name = child.getName();
+                if (excludedNodeName.contains(name)) {
+                    log.info("skipping excluded child node from stash: {}", child.getPath());
+                    continue;
+                }
                 Node tmp = getOrCreateTemporaryNode();
                 try {
-                    session.move(child.getPath(), tmp.getPath() + "/" + child.getName());
+                    session.move(child.getPath(), tmp.getPath() + "/" + name);
                 } catch (RepositoryException e) {
                     log.error("Error while moving child node to temporary location. Child
will be removed.", e);
                 }

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/JcrSysViewTransformer.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/JcrSysViewTransformer.java?rev=1764217&r1=1764216&r2=1764217&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/JcrSysViewTransformer.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/JcrSysViewTransformer.java
Tue Oct 11 09:27:49 2016
@@ -87,7 +87,7 @@ public class JcrSysViewTransformer imple
         this.existingPath = existingPath;
         if (existingPath != null) {
             // check if there is an existing node with the name
-            recovery = new ChildNodeStash(session);
+            recovery = new ChildNodeStash(session).excludeName("rep:cache");
             recovery.stashChildren(existingPath);
         }
     }

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestUserContentPackage.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestUserContentPackage.java?rev=1764217&r1=1764216&r2=1764217&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestUserContentPackage.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestUserContentPackage.java
Tue Oct 11 09:27:49 2016
@@ -97,8 +97,8 @@ public class TestUserContentPackage exte
         admin.refresh(false);
         UserManager mgr = ((JackrabbitSession) admin).getUserManager();
         for (String id: getAllAuthorizableIds()) {
-            if (preTestAuhorizables.remove(id)) {
-                removeAuthorizable(mgr, ID_TEST_USER_A);
+            if (!preTestAuhorizables.remove(id)) {
+                removeAuthorizable(mgr, id);
             }
         }
         admin.save();
@@ -361,11 +361,37 @@ public class TestUserContentPackage exte
         assertTrue(property.isMultiple());
     }
 
+    /**
+     * Tests if installing a package using {@link ImportMode#UPDATE} with a user that already
exists in the repository
+     * succeeds, even if it has a rep:cache node and is on a different location (JCRVLT-128).
+     */
+    @Test
+    public void install_moved_user_with_rep_cache_update() throws RepositoryException, IOException,
PackageException {
+        Assume.assumeTrue(isOak());
+        install_moved_user_with_rep_cache(ImportMode.UPDATE);
+    }
+
+    /**
+     * Tests if installing a package using {@link ImportMode#REPLACE} with a user that already
exists in the repository
+     * succeeds, even if it has a rep:cache node and is on a different location (JCRVLT-128).
+     */
     @Test
-    @Ignore("JCRVLT-128")
-    public void install_moved_user_with_rep_cache() throws RepositoryException, IOException,
PackageException {
+    public void install_moved_user_with_rep_cache_replace() throws RepositoryException, IOException,
PackageException {
         Assume.assumeTrue(isOak());
+        install_moved_user_with_rep_cache(ImportMode.REPLACE);
+    }
+
+    /**
+     * Tests if installing a package using {@link ImportMode#MERGE} with a user that already
exists in the repository
+     * succeeds, even if it has a rep:cache node and is on a different location (JCRVLT-128).
+     */
+    @Test
+    public void install_moved_user_with_rep_cache_merge() throws RepositoryException, IOException,
PackageException {
+        Assume.assumeTrue(isOak());
+        install_moved_user_with_rep_cache(ImportMode.MERGE);
+    }
 
+    private void install_moved_user_with_rep_cache(ImportMode mode) throws RepositoryException,
IOException, PackageException {
         UserManager mgr = ((JackrabbitSession) admin).getUserManager();
         User u = mgr.createUser(ID_TEST_USER_A, ID_TEST_PASSWORD);
         String newPath = u.getPath() + "_moved";
@@ -383,19 +409,16 @@ public class TestUserContentPackage exte
         // ensure that there is a rep:cache node
         assertNodeExists(newPath + "/rep:cache");
 
-        // install user pacakge
+        // install user package
         JcrPackage pack = packMgr.upload(getStream("testpackages/test_user_a.zip"), false);
         assertNotNull(pack);
         ImportOptions opts = getDefaultOptions();
-        opts.setImportMode(ImportMode.UPDATE);
+        opts.setImportMode(mode);
         pack.install(opts);
 
         // check if user exists
         User userA = (User) mgr.getAuthorizable(ID_TEST_USER_A);
         assertNotNull("test-user-a must exist", userA);
-
-        // check path
-        assertEquals("authorizable path must be correct", newPath, userA.getPath());
     }
 
     private User installUserA(ImportMode mode, boolean usePkgPath, boolean expectPkgPath)
throws RepositoryException, IOException, PackageException {



Mime
View raw message