Jaynil
Jaynil

Reputation: 128

Track user actions in Alfresco

I'm having requirement to track each action an user performs in Alfresco.

I want to write a Spring interceptor which is having advice "Around" and when user performs any of the action after login to portal, that should be tracked.

Action that user performs, parameters for that action should be available to custom interceptor.

Please help me if any one knows how to implement this kind of scenario.

Upvotes: 1

Views: 835

Answers (1)

streetturtle
streetturtle

Reputation: 5850

It is probably quite late, but still :)

Audit is supported out of the box. But as I understood it is turned on by default only for records management. For share actions you need to do several sreps:

  1. Create file extenstion/audit/alfresco-audit-node.xml
  2. Register an application for the actions upon node, for example let's take read action, so the content of this xml would be something like this:

    <Audit
      xmlns="http://www.alfresco.org/repo/audit/model/3.2"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.alfresco.org/repo/audit/model/3.2 alfresco-audit-3.2.xsd"
      >
      <DataExtractors>
        <DataExtractor name="simpleValue" registeredName="auditModel.extractor.simpleValue"/>
      </DataExtractors>
    
      <DataGenerators>
        <DataGenerator name="personFullName" registeredName="auditModel.generator.personFullName"/>
      </DataGenerators>
    
      <PathMappings>
        <PathMap source="/alfresco-api/post/ContentService/getReader" target="/node/read"/>
      </PathMappings>
    
      <Application name="Node" key="node">
        <AuditPath key="read">
          <AuditPath key="no-error">
            <RecordValue key="nodeRef" dataExtractor="simpleValue" dataSource="/node/read/args/nodeRef"/>
            <RecordValue key="propertyQName" dataExtractor="simpleValue" dataSource="/node/read/args/propertyQName"/>
            <RecordValue key="result" dataExtractor="simpleValue" dataSource="/node/read/result"/>
            <GenerateValue key="personFullName" dataGenerator="personFullName"/>
            <GenerateValue key="currentUser" dataGenerator="currentUser"/>
            <GenerateValue key="systemTime" dataGenerator="systemTime"/>
          </AuditPath>
          <AuditPath key="error">
            <RecordValue key="nodeRef" dataExtractor="simpleValue" dataSource="/node/read/args/nodeRef"/>
            <RecordValue key="propertyQName" dataExtractor="simpleValue" dataSource="/node/read/args/propertyQName"/>
            <RecordValue key="error" dataExtractor="simpleValue" dataSource="/node/read/error"/>
            <GenerateValue key="personFullName" dataGenerator="personFullName"/>
            <GenerateValue key="currentUser" dataGenerator="currentUser"/>
            <GenerateValue key="systemTime" dataGenerator="systemTime"/>
          </AuditPath>
        </AuditPath>
      </Application>
    
    </Audit>
    
  3. Enable application by calling a webscript, you can check it here: /alfresco/service/api/audit/control

  4. Now you are able to see the logs here: /alfresco/service/api/audit/query/Node?verbose=true&limit=10&user=admin

Upvotes: 1

Related Questions