cancel
Showing results for 
Search instead for 
Did you mean: 

Auditing service calls pre and post

hkır
Champ in-the-making
Champ in-the-making
Hi,
I want to audit metadata changes. But while I can handle post service calls, I can't extract audit data before service execution. My configuration file is:

<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"/>
      <DataGenerator name="currentUser" registeredName="auditModel.generator.user"/>
      <DataGenerator name="systemTime" registeredName="auditModel.generator.time"/>
   </DataGenerators>
   
   <PathMappings>
      <PathMap source="/alfresco-api/pre/NodeService/setProperties" target="/node/preupdateNode"/>
      <PathMap source="/alfresco-api/pre/NodeService/setProperty" target="/node/preupdateNode"/>
      <PathMap source="/alfresco-api/pre/NodeService/addProperties" target="/node/preupdateNode"/>
      <PathMap source="/alfresco-api/pre/NodeService/removeProperty" target="/node/preupdateNode"/>
      <PathMap source="/alfresco-api/pre/NodeService/setProperty" target="/node/preupdateNode"/>
      <PathMap source="/alfresco-api/pre/NodeService/addProperties" target="/node/preupdateNode"/>
      <PathMap source="/alfresco-api/pre/NodeService/removeProperty" target="/node/preupdateNode"/>

      <PathMap source="/alfresco-api/post/NodeService/setProperties" target="/node/updateNode"/>
      <PathMap source="/alfresco-api/post/NodeService/setProperty" target="/node/updateNode"/>
      <PathMap source="/alfresco-api/post/NodeService/addProperties" target="/node/updateNode"/>
      <PathMap source="/alfresco-api/post/NodeService/removeProperty" target="/node/updateNode"/>
      <PathMap source="/alfresco-api/post/NodeService/setProperty" target="/node/updateNode"/>
      <PathMap source="/alfresco-api/post/NodeService/addProperties" target="/node/updateNode"/>
      <PathMap source="/alfresco-api/post/NodeService/removeProperty" target="/node/updateNode"/>
   </PathMappings>
   
   <Application name="Node" key="node">
      
      <AuditPath key="preupdateNode">   
         <RecordValue key="nodeRef" dataExtractor="simpleValue" dataSource="/node/preupdateNode/args/nodeRef"/>
         <RecordValue key="properties" dataExtractor="simpleValue" dataSource="/node/preupdateNode/args/properties"/>
         <GenerateValue key="personFullName" dataGenerator="personFullName"/>
         <GenerateValue key="currentUser" dataGenerator="currentUser"/>
         <GenerateValue key="systemTime" dataGenerator="systemTime"/>
      </AuditPath>
      
      <AuditPath key="updateNode">
         <AuditPath key="no-error">
            <RecordValue key="nodeRef" dataExtractor="simpleValue" dataSource="/node/updateNode/args/nodeRef"/>
            <RecordValue key="properties" dataExtractor="simpleValue" dataSource="/node/updateNode/args/properties"/>
            <GenerateValue key="personFullName" dataGenerator="personFullName"/>
            <GenerateValue key="currentUser" dataGenerator="currentUser"/>
            <GenerateValue key="systemTime" dataGenerator="systemTime"/>
         </AuditPath>
      </AuditPath>
      
   </Application>
</Audit>

and my audit log is:

Extracted audit data:
        Application:    AuditApplication[ name=Node, id=7, disabledPathsId=4085]
        Values:
                /node/preupdateNode/args/nodeRef=workspace://SpacesStore/c3a52f43-5200-4364-beec-f17d95521302
                /node/preupdateNode/args/properties={{http://www.alfresco.org/model/content/1.0}description=wyet-97654321098765, {http://www.alfresco.org/model/content/1.0}title=qyet-97654321098765, {http://www.alfresco.org/model/content/1.0}taggable=null}

        New Data:

15:33:10,687 User:admin DEBUG [repo.audit.AuditComponentImpl]
Nothing audited:
        Application ID: 7
        Entry ID:       null
        Values:
                /node/preupdateNode/args/nodeRef=workspace://SpacesStore/c3a52f43-5200-4364-beec-f17d95521302
                /node/preupdateNode/args/properties={{http://www.alfresco.org/model/content/1.0}description=wyet-97654321098765, {http://www.alfresco.org/model/content/1.0}title=qyet-97654321098765, {http://www.alfresco.org/model/content/1.0}taggable=null}

15:33:10,723 User:System DEBUG [repo.audit.AuditComponentImpl]
Extracted audit data:
        Application:    AuditApplication[ name=Node, id=7, disabledPathsId=4085]
        Values:
                /node/updateNode/no-error=null
                /node/updateNode/args/nodeRef=workspace://SpacesStore/c3a52f43-5200-4364-beec-f17d95521302
                /node/updateNode/args/properties={{http://www.alfresco.org/model/content/1.0}description=wyet-97654321098765, {http://www.alfresco.org/model/content/1.0}title=qyet-97654321098765, {http://www.alfresco.org/model/content/1.0}taggable=null}

        New Data:
                /node/updateNode/no-error/nodeRef=workspace://SpacesStore/c3a52f43-5200-4364-beec-f17d95521302
                /node/updateNode/no-error/properties={{http://www.alfresco.org/model/content/1.0}description=wyet-97654321098765, {http://www.alfresco.org/model/content/1.0}title=qyet-97654321098765, {http://www.alfresco.org/model/content/1.0}taggable=null}

15:33:10,736 User:admin DEBUG [repo.audit.AuditComponentImpl]
New audit entry:
        Application ID: 7
        Entry ID:       7099
        Values:
                /node/updateNode/no-error=null
                /node/updateNode/args/nodeRef=workspace://SpacesStore/c3a52f43-5200-4364-beec-f17d95521302
                /node/updateNode/args/properties={{http://www.alfresco.org/model/content/1.0}description=wyet-97654321098765, {http://www.alfresco.org/model/content/1.0}title=qyet-97654321098765, {http://www.alfresco.org/model/content/1.0}taggable=null}

        Audit Data:
                /node/updateNode/no-error/systemTime=Fri Aug 12 15:33:10 EEST 2011
                /node/updateNode/no-error/currentUser=admin
                /node/updateNode/no-error/personFullName=Administrator
                /node/updateNode/no-error/nodeRef=workspace://SpacesStore/c3a52f43-5200-4364-beec-f17d95521302
                /node/updateNode/no-error/properties={{http://www.alfresco.org/model/content/1.0}description=wyet-97654321098765, {http://www.alfresco.org/model/content/1.0}title=qyet-97654321098765, {http://www.alfresco.org/model/content/1.0}taggable=null}
As mentioned in the logs while 'updateNode' creates a new audit entry but 'preupdateNode' audits nothing.
Thanks in advance for your help.
1 REPLY 1

hkır
Champ in-the-making
Champ in-the-making
I solved problem myself. For the ones who may need, pre update audith path should be :

      <AuditPath key="preupdateNode">   
         <AuditPath key="args">
            <AuditPath key="nodeRef">
               <RecordValue key="nodeRef" dataExtractor="simpleValue"/>
               <GenerateValue key="personFullName" dataGenerator="personFullName"/>
               <GenerateValue key="currentUser" dataGenerator="currentUser"/>
                     <GenerateValue key="systemTime" dataGenerator="systemTime"/>
            </AuditPath>
            <AuditPath key="properties">
               <RecordValue key="properties" dataExtractor="simpleValue"/>
            </AuditPath>
                  </AuditPath>
      </AuditPath>