Search in sources :

Example 1 with ScriptReplicationDefinition

use of org.alfresco.repo.replication.script.ScriptReplicationDefinition in project alfresco-repository by Alfresco.

the class ReplicationServiceIntegrationTest method testJavascriptAPI.

public void testJavascriptAPI() throws Exception {
    ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean("ServiceRegistry");
    // Setup some replication tasks
    ReplicationDefinition empty = replicationService.createReplicationDefinition(ACTION_NAME, "Empty");
    ReplicationDefinition persisted = replicationService.createReplicationDefinition(ACTION_NAME2, "Persisted");
    persisted.setTargetName(TRANSFER_TARGET);
    persisted.getPayload().add(new NodeRef("workspace://SpacesStore/Testing"));
    persisted.getPayload().add(new NodeRef("workspace://SpacesStore/Testing2"));
    replicationService.saveReplicationDefinition(persisted);
    ReplicationDefinition persisted2 = replicationService.createReplicationDefinition(ACTION_NAME3, "Persisted2");
    persisted2.setTargetName("AnotherTarget");
    replicationService.saveReplicationDefinition(persisted2);
    // Call the test
    Map<String, Object> model = new HashMap<String, Object>();
    model.put("Empty", new ScriptReplicationDefinition(serviceRegistry, replicationService, null, empty));
    model.put("EmptyName", ACTION_NAME);
    model.put("Persisted", new ScriptReplicationDefinition(serviceRegistry, replicationService, null, persisted));
    model.put("PersistedName", ACTION_NAME2);
    model.put("PersistedNodeRef", persisted.getNodeRef().toString());
    model.put("PersistedTarget", persisted.getTargetName());
    model.put("Persisted2", new ScriptReplicationDefinition(serviceRegistry, replicationService, null, persisted2));
    model.put("Persisted2Name", ACTION_NAME3);
    model.put("Persisted2NodeRef", persisted2.getNodeRef().toString());
    model.put("Persisted2Target", persisted2.getTargetName());
    ScriptLocation location = new ClasspathScriptLocation("org/alfresco/repo/replication/script/test_replicationService.js");
    this.scriptService.executeScript(location, model);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) ClasspathScriptLocation(org.alfresco.repo.jscript.ClasspathScriptLocation) ScriptReplicationDefinition(org.alfresco.repo.replication.script.ScriptReplicationDefinition) ReplicationDefinition(org.alfresco.service.cmr.replication.ReplicationDefinition) HashMap(java.util.HashMap) ScriptLocation(org.alfresco.service.cmr.repository.ScriptLocation) ClasspathScriptLocation(org.alfresco.repo.jscript.ClasspathScriptLocation) ServiceRegistry(org.alfresco.service.ServiceRegistry) ScriptReplicationDefinition(org.alfresco.repo.replication.script.ScriptReplicationDefinition)

Aggregations

HashMap (java.util.HashMap)1 ClasspathScriptLocation (org.alfresco.repo.jscript.ClasspathScriptLocation)1 ScriptReplicationDefinition (org.alfresco.repo.replication.script.ScriptReplicationDefinition)1 ServiceRegistry (org.alfresco.service.ServiceRegistry)1 ReplicationDefinition (org.alfresco.service.cmr.replication.ReplicationDefinition)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1 ScriptLocation (org.alfresco.service.cmr.repository.ScriptLocation)1