From 58b6001c5f07a814a052c2f1ab7debb799ad52c9 Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Fri, 14 Jun 2013 11:38:57 +0000 Subject: [PATCH] DOD Recert: Simple support for event and property filtering on audit git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/DEV/DODRECERT@51108 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- build.gradle | 5 +- .../RecordsManagementAuditServiceImpl.java | 47 +++++++++++++++++-- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index ca38580ce5..aea74c6c88 100644 --- a/build.gradle +++ b/build.gradle @@ -210,7 +210,7 @@ subprojects { copy { from "${configModuleDir}" include "${moduleProperties}" - include "${fileMapping}" + include "${fileMapping}" into assembleDir } @@ -222,7 +222,8 @@ subprojects { copy { from configDir exclude "**/${moduleProperties}" - exclude "**/${fileMapping}" + exclude "**/${fileMapping}" + exclude "**/dev-context.xml" into "${assembleDir}/config" } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java index 117d3b1e29..994ea8dbb0 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java @@ -768,7 +768,7 @@ public class RecordsManagementAuditServiceImpl * @param reportFormat Format to write the audit trail in, ignored if writer is null */ private void getAuditTrailImpl( - RecordsManagementAuditQueryParameters params, + final RecordsManagementAuditQueryParameters params, final List results, final Writer writer, final ReportFormat reportFormat) @@ -811,6 +811,7 @@ public class RecordsManagementAuditServiceImpl return false; } + Date timestamp = new Date(time); String eventName = null; String fullName = null; @@ -872,6 +873,22 @@ public class RecordsManagementAuditServiceImpl return true; } + // filter out events if set + if (params.getEvent() != null && + params.getEvent().endsWith(eventName) == false) + { + // skip it + return true; + } + + + if (params.getProperty() != null && + getChangedProperties(beforeProperties, afterProperties).contains(params.getProperty()) == false) + { + // skip it + return false; + } + // TODO: Refactor this to use the builder pattern RecordsManagementAuditEntry entry = new RecordsManagementAuditEntry( timestamp, @@ -904,6 +921,32 @@ public class RecordsManagementAuditServiceImpl return true; } + private List getChangedProperties(Map beforeProperties, Map afterProperties) + { + List changedProperties = new ArrayList(21); + + if (beforeProperties != null && afterProperties != null) + { + // add all the properties present before the audited action + for (QName valuePropName : beforeProperties.keySet()) + { + changedProperties.add(valuePropName); + } + + // add all the properties present after the audited action that + // have not already been added + for (QName valuePropName : afterProperties.keySet()) + { + if (!beforeProperties.containsKey(valuePropName)) + { + changedProperties.add(valuePropName); + } + } + } + + return changedProperties; + } + private void writeEntryToFile(RecordsManagementAuditEntry entry) { if (writer == null) @@ -947,8 +990,6 @@ public class RecordsManagementAuditServiceImpl Long fromTime = (params.getDateFrom() == null ? null : new Long(params.getDateFrom().getTime())); Long toTime = (params.getDateTo() == null ? null : new Long(params.getDateTo().getTime())); NodeRef nodeRef = params.getNodeRef(); - String eventName = params.getEvent(); - QName propertyQName = params.getProperty(); int maxEntries = params.getMaxEntries(); boolean forward = maxEntries > 0 ? false : true; // Reverse order if the results are limited