diff --git a/config/alfresco/extension/audit/alfresco-audit-example-extractors.xml.sample b/config/alfresco/extension/audit/alfresco-audit-example-extractors.xml.sample new file mode 100644 index 0000000000..4b9061e0c1 --- /dev/null +++ b/config/alfresco/extension/audit/alfresco-audit-example-extractors.xml.sample @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/alfresco/extension/audit/alfresco-audit-repository.xml.sample b/config/alfresco/extension/audit/alfresco-audit-example-login.xml.sample similarity index 58% rename from config/alfresco/extension/audit/alfresco-audit-repository.xml.sample rename to config/alfresco/extension/audit/alfresco-audit-example-login.xml.sample index f57a494320..cbbbf386ab 100644 --- a/config/alfresco/extension/audit/alfresco-audit-repository.xml.sample +++ b/config/alfresco/extension/audit/alfresco-audit-example-login.xml.sample @@ -1,6 +1,8 @@ - + - - - + + - + - + - + + + + + + + diff --git a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/audit-common-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/audit-common-SqlMap.xml index 508d5212eb..dce92afeb9 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/audit-common-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/audit-common-SqlMap.xml @@ -166,10 +166,10 @@ - sp_kpl.key_prop_id = #searchKeyId# + sp_pl.key_prop_id = #searchKeyId# - sp_mpl.value_prop_id = #searchValueId# + sp_pl.value_prop_id = #searchValueId# @@ -208,12 +208,9 @@ alf_audit_app app join alf_audit_entry entry on (entry.audit_app_id = app.id) - - join alf_prop_link sp_kpl on (sp_kpl.root_prop_id = entry.audit_values_id) - - - join alf_prop_link sp_mpl on (sp_mpl.root_prop_id = entry.audit_values_id) - + + join alf_prop_link sp_pl on (sp_pl.root_prop_id = entry.audit_values_id) + join alf_prop_link pl on (pl.root_prop_id = entry.audit_values_id) join alf_prop_value pv on (pl.value_prop_id = pv.id) @@ -236,12 +233,9 @@ alf_audit_app app join alf_audit_entry entry on (entry.audit_app_id = app.id) - - join alf_prop_link sp_kpl on (sp_kpl.root_prop_id = entry.audit_values_id) - - - join alf_prop_link sp_mpl on (sp_mpl.root_prop_id = entry.audit_values_id) - + + join alf_prop_link sp_pl on (sp_pl.root_prop_id = entry.audit_values_id) + diff --git a/config/alfresco/repository.properties b/config/alfresco/repository.properties index 7f62e3c732..ea08768ed3 100644 --- a/config/alfresco/repository.properties +++ b/config/alfresco/repository.properties @@ -281,7 +281,6 @@ db.pool.abandoned.log=false # Audit configuration audit.enabled=false -audit.repository.enabled=true audit.cmischangelog.enabled=true # System Configuration diff --git a/source/java/org/alfresco/repo/audit/AuditComponentImpl.java b/source/java/org/alfresco/repo/audit/AuditComponentImpl.java index a42db82028..9a230125f0 100644 --- a/source/java/org/alfresco/repo/audit/AuditComponentImpl.java +++ b/source/java/org/alfresco/repo/audit/AuditComponentImpl.java @@ -448,6 +448,11 @@ public class AuditComponentImpl implements AuditComponent ParameterCheck.mandatory("rootPath", rootPath); AuditApplication.checkPathFormat(rootPath); + if (values == null || values.isEmpty() || !areAuditValuesRequired()) + { + return Collections.emptyMap(); + } + // Log inbound values if (loggerInbound.isDebugEnabled()) { @@ -464,11 +469,6 @@ public class AuditComponentImpl implements AuditComponent loggerInbound.debug(sb.toString()); } - if (values == null || values.isEmpty() || !areAuditValuesRequired()) - { - return Collections.emptyMap(); - } - // Build the key paths using the session root path Map pathedValues = new HashMap(values.size() * 2); for (Map.Entry entry : values.entrySet()) @@ -642,18 +642,46 @@ public class AuditComponentImpl implements AuditComponent { // Persist the values entryId = auditDAO.createAuditEntry(applicationId, time, username, auditData); + // Done + if (logger.isDebugEnabled()) + { + StringBuilder sb = new StringBuilder(); + sb.append( + "\nNew audit entry: \n" + + "\tApplication ID: " + applicationId + "\n" + + "\tEntry ID: " + entryId + "\n" + + "\tValues: " + "\n"); + for (Map.Entry entry : values.entrySet()) + { + sb.append("\t\t").append(entry).append("\n"); + } + sb.append("\n\tAudit Data: \n"); + for (Map.Entry entry : auditData.entrySet()) + { + sb.append("\t\t").append(entry).append("\n"); + } + logger.debug(sb.toString()); + } + } + else + { + // Done ... nothing + if (logger.isDebugEnabled()) + { + StringBuilder sb = new StringBuilder(); + sb.append( + "\nNothing audited: \n" + + "\tApplication ID: " + applicationId + "\n" + + "\tEntry ID: " + entryId + "\n" + + "\tValues: " + "\n"); + for (Map.Entry entry : values.entrySet()) + { + sb.append("\t\t").append(entry).append("\n"); + } + logger.debug(sb.toString()); + } } - // Done - if (logger.isDebugEnabled()) - { - logger.debug( - "New audit entry: \n" + - " Application ID: " + applicationId + "\n" + - " Entry ID: " + entryId + "\n" + - " Values: " + values + "\n" + - " Audit Data: " + auditData); - } return auditData; } @@ -720,10 +748,21 @@ public class AuditComponentImpl implements AuditComponent // Done if (logger.isDebugEnabled()) { - logger.debug("Extracted audit data: \n" + - " Application: " + application + "\n" + - " Raw values: " + values + "\n" + - " Extracted: " + newData); + StringBuilder sb = new StringBuilder(); + sb.append( + "\nExtracted audit data: \n" + + "\tApplication: " + application + "\n" + + "\tValues: " + "\n"); + for (Map.Entry entry : values.entrySet()) + { + sb.append("\t\t").append(entry).append("\n"); + } + sb.append("\n\tNew Data: \n"); + for (Map.Entry entry : newData.entrySet()) + { + sb.append("\t\t").append(entry).append("\n"); + } + logger.debug(sb.toString()); } return newData; } diff --git a/source/java/org/alfresco/repo/audit/AuditServiceImpl.java b/source/java/org/alfresco/repo/audit/AuditServiceImpl.java index 871001d070..09e4128e85 100644 --- a/source/java/org/alfresco/repo/audit/AuditServiceImpl.java +++ b/source/java/org/alfresco/repo/audit/AuditServiceImpl.java @@ -20,6 +20,7 @@ package org.alfresco.repo.audit; import java.util.HashMap; import java.util.Map; +import java.util.TreeMap; import org.alfresco.service.cmr.audit.AuditQueryParameters; import org.alfresco.service.cmr.audit.AuditService; @@ -72,7 +73,7 @@ public class AuditServiceImpl implements AuditService { Map apps = auditComponent.getAuditApplications(); - Map ret = new HashMap(apps.size() * 2); + Map ret = new TreeMap(); for (String app : apps.keySet()) { String name = app; diff --git a/source/java/org/alfresco/repo/audit/model/AuditModelRegistryImpl.java b/source/java/org/alfresco/repo/audit/model/AuditModelRegistryImpl.java index c46d89edfa..9b218af2a3 100644 --- a/source/java/org/alfresco/repo/audit/model/AuditModelRegistryImpl.java +++ b/source/java/org/alfresco/repo/audit/model/AuditModelRegistryImpl.java @@ -27,6 +27,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.TreeMap; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBElement; @@ -355,8 +356,8 @@ public class AuditModelRegistryImpl extends AbstractPropertyBackedBean implement */ public void start() { - auditApplicationsByKey = new HashMap(7); - auditApplicationsByName = new HashMap(7); + auditApplicationsByKey = new TreeMap(); + auditApplicationsByName = new TreeMap(); auditPathMapper = new PathMapper(); // If we are globally disabled, skip processing the models diff --git a/source/java/org/alfresco/repo/domain/audit/AuditQueryParameters.java b/source/java/org/alfresco/repo/domain/audit/AuditQueryParameters.java index 7fa67360dc..9e145a2626 100644 --- a/source/java/org/alfresco/repo/domain/audit/AuditQueryParameters.java +++ b/source/java/org/alfresco/repo/domain/audit/AuditQueryParameters.java @@ -154,4 +154,12 @@ public class AuditQueryParameters { this.searchValueId = searchValueId; } + + /** + * @return Returns true if this object includes a key- or value-based search + */ + public boolean isKeyOrValueSearch() + { + return searchKeyId != null || searchValueId != null; + } }