mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Deployment stuff.
Filesystem deployment can now run a given java class, or external program on commit. Changed signatures of DeploymentService methods to take a NameMatcher to act as an exclusion filter for deployment. This works for filesystem deployment but isn't in place for alfresco->alfresco deployment. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6214 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -487,7 +487,7 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
// TestDeploymentCallback callback = new TestDeploymentCallback();
|
||||
fService.createStore("target");
|
||||
DeploymentReport report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin",
|
||||
"target:/a", false, false, false, null);
|
||||
"target:/a", null, false, false, false, null);
|
||||
runQueriesAgainstBasicTreeWithAOnly("target");
|
||||
System.out.println(report);
|
||||
assertEquals(fService.lookup(-1, "main:/a/b/c/foo").getGuid(), fService.lookup(-1, "target:/a/b/c/foo")
|
||||
@@ -498,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",
|
||||
report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", null,
|
||||
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",
|
||||
report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", null,
|
||||
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",
|
||||
report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", null,
|
||||
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",
|
||||
report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", null,
|
||||
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",
|
||||
report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", null,
|
||||
false, false, false, null);
|
||||
System.out.println(report);
|
||||
runQueriesForRemoveFileAndCreateDirectoryAndDeploy("target");
|
||||
report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a",
|
||||
report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", null,
|
||||
false, false, false, null);
|
||||
depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target2:/wiggly/diggly",
|
||||
depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target2:/wiggly/diggly", null,
|
||||
true, false, false, null);
|
||||
System.out.println(report);
|
||||
}
|
||||
|
@@ -235,16 +235,20 @@ public class AVMDeploySnapshotAction extends ActionExecuterAbstractBase
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Performing file server deployment to " + host + ":" + port);
|
||||
|
||||
// TODO Added new NameMatcher parameter to deploy methods. It acts as a filter.
|
||||
// Any matching path names are ignored for deployment purposes.
|
||||
report = this.deployService.deployDifferenceFS(version, path, host, port,
|
||||
remoteUsername, remotePassword, "/", true, false, false, callback);
|
||||
remoteUsername, remotePassword, "/", null, true, false, false, callback);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Performing Alfresco deployment to " + host + ":" + port);
|
||||
|
||||
// TODO Added new NameMatcher parameter to deploy methods. It acts as a filter.
|
||||
// Any matching path names are ignored for deployment purposes.
|
||||
report = this.deployService.deployDifference(version, path, host, port,
|
||||
remoteUsername, remotePassword, targetPath, true, false, false, callback);
|
||||
remoteUsername, remotePassword, targetPath, null, true, false, false, callback);
|
||||
}
|
||||
}
|
||||
catch (Throwable err)
|
||||
|
@@ -62,6 +62,7 @@ import org.alfresco.service.cmr.remote.AVMRemoteTransport;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.NameMatcher;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.springframework.remoting.rmi.RmiProxyFactoryBean;
|
||||
|
||||
@@ -101,7 +102,7 @@ public class DeploymentServiceImpl implements DeploymentService
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.avm.deploy.DeploymentService#deployDifference(int, java.lang.String, java.lang.String, int, java.lang.String, java.lang.String, java.lang.String, boolean, boolean)
|
||||
*/
|
||||
public DeploymentReport deployDifference(int version, String srcPath, String hostName, int port, String userName, String password, String dstPath, boolean createDst, boolean dontDelete, boolean dontDo, DeploymentCallback callback)
|
||||
public DeploymentReport deployDifference(int version, String srcPath, String hostName, int port, String userName, String password, String dstPath, NameMatcher matcher, boolean createDst, boolean dontDelete, boolean dontDo, DeploymentCallback callback)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -624,7 +625,7 @@ public class DeploymentServiceImpl implements DeploymentService
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.avm.deploy.DeploymentService#deployDifferenceFS(int, java.lang.String, java.lang.String, int, java.lang.String, java.lang.String, java.lang.String, boolean, boolean)
|
||||
*/
|
||||
public DeploymentReport deployDifferenceFS(int version, String srcPath, String hostName, int port, String userName, String password, String target, boolean createDst, boolean dontDelete, boolean dontDo, DeploymentCallback callback)
|
||||
public DeploymentReport deployDifferenceFS(int version, String srcPath, String hostName, int port, String userName, String password, String target, NameMatcher matcher, boolean createDst, boolean dontDelete, boolean dontDo, DeploymentCallback callback)
|
||||
{
|
||||
DeploymentReport report = new DeploymentReport();
|
||||
DeploymentReceiverService service = getReceiver(hostName, port);
|
||||
@@ -643,7 +644,7 @@ public class DeploymentServiceImpl implements DeploymentService
|
||||
version = fAVMService.createSnapshot(storeName, null, null).get(storeName);
|
||||
}
|
||||
String ticket = service.begin(target, userName, password);
|
||||
deployDirectoryPush(service, ticket, report, callback, version, srcPath, "/");
|
||||
deployDirectoryPush(service, ticket, report, callback, version, srcPath, "/", matcher);
|
||||
service.commit(ticket);
|
||||
event = new DeploymentEvent(DeploymentEvent.Type.END,
|
||||
new Pair<Integer, String>(version, srcPath),
|
||||
@@ -659,7 +660,7 @@ public class DeploymentServiceImpl implements DeploymentService
|
||||
private void deployDirectoryPush(DeploymentReceiverService service, String ticket,
|
||||
DeploymentReport report, DeploymentCallback callback,
|
||||
int version,
|
||||
String srcPath, String dstPath)
|
||||
String srcPath, String dstPath, NameMatcher matcher)
|
||||
{
|
||||
Map<String, AVMNodeDescriptor> srcListing = fAVMService.getDirectoryListing(version, srcPath);
|
||||
List<FileDescriptor> dstListing = service.getListing(ticket, dstPath);
|
||||
@@ -687,30 +688,38 @@ public class DeploymentServiceImpl implements DeploymentService
|
||||
if (src == null)
|
||||
{
|
||||
String newDstPath = extendPath(dstPath, dst.getName());
|
||||
service.delete(ticket, newDstPath);
|
||||
DeploymentEvent event = new DeploymentEvent(DeploymentEvent.Type.DELETED,
|
||||
new Pair<Integer, String>(version, extendPath(srcPath, dst.getName())),
|
||||
newDstPath);
|
||||
if (callback != null)
|
||||
if (!excluded(matcher, null, newDstPath))
|
||||
{
|
||||
callback.eventOccurred(event);
|
||||
service.delete(ticket, newDstPath);
|
||||
DeploymentEvent event = new DeploymentEvent(DeploymentEvent.Type.DELETED,
|
||||
new Pair<Integer, String>(version, extendPath(srcPath, dst.getName())),
|
||||
newDstPath);
|
||||
if (callback != null)
|
||||
{
|
||||
callback.eventOccurred(event);
|
||||
}
|
||||
report.add(event);
|
||||
}
|
||||
report.add(event);
|
||||
dst = null;
|
||||
continue;
|
||||
}
|
||||
// Nothing on the destination so copy over.
|
||||
if (dst == null)
|
||||
{
|
||||
copy(service, ticket, report, callback, version, src, dstPath);
|
||||
if (!excluded(matcher, src.getPath(), null))
|
||||
{
|
||||
copy(service, ticket, report, callback, version, src, dstPath, matcher);
|
||||
}
|
||||
src = null;
|
||||
continue;
|
||||
}
|
||||
int diff = src.getName().compareTo(dst.getName());
|
||||
if (diff < 0)
|
||||
{
|
||||
// No corresponding destination.
|
||||
copy(service, ticket, report, callback, version, src, dstPath);
|
||||
if (!excluded(matcher, src.getPath(), null))
|
||||
{
|
||||
copy(service, ticket, report, callback, version, src, dstPath, matcher);
|
||||
}
|
||||
src = null;
|
||||
continue;
|
||||
}
|
||||
@@ -724,8 +733,12 @@ public class DeploymentServiceImpl implements DeploymentService
|
||||
}
|
||||
if (src.isFile())
|
||||
{
|
||||
copyFile(service, ticket, report, callback, version, src,
|
||||
extendPath(dstPath, dst.getName()));
|
||||
String extendedPath = extendPath(dstPath, dst.getName());
|
||||
if (!excluded(matcher, src.getPath(), extendedPath))
|
||||
{
|
||||
copyFile(service, ticket, report, callback, version, src,
|
||||
extendedPath);
|
||||
}
|
||||
src = null;
|
||||
dst = null;
|
||||
continue;
|
||||
@@ -737,12 +750,19 @@ public class DeploymentServiceImpl implements DeploymentService
|
||||
{
|
||||
service.setGuid(ticket, dstPath, src.getGuid());
|
||||
}
|
||||
deployDirectoryPush(service, ticket, report, callback, version, src.getPath(), extendPath(dstPath, dst.getName()));
|
||||
String extendedPath = extendPath(dstPath, dst.getName());
|
||||
if (!excluded(matcher, src.getPath(), extendedPath))
|
||||
{
|
||||
deployDirectoryPush(service, ticket, report, callback, version, src.getPath(), extendPath(dstPath, dst.getName()), matcher);
|
||||
}
|
||||
src = null;
|
||||
dst = null;
|
||||
continue;
|
||||
}
|
||||
copy(service, ticket, report, callback, version, src, dstPath);
|
||||
if (!excluded(matcher, src.getPath(), null))
|
||||
{
|
||||
copy(service, ticket, report, callback, version, src, dstPath, matcher);
|
||||
}
|
||||
src = null;
|
||||
dst = null;
|
||||
continue;
|
||||
@@ -811,7 +831,7 @@ public class DeploymentServiceImpl implements DeploymentService
|
||||
*/
|
||||
private void copy(DeploymentReceiverService service, String ticket,
|
||||
DeploymentReport report, DeploymentCallback callback,
|
||||
int version, AVMNodeDescriptor src, String parentPath)
|
||||
int version, AVMNodeDescriptor src, String parentPath, NameMatcher matcher)
|
||||
{
|
||||
String dstPath = extendPath(parentPath, src.getName());
|
||||
if (src.isFile())
|
||||
@@ -832,7 +852,10 @@ public class DeploymentServiceImpl implements DeploymentService
|
||||
Map<String, AVMNodeDescriptor> listing = fAVMService.getDirectoryListing(src);
|
||||
for (AVMNodeDescriptor child : listing.values())
|
||||
{
|
||||
copy(service, ticket, report, callback, version, child, dstPath);
|
||||
if (!excluded(matcher, child.getPath(), null))
|
||||
{
|
||||
copy(service, ticket, report, callback, version, child, dstPath, matcher);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -850,4 +873,16 @@ public class DeploymentServiceImpl implements DeploymentService
|
||||
}
|
||||
return path + '/' + name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if either srcPath or dstPath are matched by matcher.
|
||||
* @param matcher
|
||||
* @param srcPath
|
||||
* @param dstPath
|
||||
* @return
|
||||
*/
|
||||
private boolean excluded(NameMatcher matcher, String srcPath, String dstPath)
|
||||
{
|
||||
return matcher != null && ((srcPath != null && matcher.matches(srcPath)) || (dstPath != null && matcher.matches(dstPath)));
|
||||
}
|
||||
}
|
||||
|
@@ -32,6 +32,7 @@ import org.alfresco.service.cmr.avm.deploy.DeploymentEvent;
|
||||
import org.alfresco.service.cmr.avm.deploy.DeploymentReport;
|
||||
import org.alfresco.service.cmr.avm.deploy.DeploymentService;
|
||||
import org.alfresco.util.Deleter;
|
||||
import org.alfresco.util.NameMatcher;
|
||||
import org.springframework.context.support.FileSystemXmlApplicationContext;
|
||||
|
||||
/**
|
||||
@@ -56,8 +57,10 @@ public class FSDeploymentTest extends AVMServiceTestBase
|
||||
FileSystemXmlApplicationContext receiverContext =
|
||||
new FileSystemXmlApplicationContext("../deployment/config/application-context.xml");
|
||||
DeploymentService service = (DeploymentService)fContext.getBean("DeploymentService");
|
||||
NameMatcher matcher = (NameMatcher)fContext.getBean("globalPathExcluder");
|
||||
setupBasicTree();
|
||||
DeploymentReport report = service.deployDifferenceFS(-1, "main:/", "localhost", 44100, "Giles", "Watcher", "sampleTarget", false, false, false, null);
|
||||
fService.createFile("main:/a/b", "fudge.bak").close();
|
||||
DeploymentReport report = service.deployDifferenceFS(-1, "main:/", "localhost", 44100, "Giles", "Watcher", "sampleTarget", matcher, false, false, false, null);
|
||||
int count = 0;
|
||||
for (DeploymentEvent event : report)
|
||||
{
|
||||
@@ -65,7 +68,7 @@ public class FSDeploymentTest extends AVMServiceTestBase
|
||||
count++;
|
||||
}
|
||||
assertEquals(10, count);
|
||||
report = service.deployDifferenceFS(-1, "main:/", "localhost", 44100, "Giles", "Watcher", "sampleTarget", false, false, false, null);
|
||||
report = service.deployDifferenceFS(-1, "main:/", "localhost", 44100, "Giles", "Watcher", "sampleTarget", matcher, false, false, false, null);
|
||||
count = 0;
|
||||
for (DeploymentEvent event : report)
|
||||
{
|
||||
@@ -75,7 +78,7 @@ public class FSDeploymentTest extends AVMServiceTestBase
|
||||
assertEquals(2, count);
|
||||
fService.createFile("main:/d", "jonathan").close();
|
||||
fService.removeNode("main:/a/b");
|
||||
report = service.deployDifferenceFS(-1, "main:/", "localhost", 44100, "Giles", "Watcher", "sampleTarget", false, false, false, null);
|
||||
report = service.deployDifferenceFS(-1, "main:/", "localhost", 44100, "Giles", "Watcher", "sampleTarget", matcher, false, false, false, null);
|
||||
count = 0;
|
||||
for (DeploymentEvent event : report)
|
||||
{
|
||||
@@ -85,7 +88,7 @@ public class FSDeploymentTest extends AVMServiceTestBase
|
||||
assertEquals(4, count);
|
||||
fService.removeNode("main:/d/e");
|
||||
fService.createFile("main:/d", "e").close();
|
||||
report = service.deployDifferenceFS(-1, "main:/", "localhost", 44100, "Giles", "Watcher", "sampleTarget", false, false, false, null);
|
||||
report = service.deployDifferenceFS(-1, "main:/", "localhost", 44100, "Giles", "Watcher", "sampleTarget", matcher, false, false, false, null);
|
||||
count = 0;
|
||||
for (DeploymentEvent event : report)
|
||||
{
|
||||
@@ -96,7 +99,7 @@ public class FSDeploymentTest extends AVMServiceTestBase
|
||||
fService.removeNode("main:/d/e");
|
||||
fService.createDirectory("main:/d", "e");
|
||||
fService.createFile("main:/d/e", "Warren.txt").close();
|
||||
report = service.deployDifferenceFS(-1, "main:/", "localhost", 44100, "Giles", "Watcher", "sampleTarget", false, false, false, null);
|
||||
report = service.deployDifferenceFS(-1, "main:/", "localhost", 44100, "Giles", "Watcher", "sampleTarget", matcher, false, false, false, null);
|
||||
count = 0;
|
||||
for (DeploymentEvent event : report)
|
||||
{
|
||||
@@ -116,6 +119,16 @@ public class FSDeploymentTest extends AVMServiceTestBase
|
||||
Deleter.Delete(data);
|
||||
Deleter.Delete(metadata);
|
||||
Deleter.Delete(target);
|
||||
File dot = new File(".");
|
||||
String[] listing = dot.list();
|
||||
for (String name : listing)
|
||||
{
|
||||
if (name.startsWith("dep-record-"))
|
||||
{
|
||||
File file = new File(name);
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,6 +3,8 @@
|
||||
*/
|
||||
package org.alfresco.service.cmr.avm.deploy;
|
||||
|
||||
import org.alfresco.util.NameMatcher;
|
||||
|
||||
/**
|
||||
* A service to handle AVM repository to remote AVM repository deployment.
|
||||
* @author britt
|
||||
@@ -28,6 +30,7 @@ public interface DeploymentService
|
||||
String hostName, int port,
|
||||
String userName, String password,
|
||||
String dstPath,
|
||||
NameMatcher matcher,
|
||||
boolean createDst,
|
||||
boolean dontDelete,
|
||||
boolean dontDo,
|
||||
@@ -51,6 +54,7 @@ public interface DeploymentService
|
||||
String hostName, int port,
|
||||
String userName, String password,
|
||||
String dstTarget,
|
||||
NameMatcher matcher,
|
||||
boolean createDst,
|
||||
boolean dontDelete,
|
||||
boolean dontDo,
|
||||
|
Reference in New Issue
Block a user