From eaacdeb2ed00f35acdf429b84476e21e9e0c7aa4 Mon Sep 17 00:00:00 2001 From: Derek Hulley Date: Fri, 11 Dec 2009 12:23:19 +0000 Subject: [PATCH] Example of how to get last audit entry ID for a given app name git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@17773 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../repo/audit/AuditComponentTest.java | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/source/java/org/alfresco/repo/audit/AuditComponentTest.java b/source/java/org/alfresco/repo/audit/AuditComponentTest.java index 0006a4ddf9..7c74dc6b61 100644 --- a/source/java/org/alfresco/repo/audit/AuditComponentTest.java +++ b/source/java/org/alfresco/repo/audit/AuditComponentTest.java @@ -491,7 +491,7 @@ public class AuditComponentTest extends TestCase if (logger.isDebugEnabled()) { logger.debug( - "Audit Entry: " + applicationName + ", " + user + ", " + new Date(time) + "\n" + + "Audit Entry " + entryId + ": " + applicationName + ", " + user + ", " + new Date(time) + "\n" + " Data: " + values); } sb.append("Row: ") @@ -569,4 +569,37 @@ public class AuditComponentTest extends TestCase logger.debug(sb.toString()); assertFalse("Did not get any audit results after failed login", results.isEmpty()); } + + public void testAuditQuery_MaxId() throws Exception + { + AuditQueryCallback auditQueryCallback = new AuditQueryCallback() + { + public boolean handleAuditEntry( + Long entryId, + String applicationName, + String user, + long time, + Map values) + { + if (logger.isDebugEnabled()) + { + logger.debug( + "Audit Entry " + entryId + ": " + applicationName + ", " + user + ", " + new Date(time) + "\n" + + " Data: " + values); + } + return true; + } + + public boolean handleAuditEntryError(Long entryId, String errorMsg, Throwable error) + { + throw new AlfrescoRuntimeException(errorMsg, error); + } + }; + + AuditQueryParameters params = new AuditQueryParameters(); + params.setApplicationName(APPLICATION_API_TEST); + params.setForward(false); + params.setToId(Long.MAX_VALUE); + auditService.auditQuery(auditQueryCallback, params, 1); + } }