mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
When a replication task is executing, the rest API details shouldn't include information on the previous run, such as logs and messages (ALF-4505)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@22078 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -192,9 +192,6 @@ public class ReplicationModelBuilder
|
||||
// Set the core details
|
||||
rdm.put(DEFINITION_NAME, rd.getReplicationName());
|
||||
rdm.put(DEFINITION_DESCRIPTION, rd.getDescription());
|
||||
rdm.put(DEFINITION_FAILURE_MESSAGE, rd.getExecutionFailureMessage());
|
||||
rdm.put(DEFINITION_TRANSFER_LOCAL_REPORT, rd.getLocalTransferReport());
|
||||
rdm.put(DEFINITION_TRANSFER_REMOTE_REPORT, rd.getRemoteTransferReport());
|
||||
rdm.put(DEFINITION_ENABLED, rd.isEnabled());
|
||||
rdm.put(DEFINITION_TARGET_NAME, rd.getTargetName());
|
||||
|
||||
@@ -212,6 +209,12 @@ public class ReplicationModelBuilder
|
||||
}
|
||||
}
|
||||
|
||||
// Set the details of the previous run
|
||||
// These will be null'd out later if replication is in progress
|
||||
rdm.put(DEFINITION_FAILURE_MESSAGE, rd.getExecutionFailureMessage());
|
||||
rdm.put(DEFINITION_TRANSFER_LOCAL_REPORT, rd.getLocalTransferReport());
|
||||
rdm.put(DEFINITION_TRANSFER_REMOTE_REPORT, rd.getRemoteTransferReport());
|
||||
|
||||
// Do the status
|
||||
// Includes start+end times, and running action details
|
||||
setStatus(rd, rdm);
|
||||
@@ -297,6 +300,16 @@ public class ReplicationModelBuilder
|
||||
model.put(DEFINITION_ENDED_AT, null);
|
||||
model.put(DEFINITION_RUNNING_ACTION_ID,
|
||||
AbstractActionWebscript.getRunningId(details.getExecutionSummary()));
|
||||
|
||||
// Since it's running / about to run, there shouldn't
|
||||
// be failure messages or transfer reports
|
||||
// If these currently exist on the model, remove them
|
||||
if(model.containsKey(DEFINITION_FAILURE_MESSAGE))
|
||||
model.put(DEFINITION_FAILURE_MESSAGE, null);
|
||||
if(model.containsKey(DEFINITION_TRANSFER_LOCAL_REPORT))
|
||||
model.put(DEFINITION_TRANSFER_LOCAL_REPORT, null);
|
||||
if(model.containsKey(DEFINITION_TRANSFER_REMOTE_REPORT))
|
||||
model.put(DEFINITION_TRANSFER_REMOTE_REPORT, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -667,6 +667,108 @@ public class ReplicationRestApiTest extends BaseWebScriptTest
|
||||
assertEquals(false, json.get("enabled"));
|
||||
assertEquals(JSONObject.NULL, json.get("targetName"));
|
||||
assertEquals(0, json.getJSONArray("payload").length());
|
||||
|
||||
|
||||
// When pending/running, the previous end time, transfer reports and
|
||||
// failure details are hidden
|
||||
rd = replicationService.loadReplicationDefinition("Test3");
|
||||
assertEquals(0, actionTrackingService.getExecutingActions(rd).size());
|
||||
|
||||
((ActionImpl)rd).setExecutionStartDate(null);
|
||||
actionTrackingService.recordActionPending(rd);
|
||||
assertEquals(1, actionTrackingService.getExecutingActions(rd).size());
|
||||
instanceId = ((ActionImpl)rd).getExecutionInstance();
|
||||
actionId = rd.getId();
|
||||
|
||||
response = sendRequest(new GetRequest(URL_DEFINITION + "Test3"), 200);
|
||||
assertEquals(Status.STATUS_OK, response.getStatus());
|
||||
|
||||
jsonStr = response.getContentAsString();
|
||||
json = new JSONObject(jsonStr).getJSONObject("data");
|
||||
|
||||
assertEquals("Test3", json.get("name"));
|
||||
assertEquals("3rd 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(false, json.get("enabled"));
|
||||
assertEquals(JSONObject.NULL, json.get("targetName"));
|
||||
assertEquals(0, json.getJSONArray("payload").length());
|
||||
|
||||
|
||||
actionTrackingService.recordActionExecuting(rd);
|
||||
response = sendRequest(new GetRequest(URL_DEFINITION + "Test3"), 200);
|
||||
assertEquals(Status.STATUS_OK, response.getStatus());
|
||||
|
||||
jsonStr = response.getContentAsString();
|
||||
json = new JSONObject(jsonStr).getJSONObject("data");
|
||||
startedAt = ISO8601DateFormat.format(rd.getExecutionStartDate());
|
||||
|
||||
assertEquals("Test3", json.get("name"));
|
||||
assertEquals("3rd Testing", json.get("description"));
|
||||
assertEquals("Running", json.get("status"));
|
||||
assertEquals(startedAt, json.getJSONObject("startedAt").get("iso8601"));
|
||||
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(false, json.get("enabled"));
|
||||
assertEquals(JSONObject.NULL, json.get("targetName"));
|
||||
assertEquals(0, json.getJSONArray("payload").length());
|
||||
|
||||
|
||||
actionTrackingService.requestActionCancellation(rd);
|
||||
response = sendRequest(new GetRequest(URL_DEFINITION + "Test3"), 200);
|
||||
assertEquals(Status.STATUS_OK, response.getStatus());
|
||||
|
||||
jsonStr = response.getContentAsString();
|
||||
json = new JSONObject(jsonStr).getJSONObject("data");
|
||||
startedAt = ISO8601DateFormat.format(rd.getExecutionStartDate());
|
||||
|
||||
assertEquals("Test3", json.get("name"));
|
||||
assertEquals("3rd Testing", json.get("description"));
|
||||
assertEquals("CancelRequested", json.get("status"));
|
||||
assertEquals(startedAt, json.getJSONObject("startedAt").get("iso8601"));
|
||||
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(false, json.get("enabled"));
|
||||
assertEquals(JSONObject.NULL, json.get("targetName"));
|
||||
assertEquals(0, json.getJSONArray("payload").length());
|
||||
|
||||
|
||||
// These show up again when no longer running
|
||||
actionTrackingService.recordActionComplete(rd);
|
||||
response = sendRequest(new GetRequest(URL_DEFINITION + "Test3"), 200);
|
||||
assertEquals(Status.STATUS_OK, response.getStatus());
|
||||
|
||||
jsonStr = response.getContentAsString();
|
||||
json = new JSONObject(jsonStr).getJSONObject("data");
|
||||
startedAt = ISO8601DateFormat.format(rd.getExecutionStartDate());
|
||||
endedAt = ISO8601DateFormat.format(rd.getExecutionEndDate());
|
||||
|
||||
assertEquals("Test3", json.get("name"));
|
||||
assertEquals("3rd Testing", json.get("description"));
|
||||
assertEquals("Completed", json.get("status"));
|
||||
assertEquals(startedAt, json.getJSONObject("startedAt").get("iso8601"));
|
||||
assertEquals(endedAt, json.getJSONObject("endedAt").get("iso8601"));
|
||||
assertEquals(JSONObject.NULL, json.get("failureMessage"));
|
||||
assertEquals(JSONObject.NULL, json.get("executionDetails"));
|
||||
assertEquals(repositoryHelper.getRootHome().toString(), json.get("transferLocalReport"));
|
||||
assertEquals(repositoryHelper.getCompanyHome().toString(), json.get("transferRemoteReport"));
|
||||
assertEquals(false, json.get("enabled"));
|
||||
assertEquals(JSONObject.NULL, json.get("targetName"));
|
||||
assertEquals(0, json.getJSONArray("payload").length());
|
||||
}
|
||||
|
||||
public void testReplicationDefinitionsPost() throws Exception
|
||||
|
Reference in New Issue
Block a user