本文整理汇总了Java中org.alfresco.service.cmr.replication.ReplicationDefinition.setTargetName方法的典型用法代码示例。如果您正苦于以下问题:Java ReplicationDefinition.setTargetName方法的具体用法?Java ReplicationDefinition.setTargetName怎么用?Java ReplicationDefinition.setTargetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.alfresco.service.cmr.replication.ReplicationDefinition
的用法示例。
在下文中一共展示了ReplicationDefinition.setTargetName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testLoadByTarget
import org.alfresco.service.cmr.replication.ReplicationDefinition; //导入方法依赖的package包/类
public void testLoadByTarget() throws Exception
{
assertEquals(0, replicationService.loadReplicationDefinitions().size());
assertEquals(0, replicationService.loadReplicationDefinitions("TestTarget").size());
assertEquals(0, replicationService.loadReplicationDefinitions("TestTarget2").size());
// Store some
ReplicationDefinition rdTT = replicationService.createReplicationDefinition(ACTION_NAME, "Test");
rdTT.setTargetName("TestTarget");
replicationService.saveReplicationDefinition(rdTT);
// Check it shows up correctly
assertEquals(1, replicationService.loadReplicationDefinitions().size());
assertEquals(1, replicationService.loadReplicationDefinitions("TestTarget").size());
assertEquals(0, replicationService.loadReplicationDefinitions("TestTarget2").size());
}
示例2: testReplicationExecutionLocking
import org.alfresco.service.cmr.replication.ReplicationDefinition; //导入方法依赖的package包/类
/**
* Check that the locking works.
* Take a 10 second lock on the job, then execute.
* Ensure that we really wait a little over 10 seconds.
*/
public void testReplicationExecutionLocking() throws Exception
{
// We need the test transfer target for this test
makeTransferTarget();
// Create a task
ReplicationDefinition rd = replicationService.createReplicationDefinition(ACTION_NAME, "Test");
rd.setTargetName(TRANSFER_TARGET);
rd.getPayload().add(folder1);
rd.getPayload().add(folder2);
// Get the lock, and run
long start = System.currentTimeMillis();
String token = jobLockService.getLock(
rd.getReplicationQName(),
10 * 1000,
1,
1
);
UserTransaction txn = transactionService.getUserTransaction();
txn.begin();
try {
actionService.executeAction(rd, replicationRoot);
} catch(ReplicationServiceException e) {
// This shouldn't happen normally! Something is wrong!
// Tidy up before we throw the exception
txn.rollback();
throw e;
}
txn.commit();
long end = System.currentTimeMillis();
assertTrue(
"Should wait for the lock, but didn't (waited " +
((end-start)/1000.0) + " seconds, not 10)",
end-start > 10000
);
}
示例3: testJavascriptAPI
import org.alfresco.service.cmr.replication.ReplicationDefinition; //导入方法依赖的package包/类
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);
}
示例4: testEditing
import org.alfresco.service.cmr.replication.ReplicationDefinition; //导入方法依赖的package包/类
/**
* Ensures that we can create, save, edit, save
* load, edit, save, load etc, all without
* problems, and without creating duplicates
*/
public void testEditing() throws Exception
{
ReplicationDefinition rdTT = replicationService.createReplicationDefinition(ACTION_NAME, "Test");
rdTT.setTargetName("TestTarget");
replicationService.saveReplicationDefinition(rdTT);
// Load, and check it hasn't changed
rdTT = replicationService.loadReplicationDefinition(ACTION_NAME);
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
replicationService.saveReplicationDefinition(rdTT);
rdTT = replicationService.loadReplicationDefinition(ACTION_NAME);
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);
rdTT = replicationService.loadReplicationDefinition(ACTION_NAME);
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));
// And some more changes
rdTT.setDescription("Another One");
rdTT.getPayload().clear();
rdTT.getPayload().add(folder1);
rdTT.getPayload().add(folder2b);
assertEquals(2, rdTT.getPayload().size());
// Ensure these also come with save/load
replicationService.saveReplicationDefinition(rdTT);
rdTT = replicationService.loadReplicationDefinition(ACTION_NAME);
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));
// And more payload changes
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));
}
示例5: testRenaming
import org.alfresco.service.cmr.replication.ReplicationDefinition; //导入方法依赖的package包/类
/**
* Tests that we can rename definitions
*/
public void testRenaming() throws Exception
{
// Create one instance
ReplicationDefinition rdTT = replicationService.createReplicationDefinition(ACTION_NAME, "Test");
rdTT.setTargetName("TestTarget");
replicationService.saveReplicationDefinition(rdTT);
assertEquals(1, replicationService.loadReplicationDefinitions().size());
// Rename it
replicationService.renameReplicationDefinition(ACTION_NAME, ACTION_NAME2);
assertEquals(1, replicationService.loadReplicationDefinitions().size());
assertEquals(null, replicationService.loadReplicationDefinition(ACTION_NAME));
rdTT = replicationService.loadReplicationDefinition(ACTION_NAME2);
assertNotNull(rdTT);
assertEquals(ACTION_NAME2, rdTT.getReplicationName());
assertEquals(ACTION_QNAME2, rdTT.getReplicationQName());
// If the source name doesn't exist, does nothing
replicationService.renameReplicationDefinition(ACTION_NAME, ACTION_NAME2);
assertEquals(1, replicationService.loadReplicationDefinitions().size());
assertEquals(null, replicationService.loadReplicationDefinition(ACTION_NAME));
rdTT = replicationService.loadReplicationDefinition(ACTION_NAME2);
assertNotNull(rdTT);
assertEquals(ACTION_NAME2, rdTT.getReplicationName());
assertEquals(ACTION_QNAME2, rdTT.getReplicationQName());
// Renaming to a duplicate name breaks
rdTT = replicationService.createReplicationDefinition(ACTION_NAME, "Test");
rdTT.setTargetName("TestTarget");
replicationService.saveReplicationDefinition(rdTT);
assertEquals(2, replicationService.loadReplicationDefinitions().size());
try {
replicationService.renameReplicationDefinition(ACTION_NAME, ACTION_NAME2);
fail("Shouldn't be able to rename onto a duplicate name");
} catch(ReplicationServiceException e) {}
}
示例6: testReplicationExecutionCancelling
import org.alfresco.service.cmr.replication.ReplicationDefinition; //导入方法依赖的package包/类
/**
* Check that cancelling works.
* Does this by taking a lock on the job, cancelling,
* releasing and seeing it abort.
*
* Tests that when we ask for a replication task to be cancelled,
* that it starts, cancels, and the status is correctly recorded
* for it.
*/
public void testReplicationExecutionCancelling() throws Exception
{
// We need the test transfer target for this test
makeTransferTarget();
// Create a task
ReplicationDefinition rd = replicationService.createReplicationDefinition(ACTION_NAME, "Test");
rd.setTargetName(TRANSFER_TARGET);
rd.getPayload().add(folder1);
rd.getPayload().add(folder2);
// Get the lock for 2 seconds
String token = jobLockService.getLock(
rd.getReplicationQName(),
2 * 1000,
1,
1
);
// Request it be run async
UserTransaction txn = transactionService.getUserTransaction();
txn.begin();
actionService.executeAction(rd, replicationRoot, false, true);
assertEquals(ActionStatus.Pending, rd.getExecutionStatus());
assertEquals(false, actionTrackingService.isCancellationRequested(rd));
actionTrackingService.requestActionCancellation(rd);
assertEquals(true, actionTrackingService.isCancellationRequested(rd));
txn.commit();
// Let it get going, will be waiting for the lock
// having registered with the action tracking service
for(int i=0; i<100; i++) {
// Keep asking for it to be cancelled ASAP
actionTrackingService.requestActionCancellation(rd);
if(rd.getExecutionStatus().equals(ActionStatus.Running)) {
// Good, has started up
// Stop waiting and do the cancel
break;
} else {
// Still pending, wait a bit more
Thread.sleep(10);
}
}
// Ensure it started, and should shortly stop
assertEquals(ActionStatus.Running, rd.getExecutionStatus());
assertEquals(true, actionTrackingService.isCancellationRequested(rd));
// Release our lock, should allow the replication task
// to get going and spot the cancel
jobLockService.releaseLock(token, rd.getReplicationQName());
// Let the main replication task run to cancelled/completed
// This can take quite some time though...
for(int i=0; i<10; i++) {
if(rd.getExecutionStatus() == ActionStatus.Running) {
Thread.sleep(1000);
} else {
// It has finished running, check it
break;
}
}
// Ensure it was cancelled
assertEquals(null, rd.getExecutionFailureMessage());
assertNotNull(rd.getLocalTransferReport());
assertNotNull(rd.getRemoteTransferReport());
assertEquals(ActionStatus.Cancelled, rd.getExecutionStatus());
}
示例7: updateDefinitionProperties
import org.alfresco.service.cmr.replication.ReplicationDefinition; //导入方法依赖的package包/类
/**
* Updates properties on the definition, based on the JSON.
* Doesn't save the definition
* Doesn't change the name
*/
protected void updateDefinitionProperties(ReplicationDefinition replicationDefinition, JSONObject json)
throws JSONException
{
if(json.has("description")) {
String description = json.getString("description");
replicationDefinition.setDescription(description);
}
if(json.has("targetName")) {
String targetName = json.getString("targetName");
replicationDefinition.setTargetName(targetName);
}
if(json.has("enabled")) {
boolean enabled = json.getBoolean("enabled");
replicationDefinition.setEnabled(enabled);
}
if(json.has("payload")) {
replicationDefinition.getPayload().clear();
JSONArray payload = json.getJSONArray("payload");
for(int i=0; i<payload.length(); i++) {
String node = payload.getString(i);
replicationDefinition.getPayload().add(
new NodeRef(node)
);
}
}
// Now for the scheduling parts
if(json.has("schedule") && !json.isNull("schedule")) {
// Turn on scheduling, if not already enabled
replicationService.enableScheduling(replicationDefinition);
// Update the properties
JSONObject schedule = json.getJSONObject("schedule");
if(schedule.has("start") && !schedule.isNull("start")) {
// Look for start:.... or start:{"iso8601":....}
String startDate = schedule.getString("start");
if(schedule.get("start") instanceof JSONObject) {
startDate = schedule.getJSONObject("start").getString("iso8601");
}
replicationDefinition.setScheduleStart( ISO8601DateFormat.parse(startDate) );
} else {
replicationDefinition.setScheduleStart(null);
}
if(schedule.has("intervalPeriod") && !schedule.isNull("intervalPeriod")) {
replicationDefinition.setScheduleIntervalPeriod(
IntervalPeriod.valueOf(schedule.getString("intervalPeriod"))
);
} else {
replicationDefinition.setScheduleIntervalPeriod(null);
}
if(schedule.has("intervalCount") && !schedule.isNull("intervalCount")) {
replicationDefinition.setScheduleIntervalCount(
schedule.getInt("intervalCount")
);
} else {
replicationDefinition.setScheduleIntervalCount(null);
}
} else {
// Disable scheduling
replicationService.disableScheduling(replicationDefinition);
}
}