From 9ead3bd7712de1416dd095a711a595dd12e5eb44 Mon Sep 17 00:00:00 2001 From: Tom Page Date: Wed, 20 Apr 2016 16:24:44 +0100 Subject: [PATCH] RM-2812 Add audit service and dependencies. Having thought about this more, I don't think there's any problem adding a deprecated class to the public API, as long as it's clearly marked as such. It's deprecated at the moment because we think people might be using it, but we want them to migrate to something else. Declaring this as part of the public API formalises this process. The RecordsManagementAuditService has the following dependencies: RecordsManagementAuditQueryParameters <- RecordsManagementAuditService RecordsManagementAuditEntry <- RecordsManagementAuditService AuditEvent <- RecordsManagementAuditService --- ...cordsManagementAuditServiceDeprecated.java | 2 + .../audit/RecordsManagementAuditEntry.java | 66 ++++++++++--------- ...RecordsManagementAuditQueryParameters.java | 46 ++++++------- .../audit/RecordsManagementAuditService.java | 3 +- .../audit/event/AuditEvent.java | 2 + 5 files changed, 64 insertions(+), 55 deletions(-) diff --git a/rm-community/rm-community-repo/source/compatibility/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceDeprecated.java b/rm-community/rm-community-repo/source/compatibility/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceDeprecated.java index 0e661bfdaa..249a48e301 100644 --- a/rm-community/rm-community-repo/source/compatibility/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceDeprecated.java +++ b/rm-community/rm-community-repo/source/compatibility/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceDeprecated.java @@ -31,6 +31,7 @@ import java.io.Serializable; import java.util.Date; import java.util.Map; +import org.alfresco.api.AlfrescoPublicApi; import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction; import org.alfresco.service.cmr.repository.NodeRef; @@ -41,6 +42,7 @@ import org.alfresco.service.cmr.repository.NodeRef; * @since 2.1 * @deprecated as of 2.1, see {@link RecordsManagementAuditService}. */ +@AlfrescoPublicApi public interface RecordsManagementAuditServiceDeprecated { /** diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditEntry.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditEntry.java index bae5c9b8c2..ffd71af27e 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditEntry.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditEntry.java @@ -32,6 +32,7 @@ import java.util.Date; import java.util.HashMap; import java.util.Map; +import org.alfresco.api.AlfrescoPublicApi; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; import org.alfresco.util.Pair; @@ -40,9 +41,10 @@ import org.springframework.extensions.surf.util.ISO8601DateFormat; /** * Class to represent a Records Management audit entry. - * + * * @author Gavin Cornwell */ +@AlfrescoPublicApi public final class RecordsManagementAuditEntry { private final Date timestamp; @@ -58,20 +60,20 @@ public final class RecordsManagementAuditEntry private final Map beforeProperties; private final Map afterProperties; private Map> changedProperties; - + /** * Default constructor */ - public RecordsManagementAuditEntry(Date timestamp, - String userName, String fullName, String userRole, - NodeRef nodeRef, String nodeName, String nodeType, + public RecordsManagementAuditEntry(Date timestamp, + String userName, String fullName, String userRole, + NodeRef nodeRef, String nodeName, String nodeType, String event, String identifier, String path, Map beforeProperties, Map afterProperties) { ParameterCheck.mandatory("timestamp", timestamp); ParameterCheck.mandatory("userName", userName); - + this.timestamp = timestamp; this.userName = userName; this.userRole = userRole; @@ -85,7 +87,7 @@ public final class RecordsManagementAuditEntry this.beforeProperties = beforeProperties; this.afterProperties = afterProperties; } - + @Override public String toString() { @@ -106,18 +108,18 @@ public final class RecordsManagementAuditEntry .append(")"); return sb.toString(); } - + /** - * + * * @return The date of the audit entry */ public Date getTimestamp() { return this.timestamp; } - + /** - * + * * @return The date of the audit entry as an ISO8601 formatted String */ public String getTimestampString() @@ -126,7 +128,7 @@ public final class RecordsManagementAuditEntry } /** - * + * * @return The username of the user that caused the audit log entry to be created */ public String getUserName() @@ -135,7 +137,7 @@ public final class RecordsManagementAuditEntry } /** - * + * * @return The full name of the user that caused the audit log entry to be created */ public String getFullName() @@ -144,7 +146,7 @@ public final class RecordsManagementAuditEntry } /** - * + * * @return The role of the user that caused the audit log entry to be created */ public String getUserRole() @@ -153,7 +155,7 @@ public final class RecordsManagementAuditEntry } /** - * + * * @return The NodeRef of the node the audit log entry is for */ public NodeRef getNodeRef() @@ -162,16 +164,16 @@ public final class RecordsManagementAuditEntry } /** - * + * * @return The name of the node the audit log entry is for */ public String getNodeName() { return this.nodeName; } - + /** - * + * * @return The type of the node the audit log entry is for */ public String getNodeType() @@ -180,8 +182,8 @@ public final class RecordsManagementAuditEntry } /** - * - * @return The human readable description of the reason for the audit log + * + * @return The human readable description of the reason for the audit log * entry i.e. metadata updated, record declared */ public String getEvent() @@ -191,9 +193,9 @@ public final class RecordsManagementAuditEntry /** * An identifier for the item being audited, for example for a record - * it will be the unique record identifier, for a user it would be the + * it will be the unique record identifier, for a user it would be the * username etc. - * + * * @return Ad identifier for the thing being audited */ public String getIdentifier() @@ -202,25 +204,25 @@ public final class RecordsManagementAuditEntry } /** - * + * * @return The path to the object being audited */ public String getPath() { return this.path; } - + /** - * + * * @return Map of properties before the audited action */ public Map getBeforeProperties() { return this.beforeProperties; } - + /** - * + * * @return Map of properties after the audited action */ public Map getAfterProperties() @@ -229,7 +231,7 @@ public final class RecordsManagementAuditEntry } /** - * + * * @return Map of changed properties */ public Map> getChangedProperties() @@ -238,10 +240,10 @@ public final class RecordsManagementAuditEntry { initChangedProperties(); } - + return this.changedProperties; } - + /** * Initialises the map of changed values given the before and after properties */ @@ -251,7 +253,7 @@ public final class RecordsManagementAuditEntry { this.changedProperties = new HashMap>( this.beforeProperties.size() + this.afterProperties.size()); - + // add all the properties present before the audited action for (QName valuePropName : this.beforeProperties.keySet()) { @@ -260,7 +262,7 @@ public final class RecordsManagementAuditEntry this.afterProperties.get(valuePropName)); this.changedProperties.put(valuePropName, values); } - + // add all the properties present after the audited action that // have not already been added for (QName valuePropName : this.afterProperties.keySet()) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditQueryParameters.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditQueryParameters.java index ed6922248a..f64eae495a 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditQueryParameters.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditQueryParameters.java @@ -29,15 +29,17 @@ package org.alfresco.module.org_alfresco_module_rm.audit; import java.util.Date; +import org.alfresco.api.AlfrescoPublicApi; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; /** - * Class to represent the parameters for a Records Management + * Class to represent the parameters for a Records Management * audit log query. - * + * * @author Gavin Cornwell */ +@AlfrescoPublicApi public final class RecordsManagementAuditQueryParameters { private int maxEntries = -1; @@ -56,7 +58,7 @@ public final class RecordsManagementAuditQueryParameters } /** - * + * * @return The username to filter by */ public String getUser() @@ -67,7 +69,7 @@ public final class RecordsManagementAuditQueryParameters /** * Restricts the retrieved audit trail to entries made by * the provided user. - * + * * @param user The username to filter by */ public void setUser(String user) @@ -76,7 +78,7 @@ public final class RecordsManagementAuditQueryParameters } /** - * + * * @return The maximum number of audit log entries to retrieve */ public int getMaxEntries() @@ -85,9 +87,9 @@ public final class RecordsManagementAuditQueryParameters } /** - * Restricts the retrieved audit trail to the last + * Restricts the retrieved audit trail to the last * maxEntries entries. - * + * * @param maxEntries Maximum number of entries */ public void setMaxEntries(int maxEntries) @@ -96,7 +98,7 @@ public final class RecordsManagementAuditQueryParameters } /** - * + * * @return The node to get entries for */ public NodeRef getNodeRef() @@ -107,7 +109,7 @@ public final class RecordsManagementAuditQueryParameters /** * Restricts the retrieved audit trail to only those entries * created by the give node. - * + * * @param nodeRef The node to get entries for */ public void setNodeRef(NodeRef nodeRef) @@ -116,7 +118,7 @@ public final class RecordsManagementAuditQueryParameters } /** - * + * * @return The date to retrieve entries from */ public Date getDateFrom() @@ -127,7 +129,7 @@ public final class RecordsManagementAuditQueryParameters /** * Restricts the retrieved audit trail to only those entries * that occurred after the given date. - * + * * @param dateFrom Date to retrieve entries after */ public void setDateFrom(Date dateFrom) @@ -136,7 +138,7 @@ public final class RecordsManagementAuditQueryParameters } /** - * + * * @return The date to retrive entries to */ public Date getDateTo() @@ -147,16 +149,16 @@ public final class RecordsManagementAuditQueryParameters /** * Restricts the retrieved audit trail to only those entries * that occurred before the given date. - * + * * @param dateTo Date to retrieve entries before */ public void setDateTo(Date dateTo) { this.dateTo = dateTo; } - + /** - * + * * @return The event to retrive entries for */ public String getEvent() @@ -167,16 +169,16 @@ public final class RecordsManagementAuditQueryParameters /** * Restricts the retrieved audit trail to only those entries * that match the given event string. - * + * * @param event Event to retrieve entries for */ public void setEvent(String event) { this.event = event; } - + /** - * + * * @return The property to retrieve entries for */ public QName getProperty() @@ -187,7 +189,7 @@ public final class RecordsManagementAuditQueryParameters /** * Restricts the audit trail to only those entries that involve * the given property. - * + * * @param property The property to retrieve entries for */ public void setProperty(QName property) @@ -198,17 +200,17 @@ public final class RecordsManagementAuditQueryParameters /* * @see java.lang.Object#toString() */ - @Override + @Override public String toString() { StringBuilder builder = new StringBuilder(super.toString()); - + builder.append(" (nodeRef='").append(nodeRef).append("', user='") .append(user).append("', dateFrom='").append(dateFrom) .append("', dateTo='").append(dateTo).append("', maxEntries='") .append(maxEntries).append("', event='").append(event) .append("', property='").append(property).append("')"); - + return builder.toString(); } } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditService.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditService.java index 00e3e50f23..e324093dcb 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditService.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditService.java @@ -33,6 +33,7 @@ import java.util.Date; import java.util.List; import java.util.Map; +import org.alfresco.api.AlfrescoPublicApi; import org.alfresco.module.org_alfresco_module_rm.audit.event.AuditEvent; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; @@ -42,7 +43,7 @@ import org.alfresco.service.namespace.QName; * * @author Gavin Cornwell */ -// Not @AlfrescoPublicApi as extends the deprecated class RecordsManagementAuditServiceDeprecated. +@AlfrescoPublicApi @SuppressWarnings("deprecation") public interface RecordsManagementAuditService extends RecordsManagementAuditServiceDeprecated { diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/AuditEvent.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/AuditEvent.java index 80323d00cb..93d83b2e12 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/AuditEvent.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/AuditEvent.java @@ -27,6 +27,7 @@ package org.alfresco.module.org_alfresco_module_rm.audit.event; +import org.alfresco.api.AlfrescoPublicApi; import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.util.ParameterCheck; @@ -40,6 +41,7 @@ import org.springframework.extensions.surf.util.I18NUtil; * @author Roy Wetherall * @since 1.0 */ +@AlfrescoPublicApi public class AuditEvent implements RecordsManagementModel, Comparable { /** Name */