mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-936 Audit is producing too many 'object edited' entries.
- To eliminate multiple audit maps from being generated when events with the same name are required to be fired multiple times in the same transaction, the code checks on existing auditedNode stacked for the same combination of nodeRef and eventName. If there exists such an auditNode, update its 'after' properties with the latest set of properties and leave its 'before' properties unchanged so that it retains the original set of properties. The first 'before' and last 'after' will be diff'ed when comes to building the auditMap later when the transaction commits. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@55154 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -433,13 +433,33 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
|
||||
Set<RMAuditNode> auditDetails = TransactionalResourceHelper.getSet(KEY_RM_AUDIT_NODE_RECORDS);
|
||||
AlfrescoTransactionSupport.bindListener(txnListener);
|
||||
|
||||
RMAuditNode auditedNode = new RMAuditNode();
|
||||
auditedNode.setNodeRef(nodeRef);
|
||||
auditedNode.setEventName(eventName);
|
||||
auditedNode.setNodePropertiesBefore(before);
|
||||
auditedNode.setNodePropertiesAfter(after);
|
||||
|
||||
auditDetails.add(auditedNode);
|
||||
// RM-936: Eliminate multiple audit maps from being generated when events with the same name are required to be fired multiple times in the same transaction.
|
||||
// Check if auditDetails already contains an auditedNode with the same combination of nodeRef and eventName.
|
||||
boolean auditNodeAlreadyExists = false;
|
||||
for (RMAuditNode existingRMAuditNode : auditDetails)
|
||||
{
|
||||
if (existingRMAuditNode.getNodeRef().equals(nodeRef) && existingRMAuditNode.getEventName().equals(eventName))
|
||||
{
|
||||
// If there exists such an auditNode, update its 'after' properties with the latest set of properties and leave its 'before' properties unchanged so that it
|
||||
// retains the original set of properties. The first 'before' and last 'after' will be diff'ed when comes to building the auditMap later when the transaction
|
||||
// commits.
|
||||
existingRMAuditNode.setNodePropertiesAfter(after);
|
||||
auditNodeAlreadyExists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (auditNodeAlreadyExists == false)
|
||||
{
|
||||
// Create a new auditNode if it doesn't already exist
|
||||
RMAuditNode auditedNode = new RMAuditNode();
|
||||
auditedNode.setNodeRef(nodeRef);
|
||||
auditedNode.setEventName(eventName);
|
||||
auditedNode.setNodePropertiesBefore(before);
|
||||
auditedNode.setNodePropertiesAfter(after);
|
||||
|
||||
auditDetails.add(auditedNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user