mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
ALF-4704 - Filter out deleted nodes in the replication model builder, otherwise the freemarker for the replication webscripts chokes on deleted ones. Includes new unit test.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@22376 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -32,6 +32,7 @@ import org.alfresco.service.cmr.action.ExecutionDetails;
|
|||||||
import org.alfresco.service.cmr.action.ExecutionSummary;
|
import org.alfresco.service.cmr.action.ExecutionSummary;
|
||||||
import org.alfresco.service.cmr.replication.ReplicationDefinition;
|
import org.alfresco.service.cmr.replication.ReplicationDefinition;
|
||||||
import org.alfresco.service.cmr.replication.ReplicationService;
|
import org.alfresco.service.cmr.replication.ReplicationService;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
import org.alfresco.util.ISO8601DateFormat;
|
import org.alfresco.util.ISO8601DateFormat;
|
||||||
|
|
||||||
@@ -219,9 +220,16 @@ public class ReplicationModelBuilder
|
|||||||
// Includes start+end times, and running action details
|
// Includes start+end times, and running action details
|
||||||
setStatus(rd, rdm);
|
setStatus(rd, rdm);
|
||||||
|
|
||||||
// Expand out the payload details
|
// Only include the payload entries that still exist
|
||||||
rdm.put(DEFINITION_PAYLOAD, rd.getPayload());
|
// Otherwise the freemarker layer gets upset about deleted nodes
|
||||||
|
List<NodeRef> payload = new ArrayList<NodeRef>();
|
||||||
|
for(NodeRef node : rd.getPayload()) {
|
||||||
|
if(nodeService.exists(node))
|
||||||
|
payload.add(node);
|
||||||
|
}
|
||||||
|
rdm.put(DEFINITION_PAYLOAD, payload);
|
||||||
|
|
||||||
|
// Save in the usual way
|
||||||
Map<String, Object> model = new HashMap<String,Object>();
|
Map<String, Object> model = new HashMap<String,Object>();
|
||||||
model.put(MODEL_DATA_ITEM, rdm);
|
model.put(MODEL_DATA_ITEM, rdm);
|
||||||
return model;
|
return model;
|
||||||
|
@@ -34,6 +34,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
|||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
import org.alfresco.service.cmr.security.MutableAuthenticationService;
|
import org.alfresco.service.cmr.security.MutableAuthenticationService;
|
||||||
import org.alfresco.service.cmr.security.PersonService;
|
import org.alfresco.service.cmr.security.PersonService;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.util.GUID;
|
import org.alfresco.util.GUID;
|
||||||
import org.alfresco.util.ISO8601DateFormat;
|
import org.alfresco.util.ISO8601DateFormat;
|
||||||
@@ -568,6 +569,48 @@ public class ReplicationRestApiTest extends BaseWebScriptTest
|
|||||||
assertEquals(true, payload.get("isFolder"));
|
assertEquals(true, payload.get("isFolder"));
|
||||||
assertEquals("Data Dictionary", payload.get("name"));
|
assertEquals("Data Dictionary", payload.get("name"));
|
||||||
assertEquals("/Company Home/Data Dictionary", payload.get("path"));
|
assertEquals("/Company Home/Data Dictionary", payload.get("path"));
|
||||||
|
|
||||||
|
|
||||||
|
// Add a deleted NodeRef too, will be silently ignored
|
||||||
|
// by the webscript layer
|
||||||
|
UserTransaction txn = transactionService.getUserTransaction();
|
||||||
|
txn.begin();
|
||||||
|
NodeRef deleted = nodeService.createNode(
|
||||||
|
dataDictionary, ContentModel.ASSOC_CONTAINS,
|
||||||
|
QName.createQName("IwillBEdeleted"),
|
||||||
|
ContentModel.TYPE_CONTENT
|
||||||
|
).getChildRef();
|
||||||
|
nodeService.deleteNode(deleted);
|
||||||
|
txn.commit();
|
||||||
|
|
||||||
|
rd.getPayload().add( deleted );
|
||||||
|
replicationService.saveReplicationDefinition(rd);
|
||||||
|
|
||||||
|
response = sendRequest(new GetRequest(URL_DEFINITION + "Test1"), 200);
|
||||||
|
assertEquals(Status.STATUS_OK, response.getStatus());
|
||||||
|
|
||||||
|
jsonStr = response.getContentAsString();
|
||||||
|
json = new JSONObject(jsonStr).getJSONObject("data");
|
||||||
|
|
||||||
|
assertEquals("Test1", json.get("name"));
|
||||||
|
assertEquals("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(true, json.get("enabled"));
|
||||||
|
assertEquals(JSONObject.NULL, json.get("targetName"));
|
||||||
|
|
||||||
|
// Check Payload
|
||||||
|
assertEquals(2, json.getJSONArray("payload").length());
|
||||||
|
payload = json.getJSONArray("payload").getJSONObject(0);
|
||||||
|
assertEquals("Company Home", payload.get("name"));
|
||||||
|
payload = json.getJSONArray("payload").getJSONObject(1);
|
||||||
|
assertEquals("Data Dictionary", payload.get("name"));
|
||||||
|
|
||||||
|
|
||||||
// Add a 2nd and 3rd definition
|
// Add a 2nd and 3rd definition
|
||||||
@@ -580,7 +623,7 @@ public class ReplicationRestApiTest extends BaseWebScriptTest
|
|||||||
rd.setEnabled(false);
|
rd.setEnabled(false);
|
||||||
|
|
||||||
// Have the 3rd one flagged as having failed
|
// Have the 3rd one flagged as having failed
|
||||||
UserTransaction txn = transactionService.getUserTransaction();
|
txn = transactionService.getUserTransaction();
|
||||||
txn.begin();
|
txn.begin();
|
||||||
replicationService.saveReplicationDefinition(rd);
|
replicationService.saveReplicationDefinition(rd);
|
||||||
actionTrackingService.recordActionExecuting(rd);
|
actionTrackingService.recordActionExecuting(rd);
|
||||||
|
Reference in New Issue
Block a user