diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/audit-service.properties b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/audit-service.properties index 7e55d72cc7..5f8a331f0a 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/audit-service.properties +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/audit-service.properties @@ -4,6 +4,7 @@ rm.audit.delete-object=Delete Object rm.audit.login-succeeded=Login Successful rm.audit.login-failed=Login Unsuccessful rm.audit.create-person=Create User +rm.audit.delete-person=Delete User rm.audit.linkTo=Link to rm.audit.moveTo=Move to rm.audit.copyTo=Copy to diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-audit-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-audit-context.xml index 61c53f3c6b..1a1b993d1a 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-audit-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-audit-context.xml @@ -57,6 +57,13 @@ + + + + + + diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java index 6d327e4b1b..ad9a301521 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java @@ -1494,6 +1494,7 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean { try { + logger.info("AUDIT ENTRY" + entry.toString()); JSONObject json = new JSONObject(); json.put("timestamp", entry.getTimestampString()); @@ -1514,6 +1515,17 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean json.put("nodeName", userName == null ? "": userName); json.put("createPerson", true); } + else if(entry.getEvent().equals("Delete Person") && entry.getNodeRef() != null) + { + entry.getBeforeProperties().get(ContentModel.PROP_USERNAME); + String userName = null; + if (entry.getBeforeProperties()!= null) + { + userName = (String) entry.getBeforeProperties().get(ContentModel.PROP_USERNAME);; + } + json.put("nodeName", userName == null ? "" : userName); + json.put("deletePerson", true); + } else { json.put("nodeName", entry.getNodeName() == null ? "": entry.getNodeName()); @@ -1567,7 +1579,7 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean } json.put("changedValues", changedValues); - + logger.info("Json valuse " + json.toString()); writer.write(json.toString()); } catch (JSONException je) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/DeletePersonAuditEvent.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/DeletePersonAuditEvent.java new file mode 100644 index 0000000000..f50261fe58 --- /dev/null +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/DeletePersonAuditEvent.java @@ -0,0 +1,77 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2018 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * - + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * - + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * - + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * - + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.module.org_alfresco_module_rm.audit.event; + +import java.io.Serializable; +import java.util.Map; + +import org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy; +import org.alfresco.repo.policy.annotation.Behaviour; +import org.alfresco.repo.policy.annotation.BehaviourBean; +import org.alfresco.repo.policy.annotation.BehaviourKind; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.QName; + +/** + * Audits person deletion. + * + * @author Rodica Sutu + * @since 2.7 + */ +@BehaviourBean +public class DeletePersonAuditEvent extends AuditEvent implements BeforeDeleteNodePolicy +{ + + private NodeService nodeService; + + /** + * @param nodeService + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + /** + * @see org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy#(org.alfresco.service.cmr.repository.ChildAssociationRef) + */ + + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + type = "cm:person" + ) + public void beforeDeleteNode(NodeRef nodeRef) + { + //audit the property values before the delete event + Map before = nodeService.getProperties(nodeRef); + recordsManagementAuditService.auditEvent(nodeRef, getName(), before, null, true, false); + } + + +}