<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Auditing search queries in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/auditing-search-queries/m-p/306502#M259632</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As part of a project, I need to be able to audit searches performed by users in Alfresco (running 4.2.f from the maven archetype).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've set up the Auditing subsystem, which works as advertised, but the SearchService is not part of the default alfresco-access application so I set out to create my own audit application:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;PathMappings&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;PathMap source="/alfresco-api/post/SearchService/query" target="/searchaudit/query" /&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;/PathMappings&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;Application name="SearchAudit" key="searchaudit"&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;AuditPath key="query"&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;AuditPath key="no-error"&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;RecordValue key="args" dataExtractor="simpleValue" dataSource="/searchaudit/query/args" /&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;GenerateValue key="user" dataGenerator="personFullName" /&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/AuditPath&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/AuditPath&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;/Application&amp;gt;&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I got those paths by turning on the extended audit logging which showed me these values when doing a search:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;2014-10-10 15:16:51,719&amp;nbsp; DEBUG [repo.audit.inbound] [http-bio-8080-exec-4] &lt;BR /&gt;Inbound audit values:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;/alfresco-api/post/SearchService/query/args=null&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;/alfresco-api/post/SearchService/query/no-error=null&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;/alfresco-api/post/SearchService/query/result=org.alfresco.repo.search.impl.lucene.PagingLuceneResultSet@109d90ef&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The application is loaded properly and appears as started in &lt;/SPAN&gt;&lt;A href="http://localhost:8080/alfresco/service/api/audit/control" rel="nofollow noopener noreferrer"&gt;http://localhost:8080/alfresco/service/api/audit/control&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And values appear when fetching &lt;/SPAN&gt;&lt;A href="http://localhost:8080/alfresco/service/api/audit/query/SearchAudit?verbose=true" rel="nofollow noopener noreferrer"&gt;http://localhost:8080/alfresco/service/api/audit/query/SearchAudit?verbose=true&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, no matter how I try, I cannot get this to record the terms that have been searched for (which I gather are in the /args part of the query?), only the user shows. Actually it appears as if the args are never recorded - 'args' always appear to be null both in the logs and when passing it to a custom dataExtractor I wrote and wired in for debugging purpose.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Obviously the SearchService has to be passed some sort of arguments to perform a search, so these cannot be null under the hood.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Looking at the code for SearchService.java, we can see the proper @Auditable annotations are set up where needed, so it looks like there's no problem here.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So my questions are…&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;- Am I doing something obviously wrong with the auditing subsystem?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- If not, how can I actually record the search terms though the auditing system?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Florent&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Oct 2014 02:57:31 GMT</pubDate>
    <dc:creator>florentdelannoy</dc:creator>
    <dc:date>2014-10-10T02:57:31Z</dc:date>
    <item>
      <title>Auditing search queries</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/auditing-search-queries/m-p/306502#M259632</link>
      <description>Hi,As part of a project, I need to be able to audit searches performed by users in Alfresco (running 4.2.f from the maven archetype).I've set up the Auditing subsystem, which works as advertised, but the SearchService is not part of the default alfresco-access application so I set out to create my o</description>
      <pubDate>Fri, 10 Oct 2014 02:57:31 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/auditing-search-queries/m-p/306502#M259632</guid>
      <dc:creator>florentdelannoy</dc:creator>
      <dc:date>2014-10-10T02:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: Auditing search queries</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/auditing-search-queries/m-p/306503#M259633</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It seems alfresco didn't extract invocation arguments correctly.it has nothing to do with your audit application,even if there is something wrong with&amp;nbsp; your audit application ,Alfresco should still can extract invocation arguments.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm afraid there is something wrong with your alfresco environment.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Oct 2014 08:04:46 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/auditing-search-queries/m-p/306503#M259633</guid>
      <dc:creator>kaynezhang</dc:creator>
      <dc:date>2014-10-11T08:04:46Z</dc:date>
    </item>
    <item>
      <title>Re: Auditing search queries</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/auditing-search-queries/m-p/306504#M259634</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks kaynezhang! Your comment reassured me that I wasn't doing anything wrong, so I continued investigating.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;After debugging down the code through Eclipse, it turns out that the particular query() function being called is the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;public abstract org.alfresco.service.cmr.search.ResultSet org.alfresco.service.cmr.search.SearchService.query(org.alfresco.service.cmr.search.SearchParameters)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The Audit subsystem, in this case the method getInvocationArguments from the AuditMethodInterceptor, tries to record the SearchParameters by calling getRecordableValue, but as it happens the class SearchParameters:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Is not Serializable, so we can't just save it as Serializable&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Does not have a converter to String defined in DefaultTypeConverter, so we can't save it as String&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;After these two options are exhausted, getRecordableValue gives up and tells us that the value is not auditable.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, possible solutions would be…&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- Add a SearchParameters -&amp;gt; String converter, but that would need to be an Alfresco core change. Extending the DefaultConverter is not currently possible (cf. "TODO: Support for dynamically managing conversions" in DefaultTypeConverter.java)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- Make SearchParameters Serializable, but it probably would be more work than needed for this particular issue&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In any case, there's no easy drop-in solution at this point I'm afraid.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Edit: I reported this issue in JIRA as &amp;lt;a href="&lt;/SPAN&gt;&lt;A href="https://issues.alfresco.com/jira/browse/ALF-21135" rel="nofollow noopener noreferrer"&gt;https://issues.alfresco.com/jira/browse/ALF-21135&lt;/A&gt;&lt;SPAN&gt;"&amp;gt;ALF-21135&amp;lt;/a&amp;gt;.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Oct 2014 04:10:02 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/auditing-search-queries/m-p/306504#M259634</guid>
      <dc:creator>florentdelannoy</dc:creator>
      <dc:date>2014-10-15T04:10:02Z</dc:date>
    </item>
  </channel>
</rss>

