Search code examples
javaalfresco

Modify audit trail in Alfresco using a custom webscript


I am writing a custom Java webscript that accepts document noderef and an external username (string value) as parameters. I have auditing enabled and the audit log shows access to the document when I call the webscript. Now I wanted to know if it is possible to modify the audit trail so that when it shows the log for that particular document it also shows the name of the external user.

webscript url: http://localhost:8080/alfresco/service/node/{noderef}/user/{user}

On calling this I get the following output in log:

Extracted audit data: 
    Application:    AuditApplication[ name=alfresco-access, id=1, disabledPathsId=2]
    Values:         
        /alfresco-access/transaction/sub-actions=readContent
        /alfresco-access/transaction/action=READ
        /alfresco-access/transaction/node=workspace://SpacesStore/c21db432-4ad6-4af2-8bcf-78bc89724afe
        /alfresco-access/transaction/type=cm:content
        /alfresco-access/transaction/path=/app:company_home/app:shared/cm:audit-services-context.xml
        /alfresco-access/transaction/user=admin

    New Data: 
        /alfresco-access/transaction/sub-actions=readContent
        /alfresco-access/transaction/action=READ
        /alfresco-access/transaction/type=cm:content
        /alfresco-access/transaction/user=admin
        /alfresco-access/transaction/path=/app:company_home/app:shared/cm:audit-services-context.xml

I want to store the {user} also in the audit trail.


Solution

  • You can try to use AuthenticationUtil.setFullyAuthenticatedUser. I think this should help you. But I didn't test this.