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

@@ -478,7 +478,9 @@
</property> </property>
</bean> </bean>
<bean id="relinquishHold" class="org.alfresco.module.org_alfresco_module_rm.action.impl.RelinquishHoldAction" parent="rmAction" /> <bean id="relinquishHold" class="org.alfresco.module.org_alfresco_module_rm.action.impl.RelinquishHoldAction" parent="rmAction">
<property name="auditedImmediately" value="true"/>
</bean>
<!-- Edit hold reason --> <!-- Edit hold reason -->
@@ -714,6 +716,7 @@
</bean> </bean>
<bean id="transferComplete" class="org.alfresco.module.org_alfresco_module_rm.action.impl.TransferCompleteAction" parent="rmAction" > <bean id="transferComplete" class="org.alfresco.module.org_alfresco_module_rm.action.impl.TransferCompleteAction" parent="rmAction" >
<property name="auditedImmediately" value="true"/>
</bean> </bean>
<!-- accession --> <!-- accession -->
@@ -758,6 +761,7 @@
</bean> </bean>
<bean id="accessionComplete" class="org.alfresco.module.org_alfresco_module_rm.action.impl.TransferCompleteAction" parent="rmAction"> <bean id="accessionComplete" class="org.alfresco.module.org_alfresco_module_rm.action.impl.TransferCompleteAction" parent="rmAction">
<property name="auditedImmediately" value="true"/>
</bean> </bean>
<!-- Split Email --> <!-- Split Email -->

View File

@@ -37,6 +37,9 @@ public abstract class AuditableActionExecuterAbstractBase extends ActionExecuter
/** Indicates whether the action is auditable or not */ /** Indicates whether the action is auditable or not */
protected boolean auditable = true; protected boolean auditable = true;
/** Indicates whether the action is audited immediately or not */
protected boolean auditedImmediately = false;
/** Application context */ /** Application context */
protected ApplicationContext applicationContext; protected ApplicationContext applicationContext;
@@ -51,6 +54,14 @@ public abstract class AuditableActionExecuterAbstractBase extends ActionExecuter
this.auditable = auditable; 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) * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
*/ */
@@ -95,13 +106,22 @@ public abstract class AuditableActionExecuterAbstractBase extends ActionExecuter
@Override @Override
public void execute(Action action, NodeRef actionedUponNodeRef) public void execute(Action action, NodeRef actionedUponNodeRef)
{ {
// execute the action
super.execute(action, actionedUponNodeRef);
// audit the execution of the action // audit the execution of the action
if (auditable == true) if (auditable == true)
{ {
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()); getAuditService().auditEvent(actionedUponNodeRef, this.getActionDefinition().getName());
} }
} }
// execute the action
super.execute(action, actionedUponNodeRef);
}
} }