Alfresco->Alfresco deployment understands exclusions.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6228 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2007-07-12 14:03:41 +00:00
parent 60866f22b1
commit 92c16b80d0
2 changed files with 53 additions and 39 deletions

View File

@@ -475,16 +475,19 @@ public class AVMServiceTest extends AVMServiceTestBase
try try
{ {
DeploymentService depService = (DeploymentService) fContext.getBean("DeploymentService"); DeploymentService depService = (DeploymentService) fContext.getBean("DeploymentService");
NameMatcher matcher = (NameMatcher)fContext.getBean("globalPathExcluder");
setupBasicTree(); setupBasicTree();
fService.addAspect("main:/a", ContentModel.ASPECT_REFERENCEABLE); fService.addAspect("main:/a", ContentModel.ASPECT_REFERENCEABLE);
fService.addAspect("main:/a/b", ContentModel.ASPECT_REFERENCEABLE); fService.addAspect("main:/a/b", ContentModel.ASPECT_REFERENCEABLE);
fService.addAspect("main:/a/b/c", ContentModel.ASPECT_REFERENCEABLE); fService.addAspect("main:/a/b/c", ContentModel.ASPECT_REFERENCEABLE);
fService.addAspect("main:/a/b/c/foo", ContentModel.ASPECT_REFERENCEABLE); fService.addAspect("main:/a/b/c/foo", ContentModel.ASPECT_REFERENCEABLE);
fService.addAspect("main:/a/b/c/bar", ContentModel.ASPECT_REFERENCEABLE); fService.addAspect("main:/a/b/c/bar", ContentModel.ASPECT_REFERENCEABLE);
fService.createFile("main:/a/b", "snarl.bak").close();
// TestDeploymentCallback callback = new TestDeploymentCallback(); // TestDeploymentCallback callback = new TestDeploymentCallback();
fService.createStore("target"); fService.createStore("target");
DeploymentReport report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", DeploymentReport report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin",
"target:/a", null, false, false, false, null); "target:/a", matcher, false, false, false, null);
assertNull(fService.lookup(-1, "target:/a/b/snarl.bak"));
runQueriesAgainstBasicTreeWithAOnly("target"); runQueriesAgainstBasicTreeWithAOnly("target");
System.out.println(report); System.out.println(report);
assertEquals(fService.lookup(-1, "main:/a/b/c/foo").getGuid(), fService.lookup(-1, "target:/a/b/c/foo") assertEquals(fService.lookup(-1, "main:/a/b/c/foo").getGuid(), fService.lookup(-1, "target:/a/b/c/foo")
@@ -495,39 +498,39 @@ public class AVMServiceTest extends AVMServiceTestBase
ContentData dstCD = fService.getContentDataForRead(-1, "target:/a/b/c/foo"); ContentData dstCD = fService.getContentDataForRead(-1, "target:/a/b/c/foo");
assertEquals(srcCD.getMimetype(), dstCD.getMimetype()); assertEquals(srcCD.getMimetype(), dstCD.getMimetype());
fService.createFile("main:/a/b", "biz").close(); fService.createFile("main:/a/b", "biz").close();
report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", null, report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", matcher,
false, false, true, null); false, false, true, null);
// Nothing was done // Nothing was done
runQueriesAgainstBasicTreeWithAOnly("target"); runQueriesAgainstBasicTreeWithAOnly("target");
System.out.println(report); System.out.println(report);
System.out.println(recursiveList("target", -1, true)); System.out.println(recursiveList("target", -1, true));
assertNull(fService.lookup(-1, "target:/a/b/biz")); assertNull(fService.lookup(-1, "target:/a/b/biz"));
report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", null, report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", matcher,
false, false, false, null); false, false, false, null);
System.out.println(report); System.out.println(report);
runQueriesForCreateAndDeploy("target"); runQueriesForCreateAndDeploy("target");
assertEquals(fService.lookup(-1, "main:/a/b/biz").getGuid(), fService.lookup(-1, "target:/a/b/biz") assertEquals(fService.lookup(-1, "main:/a/b/biz").getGuid(), fService.lookup(-1, "target:/a/b/biz")
.getGuid()); .getGuid());
fService.removeNode("main:/a/b/c/foo"); fService.removeNode("main:/a/b/c/foo");
report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", null, report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", matcher,
false, true, false, null); false, true, false, null);
runQueriesForCreateAndDeploy("target"); runQueriesForCreateAndDeploy("target");
System.out.println(report); System.out.println(report);
assertNotNull(fService.lookup(-1, "target:/a/b/c/foo")); assertNotNull(fService.lookup(-1, "target:/a/b/c/foo"));
report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", null, report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", matcher,
false, false, false, null); false, false, false, null);
System.out.println(report); System.out.println(report);
runQueriesForRemoveAndDelpoy("target"); runQueriesForRemoveAndDelpoy("target");
assertNull(fService.lookup(-1, "target:/a/b/c/foo")); assertNull(fService.lookup(-1, "target:/a/b/c/foo"));
fService.removeNode("main:/a/b/c/bar"); fService.removeNode("main:/a/b/c/bar");
fService.createDirectory("main:/a/b/c", "bar"); fService.createDirectory("main:/a/b/c", "bar");
report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", null, report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", matcher,
false, false, false, null); false, false, false, null);
System.out.println(report); System.out.println(report);
runQueriesForRemoveFileAndCreateDirectoryAndDeploy("target"); runQueriesForRemoveFileAndCreateDirectoryAndDeploy("target");
report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", null, report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", matcher,
false, false, false, null); false, false, false, null);
depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target2:/wiggly/diggly", null, depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target2:/wiggly/diggly", matcher,
true, false, false, null); true, false, false, null);
System.out.println(report); System.out.println(report);
} }

