From 19a4f06591b82e3301d072ce42f4673ff5c05b3a Mon Sep 17 00:00:00 2001 From: Craig Tan Date: Thu, 12 Sep 2013 06:07:29 +0000 Subject: [PATCH] RM-838 Searching for audit logs by event doesn't work for some events' types - Added a new Spring config property 'auditedImmediately' to work alongside 'auditable' property to indicate that the action should be audited immediately rather than after transaction commits. The default value of 'auditedImmediately' is false unless it is specified as true by individual action in rm-action-context.xml. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@55259 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../rm-action-context.xml | 6 +++- .../AuditableActionExecuterAbstractBase.java | 32 +++++++++++++++---- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml index e89bbe1f26..e974983d32 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml @@ -478,7 +478,9 @@ - + + + @@ -714,6 +716,7 @@ + @@ -758,6 +761,7 @@ + diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/AuditableActionExecuterAbstractBase.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/AuditableActionExecuterAbstractBase.java index 28ef3b8393..fe63055b3b 100755 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/AuditableActionExecuterAbstractBase.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/AuditableActionExecuterAbstractBase.java @@ -36,7 +36,10 @@ public abstract class AuditableActionExecuterAbstractBase extends ActionExecuter { /** Indicates whether the action is auditable or not */ protected boolean auditable = true; - + + /** Indicates whether the action is audited immediately or not */ + protected boolean auditedImmediately = false; + /** Application context */ protected ApplicationContext applicationContext; @@ -50,7 +53,15 @@ public abstract class AuditableActionExecuterAbstractBase extends ActionExecuter { this.auditable = auditable; } - + + /** + * @param auditedImmediately true if to be audited immediately, false to be audited after transaction commits + */ + public void setAuditedImmediately(boolean auditedImmediately) + { + this.auditedImmediately = auditedImmediately; + } + /** * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext) */ @@ -95,13 +106,22 @@ public abstract class AuditableActionExecuterAbstractBase extends ActionExecuter @Override public void execute(Action action, NodeRef actionedUponNodeRef) { - // execute the action - super.execute(action, actionedUponNodeRef); - // audit the execution of the action if (auditable == true) { - getAuditService().auditEvent(actionedUponNodeRef, this.getActionDefinition().getName()); + if (auditedImmediately == true) + { + // To be audited immediately before the action is executed, eg. to audit before actionedUponNodeRef gets deleted during the execution. + getAuditService().auditEvent(actionedUponNodeRef, this.getActionDefinition().getName(), null, null); + } + else + { + // To be stacked up with other audit entries and audited after the transaction commits. + getAuditService().auditEvent(actionedUponNodeRef, this.getActionDefinition().getName()); + } } + + // execute the action + super.execute(action, actionedUponNodeRef); } }