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
This commit is contained in:
Tom Page
2016-04-20 16:24:44 +01:00
parent 9c0b13133b
commit 9ead3bd771
5 changed files with 64 additions and 55 deletions

View File

@@ -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<QName, Serializable> beforeProperties;
private final Map<QName, Serializable> afterProperties;
private Map<QName, Pair<Serializable, Serializable>> 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<QName, Serializable> beforeProperties,
Map<QName, Serializable> 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<QName, Serializable> getBeforeProperties()
{
return this.beforeProperties;
}
/**
*
*
* @return Map of properties after the audited action
*/
public Map<QName, Serializable> getAfterProperties()
@@ -229,7 +231,7 @@ public final class RecordsManagementAuditEntry
}
/**
*
*
* @return Map of changed properties
*/
public Map<QName, Pair<Serializable, Serializable>> 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<QName, Pair<Serializable, Serializable>>(
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())

View File

@@ -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
* <code>maxEntries</code> 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();
}
}

View File

@@ -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
{

View File

@@ -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<AuditEvent>
{
/** Name */