mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Replication Definition enable/disable/check support (Replication 69+70)
Ability to enable and disable replication definitions, which the executor checks, along with unit tests git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@21382 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -22,7 +22,6 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
|
||||
import org.alfresco.repo.lock.JobLockService;
|
||||
@@ -30,7 +29,6 @@ import org.alfresco.repo.lock.LockAcquisitionException;
|
||||
import org.alfresco.repo.transfer.ChildAssociatedNodeFinder;
|
||||
import org.alfresco.repo.transfer.ContentClassFilter;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ActionDefinition;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.replication.ReplicationDefinition;
|
||||
import org.alfresco.service.cmr.replication.ReplicationService;
|
||||
@@ -168,6 +166,10 @@ public class ReplicationActionExecutor extends ActionExecuterAbstractBase {
|
||||
{
|
||||
throw new ReplicationServiceException("No payloads were specified");
|
||||
}
|
||||
if(!replicationDef.isEnabled())
|
||||
{
|
||||
throw new ReplicationServiceException("Unable to execute a disabled replication definition");
|
||||
}
|
||||
|
||||
// Lock the service - only one instance of the replication
|
||||
// should occur at a time
|
||||
@@ -226,11 +228,15 @@ public class ReplicationActionExecutor extends ActionExecuterAbstractBase {
|
||||
}
|
||||
/**
|
||||
* No matter what the event is, refresh
|
||||
* our lock on the {@link ReplicationDefinition}
|
||||
* our lock on the {@link ReplicationDefinition}, and
|
||||
* handle a cancel if it was requested.
|
||||
*/
|
||||
public void processEvent(TransferEvent event)
|
||||
{
|
||||
refreshLock();
|
||||
|
||||
// TODO - Check to see if cancel was requested
|
||||
// TODO - If it was, use TransferService.cancelAsync(transferId)
|
||||
}
|
||||
/**
|
||||
* Give up our lock on the
|
||||
|
@@ -43,6 +43,7 @@ public class ReplicationDefinitionImpl extends ActionImpl implements Replication
|
||||
public static final String REPLICATION_DEFINITION_NAME = "replicationActionName";
|
||||
public static final String REPLICATION_DEFINITION_TARGET = "replicationTarget";
|
||||
public static final String REPLICATION_DEFINITION_PAYLOAD = "replicationPayload";
|
||||
public static final String REPLICATION_DEFINITION_ENABLED = "replicationDefinitionEnabled";
|
||||
public static final String REPLICATION_DEFINITION_TRANSFER_REPORT = "replicationTransferReport";
|
||||
|
||||
/**
|
||||
@@ -85,6 +86,28 @@ public class ReplicationDefinitionImpl extends ActionImpl implements Replication
|
||||
return (QName) parameterValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.alfresco.service.cmr.replication.ReplicationDefinition#isEnabled()
|
||||
*/
|
||||
public boolean isEnabled()
|
||||
{
|
||||
Serializable parameterValue = getParameterValue(REPLICATION_DEFINITION_ENABLED);
|
||||
if(parameterValue == null)
|
||||
{
|
||||
// Default is enabled
|
||||
return true;
|
||||
}
|
||||
return ((Boolean)parameterValue).booleanValue();
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.alfresco.service.cmr.replication.ReplicationDefinition#setEnabled(boolean)
|
||||
*/
|
||||
public void setEnabled(boolean enabled)
|
||||
{
|
||||
setParameterValue(REPLICATION_DEFINITION_ENABLED, new Boolean(enabled));
|
||||
}
|
||||
|
||||
/*
|
||||
* @see
|
||||
* org.alfresco.service.cmr.replication.ReplicationDefinition#getPayload()
|
||||
|
@@ -309,6 +309,7 @@ public class ReplicationServiceIntegrationTest extends BaseAlfrescoSpringTest
|
||||
assertEquals(ACTION_NAME, rdTT.getReplicationName());
|
||||
assertEquals("Test", rdTT.getDescription());
|
||||
assertEquals("TestTarget", rdTT.getTargetName());
|
||||
assertEquals(true, rdTT.isEnabled());
|
||||
assertEquals(0, rdTT.getPayload().size());
|
||||
|
||||
// Save and re-load without changes
|
||||
@@ -317,11 +318,13 @@ public class ReplicationServiceIntegrationTest extends BaseAlfrescoSpringTest
|
||||
assertEquals(ACTION_NAME, rdTT.getReplicationName());
|
||||
assertEquals("Test", rdTT.getDescription());
|
||||
assertEquals("TestTarget", rdTT.getTargetName());
|
||||
assertEquals(true, rdTT.isEnabled());
|
||||
assertEquals(0, rdTT.getPayload().size());
|
||||
|
||||
// Make some small changes
|
||||
rdTT.setDescription("Test Description");
|
||||
rdTT.getPayload().add(folder2a);
|
||||
rdTT.setEnabled(false);
|
||||
|
||||
// Check we see them on save/load
|
||||
replicationService.saveReplicationDefinition(rdTT);
|
||||
@@ -329,6 +332,7 @@ public class ReplicationServiceIntegrationTest extends BaseAlfrescoSpringTest
|
||||
assertEquals(ACTION_NAME, rdTT.getReplicationName());
|
||||
assertEquals("Test Description", rdTT.getDescription());
|
||||
assertEquals("TestTarget", rdTT.getTargetName());
|
||||
assertEquals(false, rdTT.isEnabled());
|
||||
assertEquals(1, rdTT.getPayload().size());
|
||||
assertEquals(folder2a, rdTT.getPayload().get(0));
|
||||
|
||||
@@ -345,6 +349,7 @@ public class ReplicationServiceIntegrationTest extends BaseAlfrescoSpringTest
|
||||
assertEquals(ACTION_NAME, rdTT.getReplicationName());
|
||||
assertEquals("Another One", rdTT.getDescription());
|
||||
assertEquals("TestTarget", rdTT.getTargetName());
|
||||
assertEquals(false, rdTT.isEnabled());
|
||||
assertEquals(2, rdTT.getPayload().size());
|
||||
assertEquals(folder1, rdTT.getPayload().get(0));
|
||||
assertEquals(folder2b, rdTT.getPayload().get(1));
|
||||
@@ -353,12 +358,14 @@ public class ReplicationServiceIntegrationTest extends BaseAlfrescoSpringTest
|
||||
rdTT.getPayload().clear();
|
||||
rdTT.getPayload().add(content1_1);
|
||||
assertEquals(1, rdTT.getPayload().size());
|
||||
rdTT.setEnabled(true);
|
||||
|
||||
replicationService.saveReplicationDefinition(rdTT);
|
||||
rdTT = replicationService.loadReplicationDefinition(ACTION_NAME);
|
||||
assertEquals(ACTION_NAME, rdTT.getReplicationName());
|
||||
assertEquals("Another One", rdTT.getDescription());
|
||||
assertEquals("TestTarget", rdTT.getTargetName());
|
||||
assertEquals(true, rdTT.isEnabled());
|
||||
assertEquals(1, rdTT.getPayload().size());
|
||||
assertEquals(content1_1, rdTT.getPayload().get(0));
|
||||
}
|
||||
@@ -393,6 +400,16 @@ public class ReplicationServiceIntegrationTest extends BaseAlfrescoSpringTest
|
||||
} catch(ReplicationServiceException e) {}
|
||||
|
||||
|
||||
// Now disabled, not allowed
|
||||
assertEquals(true, rd.isEnabled());
|
||||
rd.setEnabled(false);
|
||||
assertEquals(false, rd.isEnabled());
|
||||
try {
|
||||
actionService.executeAction(rd, replicationRoot);
|
||||
fail("Shouldn't be permitted when disabled");
|
||||
} catch(ReplicationServiceException e) {}
|
||||
|
||||
|
||||
// Invalid Transfer Target, not allowed
|
||||
rd = replicationService.createReplicationDefinition(ACTION_NAME, "Test");
|
||||
rd.setTargetName("I am an invalid target that isn't there");
|
||||
|
@@ -51,6 +51,20 @@ public interface ReplicationDefinition extends Action, Serializable {
|
||||
*/
|
||||
void setTargetName(String targetName);
|
||||
|
||||
/**
|
||||
* Is this Replication Definition currently
|
||||
* enabled (can be run), or disabled
|
||||
* (can't be run)?
|
||||
* @return Whether the definition is enabled or not
|
||||
*/
|
||||
boolean isEnabled();
|
||||
|
||||
/**
|
||||
* Enable or Disable the Replication
|
||||
* Definition.
|
||||
*/
|
||||
void setEnabled(boolean enabled);
|
||||
|
||||
/**
|
||||
* The list of Nodes to be transfered. This
|
||||
* list can be edited as required.
|
||||
@@ -76,7 +90,5 @@ public interface ReplicationDefinition extends Action, Serializable {
|
||||
*/
|
||||
void setLocalTransferReport(NodeRef report);
|
||||
|
||||
// TODO Persistent action bits of last start, last finish, worked
|
||||
|
||||
// TODO Replication options, such as permissions and rules
|
||||
}
|
||||
|
Reference in New Issue
Block a user