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
This commit is contained in:
Craig Tan
2013-09-12 06:07:29 +00:00
parent 97b7774eed
commit 19a4f06591
2 changed files with 31 additions and 7 deletions

View File

@@ -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);
}
}