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
{
DeploymentService depService = (DeploymentService) fContext.getBean("DeploymentService");
NameMatcher matcher = (NameMatcher)fContext.getBean("globalPathExcluder");
setupBasicTree();
fService.addAspect("main:/a", 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/foo", 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();
fService.createStore("target");
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");
System.out.println(report);
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");
assertEquals(srcCD.getMimetype(), dstCD.getMimetype());
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);
// Nothing was done
runQueriesAgainstBasicTreeWithAOnly("target");
System.out.println(report);
System.out.println(recursiveList("target", -1, true));
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);
System.out.println(report);
runQueriesForCreateAndDeploy("target");
assertEquals(fService.lookup(-1, "main:/a/b/biz").getGuid(), fService.lookup(-1, "target:/a/b/biz")
.getGuid());
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);
runQueriesForCreateAndDeploy("target");
System.out.println(report);
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);
System.out.println(report);
runQueriesForRemoveAndDelpoy("target");
assertNull(fService.lookup(-1, "target:/a/b/c/foo"));
fService.removeNode("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);
System.out.println(report);
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);
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);
System.out.println(report);
}

View File

@@ -150,8 +150,7 @@ public class DeploymentServiceImpl implements DeploymentService
throw new AVMNotFoundException("Node Not Found: " + parentBase[0]);
}
}
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.
AVMNodeDescriptor dstRoot = remote.lookup(-1, dstPath);
@@ -171,7 +170,7 @@ public class DeploymentServiceImpl implements DeploymentService
{
return report;
}
copyDirectory(version, srcRoot, dstParent, remote);
copyDirectory(version, srcRoot, dstParent, remote, matcher);
remote.createSnapshot(storePath[0], "Deployment", "Post Deployment Snapshot.");
if (callback != null)
{
@@ -189,7 +188,7 @@ public class DeploymentServiceImpl implements DeploymentService
// The corresponding directory exists so recursively deploy.
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.");
if (callback != null)
{
@@ -234,7 +233,9 @@ public class DeploymentServiceImpl implements DeploymentService
*/
private void deployDirectoryPush(int version,
AVMNodeDescriptor src, AVMNodeDescriptor dst,
AVMRemote remote, boolean dontDelete, boolean dontDo,
AVMRemote remote,
NameMatcher matcher,
boolean dontDelete, boolean dontDo,
DeploymentReport report,
DeploymentCallback callback)
{
@@ -255,7 +256,10 @@ public class DeploymentServiceImpl implements DeploymentService
String name = entry.getKey();
AVMNodeDescriptor srcNode = entry.getValue();
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.
if (dontDelete)
@@ -269,20 +273,23 @@ public class DeploymentServiceImpl implements DeploymentService
Pair<Integer, String> source =
new Pair<Integer, String>(version, AVMNodeConverter.ExtendAVMPath(src.getPath(), name));
String destination = AVMNodeConverter.ExtendAVMPath(dst.getPath(), name);
DeploymentEvent event =
new DeploymentEvent(DeploymentEvent.Type.DELETED,
source,
destination);
report.add(event);
if (callback != null)
if (!excluded(matcher, null, destination))
{
callback.eventOccurred(event);
DeploymentEvent event =
new DeploymentEvent(DeploymentEvent.Type.DELETED,
source,
destination);
report.add(event);
if (callback != null)
{
callback.eventOccurred(event);
}
if (dontDo)
{
continue;
}
remote.removeNode(dst.getPath(), name);
}
if (dontDo)
{
continue;
}
remote.removeNode(dst.getPath(), name);
}
}
}
@@ -299,6 +306,7 @@ public class DeploymentServiceImpl implements DeploymentService
private void deploySinglePush(int version,
AVMNodeDescriptor src, AVMNodeDescriptor dstParent,
AVMNodeDescriptor dst, AVMRemote remote,
NameMatcher matcher,
boolean dontDelete, boolean dontDo,
DeploymentReport report,
DeploymentCallback callback)
@@ -324,7 +332,7 @@ public class DeploymentServiceImpl implements DeploymentService
{
return;
}
copyDirectory(version, src, dstParent, remote);
copyDirectory(version, src, dstParent, remote, matcher);
return;
}
Pair<Integer, String> source =
@@ -355,7 +363,7 @@ public class DeploymentServiceImpl implements DeploymentService
// If the destination is also a directory, recursively deploy.
if (dst.isDirectory())
{
deployDirectoryPush(version, src, dst, remote, dontDelete, dontDo, report, callback);
deployDirectoryPush(version, src, dst, remote, matcher, dontDelete, dontDo, report, callback);
return;
}
Pair<Integer, String> source =
@@ -373,7 +381,7 @@ public class DeploymentServiceImpl implements DeploymentService
return;
}
remote.removeNode(dstParent.getPath(), src.getName());
copyDirectory(version, src, dstParent, remote);
copyDirectory(version, src, dstParent, remote, matcher);
return;
}
// Source is a file.
@@ -436,7 +444,7 @@ public class DeploymentServiceImpl implements DeploymentService
* @param remote
*/
private void copyDirectory(int version, AVMNodeDescriptor src, AVMNodeDescriptor parent,
AVMRemote remote)
AVMRemote remote, NameMatcher matcher)
{
// Create the destination directory.
remote.createDirectory(parent.getPath(), src.getName());
@@ -447,17 +455,20 @@ public class DeploymentServiceImpl implements DeploymentService
// For each child in the source directory.
for (AVMNodeDescriptor child : list.values())
{
// If it's a file, copy it over and move on.
if (child.isFile())
if (!excluded(matcher, child.getPath(), null))
{
InputStream in = fAVMService.getFileInputStream(child);
OutputStream out = remote.createFile(newParent.getPath(), child.getName());
copyStream(in, out);
copyMetadata(version, child, remote.lookup(-1, newParent.getPath() + '/' + child.getName()), remote);
continue;
// If it's a file, copy it over and move on.
if (child.isFile())
{
InputStream in = fAVMService.getFileInputStream(child);
OutputStream out = remote.createFile(newParent.getPath(), child.getName());
copyStream(in, out);
copyMetadata(version, child, remote.lookup(-1, newParent.getPath() + '/' + child.getName()), remote);
continue;
}
// Otherwise copy the child directory recursively.
copyDirectory(version, child, newParent, remote, matcher);
}
// Otherwise copy the child directory recursively.
copyDirectory(version, child, newParent, remote);
}
}