cancel
Showing results for 
Search instead for 
Did you mean: 

fetch values from audit result

ranj
Champ on-the-rise
Champ on-the-rise
Hi,
I have created audit.xml inside shared/alfresco/classes/extension/audit
This is what it contains:

<?xml version="1.0" encoding="UTF-8"?>
<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>

  <PathMappings>
    <PathMap source="/alfresco-access" target="/my-app" />
  </PathMappings>

  <Application name="my-app" key="my-app">
      <RecordValue key="action" dataExtractor="simpleValue" dataSource="/my-app/transaction/action"
        dataTrigger="/my-app/transaction/action" />
        <RecordValue key="node" dataExtractor="simpleValue" dataSource="/my-app/transaction/node"
        dataTrigger="/my-app/transaction/node"/>
      <RecordValue key="user" dataExtractor="simpleValue" dataSource="/my-app/transaction/user"
        dataTrigger="/my-app/transaction/user"/>
  </Application>

</Audit>
i use a js to hit the webscript..heres my js.

function main() {
      var connector = remote.connect("alfresco");
             model.connector = connector;

         var results = connector.call("/api/audit/query/my-app?limit=10&user=admin");
         var data;
         data = eval('(' + results + ')');
         model.data = ""+data;
           }
main();

This perfectly renders a json result when hit as :
{
   "count":2,
   "entries":
   [
      {
         "id":18582,
         "application":"my-app",
         "user":"admin",
         "time":"2012-05-21T10:50:58.491+05:30",
        "values":         {
                     "\/my-app\/action":"READ"
                     ,"\/my-app\/user":"admin"
                     ,"\/my-app\/node":"workspace:\/\/SpacesStore\/06c7c9e9-986a-4a39-8937-1381564b3625"
                             }
        
      },
      {
         "id":18583,
         "application":"my-app",
         "user":"admin",
         "time":"2012-05-21T10:50:58.632+05:30",
         "values":         {
                     "\/my-app\/action":"DELETE"
                     ,"\/my-app\/user":"admin"
                     ,"\/my-app\/node":"workspace:\/\/SpacesStore\/7f553652-c73b-4b48-acb0-a8aa6a4145ba"
            }
        
      }
}

Now i need to retrieve these json values on to my ftl..This is how i tried..

<#list data as d>
${d.user}
${d.application}
${d.time}
</#list>

This perfectly fetches the fields..But I couldnt find a way to retrieve the "values"..i can only retrieve user,application,id,time..what i really need is to get action,node which are inside values..how do i do it..?
Need some help..

Regards,
Ranj
1 REPLY 1

lementree
Champ on-the-rise
Champ on-the-rise
Hi

You can read them as below:

<#list data as d>
${d.user}
${d.application}
${d.time}
${d.values['/my-app/user']}
${d.values['/my-app/action']}
${d.values['/my-app/node']}
</#list>