Audittrail app: Enabling audits on an entity that has System.File super-class

1
My entity needs to have a generalization from System.FileDocument class. And, I also wish to enable auditing (logs) on my entity, using the Audittrail app module. Any idea how this can be done?
asked
4 answers
3

Chris, the appstore module has been updated recently. It is no longer a requirement to inherit from the 'AudittrailSuperClass' entity.

In the latest appstore version you can choose between the old implementation, inherit from the superclass and the module automatically logs every create, change and delete for you.

Or

Add an association between the Log entity and your auditable entity. And create an after create, before commit and before delete event. Identical to the events on the AudittrailSuperClass entity. This way you can audit FileDocument subclasses as well.


The first implementation could result in performance/locking issues if you have to many instances or to many entities inheriting from the superclass. Therefore it is possible to choose if you want to inherit.

Purandara, Unfortunately there is a small bug in the module which causes this exception. There is already a fix updated, this version is awaiting approval in the appstore. So as soon as version 2.0.1 is available (probably within a day or two) you should download the latest version from the appstore, that should solve this problem.

answered
0

Edit: That was the disadvantage of the Audit trail module.

The alternative way is to extract the 'audit' microflow from the module, change to make it work with anyobject and call it in the before commit event and optionally before/after delete events.

answered
0

Thanks.. Even with an entity that doesn't extend from System.File, I get the following error. My entity in this case is MyFirstApp.Department. I don't think I am missing any step from the documentation of Audit-Trail. Any idea what may be wrong?

=============================================

An error has occurred while handling the request. [User 'Anonymous_c8f4bd9c-ac03-498d-b948-0acd4832ff25' with roles 'User']

com.mendix.core.CoreRuntimeException: lg: com.mendix.core.CoreRuntimeException: java.lang.IllegalArgumentException: The given value '[MendixIdentifier:: id=562949953421317 objectType=MyFirstApp.Department entityID=2]' with type 'class ih' is not of the same type as the member corresponding with the given member name 'AuditTrail.LogAudittrailSuperClass' at AuditTrail.ACrBCo_AudittrailSuperClass (JavaAction : 'Call 'CreateLogRecordOfObject'') at {"after":[],"before":[{},{},{}],"action":{"type":"CommitAction"},"type":"EventExtendedAction"}

Advanced stacktrace: at hC.a(SourceFile:184) Caused by: lg: com.mendix.core.CoreRuntimeException: java.lang.IllegalArgumentException: The given value '[MendixIdentifier:: id=562949953421317 objectType=MyFirstApp.Department entityID=2]' with type 'class ih' is not of the same type as the member corresponding with the given member name 'AuditTrail.LogAudittrailSuperClass' at AuditTrail.ACrBCo_AudittrailSuperClass (JavaAction : 'Call 'CreateLogRecordOfObject'') at {"after":[],"before":[{},{},{}],"action":{"type":"CommitAction"},"type":"EventExtendedAction"}

