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 bc590d3df8..117d3b1e29 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 @@ -326,6 +326,10 @@ public class RecordsManagementAuditServiceImpl new AuditEvent("createDispositionSchedule", MSG_CREATE_DISPOSITION_SCHEDULE)); this.auditEvents.put("unfreeze", new AuditEvent("unfreeze", MSG_UNFREEZE)); + + // Added for DOD compliance + this.auditEvents.put("createPerson", + new AuditEvent("createPerson", "User Created")); } @Override @@ -345,7 +349,11 @@ public class RecordsManagementAuditServiceImpl policyComponent.bindClassBehaviour( BeforeDeleteNodePolicy.QNAME, RecordsManagementModel.ASPECT_RECORD_COMPONENT_ID, - new JavaBehaviour(this, "beforeDeleteNode")); + new JavaBehaviour(this, "beforeDeleteNode")); + policyComponent.bindClassBehaviour( + OnCreateNodePolicy.QNAME, + ContentModel.TYPE_PERSON, + new JavaBehaviour(this, "onCreatePersonNode")); } @Override @@ -477,7 +485,12 @@ public class RecordsManagementAuditServiceImpl { auditRMEvent(childAssocRef.getChildRef(), RM_AUDIT_EVENT_CREATE_RM_OBJECT, null, null); } - + + public void onCreatePersonNode(ChildAssociationRef childAssocRef) + { + auditRMEvent(childAssocRef.getChildRef(), "createPerson", null, null); + } + /** * {@inheritDoc} * @since 3.2 @@ -509,19 +522,9 @@ public class RecordsManagementAuditServiceImpl { // Deleted nodes will not be available at the end of the transaction. The data needs to // be extracted now and the audit entry needs to be created now. - Map auditMap = new HashMap(13); - auditMap.put( - AuditApplication.buildPath( - RecordsManagementAuditService.RM_AUDIT_SNIPPET_EVENT, - RecordsManagementAuditService.RM_AUDIT_SNIPPET_NAME), - eventName); - // Action node - auditMap.put( - AuditApplication.buildPath( - RecordsManagementAuditService.RM_AUDIT_SNIPPET_EVENT, - RecordsManagementAuditService.RM_AUDIT_SNIPPET_NODE), - nodeRef); + Map auditMap = buildAuditMap(nodeRef, eventName); auditMap = auditComponent.recordAuditValues(RecordsManagementAuditService.RM_AUDIT_PATH_ROOT, auditMap); + if (logger.isDebugEnabled()) { logger.debug("RM Audit: Audited node deletion: \n" + auditMap); @@ -559,6 +562,31 @@ public class RecordsManagementAuditServiceImpl // That is it. The values are queued for the end of the transaction. } } + + /** + * Helper method to build audit map + * + * @param nodeRef + * @param eventName + * @return + * @since 2.0.3 + */ + private Map buildAuditMap(NodeRef nodeRef, String eventName) + { + Map auditMap = new HashMap(13); + auditMap.put( + AuditApplication.buildPath( + RecordsManagementAuditService.RM_AUDIT_SNIPPET_EVENT, + RecordsManagementAuditService.RM_AUDIT_SNIPPET_NAME), + eventName); + // Action node + auditMap.put( + AuditApplication.buildPath( + RecordsManagementAuditService.RM_AUDIT_SNIPPET_EVENT, + RecordsManagementAuditService.RM_AUDIT_SNIPPET_NODE), + nodeRef); + return auditMap; + } /** * A stateless transaction listener for RM auditing. This component picks up the data of @@ -619,20 +647,13 @@ public class RecordsManagementAuditServiceImpl RMAuditNode auditedNode = entry.getValue(); - Map auditMap = new HashMap(13); // Action description String eventName = auditedNode.getEventName(); - auditMap.put( - AuditApplication.buildPath( - RecordsManagementAuditService.RM_AUDIT_SNIPPET_EVENT, - RecordsManagementAuditService.RM_AUDIT_SNIPPET_NAME), - eventName); - // Action node - auditMap.put( - AuditApplication.buildPath( - RecordsManagementAuditService.RM_AUDIT_SNIPPET_EVENT, - RecordsManagementAuditService.RM_AUDIT_SNIPPET_NODE), - nodeRef); + + Map auditMap = buildAuditMap(nodeRef, eventName); + + // TODO do we care if the before and after are null?? + // Property changes Map propertiesBefore = auditedNode.getNodePropertiesBefore(); Map propertiesAfter = auditedNode.getNodePropertiesAfter(); @@ -652,6 +673,7 @@ public class RecordsManagementAuditServiceImpl RecordsManagementAuditService.RM_AUDIT_SNIPPET_CHANGES, RecordsManagementAuditService.RM_AUDIT_SNIPPET_AFTER), (Serializable) deltaPair.getSecond()); + // Audit it if (logger.isDebugEnabled()) { @@ -1224,7 +1246,18 @@ public class RecordsManagementAuditServiceImpl json.put("userRole", entry.getUserRole() == null ? "": entry.getUserRole()); json.put("fullName", entry.getFullName() == null ? "": entry.getFullName()); json.put("nodeRef", entry.getNodeRef() == null ? "": entry.getNodeRef()); - json.put("nodeName", entry.getNodeName() == null ? "": entry.getNodeName()); + + if (entry.getEvent().equals("createPerson") == true && entry.getNodeRef() != null) + { + NodeRef nodeRef = entry.getNodeRef(); + String userName = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_USERNAME); + json.put("nodeName", userName == null ? "": userName); + } + else + { + json.put("nodeName", entry.getNodeName() == null ? "": entry.getNodeName()); + } + json.put("nodeType", entry.getNodeType() == null ? "": entry.getNodeType()); json.put("event", entry.getEvent() == null ? "": getAuditEventLabel(entry.getEvent())); json.put("identifier", entry.getIdentifier() == null ? "": entry.getIdentifier());