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 b066c5d93d..9f376f0cf1 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 @@ -7,6 +7,7 @@ rm.audit.create-person=Create User rm.audit.delete-person=Delete User rm.audit.create-userGroup=Create User Group rm.audit.delete-userGroup=Delete User Group +rm.audit.addMember=Add To User Group 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 2a62aa660c..45a804bfd1 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 @@ -78,6 +78,12 @@ + + + + + + diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/AddToUserGroupAuditEvent.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/AddToUserGroupAuditEvent.java new file mode 100644 index 0000000000..d8a0422329 --- /dev/null +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/AddToUserGroupAuditEvent.java @@ -0,0 +1,83 @@ +/* + * #%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 static org.alfresco.repo.policy.Behaviour.NotificationFrequency.EVERY_EVENT; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.model.ContentModel; +import org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy; +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.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.QName; + +/** + * Add an authority to a user group. + * + * @author Tom Page + * @since 2.7 + */ +@BehaviourBean(defaultType = "cm:authorityContainer") +public class AddToUserGroupAuditEvent extends AuditEvent implements OnCreateChildAssociationPolicy +{ + /** Node Service */ + private NodeService nodeService; + + /** + * Sets the node service + * + * @param nodeService nodeService to set + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** Behaviour to audit adding an authority to a user group. */ + @Override + @Behaviour(kind = BehaviourKind.ASSOCIATION, notificationFrequency = EVERY_EVENT, assocType = "cm:member") + public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean isNewNode) + { + Map auditProperties = new HashMap<>(); + auditProperties.put(ContentModel.PROP_AUTHORITY_NAME, + nodeService.getProperty(childAssocRef.getChildRef(), ContentModel.PROP_AUTHORITY_NAME)); + auditProperties.put(ContentModel.PROP_USERNAME, + nodeService.getProperty(childAssocRef.getChildRef(), ContentModel.PROP_USERNAME)); + // (Ab)use link destination property here, as it vaguely sounds like where the authority ends up. + auditProperties.put(ContentModel.PROP_LINK_DESTINATION, + nodeService.getProperty(childAssocRef.getParentRef(), ContentModel.PROP_AUTHORITY_NAME)); + + recordsManagementAuditService.auditEvent(childAssocRef.getChildRef(), getName(), null, auditProperties); + } +} diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/CreateUserGroupAuditEvent.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/CreateUserGroupAuditEvent.java index a80e8aab54..177bf0c75b 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/CreateUserGroupAuditEvent.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/CreateUserGroupAuditEvent.java @@ -61,6 +61,7 @@ public class CreateUserGroupAuditEvent extends AuditEvent implements OnCreateNod this.nodeService = nodeService; } + /** Behaviour to audit user group creation. */ @Override @Behaviour(kind = BehaviourKind.CLASS, type = "cm:authorityContainer") public void onCreateNode(ChildAssociationRef childAssocRef) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/DeleteUserGroupAuditEvent.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/DeleteUserGroupAuditEvent.java index 810aca345d..ce4d2f6bf9 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/DeleteUserGroupAuditEvent.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/DeleteUserGroupAuditEvent.java @@ -63,7 +63,7 @@ public class DeleteUserGroupAuditEvent extends AuditEvent implements BeforeDelet } /** - * Behaviour that will audit user deletion + * Behaviour that will audit user group deletion * * @param nodeRef the node to be deleted */