ALF-4284 - allow cluster-wide visibility of pending actions, as well as running ones

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@21707 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Nick Burch
2010-08-10 13:38:56 +00:00
parent d55d58b860
commit 9945c6f44c
2 changed files with 55 additions and 5 deletions

View File

@@ -257,14 +257,17 @@ public class ReplicationModelBuilder
return;
}
// Use the details of the running copy
// TODO Update this following pending actions changes
// As it is running / about to run, return the
// details of the running/pending version
if(details.isCancelRequested()) {
model.put(DEFINITION_STATUS, "CancelRequested");
} else if(details.getStartedAt() == null) {
model.put(DEFINITION_STATUS, "Pending");
} else {
model.put(DEFINITION_STATUS, "Running");
}
if(details.getStartedAt() != null) {
model.put(DEFINITION_STARTED_AT, ISO8601DateFormat.format(details.getStartedAt()));
} else {

View File

@@ -133,6 +133,26 @@ public class ReplicationRestApiTest extends BaseWebScriptTest
}
// Mark it as pending execution, and re-check
actionTrackingService.recordActionPending(rd);
response = sendRequest(new GetRequest(URL_DEFINITIONS), 200);
assertEquals(Status.STATUS_OK, response.getStatus());
jsonStr = response.getContentAsString();
json = new JSONObject(jsonStr);
results = json.getJSONArray("data");
assertNotNull(results);
assertEquals(1, results.length());
jsonRD = (JSONObject)results.get(0);
assertNotNull(jsonRD);
assertEquals("Test1", jsonRD.get("name"));
assertEquals("Pending", jsonRD.get("status"));
assertEquals(true, jsonRD.get("enabled"));
assertEquals(JSONObject.NULL, jsonRD.get("startedAt"));
assertEquals("/api/replication-definition/Test1", jsonRD.get("details"));
// Change the status to running, and re-check
actionTrackingService.recordActionExecuting(rd);
String startedAt = ISO8601DateFormat.format(rd.getExecutionStartDate());
@@ -424,11 +444,38 @@ public class ReplicationRestApiTest extends BaseWebScriptTest
}
// Mark it as pending, and check
actionTrackingService.recordActionPending(rd);
String actionId = rd.getId();
int instanceId = ((ActionImpl)rd).getExecutionInstance();
response = sendRequest(new GetRequest(URL_DEFINITION + "Test1"), 200);
assertEquals(Status.STATUS_OK, response.getStatus());
jsonStr = response.getContentAsString();
json = new JSONObject(jsonStr);
assertEquals("Test1", json.get("name"));
assertEquals("Testing", json.get("description"));
assertEquals("Pending", json.get("status"));
assertEquals(JSONObject.NULL, json.get("startedAt"));
assertEquals(JSONObject.NULL, json.get("endedAt"));
assertEquals(JSONObject.NULL, json.get("failureMessage"));
assertEquals("/" + URL_RUNNING_ACTION + "replicationActionExecutor="+
actionId + "=" + instanceId, json.get("executionDetails"));
assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
assertEquals(true, json.get("enabled"));
assertEquals(JSONObject.NULL, json.get("targetName"));
// Payload is empty
assertEquals(0, json.getJSONArray("payload").length());
// Change the status to running, and re-check
actionTrackingService.recordActionExecuting(rd);
String actionId = rd.getId();
assertEquals(actionId, rd.getId());
assertEquals(instanceId, ((ActionImpl)rd).getExecutionInstance());
String startedAt = ISO8601DateFormat.format(rd.getExecutionStartDate());
int instanceId = ((ActionImpl)rd).getExecutionInstance();
response = sendRequest(new GetRequest(URL_DEFINITION + "Test1"), 200);
assertEquals(Status.STATUS_OK, response.getStatus());