Advanced stacktrace: at mt.a(SourceFile:187) Caused by: com.mendix.core.CoreException: com.mendix.core.CoreRuntimeException: java.lang.IllegalArgumentException: The given value '[MendixIdentifier:: id=562949953421317 objectType=MyFirstApp.Department entityID=2]' with type 'class ih' is not of the same type as the member corresponding with the given member name 'AuditTrail.LogAudittrailSuperClass' at com.mendix.core.Core.execute(SourceFile:232) Caused by: com.mendix.core.CoreRuntimeException: java.lang.IllegalArgumentException: The given value '[MendixIdentifier:: id=562949953421317 objectType=MyFirstApp.Department entityID=2]' with type 'class ih' is not of the same type as the member corresponding with the given member name 'AuditTrail.LogAudittrailSuperClass' at hC.b(SourceFile:218) Caused by: java.lang.IllegalArgumentException: The given value '[MendixIdentifier:: id=562949953421317 objectType=MyFirstApp.Department entityID=2]' with type 'class ih' is not of the same type as the member corresponding with the given member name 'AuditTrail.Log_AudittrailSuperClass' at ii.setValue(SourceFile:278) at audittrail.log.CreateLogObject.CreateAuditLogItems(CreateLogObject.java:97) at audittrail.log.CreateLogObject.CreateAuditLogItems(CreateLogObject.java:49) at audittrail.actions.CreateLogRecordOfObject.executeAction(CreateLogRecordOfObject.java:35) at audittrail.actions.CreateLogRecordOfObject.executeAction(CreateLogRecordOfObject.java:19) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:57) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:457) at hC.b(SourceFile:207) at com.mendix.core.Core.execute(SourceFile:226) at ln.a(SourceFile:69) at mt.a(SourceFile:72) at ms.a(SourceFile:151) at ms.executeAction(SourceFile:98) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:57) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:457) at hC.b(SourceFile:207) at com.mendix.core.Core.executeSync(SourceFile:203) at hJ.a(SourceFile:94) at hJ.f(SourceFile:69) at hJ.a(SourceFile:33) at hG.execute(SourceFile:95) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:457) at hC.b(SourceFile:211) at hC.a(SourceFile:175) at com.mendix.core.Core.commit(SourceFile:542) at com.mendix.core.Core.commit(SourceFile:519) at gk.execute(SourceFile:40) at jd.a(SourceFile:319) at com.mendix.externalinterface.connector.RequestDispatching$Worker.a(SourceFile:170) at com.mendix.externalinterface.connector.RequestDispatching$Worker$a.a(SourceFile:161) at com.mendix.externalinterface.connector.RequestDispatching$Worker$a.apply(SourceFile:160) at akka.actor.Actor$class.apply(Actor.scala:545) at com.mendix.externalinterface.connector.RequestDispatching$Worker.apply(SourceFile:156) at akka.actor.LocalActorRef.invoke(ActorRef.scala:910) at akka.dispatch.MessageInvocation.invoke(MessageHandling.scala:25) at akka.dispatch.ExecutableMailbox$class.processMailbox(ExecutorBasedEventDrivenDispatcher.scala:223) at akka.dispatch.ExecutorBasedEventDrivenDispatcher$$anon$4.processMailbox(ExecutorBasedEventDrivenDispatcher.scala:123) at akka.dispatch.ExecutableMailbox$class.run(ExecutorBasedEventDrivenDispatcher.scala:195) at akka.dispatch.ExecutorBasedEventDrivenDispatcher$$anon$4.run(ExecutorBasedEventDrivenDispatcher.scala:123) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) at java.lang.Thread.run(Thread.java:662) at akka.dispatch.MonitorableThread.run(ThreadPoolBuilder.scala:192) Caused by: java.lang.ClassCastException: ih cannot be cast to java.util.List at com.mendix.core.objectmanagement.member.MendixObjectReferenceSet.setValue(SourceFile:18) at ii.setValue(SourceFile:270) at audittrail.log.CreateLogObject.CreateAuditLogItems(CreateLogObject.java:97) at audittrail.log.CreateLogObject.CreateAuditLogItems(CreateLogObject.java:49) at audittrail.actions.CreateLogRecordOfObject.executeAction(CreateLogRecordOfObject.java:35) at audittrail.actions.CreateLogRecordOfObject.executeAction(CreateLogRecordOfObject.java:19) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:57) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:457) at hC.b(SourceFile:207) at com.mendix.core.Core.execute(SourceFile:226) at ln.a(SourceFile:69) at mt.a(SourceFile:72) at ms.a(SourceFile:151) at ms.executeAction(SourceFile:98) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:57) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:457) at hC.b(SourceFile:207) at com.mendix.core.Core.executeSync(SourceFile:203) at hJ.a(SourceFile:94) at hJ.f(SourceFile:69) at hJ.a(SourceFile:33) at hG.execute(SourceFile:95) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:457) at hC.b(SourceFile:211) at hC.a(SourceFile:175) at com.mendix.core.Core.commit(SourceFile:542) at com.mendix.core.Core.commit(SourceFile:519) at gk.execute(SourceFile:40) at jd.a(SourceFile:319) at com.mendix.externalinterface.connector.RequestDispatching$Worker.a(SourceFile:170) at com.mendix.externalinterface.connector.RequestDispatching$Worker$a.a(SourceFile:161) at com.mendix.externalinterface.connector.RequestDispatching$Worker$a.apply(SourceFile:160) at akka.actor.Actor$class.apply(Actor.scala:545) at com.mendix.externalinterface.connector.RequestDispatching$Worker.apply(SourceFile:156) at akka.actor.LocalActorRef.invoke(ActorRef.scala:910) at akka.dispatch.MessageInvocation.invoke(MessageHandling.scala:25) at akka.dispatch.ExecutableMailbox$class.processMailbox(ExecutorBasedEventDrivenDispatcher.scala:223) at akka.dispatch.ExecutorBasedEventDrivenDispatcher$$anon$4.processMailbox(ExecutorBasedEventDrivenDispatcher.scala:123) at akka.dispatch.ExecutableMailbox$class.run(ExecutorBasedEventDrivenDispatcher.scala:195) at akka.dispatch.ExecutorBasedEventDrivenDispatcher$$anon$4.run(ExecutorBasedEventDrivenDispatcher.scala:123) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) at java.lang.Thread.run(Thread.java:662) at akka.dispatch.MonitorableThread.run(ThreadPoolBuilder.scala:192)

answered
0

Thanks, Japser. I will wait for the next update, because either way, I am getting an exception. With the subset approach (when my entity doesn't inherit from System.File or any class), I get -

com.mendix.core.CoreRuntimeException: lg: com.mendix.core.CoreRuntimeException: java.lang.IllegalArgumentException: The given member name 'AuditTrail.LogAudittrailSuperClass' has no corresponding member in this object of type 'MyProject.MyEntity' at AuditTrail.ACrBCo_AudittrailSuperClass (JavaAction : 'Call 'CreateLogRecordOfObject'') at {"after":[],"before":[{},{}],"action":{"type":"CommitAction"},"type":"EventExtendedAction"}

answered