mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
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
This commit is contained in:
@@ -404,6 +404,9 @@
|
|||||||
<property name="avmSyncService">
|
<property name="avmSyncService">
|
||||||
<ref bean="avmSyncService"/>
|
<ref bean="avmSyncService"/>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="excluder">
|
||||||
|
<ref bean="globalPathExcluder"/>
|
||||||
|
</property>
|
||||||
<property name="publicAction">
|
<property name="publicAction">
|
||||||
<value>false</value>
|
<value>false</value>
|
||||||
</property>
|
</property>
|
||||||
|
@@ -243,6 +243,36 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<!-- NameMatcher beans for filtering what shows up as different in compares. -->
|
||||||
|
|
||||||
|
<bean id="excludeRegexMatcher" class="org.alfresco.util.RegexNameMatcher">
|
||||||
|
<property name="patterns">
|
||||||
|
<list>
|
||||||
|
<value>.*/#.*</value>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="excludeExtensionMatcher" class="org.alfresco.repo.avm.util.FileExtensionNameMatcher">
|
||||||
|
<property name="extensions">
|
||||||
|
<list>
|
||||||
|
<value>.o</value>
|
||||||
|
<value>.bak</value>
|
||||||
|
<value>.tmp</value>
|
||||||
|
<value>~</value>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="globalPathExcluder" class="org.alfresco.util.OrCompositeNameMatcher">
|
||||||
|
<property name="matchers">
|
||||||
|
<list>
|
||||||
|
<ref bean="excludeExtensionMatcher"/>
|
||||||
|
<ref bean="excludeRegexMatcher"/>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
|
||||||
|
|
||||||
|
@@ -471,7 +471,8 @@ public class AVMInterpreter
|
|||||||
List<AVMDifference> diffs = fSyncService.compare(Integer.parseInt(command[2]),
|
List<AVMDifference> diffs = fSyncService.compare(Integer.parseInt(command[2]),
|
||||||
command[1],
|
command[1],
|
||||||
Integer.parseInt(command[4]),
|
Integer.parseInt(command[4]),
|
||||||
command[3]);
|
command[3],
|
||||||
|
null);
|
||||||
for (AVMDifference diff : diffs)
|
for (AVMDifference diff : diffs)
|
||||||
{
|
{
|
||||||
out.println(diff);
|
out.println(diff);
|
||||||
@@ -487,7 +488,7 @@ public class AVMInterpreter
|
|||||||
-1, command[3], AVMDifference.NEWER);
|
-1, command[3], AVMDifference.NEWER);
|
||||||
List<AVMDifference> diffs = new ArrayList<AVMDifference>();
|
List<AVMDifference> diffs = new ArrayList<AVMDifference>();
|
||||||
diffs.add(diff);
|
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"))
|
else if (command[0].equals("resetLayer"))
|
||||||
{
|
{
|
||||||
|
@@ -38,7 +38,6 @@ import org.alfresco.repo.avm.actions.AVMUndoSandboxListAction;
|
|||||||
import org.alfresco.repo.avm.actions.SimpleAVMPromoteAction;
|
import org.alfresco.repo.avm.actions.SimpleAVMPromoteAction;
|
||||||
import org.alfresco.repo.avm.actions.SimpleAVMSubmitAction;
|
import org.alfresco.repo.avm.actions.SimpleAVMSubmitAction;
|
||||||
import org.alfresco.repo.avm.util.BulkLoader;
|
import org.alfresco.repo.avm.util.BulkLoader;
|
||||||
import org.alfresco.repo.avm.util.VersionPathStuffer;
|
|
||||||
import org.alfresco.repo.domain.PropertyValue;
|
import org.alfresco.repo.domain.PropertyValue;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||||
import org.alfresco.repo.transaction.TransactionUtil;
|
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.namespace.QName;
|
||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.util.GUID;
|
import org.alfresco.util.GUID;
|
||||||
|
import org.alfresco.util.NameMatcher;
|
||||||
import org.alfresco.util.Pair;
|
import org.alfresco.util.Pair;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -209,13 +209,13 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
diffs.add(new AVMDifference(-1, "layer:/a/b/c/foo",
|
diffs.add(new AVMDifference(-1, "layer:/a/b/c/foo",
|
||||||
-1, "main:/a/b/c/foo",
|
-1, "main:/a/b/c/foo",
|
||||||
AVMDifference.NEWER));
|
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");
|
fSyncService.flatten("layer:/a", "main:/a");
|
||||||
AVMNodeDescriptor b = fService.lookup(-1, "layer:/a/b");
|
AVMNodeDescriptor b = fService.lookup(-1, "layer:/a/b");
|
||||||
assertTrue(b.isLayeredDirectory());
|
assertTrue(b.isLayeredDirectory());
|
||||||
AVMNodeDescriptor c = fService.lookup(-1, "layer:/a/b/c");
|
AVMNodeDescriptor c = fService.lookup(-1, "layer:/a/b/c");
|
||||||
assertTrue(c.isPlainDirectory());
|
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)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -260,11 +260,11 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
fService.createAVMStore("area");
|
fService.createAVMStore("area");
|
||||||
fService.createLayeredDirectory("main:/a", "area:/", "a");
|
fService.createLayeredDirectory("main:/a", "area:/", "a");
|
||||||
fService.getFileOutputStream("area:/a/b/c/foo").close();
|
fService.getFileOutputStream("area:/a/b/c/foo").close();
|
||||||
List<AVMDifference> diffs = fSyncService.compare(-1, "area:/a", -1, "main:/a");
|
List<AVMDifference> diffs = fSyncService.compare(-1, "area:/a", -1, "main:/a", null);
|
||||||
assertEquals(1, diffs.size());
|
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();
|
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());
|
assertEquals(1, diffs.size());
|
||||||
final ActionImpl action = new ActionImpl(null,
|
final ActionImpl action = new ActionImpl(null,
|
||||||
GUID.generate(),
|
GUID.generate(),
|
||||||
@@ -289,7 +289,7 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
};
|
};
|
||||||
TransactionUtil.executeInUserTransaction((TransactionService)fContext.getBean("transactionComponent"),
|
TransactionUtil.executeInUserTransaction((TransactionService)fContext.getBean("transactionComponent"),
|
||||||
new TxnWork());
|
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());
|
assertEquals(0, diffs.size());
|
||||||
System.out.println(recursiveList("area", -1, true));
|
System.out.println(recursiveList("area", -1, true));
|
||||||
System.out.println(recursiveList("main", -1, true));
|
System.out.println(recursiveList("main", -1, true));
|
||||||
@@ -312,11 +312,11 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
fService.createAVMStore("area");
|
fService.createAVMStore("area");
|
||||||
fService.createLayeredDirectory("main:/a", "area:/", "a");
|
fService.createLayeredDirectory("main:/a", "area:/", "a");
|
||||||
fService.getFileOutputStream("area:/a/b/c/foo").close();
|
fService.getFileOutputStream("area:/a/b/c/foo").close();
|
||||||
List<AVMDifference> diffs = fSyncService.compare(-1, "area:/a", -1, "main:/a");
|
List<AVMDifference> diffs = fSyncService.compare(-1, "area:/a", -1, "main:/a", null);
|
||||||
assertEquals(1, diffs.size());
|
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();
|
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());
|
assertEquals(1, diffs.size());
|
||||||
final ActionImpl action = new ActionImpl(null,
|
final ActionImpl action = new ActionImpl(null,
|
||||||
GUID.generate(),
|
GUID.generate(),
|
||||||
@@ -336,7 +336,7 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
};
|
};
|
||||||
TransactionUtil.executeInUserTransaction((TransactionService)fContext.getBean("transactionComponent"),
|
TransactionUtil.executeInUserTransaction((TransactionService)fContext.getBean("transactionComponent"),
|
||||||
new TxnWork());
|
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());
|
assertEquals(0, diffs.size());
|
||||||
System.out.println(recursiveList("area", -1, true));
|
System.out.println(recursiveList("area", -1, true));
|
||||||
System.out.println(recursiveList("main", -1, true));
|
System.out.println(recursiveList("main", -1, true));
|
||||||
@@ -378,7 +378,7 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
};
|
};
|
||||||
TransactionUtil.executeInUserTransaction((TransactionService)fContext.getBean("transactionComponent"),
|
TransactionUtil.executeInUserTransaction((TransactionService)fContext.getBean("transactionComponent"),
|
||||||
new TxnWork());
|
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)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -396,15 +396,15 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
{
|
{
|
||||||
setupBasicTree();
|
setupBasicTree();
|
||||||
fService.createAVMStore("staging");
|
fService.createAVMStore("staging");
|
||||||
List<AVMDifference> diffs = fSyncService.compare(-1, "main:/", -1, "staging:/");
|
List<AVMDifference> diffs = fSyncService.compare(-1, "main:/", -1, "staging:/", null);
|
||||||
assertEquals(2, diffs.size());
|
assertEquals(2, diffs.size());
|
||||||
List<AVMDifference> noodle = new ArrayList<AVMDifference>();
|
List<AVMDifference> noodle = new ArrayList<AVMDifference>();
|
||||||
noodle.add(new AVMDifference(-1, "main:/a/b/c/foo", -1, "staging:/a/b/c/foo",
|
noodle.add(new AVMDifference(-1, "main:/a/b/c/foo", -1, "staging:/a/b/c/foo",
|
||||||
AVMDifference.NEWER));
|
AVMDifference.NEWER));
|
||||||
noodle.add(new AVMDifference(-1, "main:/d", -1, "staging:/d",
|
noodle.add(new AVMDifference(-1, "main:/d", -1, "staging:/d",
|
||||||
AVMDifference.NEWER));
|
AVMDifference.NEWER));
|
||||||
fSyncService.update(noodle, false, false, false, false, null, null);
|
fSyncService.update(noodle, null, false, false, false, false, null, null);
|
||||||
diffs = fSyncService.compare(-1, "main:/", -1, "staging:/");
|
diffs = fSyncService.compare(-1, "main:/", -1, "staging:/", null);
|
||||||
assertEquals(1, diffs.size());
|
assertEquals(1, diffs.size());
|
||||||
assertEquals("main:/a/b/c/bar", diffs.get(0).getSourcePath());
|
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.getFileOutputStream("area:/appBase/a/b/c/foo").close();
|
||||||
fService.removeNode("area:/appBase/a/b/c/bar");
|
fService.removeNode("area:/appBase/a/b/c/bar");
|
||||||
List<AVMDifference> diffs =
|
List<AVMDifference> diffs =
|
||||||
fSyncService.compare(-1, "area:/appBase", -1, "foo-staging:/appBase");
|
fSyncService.compare(-1, "area:/appBase", -1, "foo-staging:/appBase", null);
|
||||||
assertEquals(3, diffs.size());
|
assertEquals(3, diffs.size());
|
||||||
final SimpleAVMSubmitAction action = (SimpleAVMSubmitAction)fContext.getBean("simple-avm-submit");
|
final SimpleAVMSubmitAction action = (SimpleAVMSubmitAction)fContext.getBean("simple-avm-submit");
|
||||||
class TxnWork implements TransactionUtil.TransactionWork<Object>
|
class TxnWork implements TransactionUtil.TransactionWork<Object>
|
||||||
@@ -452,7 +452,7 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
TransactionUtil.executeInUserTransaction((TransactionService)fContext.getBean("transactionComponent"),
|
TransactionUtil.executeInUserTransaction((TransactionService)fContext.getBean("transactionComponent"),
|
||||||
worker);
|
worker);
|
||||||
diffs =
|
diffs =
|
||||||
fSyncService.compare(-1, "area:/appBase", -1, "foo-staging:/appBase");
|
fSyncService.compare(-1, "area:/appBase", -1, "foo-staging:/appBase", null);
|
||||||
assertEquals(0, diffs.size());
|
assertEquals(0, diffs.size());
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -504,17 +504,17 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
loader.recursiveLoad("config/alfresco/extension", "source:/");
|
loader.recursiveLoad("config/alfresco/extension", "source:/");
|
||||||
int version2 = fService.createSnapshot("source", null, null);
|
int version2 = fService.createSnapshot("source", null, null);
|
||||||
List<AVMDifference> diffs =
|
List<AVMDifference> diffs =
|
||||||
fSyncService.compare(version1, "source:/", -1, "dest:/");
|
fSyncService.compare(version1, "source:/", -1, "dest:/", null);
|
||||||
fService.createSnapshot("dest", null, null);
|
fService.createSnapshot("dest", null, null);
|
||||||
assertEquals(1, diffs.size());
|
assertEquals(1, diffs.size());
|
||||||
fSyncService.update(diffs, false, false, false, false, null, null);
|
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||||
diffs = fSyncService.compare(version1, "source:/", -1, "dest:/");
|
diffs = fSyncService.compare(version1, "source:/", -1, "dest:/", null);
|
||||||
assertEquals(0, diffs.size());
|
assertEquals(0, diffs.size());
|
||||||
diffs = fSyncService.compare(version2, "source:/", -1, "dest:/");
|
diffs = fSyncService.compare(version2, "source:/", -1, "dest:/", null);
|
||||||
assertEquals(1, diffs.size());
|
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);
|
fService.createSnapshot("dest", null, null);
|
||||||
diffs = fSyncService.compare(version2, "source:/", -1, "dest:/");
|
diffs = fSyncService.compare(version2, "source:/", -1, "dest:/", null);
|
||||||
assertEquals(0, diffs.size());
|
assertEquals(0, diffs.size());
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -539,11 +539,11 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
fService.getFileOutputStream("branch:/branch/a/b/c/foo").close();
|
fService.getFileOutputStream("branch:/branch/a/b/c/foo").close();
|
||||||
fService.removeNode("branch:/branch/a/b/c", "bar");
|
fService.removeNode("branch:/branch/a/b/c", "bar");
|
||||||
List<AVMDifference> diffs =
|
List<AVMDifference> diffs =
|
||||||
fSyncService.compare(-1, "branch:/branch", -1, "main:/");
|
fSyncService.compare(-1, "branch:/branch", -1, "main:/", null);
|
||||||
assertEquals(3, diffs.size());
|
assertEquals(3, diffs.size());
|
||||||
// Now update.
|
// Now update.
|
||||||
fSyncService.update(diffs, false, false, false, false, null, null);
|
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||||
diffs = fSyncService.compare(-1, "branch:/branch", -1, "main:/");
|
diffs = fSyncService.compare(-1, "branch:/branch", -1, "main:/", null);
|
||||||
assertEquals(0, diffs.size());
|
assertEquals(0, diffs.size());
|
||||||
fService.getFileOutputStream("branch:/branch/a/b/fing").close();
|
fService.getFileOutputStream("branch:/branch/a/b/fing").close();
|
||||||
assertTrue(fService.lookup(-1, "branch:/branch/a/b/fing").getId() !=
|
assertTrue(fService.lookup(-1, "branch:/branch/a/b/fing").getId() !=
|
||||||
@@ -591,12 +591,12 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
fService.createAVMStore("layer");
|
fService.createAVMStore("layer");
|
||||||
fService.createLayeredDirectory("main:/", "layer:/", "layer");
|
fService.createLayeredDirectory("main:/", "layer:/", "layer");
|
||||||
loader.recursiveLoad("config/alfresco/bootstrap", "layer:/layer");
|
loader.recursiveLoad("config/alfresco/bootstrap", "layer:/layer");
|
||||||
List<AVMDifference> diffs = fSyncService.compare(-1, "layer:/layer", -1, "main:/");
|
List<AVMDifference> diffs = fSyncService.compare(-1, "layer:/layer", -1, "main:/", null);
|
||||||
assertEquals(1, diffs.size());
|
assertEquals(1, diffs.size());
|
||||||
fService.createSnapshot("layer", null, null);
|
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);
|
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());
|
assertEquals(0, diffs.size());
|
||||||
fSyncService.flatten("layer:/layer", "main:/");
|
fSyncService.flatten("layer:/layer", "main:/");
|
||||||
System.out.println("Layer:");
|
System.out.println("Layer:");
|
||||||
@@ -607,13 +607,13 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
fService.createLayeredDirectory("layer:/layer", "layer2:/", "layer");
|
fService.createLayeredDirectory("layer:/layer", "layer2:/", "layer");
|
||||||
loader.recursiveLoad("config/alfresco/bootstrap", "layer2:/layer/bootstrap");
|
loader.recursiveLoad("config/alfresco/bootstrap", "layer2:/layer/bootstrap");
|
||||||
fService.createSnapshot("layer2", null, null);
|
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());
|
assertEquals(1, diffs.size());
|
||||||
fSyncService.update(diffs, false, false, false, false, null, null);
|
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||||
diffs = fSyncService.compare(-1, "layer2:/layer", -1, "layer:/layer");
|
diffs = fSyncService.compare(-1, "layer2:/layer", -1, "layer:/layer", null);
|
||||||
assertEquals(0, diffs.size());
|
assertEquals(0, diffs.size());
|
||||||
fSyncService.flatten("layer2:/layer", "layer:/layer");
|
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());
|
assertEquals(1, diffs.size());
|
||||||
System.out.println("Layer2:");
|
System.out.println("Layer2:");
|
||||||
System.out.println(recursiveList("layer2", -1, true));
|
System.out.println(recursiveList("layer2", -1, true));
|
||||||
@@ -647,13 +647,13 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
System.out.println(recursiveList("main", -1, true));
|
System.out.println(recursiveList("main", -1, true));
|
||||||
// Do a compare.
|
// Do a compare.
|
||||||
List<AVMDifference> diffs =
|
List<AVMDifference> diffs =
|
||||||
fSyncService.compare(-1, "main:/layer", -1, "main:/a");
|
fSyncService.compare(-1, "main:/layer", -1, "main:/a", null);
|
||||||
for (AVMDifference diff : diffs)
|
for (AVMDifference diff : diffs)
|
||||||
{
|
{
|
||||||
System.out.println(diff);
|
System.out.println(diff);
|
||||||
}
|
}
|
||||||
// Update.
|
// 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));
|
System.out.println(recursiveList("main", -1, true));
|
||||||
// Flatten.
|
// Flatten.
|
||||||
fSyncService.flatten("main:/layer", "main:/a");
|
fSyncService.flatten("main:/layer", "main:/a");
|
||||||
@@ -701,14 +701,17 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
NameMatcher excluder = (NameMatcher)fContext.getBean("globalPathExcluder");
|
||||||
setupBasicTree();
|
setupBasicTree();
|
||||||
// Try branch to branch update.
|
// Try branch to branch update.
|
||||||
fService.createBranch(-1, "main:/a", "main:/", "abranch");
|
fService.createBranch(-1, "main:/a", "main:/", "abranch");
|
||||||
fService.createFile("main:/abranch", "monkey").close();
|
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();
|
fService.getFileOutputStream("main:/abranch/b/c/foo").close();
|
||||||
System.out.println(recursiveList("main", -1, true));
|
System.out.println(recursiveList("main", -1, true));
|
||||||
List<AVMDifference> cmp =
|
List<AVMDifference> cmp =
|
||||||
fSyncService.compare(-1, "main:/abranch", -1, "main:/a");
|
fSyncService.compare(-1, "main:/abranch", -1, "main:/a", excluder);
|
||||||
for (AVMDifference diff : cmp)
|
for (AVMDifference diff : cmp)
|
||||||
{
|
{
|
||||||
System.out.println(diff);
|
System.out.println(diff);
|
||||||
@@ -721,7 +724,7 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
diffs.add(new AVMDifference(-1, "main:/abranch/b/c/foo",
|
diffs.add(new AVMDifference(-1, "main:/abranch/b/c/foo",
|
||||||
-1, "main:/a/b/c/foo",
|
-1, "main:/a/b/c/foo",
|
||||||
AVMDifference.NEWER));
|
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);
|
fService.createSnapshot("main", null, null);
|
||||||
System.out.println(recursiveList("main", -1, true));
|
System.out.println(recursiveList("main", -1, true));
|
||||||
assertEquals(fService.lookup(-1, "main:/abranch/monkey").getId(),
|
assertEquals(fService.lookup(-1, "main:/abranch/monkey").getId(),
|
||||||
@@ -732,7 +735,7 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
fService.removeNode("main:/abranch", "monkey");
|
fService.removeNode("main:/abranch", "monkey");
|
||||||
System.out.println(recursiveList("main", -1, true));
|
System.out.println(recursiveList("main", -1, true));
|
||||||
cmp =
|
cmp =
|
||||||
fSyncService.compare(-1, "main:/abranch", -1, "main:/a");
|
fSyncService.compare(-1, "main:/abranch", -1, "main:/a", excluder);
|
||||||
for (AVMDifference diff : cmp)
|
for (AVMDifference diff : cmp)
|
||||||
{
|
{
|
||||||
System.out.println(diff);
|
System.out.println(diff);
|
||||||
@@ -742,8 +745,8 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
diffs.add(new AVMDifference(-1, "main:/abranch/monkey",
|
diffs.add(new AVMDifference(-1, "main:/abranch/monkey",
|
||||||
-1, "main:/a/monkey",
|
-1, "main:/a/monkey",
|
||||||
AVMDifference.NEWER));
|
AVMDifference.NEWER));
|
||||||
fSyncService.update(diffs, false, false, false, false, null, null);
|
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||||
assertEquals(0, fSyncService.compare(-1, "main:/abranch", -1, "main:/a").size());
|
assertEquals(0, fSyncService.compare(-1, "main:/abranch", -1, "main:/a", excluder).size());
|
||||||
fService.createSnapshot("main", null, null);
|
fService.createSnapshot("main", null, null);
|
||||||
System.out.println(recursiveList("main", -1, true));
|
System.out.println(recursiveList("main", -1, true));
|
||||||
assertEquals(fService.lookup(-1, "main:/abranch/monkey", true).getId(),
|
assertEquals(fService.lookup(-1, "main:/abranch/monkey", true).getId(),
|
||||||
@@ -751,7 +754,7 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
// Try one that should fail.
|
// Try one that should fail.
|
||||||
fService.createFile("main:/abranch", "monkey").close();
|
fService.createFile("main:/abranch", "monkey").close();
|
||||||
cmp =
|
cmp =
|
||||||
fSyncService.compare(-1, "main:/abranch", -1, "main:/a");
|
fSyncService.compare(-1, "main:/abranch", -1, "main:/a", excluder);
|
||||||
for (AVMDifference diff : cmp)
|
for (AVMDifference diff : cmp)
|
||||||
{
|
{
|
||||||
System.out.println(diff);
|
System.out.println(diff);
|
||||||
@@ -763,7 +766,7 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
AVMDifference.NEWER));
|
AVMDifference.NEWER));
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
fSyncService.update(diffs, false, false, false, false, null, null);
|
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||||
fail();
|
fail();
|
||||||
}
|
}
|
||||||
catch (AVMSyncException se)
|
catch (AVMSyncException se)
|
||||||
@@ -776,8 +779,8 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
diffs.add(new AVMDifference(-1, "main:/a/monkey",
|
diffs.add(new AVMDifference(-1, "main:/a/monkey",
|
||||||
-1, "main:/abranch/monkey",
|
-1, "main:/abranch/monkey",
|
||||||
AVMDifference.NEWER));
|
AVMDifference.NEWER));
|
||||||
fSyncService.update(diffs, false, false, true, false, null, null);
|
fSyncService.update(diffs, null, false, false, true, false, null, null);
|
||||||
assertEquals(0, fSyncService.compare(-1, "main:/abranch", -1, "main:/a").size());
|
assertEquals(0, fSyncService.compare(-1, "main:/abranch", -1, "main:/a", excluder).size());
|
||||||
fService.createSnapshot("main", null, null);
|
fService.createSnapshot("main", null, null);
|
||||||
System.out.println(recursiveList("main", -1, true));
|
System.out.println(recursiveList("main", -1, true));
|
||||||
assertEquals(fService.lookup(-1, "main:/a/monkey", true).getId(),
|
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.createFile("main:/layer", "monkey").close();
|
||||||
fService.getFileOutputStream("main:/layer/b/c/foo").close();
|
fService.getFileOutputStream("main:/layer/b/c/foo").close();
|
||||||
cmp =
|
cmp =
|
||||||
fSyncService.compare(-1, "main:/layer", -1, "main:/a");
|
fSyncService.compare(-1, "main:/layer", -1, "main:/a", excluder);
|
||||||
for (AVMDifference diff : cmp)
|
for (AVMDifference diff : cmp)
|
||||||
{
|
{
|
||||||
System.out.println(diff);
|
System.out.println(diff);
|
||||||
@@ -804,8 +807,8 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
diffs.add(new AVMDifference(-1, "main:/layer/b/c/foo",
|
diffs.add(new AVMDifference(-1, "main:/layer/b/c/foo",
|
||||||
-1, "main:/a/b/c/foo",
|
-1, "main:/a/b/c/foo",
|
||||||
AVMDifference.NEWER));
|
AVMDifference.NEWER));
|
||||||
fSyncService.update(diffs, false, false, false, false, null, null);
|
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||||
assertEquals(0, fSyncService.compare(-1, "main:/layer", -1, "main:/a").size());
|
assertEquals(0, fSyncService.compare(-1, "main:/layer", -1, "main:/a", excluder).size());
|
||||||
fService.createSnapshot("main", null, null);
|
fService.createSnapshot("main", null, null);
|
||||||
System.out.println(recursiveList("main", -1, true));
|
System.out.println(recursiveList("main", -1, true));
|
||||||
assertEquals(fService.lookup(-1, "main:/layer/monkey").getId(),
|
assertEquals(fService.lookup(-1, "main:/layer/monkey").getId(),
|
||||||
@@ -816,7 +819,7 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
fService.removeNode("main:/layer", "monkey");
|
fService.removeNode("main:/layer", "monkey");
|
||||||
System.out.println(recursiveList("main", -1, true));
|
System.out.println(recursiveList("main", -1, true));
|
||||||
cmp =
|
cmp =
|
||||||
fSyncService.compare(-1, "main:/layer", -1, "main:/a");
|
fSyncService.compare(-1, "main:/layer", -1, "main:/a", excluder);
|
||||||
for (AVMDifference diff : cmp)
|
for (AVMDifference diff : cmp)
|
||||||
{
|
{
|
||||||
System.out.println(diff);
|
System.out.println(diff);
|
||||||
@@ -826,8 +829,8 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
diffs.add(new AVMDifference(-1, "main:/layer/monkey",
|
diffs.add(new AVMDifference(-1, "main:/layer/monkey",
|
||||||
-1, "main:/a/monkey",
|
-1, "main:/a/monkey",
|
||||||
AVMDifference.NEWER));
|
AVMDifference.NEWER));
|
||||||
fSyncService.update(diffs, false, false, false, false, null, null);
|
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||||
assertEquals(0, fSyncService.compare(-1, "main:/layer", -1, "main:/a").size());
|
assertEquals(0, fSyncService.compare(-1, "main:/layer", -1, "main:/a", excluder).size());
|
||||||
fService.createSnapshot("main", null, null);
|
fService.createSnapshot("main", null, null);
|
||||||
System.out.println(recursiveList("main", -1, true));
|
System.out.println(recursiveList("main", -1, true));
|
||||||
assertEquals(fService.lookup(-1, "main:/layer/monkey", true).getId(),
|
assertEquals(fService.lookup(-1, "main:/layer/monkey", true).getId(),
|
||||||
@@ -835,7 +838,7 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
// Try one that should fail.
|
// Try one that should fail.
|
||||||
fService.createFile("main:/layer", "monkey").close();
|
fService.createFile("main:/layer", "monkey").close();
|
||||||
cmp =
|
cmp =
|
||||||
fSyncService.compare(-1, "main:/layer", -1, "main:/a");
|
fSyncService.compare(-1, "main:/layer", -1, "main:/a", excluder);
|
||||||
for (AVMDifference diff : cmp)
|
for (AVMDifference diff : cmp)
|
||||||
{
|
{
|
||||||
System.out.println(diff);
|
System.out.println(diff);
|
||||||
@@ -847,7 +850,7 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
AVMDifference.NEWER));
|
AVMDifference.NEWER));
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
fSyncService.update(diffs, false, false, false, false, null, null);
|
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||||
fail();
|
fail();
|
||||||
}
|
}
|
||||||
catch (AVMSyncException se)
|
catch (AVMSyncException se)
|
||||||
@@ -860,8 +863,8 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
diffs.add(new AVMDifference(-1, "main:/a/monkey",
|
diffs.add(new AVMDifference(-1, "main:/a/monkey",
|
||||||
-1, "main:/layer/monkey",
|
-1, "main:/layer/monkey",
|
||||||
AVMDifference.NEWER));
|
AVMDifference.NEWER));
|
||||||
fSyncService.update(diffs, false, false, true, false, null, null);
|
fSyncService.update(diffs, null, false, false, true, false, null, null);
|
||||||
assertEquals(0, fSyncService.compare(-1, "main:/layer", -1, "main:/a").size());
|
assertEquals(0, fSyncService.compare(-1, "main:/layer", -1, "main:/a", excluder).size());
|
||||||
fService.createSnapshot("main", null, null);
|
fService.createSnapshot("main", null, null);
|
||||||
System.out.println(recursiveList("main", -1, true));
|
System.out.println(recursiveList("main", -1, true));
|
||||||
assertEquals(fService.lookup(-1, "main:/a/monkey", true).getId(),
|
assertEquals(fService.lookup(-1, "main:/a/monkey", true).getId(),
|
||||||
|
@@ -24,16 +24,14 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.repo.domain.PropertyValue;
|
|
||||||
import org.alfresco.service.cmr.avm.AVMBadArgumentException;
|
import org.alfresco.service.cmr.avm.AVMBadArgumentException;
|
||||||
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
||||||
import org.alfresco.service.cmr.avm.AVMNotFoundException;
|
import org.alfresco.service.cmr.avm.AVMNotFoundException;
|
||||||
import org.alfresco.service.cmr.avm.AVMService;
|
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.AVMDifference;
|
||||||
import org.alfresco.service.cmr.avmsync.AVMSyncException;
|
import org.alfresco.service.cmr.avmsync.AVMSyncException;
|
||||||
import org.alfresco.service.cmr.avmsync.AVMSyncService;
|
import org.alfresco.service.cmr.avmsync.AVMSyncService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.util.NameMatcher;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,11 +81,13 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
|||||||
* @param srcPath The avm path to the source tree.
|
* @param srcPath The avm path to the source tree.
|
||||||
* @param dstVersion The version id for the destination tree.
|
* @param dstVersion The version id for the destination tree.
|
||||||
* @param dstPath The avm path to 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
|
* @return A List of AVMDifference structs which can be used for
|
||||||
* the update operation.
|
* the update operation.
|
||||||
*/
|
*/
|
||||||
public List<AVMDifference> compare(int srcVersion, String srcPath,
|
public List<AVMDifference> compare(int srcVersion, String srcPath,
|
||||||
int dstVersion, String dstPath)
|
int dstVersion, String dstPath,
|
||||||
|
NameMatcher excluder)
|
||||||
{
|
{
|
||||||
if (srcPath == null || dstPath == null)
|
if (srcPath == null || dstPath == null)
|
||||||
{
|
{
|
||||||
@@ -110,7 +110,7 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Invoke the recursive implementation.
|
// Invoke the recursive implementation.
|
||||||
compare(srcVersion, srcDesc, dstVersion, dstDesc, result);
|
compare(srcVersion, srcDesc, dstVersion, dstDesc, result, excluder);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -124,9 +124,14 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
|||||||
*/
|
*/
|
||||||
private void compare(int srcVersion, AVMNodeDescriptor srcDesc,
|
private void compare(int srcVersion, AVMNodeDescriptor srcDesc,
|
||||||
int dstVersion, AVMNodeDescriptor dstDesc,
|
int dstVersion, AVMNodeDescriptor dstDesc,
|
||||||
List<AVMDifference> result)
|
List<AVMDifference> result, NameMatcher excluder)
|
||||||
{
|
{
|
||||||
// Determine how the source and destination nodes differ.
|
// 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);
|
int diffCode = compareOne(srcDesc, dstDesc);
|
||||||
switch (diffCode)
|
switch (diffCode)
|
||||||
{
|
{
|
||||||
@@ -168,19 +173,25 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
|||||||
{
|
{
|
||||||
AVMNodeDescriptor srcChild = srcList.get(name);
|
AVMNodeDescriptor srcChild = srcList.get(name);
|
||||||
AVMNodeDescriptor dstChild = dstList.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)
|
if (dstChild == null)
|
||||||
{
|
{
|
||||||
// A missing destination child means the source is NEWER.
|
// A missing destination child means the source is NEWER.
|
||||||
result.add(new AVMDifference(srcVersion, srcChild.getPath(),
|
result.add(new AVMDifference(srcVersion, srcChild.getPath(),
|
||||||
dstVersion,
|
dstVersion,
|
||||||
AVMNodeConverter.ExtendAVMPath(dstDesc.getPath(), name),
|
dstPath,
|
||||||
AVMDifference.NEWER));
|
AVMDifference.NEWER));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Otherwise recursively invoke.
|
// Otherwise recursively invoke.
|
||||||
compare(srcVersion, srcChild,
|
compare(srcVersion, srcChild,
|
||||||
dstVersion, dstChild,
|
dstVersion, dstChild,
|
||||||
result);
|
result, excluder);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -203,11 +214,17 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
|||||||
{
|
{
|
||||||
AVMNodeDescriptor dstChild = dstList.get(name);
|
AVMNodeDescriptor dstChild = dstList.get(name);
|
||||||
AVMNodeDescriptor srcChild = srcList.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)
|
if (srcChild == null)
|
||||||
{
|
{
|
||||||
// Missing means the source is older.
|
// Missing means the source is older.
|
||||||
result.add(new AVMDifference(srcVersion,
|
result.add(new AVMDifference(srcVersion,
|
||||||
AVMNodeConverter.ExtendAVMPath(srcDesc.getPath(), name),
|
srcPath,
|
||||||
dstVersion, dstChild.getPath(),
|
dstVersion, dstChild.getPath(),
|
||||||
AVMDifference.OLDER));
|
AVMDifference.OLDER));
|
||||||
continue;
|
continue;
|
||||||
@@ -215,7 +232,7 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
|||||||
// Otherwise, recursively invoke.
|
// Otherwise, recursively invoke.
|
||||||
compare(srcVersion, srcChild,
|
compare(srcVersion, srcChild,
|
||||||
dstVersion, dstChild,
|
dstVersion, dstChild,
|
||||||
result);
|
result, excluder);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -229,19 +246,25 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
|||||||
{
|
{
|
||||||
AVMNodeDescriptor srcChild = srcList.get(name);
|
AVMNodeDescriptor srcChild = srcList.get(name);
|
||||||
AVMNodeDescriptor dstChild = dstList.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)
|
if (dstChild == null)
|
||||||
{
|
{
|
||||||
// Not found in the destination means NEWER.
|
// Not found in the destination means NEWER.
|
||||||
result.add(new AVMDifference(srcVersion, srcChild.getPath(),
|
result.add(new AVMDifference(srcVersion, srcChild.getPath(),
|
||||||
dstVersion,
|
dstVersion,
|
||||||
AVMNodeConverter.ExtendAVMPath(dstDesc.getPath(), name),
|
dstPath,
|
||||||
AVMDifference.NEWER));
|
AVMDifference.NEWER));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Otherwise recursive invocation.
|
// Otherwise recursive invocation.
|
||||||
compare(srcVersion, srcChild,
|
compare(srcVersion, srcChild,
|
||||||
dstVersion, dstChild,
|
dstVersion, dstChild,
|
||||||
result);
|
result, excluder);
|
||||||
}
|
}
|
||||||
// Iterate over the destination.
|
// Iterate over the destination.
|
||||||
for (String name : dstList.keySet())
|
for (String name : dstList.keySet())
|
||||||
@@ -251,9 +274,15 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
AVMNodeDescriptor dstChild = dstList.get(name);
|
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.
|
// An entry not found in the source is OLDER.
|
||||||
result.add(new AVMDifference(srcVersion,
|
result.add(new AVMDifference(srcVersion,
|
||||||
AVMNodeConverter.ExtendAVMPath(srcDesc.getPath(), name),
|
srcPath,
|
||||||
dstVersion, dstChild.getPath(),
|
dstVersion, dstChild.getPath(),
|
||||||
AVMDifference.OLDER));
|
AVMDifference.OLDER));
|
||||||
}
|
}
|
||||||
@@ -272,6 +301,7 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
|||||||
* which the source of an AVMDifference is older than the destination
|
* which the source of an AVMDifference is older than the destination
|
||||||
* will cause the transaction to roll back.
|
* will cause the transaction to roll back.
|
||||||
* @param diffList A List of AVMDifference structs.
|
* @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
|
* @param ignoreConflicts If this is true the update will skip those
|
||||||
* AVMDifferences which are in conflict with
|
* AVMDifferences which are in conflict with
|
||||||
* the destination.
|
* the destination.
|
||||||
@@ -284,13 +314,19 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
|||||||
* @param description Full update blurb.
|
* @param description Full update blurb.
|
||||||
* in which the source is older than the destination and overwrite the destination.
|
* in which the source is older than the destination and overwrite the destination.
|
||||||
*/
|
*/
|
||||||
public void update(List<AVMDifference> diffList, boolean ignoreConflicts, boolean ignoreOlder,
|
public void update(List<AVMDifference> diffList,
|
||||||
|
NameMatcher excluder, boolean ignoreConflicts, boolean ignoreOlder,
|
||||||
boolean overrideConflicts, boolean overrideOlder, String tag, String description)
|
boolean overrideConflicts, boolean overrideOlder, String tag, String description)
|
||||||
{
|
{
|
||||||
Map<String, Integer> storeVersions = new HashMap<String, Integer>();
|
Map<String, Integer> storeVersions = new HashMap<String, Integer>();
|
||||||
Set<String> destStores = new HashSet<String>();
|
Set<String> destStores = new HashSet<String>();
|
||||||
for (AVMDifference diff : diffList)
|
for (AVMDifference diff : diffList)
|
||||||
{
|
{
|
||||||
|
if (excluder != null && (excluder.matches(diff.getSourcePath()) ||
|
||||||
|
excluder.matches(diff.getDestinationPath())))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!diff.isValid())
|
if (!diff.isValid())
|
||||||
{
|
{
|
||||||
throw new AVMSyncException("Malformed AVMDifference.");
|
throw new AVMSyncException("Malformed AVMDifference.");
|
||||||
@@ -317,10 +353,6 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
|||||||
}
|
}
|
||||||
AVMNodeDescriptor srcDesc = fAVMService.lookup(version,
|
AVMNodeDescriptor srcDesc = fAVMService.lookup(version,
|
||||||
diff.getSourcePath(), true);
|
diff.getSourcePath(), true);
|
||||||
// if (srcDesc == null)
|
|
||||||
// {
|
|
||||||
// throw new AVMSyncException("Source node not found: " + diff.getSourcePath());
|
|
||||||
// }
|
|
||||||
String [] dstParts = AVMNodeConverter.SplitBase(diff.getDestinationPath());
|
String [] dstParts = AVMNodeConverter.SplitBase(diff.getDestinationPath());
|
||||||
if (dstParts[0] == null || diff.getDestinationVersion() >= 0)
|
if (dstParts[0] == null || diff.getDestinationVersion() >= 0)
|
||||||
{
|
{
|
||||||
@@ -350,7 +382,7 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
|||||||
case AVMDifference.NEWER :
|
case AVMDifference.NEWER :
|
||||||
{
|
{
|
||||||
// You can't delete what isn't there.
|
// 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;
|
continue;
|
||||||
}
|
}
|
||||||
case AVMDifference.OLDER :
|
case AVMDifference.OLDER :
|
||||||
@@ -358,7 +390,7 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
|||||||
// You can force it.
|
// You can force it.
|
||||||
if (overrideOlder)
|
if (overrideOlder)
|
||||||
{
|
{
|
||||||
linkIn(dstParts[0], dstParts[1], srcDesc, !dstDesc.isDeleted());
|
linkIn(dstParts[0], dstParts[1], srcDesc, excluder, !dstDesc.isDeleted());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// You can ignore it.
|
// You can ignore it.
|
||||||
@@ -374,7 +406,7 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
|||||||
// You can force it.
|
// You can force it.
|
||||||
if (overrideConflicts)
|
if (overrideConflicts)
|
||||||
{
|
{
|
||||||
linkIn(dstParts[0], dstParts[1], srcDesc, true);
|
linkIn(dstParts[0], dstParts[1], srcDesc, excluder, true);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// You can ignore it.
|
// You can ignore it.
|
||||||
@@ -414,7 +446,7 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
|||||||
* @param toLink The node descriptor.
|
* @param toLink The node descriptor.
|
||||||
* @param removeFirst Whether to do a removeNode before linking in.
|
* @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.
|
// This is a delete.
|
||||||
if (toLink == null)
|
if (toLink == null)
|
||||||
@@ -429,7 +461,7 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
|||||||
}
|
}
|
||||||
if (toLink.isLayeredDirectory() && !toLink.isPrimary())
|
if (toLink.isLayeredDirectory() && !toLink.isPrimary())
|
||||||
{
|
{
|
||||||
recursiveCopy(parentPath, name, toLink);
|
recursiveCopy(parentPath, name, toLink, excluder);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fAVMService.link(parentPath, name, toLink);
|
fAVMService.link(parentPath, name, toLink);
|
||||||
@@ -441,7 +473,7 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
|||||||
* @param name The name to give it.
|
* @param name The name to give it.
|
||||||
* @param toCopy The it to put.
|
* @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);
|
fAVMService.createDirectory(parentPath, name);
|
||||||
String newParentPath = AVMNodeConverter.ExtendAVMPath(parentPath, name);
|
String newParentPath = AVMNodeConverter.ExtendAVMPath(parentPath, name);
|
||||||
@@ -451,7 +483,7 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
|||||||
fAVMService.getDirectoryListing(toCopy, true);
|
fAVMService.getDirectoryListing(toCopy, true);
|
||||||
for (Map.Entry<String, AVMNodeDescriptor> entry : children.entrySet())
|
for (Map.Entry<String, AVMNodeDescriptor> 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 name The name to link in.
|
||||||
* @param toCopy The node 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 it's a file or deleted simply link it in.
|
||||||
if (toCopy.isFile() || toCopy.isDeleted() || toCopy.isPlainDirectory())
|
if (toCopy.isFile() || toCopy.isDeleted() || toCopy.isPlainDirectory())
|
||||||
{
|
{
|
||||||
@@ -477,7 +515,7 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
|||||||
fAVMService.getDirectoryListing(toCopy, true);
|
fAVMService.getDirectoryListing(toCopy, true);
|
||||||
for (Map.Entry<String, AVMNodeDescriptor> entry : children.entrySet())
|
for (Map.Entry<String, AVMNodeDescriptor> entry : children.entrySet())
|
||||||
{
|
{
|
||||||
recursiveCopy(newParentDesc, entry.getKey(), entry.getValue());
|
recursiveCopy(newParentDesc, entry.getKey(), entry.getValue(), excluder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -9,6 +9,7 @@ import org.alfresco.service.cmr.avmsync.AVMDifference;
|
|||||||
import org.alfresco.service.cmr.avmsync.AVMSyncService;
|
import org.alfresco.service.cmr.avmsync.AVMSyncService;
|
||||||
import org.alfresco.service.cmr.remote.AVMSyncServiceTransport;
|
import org.alfresco.service.cmr.remote.AVMSyncServiceTransport;
|
||||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||||
|
import org.alfresco.util.NameMatcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Server side implementation of the remote wrapper of AVMSyncService.
|
* 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)
|
* @see org.alfresco.service.cmr.avmsync.AVMSyncServiceTransport#compare(java.lang.String, int, java.lang.String, int, java.lang.String)
|
||||||
*/
|
*/
|
||||||
public List<AVMDifference> compare(String ticket, int srcVersion,
|
public List<AVMDifference> compare(String ticket, int srcVersion,
|
||||||
String srcPath, int dstVersion, String dstPath)
|
String srcPath, int dstVersion, String dstPath, NameMatcher excluder)
|
||||||
{
|
{
|
||||||
fAuthenticationService.validate(ticket);
|
fAuthenticationService.validate(ticket);
|
||||||
return fSyncService.compare(srcVersion, srcPath, dstVersion, dstPath);
|
return fSyncService.compare(srcVersion, srcPath, dstVersion, dstPath, excluder);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@@ -74,12 +75,12 @@ public class AVMSyncServiceTransportImpl implements AVMSyncServiceTransport
|
|||||||
/* (non-Javadoc)
|
/* (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)
|
* @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<AVMDifference> diffList,
|
public void update(String ticket, List<AVMDifference> diffList, NameMatcher excluder,
|
||||||
boolean ignoreConflicts, boolean ignoreOlder,
|
boolean ignoreConflicts, boolean ignoreOlder,
|
||||||
boolean overrideConflicts, boolean overrideOlder, String tag,
|
boolean overrideConflicts, boolean overrideOlder, String tag,
|
||||||
String description)
|
String description)
|
||||||
{
|
{
|
||||||
fAuthenticationService.validate(ticket);
|
fAuthenticationService.validate(ticket);
|
||||||
fSyncService.update(diffList, ignoreConflicts, ignoreOlder, overrideConflicts, overrideOlder, tag, description);
|
fSyncService.update(diffList, excluder, ignoreConflicts, ignoreOlder, overrideConflicts, overrideOlder, tag, description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -199,14 +199,14 @@ public class AVMTestRemote extends TestCase
|
|||||||
fAVMRemote.createAVMStore("broo");
|
fAVMRemote.createAVMStore("broo");
|
||||||
// Create a branch.
|
// Create a branch.
|
||||||
fAVMRemote.createBranch(-1, "froo:/a", "broo:/", "a");
|
fAVMRemote.createBranch(-1, "froo:/a", "broo:/", "a");
|
||||||
List<AVMDifference> diffs = fAVMSync.compare(-1, "froo:/a", -1, "broo:/a");
|
List<AVMDifference> diffs = fAVMSync.compare(-1, "froo:/a", -1, "broo:/a", null);
|
||||||
assertEquals(0, diffs.size());
|
assertEquals(0, diffs.size());
|
||||||
fAVMRemote.createFile("froo:/a", "bar").close();
|
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());
|
assertEquals(1, diffs.size());
|
||||||
// Update.
|
// Update.
|
||||||
fAVMSync.update(diffs, false, false, false, false, "flippy", "Stuff");
|
fAVMSync.update(diffs, null, false, false, false, false, "flippy", "Stuff");
|
||||||
diffs = fAVMSync.compare(-1, "froo:/a", -1, "broo:/a");
|
diffs = fAVMSync.compare(-1, "froo:/a", -1, "broo:/a", null);
|
||||||
assertEquals(0, diffs.size());
|
assertEquals(0, diffs.size());
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@@ -555,6 +555,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
|
|||||||
ChildKey key = new ChildKey(this, name);
|
ChildKey key = new ChildKey(this, name);
|
||||||
ChildEntry entry = AVMDAOs.Instance().fChildEntryDAO.get(key);
|
ChildEntry entry = AVMDAOs.Instance().fChildEntryDAO.get(key);
|
||||||
AVMNode child = null;
|
AVMNode child = null;
|
||||||
|
boolean indirect = false;
|
||||||
if (entry != null)
|
if (entry != null)
|
||||||
{
|
{
|
||||||
child = entry.getChild();
|
child = entry.getChild();
|
||||||
@@ -567,13 +568,21 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
child = lookupChild(lPath, name, false);
|
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -229,13 +229,20 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AVMNode ghost = new DeletedNodeImpl(lPath.getAVMStore().getAVMRepository().issueID(),
|
|
||||||
lPath.getAVMStore());
|
|
||||||
AVMDAOs.Instance().fChildEntryDAO.delete(entry);
|
AVMDAOs.Instance().fChildEntryDAO.delete(entry);
|
||||||
AVMDAOs.Instance().fAVMNodeDAO.save(ghost);
|
if (child.getStoreNew() == null || child.getAncestor() != null)
|
||||||
AVMDAOs.Instance().fAVMNodeDAO.flush();
|
{
|
||||||
ghost.setAncestor(child);
|
AVMNode ghost = new DeletedNodeImpl(lPath.getAVMStore().getAVMRepository().issueID(),
|
||||||
putChild(name, ghost);
|
lPath.getAVMStore());
|
||||||
|
AVMDAOs.Instance().fAVMNodeDAO.save(ghost);
|
||||||
|
AVMDAOs.Instance().fAVMNodeDAO.flush();
|
||||||
|
ghost.setAncestor(child);
|
||||||
|
putChild(name, ghost);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AVMDAOs.Instance().fAVMNodeDAO.flush();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -68,11 +68,11 @@ public class AVMRevertListAction extends ActionExecuterAbstractBase
|
|||||||
{
|
{
|
||||||
List<AVMDifference> diffSet =
|
List<AVMDifference> diffSet =
|
||||||
fSyncService.compare(revertVersion, item.getSecond(),
|
fSyncService.compare(revertVersion, item.getSecond(),
|
||||||
-1, item.getSecond());
|
-1, item.getSecond(), null);
|
||||||
diffs.addAll(diffSet);
|
diffs.addAll(diffSet);
|
||||||
}
|
}
|
||||||
String message = "Reverted to version " + revertVersion;
|
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))
|
if (!(Boolean)action.getParameterValue(PARAM_FLATTEN))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@@ -54,9 +54,9 @@ public class AVMRevertStoreAction extends ActionExecuterAbstractBase
|
|||||||
int revertVersion = (Integer)action.getParameterValue(PARAM_VERSION);
|
int revertVersion = (Integer)action.getParameterValue(PARAM_VERSION);
|
||||||
List<AVMDifference> diffs =
|
List<AVMDifference> diffs =
|
||||||
fSyncService.compare(revertVersion, pathVersion.getSecond(),
|
fSyncService.compare(revertVersion, pathVersion.getSecond(),
|
||||||
-1, pathVersion.getSecond());
|
-1, pathVersion.getSecond(), null);
|
||||||
String message = "Reverted to Version " + revertVersion + ".";
|
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)
|
/* (non-Javadoc)
|
||||||
|
@@ -89,10 +89,10 @@ public class SimpleAVMPromoteAction extends ActionExecuterAbstractBase
|
|||||||
String targetPath = targetStoreName + ":" + storePath[1];
|
String targetPath = targetStoreName + ":" + storePath[1];
|
||||||
// Find the differences.
|
// Find the differences.
|
||||||
List<AVMDifference> diffs =
|
List<AVMDifference> diffs =
|
||||||
fAVMSyncService.compare(version, path, -1, targetPath);
|
fAVMSyncService.compare(version, path, -1, targetPath, null);
|
||||||
// TODO fix update comments at some point.
|
// TODO fix update comments at some point.
|
||||||
// Do the promote.
|
// 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.
|
// Flatten the source on top of the destination.
|
||||||
fAVMSyncService.flatten(storePath[0] + ":/appBase",
|
fAVMSyncService.flatten(storePath[0] + ":/appBase",
|
||||||
targetStoreName + ":/appBase");
|
targetStoreName + ":/appBase");
|
||||||
|
@@ -31,6 +31,7 @@ import org.alfresco.service.cmr.avmsync.AVMSyncException;
|
|||||||
import org.alfresco.service.cmr.avmsync.AVMSyncService;
|
import org.alfresco.service.cmr.avmsync.AVMSyncService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.alfresco.util.NameMatcher;
|
||||||
import org.alfresco.util.Pair;
|
import org.alfresco.util.Pair;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
@@ -55,6 +56,11 @@ public class SimpleAVMSubmitAction extends ActionExecuterAbstractBase
|
|||||||
*/
|
*/
|
||||||
private AVMSyncService fAVMSyncService;
|
private AVMSyncService fAVMSyncService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Excluding NameMatcher.
|
||||||
|
*/
|
||||||
|
private NameMatcher fExcluder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor.
|
* Default constructor.
|
||||||
*/
|
*/
|
||||||
@@ -81,6 +87,16 @@ public class SimpleAVMSubmitAction extends ActionExecuterAbstractBase
|
|||||||
fAVMSyncService = avmSyncService;
|
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.
|
* Perform the action. The NodeRef must be an AVM NodeRef.
|
||||||
* @param action Don't actually need anything from this here.
|
* @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];
|
String avmDest = websiteName + "-staging:" + storePath[1];
|
||||||
// Get the difference between source and destination.
|
// Get the difference between source and destination.
|
||||||
List<AVMDifference> diffs =
|
List<AVMDifference> diffs =
|
||||||
fAVMSyncService.compare(version, path, -1, avmDest);
|
fAVMSyncService.compare(version, path, -1, avmDest, fExcluder);
|
||||||
// TODO fix update comments at some point.
|
// TODO fix update comments at some point.
|
||||||
// Do the update.
|
// 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);
|
"Submit of item: " + AVMNodeConverter.SplitBase(path)[1], null);
|
||||||
// Cleanup by flattening the source relative to the destination.
|
// Cleanup by flattening the source relative to the destination.
|
||||||
AVMDAOs.Instance().fAVMNodeDAO.flush();
|
AVMDAOs.Instance().fAVMNodeDAO.flush();
|
||||||
|
@@ -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<String> fExtensions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
public FileExtensionNameMatcher()
|
||||||
|
{
|
||||||
|
fExtensions = new ArrayList<String>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the extensions case insensitively.
|
||||||
|
* @param extensions
|
||||||
|
*/
|
||||||
|
public void setExtensions(List<String> 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;
|
||||||
|
}
|
||||||
|
}
|
@@ -78,10 +78,10 @@ public class AVMSubmitHandler extends JBPMSpringActionHandler
|
|||||||
getStringValue();
|
getStringValue();
|
||||||
String avmDest = webSiteName + "-staging:" + storePath[1];
|
String avmDest = webSiteName + "-staging:" + storePath[1];
|
||||||
List<AVMDifference> diffs =
|
List<AVMDifference> diffs =
|
||||||
fAVMSyncService.compare(-1, avmSource, -1, avmDest);
|
fAVMSyncService.compare(-1, avmSource, -1, avmDest, null);
|
||||||
// TODO fix update comments if needed.
|
// TODO fix update comments if needed.
|
||||||
// Ignore conflicts and older nodes for now.
|
// 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.
|
// Now flatten out the source.
|
||||||
fAVMSyncService.flatten(avmSource, avmDest);
|
fAVMSyncService.flatten(avmSource, avmDest);
|
||||||
}
|
}
|
||||||
|
@@ -59,8 +59,8 @@ public class AVMSubmitPackageHandler extends JBPMSpringActionHandler implements
|
|||||||
|
|
||||||
AVMNodeDescriptor pkgDesc = fAVMService.lookup(pkgPath.getFirst(), pkgPath.getSecond());
|
AVMNodeDescriptor pkgDesc = fAVMService.lookup(pkgPath.getFirst(), pkgPath.getSecond());
|
||||||
String targetPath = pkgDesc.getIndirection();
|
String targetPath = pkgDesc.getIndirection();
|
||||||
List<AVMDifference> diff = fAVMSyncService.compare(pkgPath.getFirst(), pkgPath.getSecond(), -1, targetPath);
|
List<AVMDifference> diff = fAVMSyncService.compare(pkgPath.getFirst(), pkgPath.getSecond(), -1, targetPath, null);
|
||||||
fAVMSyncService.update(diff, true, true, false, false, null, null);
|
fAVMSyncService.update(diff, null, true, true, false, false, null, null);
|
||||||
|
|
||||||
String from = (String)executionContext.getContextInstance().getVariable("wf_from");
|
String from = (String)executionContext.getContextInstance().getVariable("wf_from");
|
||||||
fAVMSyncService.flatten(from, targetPath);
|
fAVMSyncService.flatten(from, targetPath);
|
||||||
|
@@ -8,6 +8,7 @@ import java.util.List;
|
|||||||
import org.alfresco.service.cmr.avmsync.AVMDifference;
|
import org.alfresco.service.cmr.avmsync.AVMDifference;
|
||||||
import org.alfresco.service.cmr.avmsync.AVMSyncService;
|
import org.alfresco.service.cmr.avmsync.AVMSyncService;
|
||||||
import org.alfresco.service.cmr.remote.AVMSyncServiceTransport;
|
import org.alfresco.service.cmr.remote.AVMSyncServiceTransport;
|
||||||
|
import org.alfresco.util.NameMatcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client side wrapper around the RMI based AVMSyncServiceTransport.
|
* 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)
|
* @see org.alfresco.service.cmr.avmsync.AVMSyncService#compare(int, java.lang.String, int, java.lang.String)
|
||||||
*/
|
*/
|
||||||
public List<AVMDifference> compare(int srcVersion, String srcPath,
|
public List<AVMDifference> 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)
|
/* (non-Javadoc)
|
||||||
@@ -63,10 +64,11 @@ public class AVMSyncServiceClient implements AVMSyncService
|
|||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.service.cmr.avmsync.AVMSyncService#update(java.util.List, boolean, boolean, boolean, boolean, java.lang.String, java.lang.String)
|
* @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<AVMDifference> diffList, boolean ignoreConflicts,
|
public void update(List<AVMDifference> diffList,
|
||||||
boolean ignoreOlder, boolean overrideConflicts,
|
NameMatcher excluder, boolean ignoreConflicts,
|
||||||
boolean overrideOlder, String tag, String description)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -720,8 +720,8 @@ public class WorkflowInterpreter
|
|||||||
if (avmSourceIndirection != null)
|
if (avmSourceIndirection != null)
|
||||||
{
|
{
|
||||||
avmService.createLayeredDirectory(avmSourceIndirection, packagesPath, packageName);
|
avmService.createLayeredDirectory(avmSourceIndirection, packagesPath, packageName);
|
||||||
List<AVMDifference> diff = avmSyncService.compare(-1, avmSource.getPath(), -1, packagesPath + "/" + packageName);
|
List<AVMDifference> diff = avmSyncService.compare(-1, avmSource.getPath(), -1, packagesPath + "/" + packageName, null);
|
||||||
avmSyncService.update(diff, true, true, false, false, null, null);
|
avmSyncService.update(diff, null, true, true, false, false, null, null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -19,6 +19,8 @@ package org.alfresco.service.cmr.avmsync;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.alfresco.util.NameMatcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This service handles comparisons and synchronizations between
|
* This service handles comparisons and synchronizations between
|
||||||
* corresponding avm node trees.
|
* corresponding avm node trees.
|
||||||
@@ -32,11 +34,13 @@ public interface AVMSyncService
|
|||||||
* @param srcPath The avm path to the source tree.
|
* @param srcPath The avm path to the source tree.
|
||||||
* @param dstVersion The version id for the destination tree.
|
* @param dstVersion The version id for the destination tree.
|
||||||
* @param dstPath The avm path to 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
|
* @return A List of AVMDifference structs which can be used for
|
||||||
* the update operation.
|
* the update operation.
|
||||||
*/
|
*/
|
||||||
public List<AVMDifference> compare(int srcVersion, String srcPath,
|
public List<AVMDifference> compare(int srcVersion, String srcPath,
|
||||||
int dstVersion, String dstPath);
|
int dstVersion, String dstPath,
|
||||||
|
NameMatcher excluder);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the destination nodes in the AVMDifferences
|
* Updates the destination nodes in the AVMDifferences
|
||||||
@@ -56,7 +60,7 @@ public interface AVMSyncService
|
|||||||
* @param tag Short comment.
|
* @param tag Short comment.
|
||||||
* @param description Full update blurb.
|
* @param description Full update blurb.
|
||||||
*/
|
*/
|
||||||
public void update(List<AVMDifference> diffList, boolean ignoreConflicts, boolean ignoreOlder,
|
public void update(List<AVMDifference> diffList, NameMatcher excluder, boolean ignoreConflicts, boolean ignoreOlder,
|
||||||
boolean overrideConflicts, boolean overrideOlder, String tag, String description);
|
boolean overrideConflicts, boolean overrideOlder, String tag, String description);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -6,6 +6,7 @@ package org.alfresco.service.cmr.remote;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.alfresco.service.cmr.avmsync.AVMDifference;
|
import org.alfresco.service.cmr.avmsync.AVMDifference;
|
||||||
|
import org.alfresco.util.NameMatcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A wrapper around AVMSyncService for remote access.
|
* A wrapper around AVMSyncService for remote access.
|
||||||
@@ -24,7 +25,8 @@ public interface AVMSyncServiceTransport
|
|||||||
*/
|
*/
|
||||||
public List<AVMDifference> compare(String ticket,
|
public List<AVMDifference> compare(String ticket,
|
||||||
int srcVersion, String srcPath,
|
int srcVersion, String srcPath,
|
||||||
int dstVersion, String dstPath);
|
int dstVersion, String dstPath,
|
||||||
|
NameMatcher excluder);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the destination nodes in the AVMDifferences
|
* 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
|
* which the source of an AVMDifference is older than the destination
|
||||||
* will cause the transaction to roll back.
|
* will cause the transaction to roll back.
|
||||||
* @param diffList A List of AVMDifference structs.
|
* @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
|
* @param ignoreConflicts If this is true the update will skip those
|
||||||
* AVMDifferences which are in conflict with
|
* AVMDifferences which are in conflict with
|
||||||
* the destination.
|
* the destination.
|
||||||
@@ -44,7 +47,8 @@ public interface AVMSyncServiceTransport
|
|||||||
* @param tag Short comment.
|
* @param tag Short comment.
|
||||||
* @param description Full update blurb.
|
* @param description Full update blurb.
|
||||||
*/
|
*/
|
||||||
public void update(String ticket, List<AVMDifference> diffList, boolean ignoreConflicts, boolean ignoreOlder,
|
public void update(String ticket, List<AVMDifference> diffList,
|
||||||
|
NameMatcher excluder, boolean ignoreConflicts, boolean ignoreOlder,
|
||||||
boolean overrideConflicts, boolean overrideOlder, String tag, String description);
|
boolean overrideConflicts, boolean overrideOlder, String tag, String description);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user