View File

@@ -151,7 +151,6 @@ public class DeploymentServiceImpl implements DeploymentService
} }
} }
snapshot = remote.createSnapshot(storePath[0], "PreDeploy", "Pre Deployment Snapshot").get(storePath[0]); snapshot = remote.createSnapshot(storePath[0], "PreDeploy", "Pre Deployment Snapshot").get(storePath[0]);
} }
// Get the root of the deployment on the destination server. // Get the root of the deployment on the destination server.
AVMNodeDescriptor dstRoot = remote.lookup(-1, dstPath); AVMNodeDescriptor dstRoot = remote.lookup(-1, dstPath);
@@ -171,7 +170,7 @@ public class DeploymentServiceImpl implements DeploymentService
{ {
return report; return report;
} }
copyDirectory(version, srcRoot, dstParent, remote); copyDirectory(version, srcRoot, dstParent, remote, matcher);
remote.createSnapshot(storePath[0], "Deployment", "Post Deployment Snapshot."); remote.createSnapshot(storePath[0], "Deployment", "Post Deployment Snapshot.");
if (callback != null) if (callback != null)
{ {
@@ -189,7 +188,7 @@ public class DeploymentServiceImpl implements DeploymentService
// The corresponding directory exists so recursively deploy. // The corresponding directory exists so recursively deploy.
try try
{ {
deployDirectoryPush(version, srcRoot, dstRoot, remote, dontDelete, dontDo, report, callback); deployDirectoryPush(version, srcRoot, dstRoot, remote, matcher, dontDelete, dontDo, report, callback);
remote.createSnapshot(storePath[0], "Deployment", "Post Deployment Snapshot."); remote.createSnapshot(storePath[0], "Deployment", "Post Deployment Snapshot.");
if (callback != null) if (callback != null)
{ {
@@ -234,7 +233,9 @@ public class DeploymentServiceImpl implements DeploymentService
*/ */
private void deployDirectoryPush(int version, private void deployDirectoryPush(int version,
AVMNodeDescriptor src, AVMNodeDescriptor dst, AVMNodeDescriptor src, AVMNodeDescriptor dst,
AVMRemote remote, boolean dontDelete, boolean dontDo, AVMRemote remote,
NameMatcher matcher,
boolean dontDelete, boolean dontDo,
DeploymentReport report, DeploymentReport report,
DeploymentCallback callback) DeploymentCallback callback)
{ {
@@ -255,7 +256,10 @@ public class DeploymentServiceImpl implements DeploymentService
String name = entry.getKey(); String name = entry.getKey();
AVMNodeDescriptor srcNode = entry.getValue(); AVMNodeDescriptor srcNode = entry.getValue();
AVMNodeDescriptor dstNode = dstList.get(name); AVMNodeDescriptor dstNode = dstList.get(name);
deploySinglePush(version, srcNode, dst, dstNode, remote, dontDelete, dontDo, report, callback); if (!excluded(matcher, srcNode.getPath(), dstNode != null ? dstNode.getPath() : null))
{
deploySinglePush(version, srcNode, dst, dstNode, remote, matcher, dontDelete, dontDo, report, callback);
}
} }
// Delete nodes that are missing in the source. // Delete nodes that are missing in the source.
if (dontDelete) if (dontDelete)
@@ -269,6 +273,8 @@ public class DeploymentServiceImpl implements DeploymentService
Pair<Integer, String> source = Pair<Integer, String> source =
new Pair<Integer, String>(version, AVMNodeConverter.ExtendAVMPath(src.getPath(), name)); new Pair<Integer, String>(version, AVMNodeConverter.ExtendAVMPath(src.getPath(), name));
String destination = AVMNodeConverter.ExtendAVMPath(dst.getPath(), name); String destination = AVMNodeConverter.ExtendAVMPath(dst.getPath(), name);
if (!excluded(matcher, null, destination))
{
DeploymentEvent event = DeploymentEvent event =
new DeploymentEvent(DeploymentEvent.Type.DELETED, new DeploymentEvent(DeploymentEvent.Type.DELETED,
source, source,
@@ -286,6 +292,7 @@ public class DeploymentServiceImpl implements DeploymentService
} }
} }
} }
}
/** /**
* Push out a single node. * Push out a single node.
@@ -299,6 +306,7 @@ public class DeploymentServiceImpl implements DeploymentService
private void deploySinglePush(int version, private void deploySinglePush(int version,
AVMNodeDescriptor src, AVMNodeDescriptor dstParent, AVMNodeDescriptor src, AVMNodeDescriptor dstParent,
AVMNodeDescriptor dst, AVMRemote remote, AVMNodeDescriptor dst, AVMRemote remote,
NameMatcher matcher,
boolean dontDelete, boolean dontDo, boolean dontDelete, boolean dontDo,
DeploymentReport report, DeploymentReport report,
DeploymentCallback callback) DeploymentCallback callback)
@@ -324,7 +332,7 @@ public class DeploymentServiceImpl implements DeploymentService
{ {
return; return;
} }
copyDirectory(version, src, dstParent, remote); copyDirectory(version, src, dstParent, remote, matcher);
return; return;
} }
Pair<Integer, String> source = Pair<Integer, String> source =
@@ -355,7 +363,7 @@ public class DeploymentServiceImpl implements DeploymentService
// If the destination is also a directory, recursively deploy. // If the destination is also a directory, recursively deploy.
if (dst.isDirectory()) if (dst.isDirectory())
{ {
deployDirectoryPush(version, src, dst, remote, dontDelete, dontDo, report, callback); deployDirectoryPush(version, src, dst, remote, matcher, dontDelete, dontDo, report, callback);
return; return;
} }
Pair<Integer, String> source = Pair<Integer, String> source =
@@ -373,7 +381,7 @@ public class DeploymentServiceImpl implements DeploymentService
return; return;
} }
remote.removeNode(dstParent.getPath(), src.getName()); remote.removeNode(dstParent.getPath(), src.getName());
copyDirectory(version, src, dstParent, remote); copyDirectory(version, src, dstParent, remote, matcher);
return; return;
} }
// Source is a file. // Source is a file.
@@ -436,7 +444,7 @@ public class DeploymentServiceImpl implements DeploymentService
* @param remote * @param remote
*/ */
private void copyDirectory(int version, AVMNodeDescriptor src, AVMNodeDescriptor parent, private void copyDirectory(int version, AVMNodeDescriptor src, AVMNodeDescriptor parent,
AVMRemote remote) AVMRemote remote, NameMatcher matcher)
{ {
// Create the destination directory. // Create the destination directory.
remote.createDirectory(parent.getPath(), src.getName()); remote.createDirectory(parent.getPath(), src.getName());
@@ -446,6 +454,8 @@ public class DeploymentServiceImpl implements DeploymentService
fAVMService.getDirectoryListing(src); fAVMService.getDirectoryListing(src);
// For each child in the source directory. // For each child in the source directory.
for (AVMNodeDescriptor child : list.values()) for (AVMNodeDescriptor child : list.values())
{
if (!excluded(matcher, child.getPath(), null))
{ {
// If it's a file, copy it over and move on. // If it's a file, copy it over and move on.
if (child.isFile()) if (child.isFile())
@@ -457,7 +467,8 @@ public class DeploymentServiceImpl implements DeploymentService
continue; continue;
} }
// Otherwise copy the child directory recursively. // Otherwise copy the child directory recursively.
copyDirectory(version, child, newParent, remote); copyDirectory(version, child, newParent, remote, matcher);
}
} }
} }