Who’s reading your documents?
Chris Davidson, Software Consultant, Wednesday 4th March 2009
For compliance purposes it can be very useful to produce a list of people who have read a document. Now whilst it may not be possible to actually prove someone has read a document using an audit trail you can prove they have opened the file, thus implying they know of its existence.
Alfresco allows you to capture an audit trail of the events that have occurred within the system. This trail can capture edits, permissions changes or indeed any event that goes through the Alfresco services. There is an XML file that is used to configure which events get audited however it does not have the reader method in there, so even if you turn the audit on you will still not capture which users are reading a document.
The auditConfig.xml file controls what is audited within Alfresco, you can find this in alfresco\WEB-INF\classes\alfresco. To configure the audit it is best to copy this file to the shared extension directory (that way it doesn’t get written over when you upgrade), tomcat\shared\classes\alfresco\extension on a Tomcat installation. Also add a file custom-audit-services-context.xml, that will get Alfresco to load the config file, with the following XML:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<!-- The configuration of the audit model -->
<bean id="auditConfiguration" class="org.alfresco.repo.audit.AuditConfigurationImpl">
<property name="config">
<value>alfresco/extension/auditConfig.xml</value>
</property>
</bean>
</beans>
Now to turn auditing on you will need to edit the auditConfig.xml, change the audit tag at the top so that enabled equals true. This now turns on all the services auditing:
<Audit xmlns="http://www.alfresco.org/model/audit/1.0" xmlns:xsi="http://www.w3.org/
2001/XMLSchema-instance" enabled="true" auditInternal="false" mode="all">
If you just have this Audit element in the XML and remove the rest then everything will get audited, not necessarily what you want as there will be some processor expense for storing this in the database. So we will leave the configuration as it is, we just need to add the read method “getReader” to the audit. This method exists within two services FileFolderService and the ContentService, edit the XML as below to add read (Note. There was a bug in 2.2 SP1 when enabling getReader, do not use on that version, it was fixed in SP2).
<Service name="FileFolderService" mode="none">
<Method name="rename" mode="all"/>
<Method name="move" mode="all"/>
<Method name="copy" mode="all" auditInternal="true"/>
<Method name="create" mode="all"/>
<Method name="delete" mode="all"/>
<Method name="makeFolders" mode="all"/>
<Method name="getWriter" mode="all"/>
<Method name="getReader" mode="all"/>
</Service>
<Service name="ContentService" mode="none">
<Method name="getWriter" mode="all"/>
<Method name="transform" mode="all"/>
<Method name="getReader" mode="all"/>
</Service>
Now restart the server and add a document to Alfresco, carry out some actions on the document including opening, editing (content and properties), set a permission.
The easiest way to view these audit entries is to use a presentation template. There is one built in that has everything in it. Go to View Details on the document you have edited, click Preview in Template and select show_audit.ftl from the drop down. You should be able to see all of the actions you just carried out. This template is a bit over the top in that it returns everything but it is pretty simple to create a stripped down version of this that is more user friendly.
It is also possible to retrieve audits from the database direct. The Alfresco wiki has some SQL examples at Auditing Design and Implementation, towards the bottom is the following that will show all the documents read by a user in the last 7 days. This page also contains some brief details of audit.







Comments
Be the first to comment.
Add your comment