You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by re...@apache.org on 2023/02/14 16:18:34 UTC

[jackrabbit-filevault] branch master updated: JCRVLT-685: stash-recover properties for ImportMode REPLACE as well (restoring pre JCRVLT-551 behavior) (#274)

This is an automated email from the ASF dual-hosted git repository.

reschke pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jackrabbit-filevault.git


The following commit(s) were added to refs/heads/master by this push:
     new 0a9b076a JCRVLT-685: stash-recover properties for ImportMode REPLACE as well (restoring pre JCRVLT-551 behavior) (#274)
0a9b076a is described below

commit 0a9b076a2d85ee40276d06ccef1c106a60221de1
Author: Julian Reschke <ju...@gmx.de>
AuthorDate: Tue Feb 14 17:18:29 2023 +0100

    JCRVLT-685: stash-recover properties for ImportMode REPLACE as well (restoring pre JCRVLT-551 behavior) (#274)
    
    * JCRVLT-684: test coverage and fix for bug in mixin restoration
    
    * fix mixin type decl
    
    * restrict test to Oak
    
    * JCRVLT-685: stash-recover properties for ImportMode REPLACE as well (restoring pre JCRVLT-551 behavior)
    
    * cleanup
---
 .../jackrabbit/vault/fs/impl/io/NodeStash.java      | 21 ++++++++++-----------
 .../vault/packaging/integration/NodeStashingIT.java | 15 ++++++++++++---
 2 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/NodeStash.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/NodeStash.java
index f0b265fd..7fe00803 100644
--- a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/NodeStash.java
+++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/NodeStash.java
@@ -187,16 +187,15 @@ public class NodeStash {
                     }
                 }
             }
-            if (importMode != ImportMode.REPLACE) {
-                try {
-                    recoverProperties(importMode==ImportMode.MERGE || importMode == ImportMode.MERGE_PROPERTIES);
-                } catch (RepositoryException e) {
-                    log.warn("Unable to restore properties at {} due to: {}. Properties will remain in temporary location: {}",
-                            path, e.getMessage(), tmpNode.getPath());
-                    if (importInfo != null) {
-                        importInfo.onError(path, e);
-                        hasErrors = true;
-                    }
+
+            try {
+                recoverProperties(importMode == ImportMode.MERGE || importMode == ImportMode.MERGE_PROPERTIES);
+            } catch (RepositoryException e) {
+                log.warn("Unable to restore properties at {} due to: {}. Properties will remain in temporary location: {}", path,
+                        e.getMessage(), tmpNode.getPath());
+                if (importInfo != null) {
+                    importInfo.onError(path, e);
+                    hasErrors = true;
                 }
             }
             if (!hasErrors) {
@@ -204,7 +203,7 @@ public class NodeStash {
             }
         }
     }
-    
+
     private void recoverProperties(boolean overwriteNewOnes) throws RepositoryException {
         Node destNode = session.getNode(path);
 
diff --git a/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/NodeStashingIT.java b/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/NodeStashingIT.java
index b5ce2dd5..4ab759ba 100644
--- a/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/NodeStashingIT.java
+++ b/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/NodeStashingIT.java
@@ -36,12 +36,21 @@ public class NodeStashingIT extends IntegrationTestBase {
     private static final String TESTNS = "https://issues.apache.org/jira/browse/JCRVLT-684";
 
     @Test
-    public void testStashMixinMandatoryChildNode() throws RepositoryException, IOException, PackageException {
+    public void testStashMixinMandatoryChildNodeModeReplace() throws RepositoryException, IOException, PackageException {
+        testStashMixinMandatoryChildNode(ImportMode.REPLACE);
+    }
+
+    @Test
+    public void testStashMixinMandatoryChildNodeModeMergeProperties() throws RepositoryException, IOException, PackageException {
+        testStashMixinMandatoryChildNode(ImportMode.MERGE_PROPERTIES);
+    }
+
+    private void testStashMixinMandatoryChildNode(ImportMode mode) throws RepositoryException, IOException, PackageException {
 
-        assumeTrue(isOak()); // see JCRVLT-687
+        assumeTrue(isOak());
 
         ImportOptions options = getDefaultOptions();
-        options.setImportMode(ImportMode.MERGE_PROPERTIES);
+        options.setImportMode(mode);
 
         // import test structure from package
         extractVaultPackage("/test-packages/stashing/create.zip", options);