Stub the replication service action executor

Doesn't trigger a transfer yet, as waiting on the appropriate node finder


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@20967 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Nick Burch
2010-07-06 20:40:35 +00:00
parent 7a8e50de23
commit 553df63c59
5 changed files with 155 additions and 15 deletions

View File

@@ -0,0 +1,100 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.replication;
import java.util.List;
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
import org.alfresco.repo.lock.JobLockService;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.replication.ReplicationService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.transfer.TransferService;
/**
* @author Nick Burch
* @since 3.4
*/
public class ReplicationActionExecutor extends ActionExecuterAbstractBase {
private NodeService nodeService;
private JobLockService jobLockService;
private ReplicationService replicationService;
private TransferService transferService;
/**
* Injects the NodeService bean.
*
* @param nodeService the NodeService.
*/
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
/**
* Injects the JobLockService bean.
*
* @param nodeService the JobLockService.
*/
public void setJobLockService(JobLockService jobLockService)
{
this.jobLockService = jobLockService;
}
/**
* Injects the ReplicationService bean.
*
* @param nodeService the ReplicationService.
*/
public void setReplicationService(ReplicationService replicationService)
{
this.replicationService = replicationService;
}
/**
* Injects the TransferService bean.
*
* @param transferService the TransferService.
*/
public void setTransferService(TransferService transferService)
{
this.transferService = transferService;
}
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList) {
// TODO
}
@Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef) {
// Lock the service - only one instance of the replication
// should occur at a time
// Turn our payload list of root nodes into something that
// the transfer service can work with
// Ask the transfer service to do the replication
// work for us
// TODO
}
}

View File

@@ -66,7 +66,7 @@ public class ReplicationDefinitionImpl extends ActionImpl implements Replication
*/
public ReplicationDefinitionImpl(String id, QName replicationName, String description)
{
super(null, id, description);
super(null, id, "replicationActionExecutor");
setParameterValue(REPLICATION_DEFINITION_NAME, replicationName);
setDescription(description);
}

View File

@@ -155,6 +155,9 @@ public class ReplicationServiceImpl implements ReplicationService, ReplicationDe
* (ReplicationDefinition)
*/
public void replicate(ReplicationDefinition replicationDefinition) {
// TODO Implement the replication work
actionService.executeAction(
replicationDefinition,
ReplicationDefinitionPersisterImpl.REPLICATION_ACTION_ROOT_NODE_REF
);
}
}

View File

@@ -38,6 +38,8 @@ public class ReplicationServiceIntegrationTest extends BaseAlfrescoSpringTest
private ReplicationService replicationService;
private NodeService nodeService;
private NodeRef replicationRoot;
private final QName ACTION_NAME = QName.createQName(NamespaceService.ALFRESCO_URI, "testName");
private final QName ACTION_NAME2 = QName.createQName(NamespaceService.ALFRESCO_URI, "testName2");
@@ -52,7 +54,7 @@ public class ReplicationServiceIntegrationTest extends BaseAlfrescoSpringTest
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
// Zap any existing entries
NodeRef replicationRoot = ReplicationDefinitionPersisterImpl.REPLICATION_ACTION_ROOT_NODE_REF;
replicationRoot = ReplicationDefinitionPersisterImpl.REPLICATION_ACTION_ROOT_NODE_REF;
for(ChildAssociationRef child : nodeService.getChildAssocs(replicationRoot)) {
QName type = nodeService.getType( child.getChildRef() );
if(ReplicationDefinitionPersisterImpl.ACTION_TYPES.contains(type)) {
@@ -137,4 +139,31 @@ public class ReplicationServiceIntegrationTest extends BaseAlfrescoSpringTest
assertEquals(0, replicationService.loadReplicationDefinitions("TestTarget2").size());
}
/**
* Test that the action service can find the executor
* for us, and that it has everything it needs
*/
public void testBasicExecution() throws Exception
{
// First with a transient definition
ReplicationDefinition rd = replicationService.createReplicationDefinition(ACTION_NAME, "Test");
rd.setTargetName("TestTarget");
rd.getPayload().add(
new NodeRef("workspace://SpacesStore/Testing")
);
actionService.executeAction(rd, replicationRoot);
// Now with one that's in the repo
}
/**
* Test that, with a mock transfer service, we
* pick the right things to replicate and call
* the transfer service correctly.
*/
public void testReplicationExecution() throws Exception
{
// TODO
}
}