cancel
Showing results for 
Search instead for 
Did you mean: 

Problems auditing nodes and own methods

saruqui
Champ in-the-making
Champ in-the-making
Hi,

I have 2 questions about AuditService in Alfresco 4.
1. I don't have any problem auditing Alfresco's services but when I try to audit my own methods in my module I don't get any data about it.

My code is:
<?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-api/pre/ExtractorService/updateMetadata"  target="/Extractor" />
                <PathMap source="/alfresco-api/post/ExtractorService/updateMetadata"  target="/Extractor" />
        </PathMappings>

      <Application name="Extractor" key="Extractor">
      <AuditPath key="update">
            <AuditPath key="in">
                <RecordValue key="nodeRef" dataExtractor="simpleValue" dataSource="/Extractor/args/nodeRef" dataTrigger="/Extractor/no-error"/>                    
            </AuditPath>
            <AuditPath key="out">
                <RecordValue key="result" dataExtractor="simpleValue" dataSource="/Extractor/result" dataTrigger="/Extractor/no-error"/>            
            </AuditPath>         
   </AuditPath>      
    </Application>   
</Audit>



public interface ExtractorService {

   @Auditable(parameters={"nodeRef"})
   public ContentReader getContent(NodeRef nodeRef) throws ServiceException, IOException;
}

Any idea?


2. I have the following doubt. If I'm auditing nodeService, CheckoutCheckinService, permissionService, alfresco-access… and I want to know everything about a node. Are there any query,

service or anything for resolving it or do I need to create a query for everyone and then a merge about the results?

Thx in advance  Smiley Very Happy
2 REPLIES 2

afaust
Legendary Innovator
Legendary Innovator
Hello,

I have a feeling your service declaration and Spring configuration may be incomplete, which is why your service may not be properly audited.

  • Make sure your service is fully annotated - I think in addition to Auditable on the method you need PublicService (or something in that direction) on the interface itself (look at the NodeService interface for reference)

  • Make sure you have properly encapsulated your service bean in a public service proxy - only a proxy with the AuditMethodInterceptor will actually be able to log your service invocations

  • Turn the audit debugging on to see if you actually collect data or have any path mapping errors
For providing your own public service proxy, refer to the example from the NodeService:

<bean id="NodeService" class="org.springframework.aop.framework.ProxyFactoryBean">
   <property name="proxyInterfaces">
      <list>
         <value>org.alfresco.service.ServiceDescriptor</value>
         <value>org.alfresco.service.cmr.repository.NodeService</value>
      </list>
   </property>
   <property name="target">
      <ref bean="nodeService"/>
   </property>
   <property name="interceptorNames">
      <list>
         <idref local="NodeService_transaction"/>
         <idref local="AuditMethodInterceptor"/>
         <idref local="exceptionTranslator"/>
         <idref bean="NodeService_security"/>
         <idref local="NodeService_descriptor"/>
      </list>
   </property>
</bean>

Regards
Axel

saruqui
Champ in-the-making
Champ in-the-making
Hi again,

Thx Axel for your help but I'm still having problems to audit my methods.
I've added a reference to RegistryService (I'm not sure if this is the service for converting my interface into a public service) and the setter/getter in my

implementation class.

My module-context.xml for my interface is:
….
<bean id="ExtractorService" class="org.springframework.aop.framework.ProxyFactoryBean">
       <property name="proxyInterfaces">
          <list>            
             <value>com.saruqui.alfresco.services.ExtractorService</value>
          </list>
       </property>
       <property name="target">
          <ref bean="ExtractorService"/>
       </property>
       <property name="interceptorNames">
          <list>
             <idref local="ExtractorService_transaction"/>
             <idref local="ExtractorService_security"/>
             <idref bean="AuditMethodInterceptor"/>
             <idref bean="exceptionTranslator"/>            
       
          </list>
       </property>
    </bean>
       <bean id="ExtractorService_transaction" class="org.springframework.transaction.interceptor.TransactionInterceptor">
        <property name="transactionManager">
            <ref bean="transactionManager"/>
        </property>
        <property name="transactionAttributes">
            <props>
                <prop key="*">${server.transaction.mode.default}</prop>
            </props>
        </property>
    </bean>
       
    <bean id="ExtractorService_security" class="org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor" />
   

   <bean id="ExtractorService" class="com.saruqui.alfresco.services.ExtractorServiceImpl">
      <property name="contentService" ref="ContentService" />
      <property name="dictionaryService" ref="DictionaryService" />
      <property name="mimetypeService" ref="MimetypeService" />
      <property name="nodeService" ref="NodeService" />
      <property name="serviceRegistry" ref="ServiceRegistry" />      
      <property name="genericMetadataExtractor" ref="GenericMetadataExtractor" /> 
      
   </bean>
….

I don't know if I need anything else or how I have to use the ServiceRegistry  :?:

Regards,