diff --git a/config/alfresco/audit/alfresco-audit-repository.xml b/config/alfresco/audit/alfresco-audit-repository.xml index 0037f565bf..f06ea65370 100644 --- a/config/alfresco/audit/alfresco-audit-repository.xml +++ b/config/alfresco/audit/alfresco-audit-repository.xml @@ -9,43 +9,33 @@ > - - + + - + - + - - - - - - - - - - - - - - - + + + + + + + + + diff --git a/source/java/org/alfresco/repo/audit/AuditComponent.java b/source/java/org/alfresco/repo/audit/AuditComponent.java index 121cfb145d..164fa37f08 100644 --- a/source/java/org/alfresco/repo/audit/AuditComponent.java +++ b/source/java/org/alfresco/repo/audit/AuditComponent.java @@ -20,7 +20,6 @@ package org.alfresco.repo.audit; import java.io.Serializable; import java.util.Map; -import java.util.Set; import org.alfresco.repo.audit.model.AuditApplication; import org.alfresco.repo.audit.model.AuditModelRegistry; @@ -56,11 +55,11 @@ public interface AuditComponent /** * Get all registered audit applications, whether active or not. * - * @return Returns a set of registered audit applications + * @return Returns a map of registered audit applications keyed by name * * @since 3.4 */ - public Set getAuditApplications(); + public Map getAuditApplications(); /** * Determines whether the given source path is mapped to any audit applications. Allows optimizations to be made in diff --git a/source/java/org/alfresco/repo/audit/AuditComponentImpl.java b/source/java/org/alfresco/repo/audit/AuditComponentImpl.java index 5e1e643cde..64a570339c 100644 --- a/source/java/org/alfresco/repo/audit/AuditComponentImpl.java +++ b/source/java/org/alfresco/repo/audit/AuditComponentImpl.java @@ -48,7 +48,8 @@ import org.apache.commons.logging.LogFactory; import org.springframework.extensions.surf.util.ParameterCheck; /** - * The default audit component implementation. TODO: Implement before, after and exception filtering. At the moment + * The default audit component implementation. + * * The V3.2 audit functionality is contained within the same component. When the newer audit @@ -190,10 +191,9 @@ public class AuditComponentImpl implements AuditComponent * {@inheritDoc} * @since 3.4 */ - public Set getAuditApplications() + public Map getAuditApplications() { - Map auditApps = auditModelRegistry.getAuditApplications(); - return auditApps.keySet(); + return auditModelRegistry.getAuditApplications(); } /** diff --git a/source/java/org/alfresco/repo/audit/AuditServiceImpl.java b/source/java/org/alfresco/repo/audit/AuditServiceImpl.java index f15f10fdbf..5f4d07d949 100644 --- a/source/java/org/alfresco/repo/audit/AuditServiceImpl.java +++ b/source/java/org/alfresco/repo/audit/AuditServiceImpl.java @@ -18,7 +18,8 @@ */ package org.alfresco.repo.audit; -import java.util.Set; +import java.util.HashMap; +import java.util.Map; import org.alfresco.service.cmr.audit.AuditQueryParameters; import org.alfresco.service.cmr.audit.AuditService; @@ -67,9 +68,20 @@ public class AuditServiceImpl implements AuditService * @since 3.4 */ @Override - public Set getAuditApplications() + public Map getAuditApplications() { - return auditComponent.getAuditApplications(); + Map apps = auditComponent.getAuditApplications(); + + Map ret = new HashMap(apps.size() * 2); + for (String app : apps.keySet()) + { + String name = app; + String key = org.alfresco.repo.audit.model.AuditApplication.AUDIT_PATH_SEPARATOR + apps.get(app).getApplicationKey(); + boolean enabled = auditComponent.isAuditPathEnabled(app, key); + AuditApplication auditApplication = new AuditApplication(name, key, enabled); + ret.put(name, auditApplication); + } + return ret; } /** diff --git a/source/java/org/alfresco/repo/audit/model/AuditApplication.java b/source/java/org/alfresco/repo/audit/model/AuditApplication.java index d030565fc4..3c24795622 100644 --- a/source/java/org/alfresco/repo/audit/model/AuditApplication.java +++ b/source/java/org/alfresco/repo/audit/model/AuditApplication.java @@ -199,11 +199,12 @@ public class AuditApplication { if (path == null || path.length() == 0) { - throw new AuditModelException("Empty or null audit path"); + throw new AuditModelException("Empty or null audit path: " + path); } else if (!path.matches(AUDIT_PATH_REGEX)) { - throw new AuditModelException("An audit must match regular expression: " + AUDIT_PATH_REGEX); + throw new AuditModelException( + "Audit path '" + path + "' does not match regular expression: " + AUDIT_PATH_REGEX); } } diff --git a/source/java/org/alfresco/repo/node/NodeAuditor.java b/source/java/org/alfresco/repo/node/NodeAuditor.java index 3457d46691..7ac10fef92 100644 --- a/source/java/org/alfresco/repo/node/NodeAuditor.java +++ b/source/java/org/alfresco/repo/node/NodeAuditor.java @@ -37,6 +37,14 @@ import org.alfresco.util.PropertyCheck; * A listener that ensures that an event is audited for every deleted node in a tree of nodes, not just the top one * captured by {@link AuditMethodInterceptor}! * + * The values passed to the audit component are: + *
+ * /alfresco-node
+ *    /beforeDeleteNode
+ *       /node=<nodeRef>
+ * 
+ * 
+ * * @author dward */ public class NodeAuditor implements InitializingBean, NodeServicePolicies.BeforeDeleteNodePolicy diff --git a/source/java/org/alfresco/service/cmr/audit/AuditService.java b/source/java/org/alfresco/service/cmr/audit/AuditService.java index 9f0f2d7abc..ea4c830898 100644 --- a/source/java/org/alfresco/service/cmr/audit/AuditService.java +++ b/source/java/org/alfresco/service/cmr/audit/AuditService.java @@ -20,7 +20,6 @@ package org.alfresco.service.cmr.audit; import java.io.Serializable; import java.util.Map; -import java.util.Set; import org.alfresco.service.PublicService; @@ -47,15 +46,49 @@ public interface AuditService * @since 3.4 */ void setAuditEnabled(boolean enable); + + /** + * Helper bean to carry information about an audit application. + * + * @author Derek Hulley + * @since 3.4 + */ + public static class AuditApplication + { + private final String name; + private final String key; + private final boolean enabled; + /** + * Constructor for final variables + */ + public AuditApplication(String name, String key, boolean enabled) + { + this.name = name; + this.key = key; + this.enabled = enabled; + } + public String getName() + { + return name; + } + public String getKey() + { + return key; + } + public boolean isEnabled() + { + return enabled; + } + } /** * Get all registered audit applications * - * @return Returns a set of all available audit applications + * @return Returns a map of audit applications keyed by their name * * @since 3.4 */ - Set getAuditApplications(); + Map getAuditApplications(); /** * @param applicationName the name of the application to check