From 8b65510d6f3936247cb6ce76d18b0c34130f7412 Mon Sep 17 00:00:00 2001 From: Britt Park Date: Tue, 5 Dec 2006 22:26:02 +0000 Subject: [PATCH] This checkin does two things: 1. Refines the semantics of ghost creation, so that they only appear when warranted. 2. Implements a mechanism for filtering out files which should not appear in comparison results or be pushed along by updates. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4525 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/action-services-context.xml | 3 + config/alfresco/avm-services-context.xml | 30 +++++ .../org/alfresco/repo/avm/AVMInterpreter.java | 5 +- .../org/alfresco/repo/avm/AVMServiceTest.java | 111 +++++++++--------- .../alfresco/repo/avm/AVMSyncServiceImpl.java | 96 ++++++++++----- .../repo/avm/AVMSyncServiceTransportImpl.java | 9 +- .../org/alfresco/repo/avm/AVMTestRemote.java | 8 +- .../repo/avm/LayeredDirectoryNodeImpl.java | 21 +++- .../repo/avm/PlainDirectoryNodeImpl.java | 19 ++- .../repo/avm/actions/AVMRevertListAction.java | 4 +- .../avm/actions/AVMRevertStoreAction.java | 4 +- .../avm/actions/SimpleAVMPromoteAction.java | 4 +- .../avm/actions/SimpleAVMSubmitAction.java | 20 +++- .../avm/util/FileExtensionNameMatcher.java | 57 +++++++++ .../repo/avm/wf/AVMSubmitHandler.java | 4 +- .../repo/avm/wf/AVMSubmitPackageHandler.java | 4 +- .../repo/remote/AVMSyncServiceClient.java | 14 ++- .../repo/workflow/WorkflowInterpreter.java | 4 +- .../service/cmr/avmsync/AVMSyncService.java | 8 +- .../cmr/remote/AVMSyncServiceTransport.java | 8 +- 20 files changed, 304 insertions(+), 129 deletions(-) create mode 100644 source/java/org/alfresco/repo/avm/util/FileExtensionNameMatcher.java diff --git a/config/alfresco/action-services-context.xml b/config/alfresco/action-services-context.xml index 4bd28877a8..e08637baee 100644 --- a/config/alfresco/action-services-context.xml +++ b/config/alfresco/action-services-context.xml @@ -404,6 +404,9 @@ + + + false diff --git a/config/alfresco/avm-services-context.xml b/config/alfresco/avm-services-context.xml index 9da214476f..ec6f032d1a 100644 --- a/config/alfresco/avm-services-context.xml +++ b/config/alfresco/avm-services-context.xml @@ -243,6 +243,36 @@ + + + + + + .*/#.* + + + + + + + + .o + .bak + .tmp + ~ + + + + + + + + + + + + + diff --git a/source/java/org/alfresco/repo/avm/AVMInterpreter.java b/source/java/org/alfresco/repo/avm/AVMInterpreter.java index 1e2bf3e946..659bbe0d08 100644 --- a/source/java/org/alfresco/repo/avm/AVMInterpreter.java +++ b/source/java/org/alfresco/repo/avm/AVMInterpreter.java @@ -471,7 +471,8 @@ public class AVMInterpreter List diffs = fSyncService.compare(Integer.parseInt(command[2]), command[1], Integer.parseInt(command[4]), - command[3]); + command[3], + null); for (AVMDifference diff : diffs) { out.println(diff); @@ -487,7 +488,7 @@ public class AVMInterpreter -1, command[3], AVMDifference.NEWER); List diffs = new ArrayList(); diffs.add(diff); - fSyncService.update(diffs, false, false, false, false, null, null); + fSyncService.update(diffs, null, false, false, false, false, null, null); } else if (command[0].equals("resetLayer")) { diff --git a/source/java/org/alfresco/repo/avm/AVMServiceTest.java b/source/java/org/alfresco/repo/avm/AVMServiceTest.java index f4915c798e..a681e3d6c2 100644 --- a/source/java/org/alfresco/repo/avm/AVMServiceTest.java +++ b/source/java/org/alfresco/repo/avm/AVMServiceTest.java @@ -38,7 +38,6 @@ import org.alfresco.repo.avm.actions.AVMUndoSandboxListAction; import org.alfresco.repo.avm.actions.SimpleAVMPromoteAction; import org.alfresco.repo.avm.actions.SimpleAVMSubmitAction; import org.alfresco.repo.avm.util.BulkLoader; -import org.alfresco.repo.avm.util.VersionPathStuffer; import org.alfresco.repo.domain.PropertyValue; import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.repo.transaction.TransactionUtil; @@ -61,6 +60,7 @@ import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.GUID; +import org.alfresco.util.NameMatcher; import org.alfresco.util.Pair; /** @@ -209,13 +209,13 @@ public class AVMServiceTest extends AVMServiceTestBase diffs.add(new AVMDifference(-1, "layer:/a/b/c/foo", -1, "main:/a/b/c/foo", AVMDifference.NEWER)); - fSyncService.update(diffs, false, false, false, false, null, null); + fSyncService.update(diffs, null, false, false, false, false, null, null); fSyncService.flatten("layer:/a", "main:/a"); AVMNodeDescriptor b = fService.lookup(-1, "layer:/a/b"); assertTrue(b.isLayeredDirectory()); AVMNodeDescriptor c = fService.lookup(-1, "layer:/a/b/c"); assertTrue(c.isPlainDirectory()); - assertEquals(1, fSyncService.compare(-1, "layer:/a", -1, "main:/a").size()); + assertEquals(1, fSyncService.compare(-1, "layer:/a", -1, "main:/a", null).size()); } catch (Exception e) { @@ -260,11 +260,11 @@ public class AVMServiceTest extends AVMServiceTestBase fService.createAVMStore("area"); fService.createLayeredDirectory("main:/a", "area:/", "a"); fService.getFileOutputStream("area:/a/b/c/foo").close(); - List diffs = fSyncService.compare(-1, "area:/a", -1, "main:/a"); + List diffs = fSyncService.compare(-1, "area:/a", -1, "main:/a", null); assertEquals(1, diffs.size()); - fSyncService.update(diffs, false, false, false, false, null, null); + fSyncService.update(diffs, null, false, false, false, false, null, null); fService.getFileOutputStream("area:/a/b/c/bar").close(); - diffs = fSyncService.compare(-1, "area:/a", -1, "main:/a"); + diffs = fSyncService.compare(-1, "area:/a", -1, "main:/a", null); assertEquals(1, diffs.size()); final ActionImpl action = new ActionImpl(null, GUID.generate(), @@ -289,7 +289,7 @@ public class AVMServiceTest extends AVMServiceTestBase }; TransactionUtil.executeInUserTransaction((TransactionService)fContext.getBean("transactionComponent"), new TxnWork()); - diffs = fSyncService.compare(-1, "area:/a", -1, "main:/a"); + diffs = fSyncService.compare(-1, "area:/a", -1, "main:/a", null); assertEquals(0, diffs.size()); System.out.println(recursiveList("area", -1, true)); System.out.println(recursiveList("main", -1, true)); @@ -312,11 +312,11 @@ public class AVMServiceTest extends AVMServiceTestBase fService.createAVMStore("area"); fService.createLayeredDirectory("main:/a", "area:/", "a"); fService.getFileOutputStream("area:/a/b/c/foo").close(); - List diffs = fSyncService.compare(-1, "area:/a", -1, "main:/a"); + List diffs = fSyncService.compare(-1, "area:/a", -1, "main:/a", null); assertEquals(1, diffs.size()); - fSyncService.update(diffs, false, false, false, false, null, null); + fSyncService.update(diffs, null, false, false, false, false, null, null); fService.getFileOutputStream("area:/a/b/c/bar").close(); - diffs = fSyncService.compare(-1, "area:/a", -1, "main:/a"); + diffs = fSyncService.compare(-1, "area:/a", -1, "main:/a", null); assertEquals(1, diffs.size()); final ActionImpl action = new ActionImpl(null, GUID.generate(), @@ -336,7 +336,7 @@ public class AVMServiceTest extends AVMServiceTestBase }; TransactionUtil.executeInUserTransaction((TransactionService)fContext.getBean("transactionComponent"), new TxnWork()); - diffs = fSyncService.compare(-1, "area:/a", -1, "main:/a"); + diffs = fSyncService.compare(-1, "area:/a", -1, "main:/a", null); assertEquals(0, diffs.size()); System.out.println(recursiveList("area", -1, true)); System.out.println(recursiveList("main", -1, true)); @@ -378,7 +378,7 @@ public class AVMServiceTest extends AVMServiceTestBase }; TransactionUtil.executeInUserTransaction((TransactionService)fContext.getBean("transactionComponent"), new TxnWork()); - assertEquals(0, fSyncService.compare(-1, "source:/appBase", -1, "main:/appBase").size()); + assertEquals(0, fSyncService.compare(-1, "source:/appBase", -1, "main:/appBase", null).size()); } catch (Exception e) { @@ -396,15 +396,15 @@ public class AVMServiceTest extends AVMServiceTestBase { setupBasicTree(); fService.createAVMStore("staging"); - List diffs = fSyncService.compare(-1, "main:/", -1, "staging:/"); + List diffs = fSyncService.compare(-1, "main:/", -1, "staging:/", null); assertEquals(2, diffs.size()); List noodle = new ArrayList(); noodle.add(new AVMDifference(-1, "main:/a/b/c/foo", -1, "staging:/a/b/c/foo", AVMDifference.NEWER)); noodle.add(new AVMDifference(-1, "main:/d", -1, "staging:/d", AVMDifference.NEWER)); - fSyncService.update(noodle, false, false, false, false, null, null); - diffs = fSyncService.compare(-1, "main:/", -1, "staging:/"); + fSyncService.update(noodle, null, false, false, false, false, null, null); + diffs = fSyncService.compare(-1, "main:/", -1, "staging:/", null); assertEquals(1, diffs.size()); assertEquals("main:/a/b/c/bar", diffs.get(0).getSourcePath()); } @@ -437,7 +437,7 @@ public class AVMServiceTest extends AVMServiceTestBase fService.getFileOutputStream("area:/appBase/a/b/c/foo").close(); fService.removeNode("area:/appBase/a/b/c/bar"); List diffs = - fSyncService.compare(-1, "area:/appBase", -1, "foo-staging:/appBase"); + fSyncService.compare(-1, "area:/appBase", -1, "foo-staging:/appBase", null); assertEquals(3, diffs.size()); final SimpleAVMSubmitAction action = (SimpleAVMSubmitAction)fContext.getBean("simple-avm-submit"); class TxnWork implements TransactionUtil.TransactionWork @@ -452,7 +452,7 @@ public class AVMServiceTest extends AVMServiceTestBase TransactionUtil.executeInUserTransaction((TransactionService)fContext.getBean("transactionComponent"), worker); diffs = - fSyncService.compare(-1, "area:/appBase", -1, "foo-staging:/appBase"); + fSyncService.compare(-1, "area:/appBase", -1, "foo-staging:/appBase", null); assertEquals(0, diffs.size()); } catch (Exception e) @@ -504,17 +504,17 @@ public class AVMServiceTest extends AVMServiceTestBase loader.recursiveLoad("config/alfresco/extension", "source:/"); int version2 = fService.createSnapshot("source", null, null); List diffs = - fSyncService.compare(version1, "source:/", -1, "dest:/"); + fSyncService.compare(version1, "source:/", -1, "dest:/", null); fService.createSnapshot("dest", null, null); assertEquals(1, diffs.size()); - fSyncService.update(diffs, false, false, false, false, null, null); - diffs = fSyncService.compare(version1, "source:/", -1, "dest:/"); + fSyncService.update(diffs, null, false, false, false, false, null, null); + diffs = fSyncService.compare(version1, "source:/", -1, "dest:/", null); assertEquals(0, diffs.size()); - diffs = fSyncService.compare(version2, "source:/", -1, "dest:/"); + diffs = fSyncService.compare(version2, "source:/", -1, "dest:/", null); assertEquals(1, diffs.size()); - fSyncService.update(diffs, false, false, false, false, null, null); + fSyncService.update(diffs, null, false, false, false, false, null, null); fService.createSnapshot("dest", null, null); - diffs = fSyncService.compare(version2, "source:/", -1, "dest:/"); + diffs = fSyncService.compare(version2, "source:/", -1, "dest:/", null); assertEquals(0, diffs.size()); } catch (Exception e) @@ -539,11 +539,11 @@ public class AVMServiceTest extends AVMServiceTestBase fService.getFileOutputStream("branch:/branch/a/b/c/foo").close(); fService.removeNode("branch:/branch/a/b/c", "bar"); List diffs = - fSyncService.compare(-1, "branch:/branch", -1, "main:/"); + fSyncService.compare(-1, "branch:/branch", -1, "main:/", null); assertEquals(3, diffs.size()); // Now update. - fSyncService.update(diffs, false, false, false, false, null, null); - diffs = fSyncService.compare(-1, "branch:/branch", -1, "main:/"); + fSyncService.update(diffs, null, false, false, false, false, null, null); + diffs = fSyncService.compare(-1, "branch:/branch", -1, "main:/", null); assertEquals(0, diffs.size()); fService.getFileOutputStream("branch:/branch/a/b/fing").close(); assertTrue(fService.lookup(-1, "branch:/branch/a/b/fing").getId() != @@ -591,12 +591,12 @@ public class AVMServiceTest extends AVMServiceTestBase fService.createAVMStore("layer"); fService.createLayeredDirectory("main:/", "layer:/", "layer"); loader.recursiveLoad("config/alfresco/bootstrap", "layer:/layer"); - List diffs = fSyncService.compare(-1, "layer:/layer", -1, "main:/"); + List diffs = fSyncService.compare(-1, "layer:/layer", -1, "main:/", null); assertEquals(1, diffs.size()); fService.createSnapshot("layer", null, null); - fSyncService.update(diffs, false, false, false, false, null, null); + fSyncService.update(diffs, null, false, false, false, false, null, null); fService.createSnapshot("main", null, null); - diffs = fSyncService.compare(-1, "layer:/layer", -1, "main:/"); + diffs = fSyncService.compare(-1, "layer:/layer", -1, "main:/", null); assertEquals(0, diffs.size()); fSyncService.flatten("layer:/layer", "main:/"); System.out.println("Layer:"); @@ -607,13 +607,13 @@ public class AVMServiceTest extends AVMServiceTestBase fService.createLayeredDirectory("layer:/layer", "layer2:/", "layer"); loader.recursiveLoad("config/alfresco/bootstrap", "layer2:/layer/bootstrap"); fService.createSnapshot("layer2", null, null); - diffs = fSyncService.compare(-1, "layer2:/layer", -1, "layer:/layer"); + diffs = fSyncService.compare(-1, "layer2:/layer", -1, "layer:/layer", null); assertEquals(1, diffs.size()); - fSyncService.update(diffs, false, false, false, false, null, null); - diffs = fSyncService.compare(-1, "layer2:/layer", -1, "layer:/layer"); + fSyncService.update(diffs, null, false, false, false, false, null, null); + diffs = fSyncService.compare(-1, "layer2:/layer", -1, "layer:/layer", null); assertEquals(0, diffs.size()); fSyncService.flatten("layer2:/layer", "layer:/layer"); - diffs = fSyncService.compare(-1, "layer:/layer", -1, "main:/"); + diffs = fSyncService.compare(-1, "layer:/layer", -1, "main:/", null); assertEquals(1, diffs.size()); System.out.println("Layer2:"); System.out.println(recursiveList("layer2", -1, true)); @@ -647,13 +647,13 @@ public class AVMServiceTest extends AVMServiceTestBase System.out.println(recursiveList("main", -1, true)); // Do a compare. List diffs = - fSyncService.compare(-1, "main:/layer", -1, "main:/a"); + fSyncService.compare(-1, "main:/layer", -1, "main:/a", null); for (AVMDifference diff : diffs) { System.out.println(diff); } // Update. - fSyncService.update(diffs, false, false, false, false, null, null); + fSyncService.update(diffs, null, false, false, false, false, null, null); System.out.println(recursiveList("main", -1, true)); // Flatten. fSyncService.flatten("main:/layer", "main:/a"); @@ -701,14 +701,17 @@ public class AVMServiceTest extends AVMServiceTestBase { try { + NameMatcher excluder = (NameMatcher)fContext.getBean("globalPathExcluder"); setupBasicTree(); // Try branch to branch update. fService.createBranch(-1, "main:/a", "main:/", "abranch"); fService.createFile("main:/abranch", "monkey").close(); + fService.createFile("main:/abranch", "#foo").close(); + fService.createFile("main:/abranch", "figs.tmp").close(); fService.getFileOutputStream("main:/abranch/b/c/foo").close(); System.out.println(recursiveList("main", -1, true)); List cmp = - fSyncService.compare(-1, "main:/abranch", -1, "main:/a"); + fSyncService.compare(-1, "main:/abranch", -1, "main:/a", excluder); for (AVMDifference diff : cmp) { System.out.println(diff); @@ -721,7 +724,7 @@ public class AVMServiceTest extends AVMServiceTestBase diffs.add(new AVMDifference(-1, "main:/abranch/b/c/foo", -1, "main:/a/b/c/foo", AVMDifference.NEWER)); - fSyncService.update(diffs, false, false, false, false, null, null); + fSyncService.update(diffs, null, false, false, false, false, null, null); fService.createSnapshot("main", null, null); System.out.println(recursiveList("main", -1, true)); assertEquals(fService.lookup(-1, "main:/abranch/monkey").getId(), @@ -732,7 +735,7 @@ public class AVMServiceTest extends AVMServiceTestBase fService.removeNode("main:/abranch", "monkey"); System.out.println(recursiveList("main", -1, true)); cmp = - fSyncService.compare(-1, "main:/abranch", -1, "main:/a"); + fSyncService.compare(-1, "main:/abranch", -1, "main:/a", excluder); for (AVMDifference diff : cmp) { System.out.println(diff); @@ -742,8 +745,8 @@ public class AVMServiceTest extends AVMServiceTestBase diffs.add(new AVMDifference(-1, "main:/abranch/monkey", -1, "main:/a/monkey", AVMDifference.NEWER)); - fSyncService.update(diffs, false, false, false, false, null, null); - assertEquals(0, fSyncService.compare(-1, "main:/abranch", -1, "main:/a").size()); + fSyncService.update(diffs, null, false, false, false, false, null, null); + assertEquals(0, fSyncService.compare(-1, "main:/abranch", -1, "main:/a", excluder).size()); fService.createSnapshot("main", null, null); System.out.println(recursiveList("main", -1, true)); assertEquals(fService.lookup(-1, "main:/abranch/monkey", true).getId(), @@ -751,7 +754,7 @@ public class AVMServiceTest extends AVMServiceTestBase // Try one that should fail. fService.createFile("main:/abranch", "monkey").close(); cmp = - fSyncService.compare(-1, "main:/abranch", -1, "main:/a"); + fSyncService.compare(-1, "main:/abranch", -1, "main:/a", excluder); for (AVMDifference diff : cmp) { System.out.println(diff); @@ -763,7 +766,7 @@ public class AVMServiceTest extends AVMServiceTestBase AVMDifference.NEWER)); try { - fSyncService.update(diffs, false, false, false, false, null, null); + fSyncService.update(diffs, null, false, false, false, false, null, null); fail(); } catch (AVMSyncException se) @@ -776,8 +779,8 @@ public class AVMServiceTest extends AVMServiceTestBase diffs.add(new AVMDifference(-1, "main:/a/monkey", -1, "main:/abranch/monkey", AVMDifference.NEWER)); - fSyncService.update(diffs, false, false, true, false, null, null); - assertEquals(0, fSyncService.compare(-1, "main:/abranch", -1, "main:/a").size()); + fSyncService.update(diffs, null, false, false, true, false, null, null); + assertEquals(0, fSyncService.compare(-1, "main:/abranch", -1, "main:/a", excluder).size()); fService.createSnapshot("main", null, null); System.out.println(recursiveList("main", -1, true)); assertEquals(fService.lookup(-1, "main:/a/monkey", true).getId(), @@ -790,7 +793,7 @@ public class AVMServiceTest extends AVMServiceTestBase fService.createFile("main:/layer", "monkey").close(); fService.getFileOutputStream("main:/layer/b/c/foo").close(); cmp = - fSyncService.compare(-1, "main:/layer", -1, "main:/a"); + fSyncService.compare(-1, "main:/layer", -1, "main:/a", excluder); for (AVMDifference diff : cmp) { System.out.println(diff); @@ -804,8 +807,8 @@ public class AVMServiceTest extends AVMServiceTestBase diffs.add(new AVMDifference(-1, "main:/layer/b/c/foo", -1, "main:/a/b/c/foo", AVMDifference.NEWER)); - fSyncService.update(diffs, false, false, false, false, null, null); - assertEquals(0, fSyncService.compare(-1, "main:/layer", -1, "main:/a").size()); + fSyncService.update(diffs, null, false, false, false, false, null, null); + assertEquals(0, fSyncService.compare(-1, "main:/layer", -1, "main:/a", excluder).size()); fService.createSnapshot("main", null, null); System.out.println(recursiveList("main", -1, true)); assertEquals(fService.lookup(-1, "main:/layer/monkey").getId(), @@ -816,7 +819,7 @@ public class AVMServiceTest extends AVMServiceTestBase fService.removeNode("main:/layer", "monkey"); System.out.println(recursiveList("main", -1, true)); cmp = - fSyncService.compare(-1, "main:/layer", -1, "main:/a"); + fSyncService.compare(-1, "main:/layer", -1, "main:/a", excluder); for (AVMDifference diff : cmp) { System.out.println(diff); @@ -826,8 +829,8 @@ public class AVMServiceTest extends AVMServiceTestBase diffs.add(new AVMDifference(-1, "main:/layer/monkey", -1, "main:/a/monkey", AVMDifference.NEWER)); - fSyncService.update(diffs, false, false, false, false, null, null); - assertEquals(0, fSyncService.compare(-1, "main:/layer", -1, "main:/a").size()); + fSyncService.update(diffs, null, false, false, false, false, null, null); + assertEquals(0, fSyncService.compare(-1, "main:/layer", -1, "main:/a", excluder).size()); fService.createSnapshot("main", null, null); System.out.println(recursiveList("main", -1, true)); assertEquals(fService.lookup(-1, "main:/layer/monkey", true).getId(), @@ -835,7 +838,7 @@ public class AVMServiceTest extends AVMServiceTestBase // Try one that should fail. fService.createFile("main:/layer", "monkey").close(); cmp = - fSyncService.compare(-1, "main:/layer", -1, "main:/a"); + fSyncService.compare(-1, "main:/layer", -1, "main:/a", excluder); for (AVMDifference diff : cmp) { System.out.println(diff); @@ -847,7 +850,7 @@ public class AVMServiceTest extends AVMServiceTestBase AVMDifference.NEWER)); try { - fSyncService.update(diffs, false, false, false, false, null, null); + fSyncService.update(diffs, null, false, false, false, false, null, null); fail(); } catch (AVMSyncException se) @@ -860,8 +863,8 @@ public class AVMServiceTest extends AVMServiceTestBase diffs.add(new AVMDifference(-1, "main:/a/monkey", -1, "main:/layer/monkey", AVMDifference.NEWER)); - fSyncService.update(diffs, false, false, true, false, null, null); - assertEquals(0, fSyncService.compare(-1, "main:/layer", -1, "main:/a").size()); + fSyncService.update(diffs, null, false, false, true, false, null, null); + assertEquals(0, fSyncService.compare(-1, "main:/layer", -1, "main:/a", excluder).size()); fService.createSnapshot("main", null, null); System.out.println(recursiveList("main", -1, true)); assertEquals(fService.lookup(-1, "main:/a/monkey", true).getId(), diff --git a/source/java/org/alfresco/repo/avm/AVMSyncServiceImpl.java b/source/java/org/alfresco/repo/avm/AVMSyncServiceImpl.java index fa4bf4f155..e6392a4814 100644 --- a/source/java/org/alfresco/repo/avm/AVMSyncServiceImpl.java +++ b/source/java/org/alfresco/repo/avm/AVMSyncServiceImpl.java @@ -24,16 +24,14 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.alfresco.repo.domain.PropertyValue; import org.alfresco.service.cmr.avm.AVMBadArgumentException; import org.alfresco.service.cmr.avm.AVMNodeDescriptor; import org.alfresco.service.cmr.avm.AVMNotFoundException; import org.alfresco.service.cmr.avm.AVMService; -import org.alfresco.service.cmr.avm.AVMWrongTypeException; import org.alfresco.service.cmr.avmsync.AVMDifference; import org.alfresco.service.cmr.avmsync.AVMSyncException; import org.alfresco.service.cmr.avmsync.AVMSyncService; -import org.alfresco.service.namespace.QName; +import org.alfresco.util.NameMatcher; import org.apache.log4j.Logger; /** @@ -83,11 +81,13 @@ public class AVMSyncServiceImpl implements AVMSyncService * @param srcPath The avm path to the source tree. * @param dstVersion The version id for the destination tree. * @param dstPath The avm path to the destination tree. + * @param excluder A NameMatcher used to exclude files from consideration. * @return A List of AVMDifference structs which can be used for * the update operation. */ public List compare(int srcVersion, String srcPath, - int dstVersion, String dstPath) + int dstVersion, String dstPath, + NameMatcher excluder) { if (srcPath == null || dstPath == null) { @@ -110,7 +110,7 @@ public class AVMSyncServiceImpl implements AVMSyncService else { // Invoke the recursive implementation. - compare(srcVersion, srcDesc, dstVersion, dstDesc, result); + compare(srcVersion, srcDesc, dstVersion, dstDesc, result, excluder); } return result; } @@ -124,9 +124,14 @@ public class AVMSyncServiceImpl implements AVMSyncService */ private void compare(int srcVersion, AVMNodeDescriptor srcDesc, int dstVersion, AVMNodeDescriptor dstDesc, - List result) + List result, NameMatcher excluder) { // Determine how the source and destination nodes differ. + if (excluder != null && (excluder.matches(srcDesc.getPath()) || + excluder.matches(dstDesc.getPath()))) + { + return; + } int diffCode = compareOne(srcDesc, dstDesc); switch (diffCode) { @@ -168,19 +173,25 @@ public class AVMSyncServiceImpl implements AVMSyncService { AVMNodeDescriptor srcChild = srcList.get(name); AVMNodeDescriptor dstChild = dstList.get(name); + String dstPath = AVMNodeConverter.ExtendAVMPath(dstDesc.getPath(), name); + if (excluder != null && (excluder.matches(srcChild.getPath()) || + excluder.matches(dstPath))) + { + continue; + } if (dstChild == null) { // A missing destination child means the source is NEWER. result.add(new AVMDifference(srcVersion, srcChild.getPath(), - dstVersion, - AVMNodeConverter.ExtendAVMPath(dstDesc.getPath(), name), - AVMDifference.NEWER)); + dstVersion, + dstPath, + AVMDifference.NEWER)); continue; } // Otherwise recursively invoke. compare(srcVersion, srcChild, dstVersion, dstChild, - result); + result, excluder); } return; } @@ -203,11 +214,17 @@ public class AVMSyncServiceImpl implements AVMSyncService { AVMNodeDescriptor dstChild = dstList.get(name); AVMNodeDescriptor srcChild = srcList.get(name); + String srcPath = AVMNodeConverter.ExtendAVMPath(srcDesc.getPath(), name); + if (excluder != null && (excluder.matches(srcPath) || + excluder.matches(dstChild.getPath()))) + { + continue; + } if (srcChild == null) { // Missing means the source is older. result.add(new AVMDifference(srcVersion, - AVMNodeConverter.ExtendAVMPath(srcDesc.getPath(), name), + srcPath, dstVersion, dstChild.getPath(), AVMDifference.OLDER)); continue; @@ -215,7 +232,7 @@ public class AVMSyncServiceImpl implements AVMSyncService // Otherwise, recursively invoke. compare(srcVersion, srcChild, dstVersion, dstChild, - result); + result, excluder); } return; } @@ -229,19 +246,25 @@ public class AVMSyncServiceImpl implements AVMSyncService { AVMNodeDescriptor srcChild = srcList.get(name); AVMNodeDescriptor dstChild = dstList.get(name); + String dstPath = AVMNodeConverter.ExtendAVMPath(dstDesc.getPath(), name); + if (excluder != null && (excluder.matches(srcChild.getPath()) || + excluder.matches(dstPath))) + { + continue; + } if (dstChild == null) { // Not found in the destination means NEWER. result.add(new AVMDifference(srcVersion, srcChild.getPath(), dstVersion, - AVMNodeConverter.ExtendAVMPath(dstDesc.getPath(), name), + dstPath, AVMDifference.NEWER)); continue; } // Otherwise recursive invocation. compare(srcVersion, srcChild, dstVersion, dstChild, - result); + result, excluder); } // Iterate over the destination. for (String name : dstList.keySet()) @@ -251,9 +274,15 @@ public class AVMSyncServiceImpl implements AVMSyncService continue; } AVMNodeDescriptor dstChild = dstList.get(name); + String srcPath = AVMNodeConverter.ExtendAVMPath(srcDesc.getPath(), name); + if (excluder != null && (excluder.matches(srcPath) || + excluder.matches(dstChild.getPath()))) + { + continue; + } // An entry not found in the source is OLDER. result.add(new AVMDifference(srcVersion, - AVMNodeConverter.ExtendAVMPath(srcDesc.getPath(), name), + srcPath, dstVersion, dstChild.getPath(), AVMDifference.OLDER)); } @@ -272,6 +301,7 @@ public class AVMSyncServiceImpl implements AVMSyncService * which the source of an AVMDifference is older than the destination * will cause the transaction to roll back. * @param diffList A List of AVMDifference structs. + * @param excluder A possibly null name matcher to exclude unwanted updates. * @param ignoreConflicts If this is true the update will skip those * AVMDifferences which are in conflict with * the destination. @@ -284,13 +314,19 @@ public class AVMSyncServiceImpl implements AVMSyncService * @param description Full update blurb. * in which the source is older than the destination and overwrite the destination. */ - public void update(List diffList, boolean ignoreConflicts, boolean ignoreOlder, + public void update(List diffList, + NameMatcher excluder, boolean ignoreConflicts, boolean ignoreOlder, boolean overrideConflicts, boolean overrideOlder, String tag, String description) { Map storeVersions = new HashMap(); Set destStores = new HashSet(); for (AVMDifference diff : diffList) { + if (excluder != null && (excluder.matches(diff.getSourcePath()) || + excluder.matches(diff.getDestinationPath()))) + { + continue; + } if (!diff.isValid()) { throw new AVMSyncException("Malformed AVMDifference."); @@ -317,10 +353,6 @@ public class AVMSyncServiceImpl implements AVMSyncService } AVMNodeDescriptor srcDesc = fAVMService.lookup(version, diff.getSourcePath(), true); -// if (srcDesc == null) -// { -// throw new AVMSyncException("Source node not found: " + diff.getSourcePath()); -// } String [] dstParts = AVMNodeConverter.SplitBase(diff.getDestinationPath()); if (dstParts[0] == null || diff.getDestinationVersion() >= 0) { @@ -350,7 +382,7 @@ public class AVMSyncServiceImpl implements AVMSyncService case AVMDifference.NEWER : { // You can't delete what isn't there. - linkIn(dstParts[0], dstParts[1], srcDesc, dstDesc != null); + linkIn(dstParts[0], dstParts[1], srcDesc, excluder, dstDesc != null); continue; } case AVMDifference.OLDER : @@ -358,7 +390,7 @@ public class AVMSyncServiceImpl implements AVMSyncService // You can force it. if (overrideOlder) { - linkIn(dstParts[0], dstParts[1], srcDesc, !dstDesc.isDeleted()); + linkIn(dstParts[0], dstParts[1], srcDesc, excluder, !dstDesc.isDeleted()); continue; } // You can ignore it. @@ -374,7 +406,7 @@ public class AVMSyncServiceImpl implements AVMSyncService // You can force it. if (overrideConflicts) { - linkIn(dstParts[0], dstParts[1], srcDesc, true); + linkIn(dstParts[0], dstParts[1], srcDesc, excluder, true); continue; } // You can ignore it. @@ -414,7 +446,7 @@ public class AVMSyncServiceImpl implements AVMSyncService * @param toLink The node descriptor. * @param removeFirst Whether to do a removeNode before linking in. */ - private void linkIn(String parentPath, String name, AVMNodeDescriptor toLink, boolean removeFirst) + private void linkIn(String parentPath, String name, AVMNodeDescriptor toLink, NameMatcher excluder, boolean removeFirst) { // This is a delete. if (toLink == null) @@ -429,7 +461,7 @@ public class AVMSyncServiceImpl implements AVMSyncService } if (toLink.isLayeredDirectory() && !toLink.isPrimary()) { - recursiveCopy(parentPath, name, toLink); + recursiveCopy(parentPath, name, toLink, excluder); return; } fAVMService.link(parentPath, name, toLink); @@ -441,7 +473,7 @@ public class AVMSyncServiceImpl implements AVMSyncService * @param name The name to give it. * @param toCopy The it to put. */ - private void recursiveCopy(String parentPath, String name, AVMNodeDescriptor toCopy) + private void recursiveCopy(String parentPath, String name, AVMNodeDescriptor toCopy, NameMatcher excluder) { fAVMService.createDirectory(parentPath, name); String newParentPath = AVMNodeConverter.ExtendAVMPath(parentPath, name); @@ -451,7 +483,7 @@ public class AVMSyncServiceImpl implements AVMSyncService fAVMService.getDirectoryListing(toCopy, true); for (Map.Entry entry : children.entrySet()) { - recursiveCopy(parentDesc, entry.getKey(), entry.getValue()); + recursiveCopy(parentDesc, entry.getKey(), entry.getValue(), excluder); } } @@ -461,8 +493,14 @@ public class AVMSyncServiceImpl implements AVMSyncService * @param name The name to link in. * @param toCopy The node to link in. */ - private void recursiveCopy(AVMNodeDescriptor parent, String name, AVMNodeDescriptor toCopy) + private void recursiveCopy(AVMNodeDescriptor parent, String name, AVMNodeDescriptor toCopy, NameMatcher excluder) { + String newPath = AVMNodeConverter.ExtendAVMPath(parent.getPath(), name); + if (excluder != null && (excluder.matches(newPath) || + excluder.matches(toCopy.getPath()))) + { + return; + } // If it's a file or deleted simply link it in. if (toCopy.isFile() || toCopy.isDeleted() || toCopy.isPlainDirectory()) { @@ -477,7 +515,7 @@ public class AVMSyncServiceImpl implements AVMSyncService fAVMService.getDirectoryListing(toCopy, true); for (Map.Entry entry : children.entrySet()) { - recursiveCopy(newParentDesc, entry.getKey(), entry.getValue()); + recursiveCopy(newParentDesc, entry.getKey(), entry.getValue(), excluder); } } diff --git a/source/java/org/alfresco/repo/avm/AVMSyncServiceTransportImpl.java b/source/java/org/alfresco/repo/avm/AVMSyncServiceTransportImpl.java index 7492e38653..1fd011ee93 100644 --- a/source/java/org/alfresco/repo/avm/AVMSyncServiceTransportImpl.java +++ b/source/java/org/alfresco/repo/avm/AVMSyncServiceTransportImpl.java @@ -9,6 +9,7 @@ import org.alfresco.service.cmr.avmsync.AVMDifference; import org.alfresco.service.cmr.avmsync.AVMSyncService; import org.alfresco.service.cmr.remote.AVMSyncServiceTransport; import org.alfresco.service.cmr.security.AuthenticationService; +import org.alfresco.util.NameMatcher; /** * Server side implementation of the remote wrapper of AVMSyncService. @@ -47,10 +48,10 @@ public class AVMSyncServiceTransportImpl implements AVMSyncServiceTransport * @see org.alfresco.service.cmr.avmsync.AVMSyncServiceTransport#compare(java.lang.String, int, java.lang.String, int, java.lang.String) */ public List compare(String ticket, int srcVersion, - String srcPath, int dstVersion, String dstPath) + String srcPath, int dstVersion, String dstPath, NameMatcher excluder) { fAuthenticationService.validate(ticket); - return fSyncService.compare(srcVersion, srcPath, dstVersion, dstPath); + return fSyncService.compare(srcVersion, srcPath, dstVersion, dstPath, excluder); } /* (non-Javadoc) @@ -74,12 +75,12 @@ public class AVMSyncServiceTransportImpl implements AVMSyncServiceTransport /* (non-Javadoc) * @see org.alfresco.service.cmr.avmsync.AVMSyncServiceTransport#update(java.lang.String, java.util.List, boolean, boolean, boolean, boolean, java.lang.String, java.lang.String) */ - public void update(String ticket, List diffList, + public void update(String ticket, List diffList, NameMatcher excluder, boolean ignoreConflicts, boolean ignoreOlder, boolean overrideConflicts, boolean overrideOlder, String tag, String description) { fAuthenticationService.validate(ticket); - fSyncService.update(diffList, ignoreConflicts, ignoreOlder, overrideConflicts, overrideOlder, tag, description); + fSyncService.update(diffList, excluder, ignoreConflicts, ignoreOlder, overrideConflicts, overrideOlder, tag, description); } } diff --git a/source/java/org/alfresco/repo/avm/AVMTestRemote.java b/source/java/org/alfresco/repo/avm/AVMTestRemote.java index 25d7d8f5ed..d99f631244 100644 --- a/source/java/org/alfresco/repo/avm/AVMTestRemote.java +++ b/source/java/org/alfresco/repo/avm/AVMTestRemote.java @@ -199,14 +199,14 @@ public class AVMTestRemote extends TestCase fAVMRemote.createAVMStore("broo"); // Create a branch. fAVMRemote.createBranch(-1, "froo:/a", "broo:/", "a"); - List diffs = fAVMSync.compare(-1, "froo:/a", -1, "broo:/a"); + List diffs = fAVMSync.compare(-1, "froo:/a", -1, "broo:/a", null); assertEquals(0, diffs.size()); fAVMRemote.createFile("froo:/a", "bar").close(); - diffs = fAVMSync.compare(-1, "froo:/a", -1, "broo:/a"); + diffs = fAVMSync.compare(-1, "froo:/a", -1, "broo:/a", null); assertEquals(1, diffs.size()); // Update. - fAVMSync.update(diffs, false, false, false, false, "flippy", "Stuff"); - diffs = fAVMSync.compare(-1, "froo:/a", -1, "broo:/a"); + fAVMSync.update(diffs, null, false, false, false, false, "flippy", "Stuff"); + diffs = fAVMSync.compare(-1, "froo:/a", -1, "broo:/a", null); assertEquals(0, diffs.size()); } catch (Exception e) diff --git a/source/java/org/alfresco/repo/avm/LayeredDirectoryNodeImpl.java b/source/java/org/alfresco/repo/avm/LayeredDirectoryNodeImpl.java index d29a0d367a..1dc2c39ab3 100644 --- a/source/java/org/alfresco/repo/avm/LayeredDirectoryNodeImpl.java +++ b/source/java/org/alfresco/repo/avm/LayeredDirectoryNodeImpl.java @@ -555,6 +555,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec ChildKey key = new ChildKey(this, name); ChildEntry entry = AVMDAOs.Instance().fChildEntryDAO.get(key); AVMNode child = null; + boolean indirect = false; if (entry != null) { child = entry.getChild(); @@ -567,13 +568,21 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec else { child = lookupChild(lPath, name, false); + indirect = true; + } + if (child != null && (indirect || child.getStoreNew() == null || child.getAncestor() != null)) + { + AVMNode ghost = new DeletedNodeImpl(lPath.getAVMStore().getAVMRepository().issueID(), + lPath.getAVMStore()); + AVMDAOs.Instance().fAVMNodeDAO.save(ghost); + AVMDAOs.Instance().fAVMNodeDAO.flush(); + ghost.setAncestor(child); + this.putChild(name, ghost); + } + else + { + AVMDAOs.Instance().fAVMNodeDAO.flush(); } - AVMNode ghost = new DeletedNodeImpl(lPath.getAVMStore().getAVMRepository().issueID(), - lPath.getAVMStore()); - AVMDAOs.Instance().fAVMNodeDAO.save(ghost); - AVMDAOs.Instance().fAVMNodeDAO.flush(); - ghost.setAncestor(child); - this.putChild(name, ghost); } /** diff --git a/source/java/org/alfresco/repo/avm/PlainDirectoryNodeImpl.java b/source/java/org/alfresco/repo/avm/PlainDirectoryNodeImpl.java index ce9271626a..e05156abaa 100644 --- a/source/java/org/alfresco/repo/avm/PlainDirectoryNodeImpl.java +++ b/source/java/org/alfresco/repo/avm/PlainDirectoryNodeImpl.java @@ -229,13 +229,20 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory { return; } - AVMNode ghost = new DeletedNodeImpl(lPath.getAVMStore().getAVMRepository().issueID(), - lPath.getAVMStore()); AVMDAOs.Instance().fChildEntryDAO.delete(entry); - AVMDAOs.Instance().fAVMNodeDAO.save(ghost); - AVMDAOs.Instance().fAVMNodeDAO.flush(); - ghost.setAncestor(child); - putChild(name, ghost); + if (child.getStoreNew() == null || child.getAncestor() != null) + { + AVMNode ghost = new DeletedNodeImpl(lPath.getAVMStore().getAVMRepository().issueID(), + lPath.getAVMStore()); + AVMDAOs.Instance().fAVMNodeDAO.save(ghost); + AVMDAOs.Instance().fAVMNodeDAO.flush(); + ghost.setAncestor(child); + putChild(name, ghost); + } + else + { + AVMDAOs.Instance().fAVMNodeDAO.flush(); + } } } diff --git a/source/java/org/alfresco/repo/avm/actions/AVMRevertListAction.java b/source/java/org/alfresco/repo/avm/actions/AVMRevertListAction.java index c5b3099e82..f0a709eb11 100644 --- a/source/java/org/alfresco/repo/avm/actions/AVMRevertListAction.java +++ b/source/java/org/alfresco/repo/avm/actions/AVMRevertListAction.java @@ -68,11 +68,11 @@ public class AVMRevertListAction extends ActionExecuterAbstractBase { List diffSet = fSyncService.compare(revertVersion, item.getSecond(), - -1, item.getSecond()); + -1, item.getSecond(), null); diffs.addAll(diffSet); } String message = "Reverted to version " + revertVersion; - fSyncService.update(diffs, false, false, true, true, message, message); + fSyncService.update(diffs, null, false, false, true, true, message, message); if (!(Boolean)action.getParameterValue(PARAM_FLATTEN)) { return; diff --git a/source/java/org/alfresco/repo/avm/actions/AVMRevertStoreAction.java b/source/java/org/alfresco/repo/avm/actions/AVMRevertStoreAction.java index dc01608507..8cc56423d8 100644 --- a/source/java/org/alfresco/repo/avm/actions/AVMRevertStoreAction.java +++ b/source/java/org/alfresco/repo/avm/actions/AVMRevertStoreAction.java @@ -54,9 +54,9 @@ public class AVMRevertStoreAction extends ActionExecuterAbstractBase int revertVersion = (Integer)action.getParameterValue(PARAM_VERSION); List diffs = fSyncService.compare(revertVersion, pathVersion.getSecond(), - -1, pathVersion.getSecond()); + -1, pathVersion.getSecond(), null); String message = "Reverted to Version " + revertVersion + "."; - fSyncService.update(diffs, false, false, true, true, message, message); + fSyncService.update(diffs, null, false, false, true, true, message, message); } /* (non-Javadoc) diff --git a/source/java/org/alfresco/repo/avm/actions/SimpleAVMPromoteAction.java b/source/java/org/alfresco/repo/avm/actions/SimpleAVMPromoteAction.java index c81e02be80..2399ccfb8c 100644 --- a/source/java/org/alfresco/repo/avm/actions/SimpleAVMPromoteAction.java +++ b/source/java/org/alfresco/repo/avm/actions/SimpleAVMPromoteAction.java @@ -89,10 +89,10 @@ public class SimpleAVMPromoteAction extends ActionExecuterAbstractBase String targetPath = targetStoreName + ":" + storePath[1]; // Find the differences. List diffs = - fAVMSyncService.compare(version, path, -1, targetPath); + fAVMSyncService.compare(version, path, -1, targetPath, null); // TODO fix update comments at some point. // Do the promote. - fAVMSyncService.update(diffs, true, true, false, false, null, null); + fAVMSyncService.update(diffs, null, true, true, false, false, null, null); // Flatten the source on top of the destination. fAVMSyncService.flatten(storePath[0] + ":/appBase", targetStoreName + ":/appBase"); diff --git a/source/java/org/alfresco/repo/avm/actions/SimpleAVMSubmitAction.java b/source/java/org/alfresco/repo/avm/actions/SimpleAVMSubmitAction.java index 0cabf9bc15..008214dc8a 100644 --- a/source/java/org/alfresco/repo/avm/actions/SimpleAVMSubmitAction.java +++ b/source/java/org/alfresco/repo/avm/actions/SimpleAVMSubmitAction.java @@ -31,6 +31,7 @@ import org.alfresco.service.cmr.avmsync.AVMSyncException; import org.alfresco.service.cmr.avmsync.AVMSyncService; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; +import org.alfresco.util.NameMatcher; import org.alfresco.util.Pair; import org.apache.log4j.Logger; @@ -55,6 +56,11 @@ public class SimpleAVMSubmitAction extends ActionExecuterAbstractBase */ private AVMSyncService fAVMSyncService; + /** + * The Excluding NameMatcher. + */ + private NameMatcher fExcluder; + /** * Default constructor. */ @@ -81,6 +87,16 @@ public class SimpleAVMSubmitAction extends ActionExecuterAbstractBase fAVMSyncService = avmSyncService; } + // TODO This should be a parameter of the action execution really. + /** + * Set the excluder. + * @param excluder + */ + public void setExcluder(NameMatcher excluder) + { + fExcluder = excluder; + } + /** * Perform the action. The NodeRef must be an AVM NodeRef. * @param action Don't actually need anything from this here. @@ -114,10 +130,10 @@ public class SimpleAVMSubmitAction extends ActionExecuterAbstractBase String avmDest = websiteName + "-staging:" + storePath[1]; // Get the difference between source and destination. List diffs = - fAVMSyncService.compare(version, path, -1, avmDest); + fAVMSyncService.compare(version, path, -1, avmDest, fExcluder); // TODO fix update comments at some point. // Do the update. - fAVMSyncService.update(diffs, false, false, true, true, + fAVMSyncService.update(diffs, fExcluder, false, false, true, true, "Submit of item: " + AVMNodeConverter.SplitBase(path)[1], null); // Cleanup by flattening the source relative to the destination. AVMDAOs.Instance().fAVMNodeDAO.flush(); diff --git a/source/java/org/alfresco/repo/avm/util/FileExtensionNameMatcher.java b/source/java/org/alfresco/repo/avm/util/FileExtensionNameMatcher.java new file mode 100644 index 0000000000..bafe6e0ac6 --- /dev/null +++ b/source/java/org/alfresco/repo/avm/util/FileExtensionNameMatcher.java @@ -0,0 +1,57 @@ +/** + * + */ +package org.alfresco.repo.avm.util; + +import java.util.ArrayList; +import java.util.List; + +import org.alfresco.util.NameMatcher; + +/** + * NameMatcher that matches a list of extensions (case insensitively). + * @author britt + */ +public class FileExtensionNameMatcher implements NameMatcher +{ + /** + * The extensions to match. + */ + private List fExtensions; + + /** + * Default constructor. + */ + public FileExtensionNameMatcher() + { + fExtensions = new ArrayList(); + } + + /** + * Set the extensions case insensitively. + * @param extensions + */ + public void setExtensions(List extensions) + { + for (String extension : extensions) + { + fExtensions.add(extension.toLowerCase()); + } + } + + /* (non-Javadoc) + * @see org.alfresco.util.NameMatcher#matches(java.lang.String) + */ + public boolean matches(String name) + { + String lcName = name.toLowerCase(); + for (String ext : fExtensions) + { + if (lcName.endsWith(ext)) + { + return true; + } + } + return false; + } +} diff --git a/source/java/org/alfresco/repo/avm/wf/AVMSubmitHandler.java b/source/java/org/alfresco/repo/avm/wf/AVMSubmitHandler.java index 0ea6e7bb73..04b4e67e00 100644 --- a/source/java/org/alfresco/repo/avm/wf/AVMSubmitHandler.java +++ b/source/java/org/alfresco/repo/avm/wf/AVMSubmitHandler.java @@ -78,10 +78,10 @@ public class AVMSubmitHandler extends JBPMSpringActionHandler getStringValue(); String avmDest = webSiteName + "-staging:" + storePath[1]; List diffs = - fAVMSyncService.compare(-1, avmSource, -1, avmDest); + fAVMSyncService.compare(-1, avmSource, -1, avmDest, null); // TODO fix update comments if needed. // Ignore conflicts and older nodes for now. - fAVMSyncService.update(diffs, true, true, false, false, null, null); + fAVMSyncService.update(diffs, null, true, true, false, false, null, null); // Now flatten out the source. fAVMSyncService.flatten(avmSource, avmDest); } diff --git a/source/java/org/alfresco/repo/avm/wf/AVMSubmitPackageHandler.java b/source/java/org/alfresco/repo/avm/wf/AVMSubmitPackageHandler.java index 1011be69ac..3f43bd30f0 100644 --- a/source/java/org/alfresco/repo/avm/wf/AVMSubmitPackageHandler.java +++ b/source/java/org/alfresco/repo/avm/wf/AVMSubmitPackageHandler.java @@ -59,8 +59,8 @@ public class AVMSubmitPackageHandler extends JBPMSpringActionHandler implements AVMNodeDescriptor pkgDesc = fAVMService.lookup(pkgPath.getFirst(), pkgPath.getSecond()); String targetPath = pkgDesc.getIndirection(); - List diff = fAVMSyncService.compare(pkgPath.getFirst(), pkgPath.getSecond(), -1, targetPath); - fAVMSyncService.update(diff, true, true, false, false, null, null); + List diff = fAVMSyncService.compare(pkgPath.getFirst(), pkgPath.getSecond(), -1, targetPath, null); + fAVMSyncService.update(diff, null, true, true, false, false, null, null); String from = (String)executionContext.getContextInstance().getVariable("wf_from"); fAVMSyncService.flatten(from, targetPath); diff --git a/source/java/org/alfresco/repo/remote/AVMSyncServiceClient.java b/source/java/org/alfresco/repo/remote/AVMSyncServiceClient.java index 84f43b7b77..a5d2072f58 100644 --- a/source/java/org/alfresco/repo/remote/AVMSyncServiceClient.java +++ b/source/java/org/alfresco/repo/remote/AVMSyncServiceClient.java @@ -8,6 +8,7 @@ import java.util.List; import org.alfresco.service.cmr.avmsync.AVMDifference; import org.alfresco.service.cmr.avmsync.AVMSyncService; import org.alfresco.service.cmr.remote.AVMSyncServiceTransport; +import org.alfresco.util.NameMatcher; /** * Client side wrapper around the RMI based AVMSyncServiceTransport. @@ -39,9 +40,9 @@ public class AVMSyncServiceClient implements AVMSyncService * @see org.alfresco.service.cmr.avmsync.AVMSyncService#compare(int, java.lang.String, int, java.lang.String) */ public List compare(int srcVersion, String srcPath, - int dstVersion, String dstPath) + int dstVersion, String dstPath, NameMatcher excluder) { - return fTransport.compare(ClientTicketHolder.GetTicket(), srcVersion, srcPath, dstVersion, dstPath); + return fTransport.compare(ClientTicketHolder.GetTicket(), srcVersion, srcPath, dstVersion, dstPath, excluder); } /* (non-Javadoc) @@ -63,10 +64,11 @@ public class AVMSyncServiceClient implements AVMSyncService /* (non-Javadoc) * @see org.alfresco.service.cmr.avmsync.AVMSyncService#update(java.util.List, boolean, boolean, boolean, boolean, java.lang.String, java.lang.String) */ - public void update(List diffList, boolean ignoreConflicts, - boolean ignoreOlder, boolean overrideConflicts, - boolean overrideOlder, String tag, String description) + public void update(List diffList, + NameMatcher excluder, boolean ignoreConflicts, + boolean ignoreOlder, boolean overrideConflicts, + boolean overrideOlder, String tag, String description) { - fTransport.update(ClientTicketHolder.GetTicket(), diffList, ignoreConflicts, ignoreOlder, overrideConflicts, overrideOlder, tag, description); + fTransport.update(ClientTicketHolder.GetTicket(), diffList, excluder, ignoreConflicts, ignoreOlder, overrideConflicts, overrideOlder, tag, description); } } diff --git a/source/java/org/alfresco/repo/workflow/WorkflowInterpreter.java b/source/java/org/alfresco/repo/workflow/WorkflowInterpreter.java index 3a9059fb16..88679c8642 100644 --- a/source/java/org/alfresco/repo/workflow/WorkflowInterpreter.java +++ b/source/java/org/alfresco/repo/workflow/WorkflowInterpreter.java @@ -720,8 +720,8 @@ public class WorkflowInterpreter if (avmSourceIndirection != null) { avmService.createLayeredDirectory(avmSourceIndirection, packagesPath, packageName); - List diff = avmSyncService.compare(-1, avmSource.getPath(), -1, packagesPath + "/" + packageName); - avmSyncService.update(diff, true, true, false, false, null, null); + List diff = avmSyncService.compare(-1, avmSource.getPath(), -1, packagesPath + "/" + packageName, null); + avmSyncService.update(diff, null, true, true, false, false, null, null); } else { diff --git a/source/java/org/alfresco/service/cmr/avmsync/AVMSyncService.java b/source/java/org/alfresco/service/cmr/avmsync/AVMSyncService.java index 5c963b0be7..8422c9eff2 100644 --- a/source/java/org/alfresco/service/cmr/avmsync/AVMSyncService.java +++ b/source/java/org/alfresco/service/cmr/avmsync/AVMSyncService.java @@ -19,6 +19,8 @@ package org.alfresco.service.cmr.avmsync; import java.util.List; +import org.alfresco.util.NameMatcher; + /** * This service handles comparisons and synchronizations between * corresponding avm node trees. @@ -32,11 +34,13 @@ public interface AVMSyncService * @param srcPath The avm path to the source tree. * @param dstVersion The version id for the destination tree. * @param dstPath The avm path to the destination tree. + * @param excluder A NameMatcher used to exclude files from consideration. * @return A List of AVMDifference structs which can be used for * the update operation. */ public List compare(int srcVersion, String srcPath, - int dstVersion, String dstPath); + int dstVersion, String dstPath, + NameMatcher excluder); /** * Updates the destination nodes in the AVMDifferences @@ -56,7 +60,7 @@ public interface AVMSyncService * @param tag Short comment. * @param description Full update blurb. */ - public void update(List diffList, boolean ignoreConflicts, boolean ignoreOlder, + public void update(List diffList, NameMatcher excluder, boolean ignoreConflicts, boolean ignoreOlder, boolean overrideConflicts, boolean overrideOlder, String tag, String description); /** diff --git a/source/java/org/alfresco/service/cmr/remote/AVMSyncServiceTransport.java b/source/java/org/alfresco/service/cmr/remote/AVMSyncServiceTransport.java index e47c6f17f3..fa95699909 100644 --- a/source/java/org/alfresco/service/cmr/remote/AVMSyncServiceTransport.java +++ b/source/java/org/alfresco/service/cmr/remote/AVMSyncServiceTransport.java @@ -6,6 +6,7 @@ package org.alfresco.service.cmr.remote; import java.util.List; import org.alfresco.service.cmr.avmsync.AVMDifference; +import org.alfresco.util.NameMatcher; /** * A wrapper around AVMSyncService for remote access. @@ -24,7 +25,8 @@ public interface AVMSyncServiceTransport */ public List compare(String ticket, int srcVersion, String srcPath, - int dstVersion, String dstPath); + int dstVersion, String dstPath, + NameMatcher excluder); /** * Updates the destination nodes in the AVMDifferences @@ -32,6 +34,7 @@ public interface AVMSyncServiceTransport * which the source of an AVMDifference is older than the destination * will cause the transaction to roll back. * @param diffList A List of AVMDifference structs. + * @param excluder A NameMatcher to exclude undesired updates. * @param ignoreConflicts If this is true the update will skip those * AVMDifferences which are in conflict with * the destination. @@ -44,7 +47,8 @@ public interface AVMSyncServiceTransport * @param tag Short comment. * @param description Full update blurb. */ - public void update(String ticket, List diffList, boolean ignoreConflicts, boolean ignoreOlder, + public void update(String ticket, List diffList, + NameMatcher excluder, boolean ignoreConflicts, boolean ignoreOlder, boolean overrideConflicts, boolean overrideOlder, String tag, String description); /**