mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
review changes
This commit is contained in:
@@ -59,7 +59,6 @@
|
||||
|
||||
<bean id="audit-event.delete-person" parent="audit-event"
|
||||
class="org.alfresco.module.org_alfresco_module_rm.audit.event.DeletePersonAuditEvent">
|
||||
<property name="dictionaryService" ref="dictionaryService" />
|
||||
<property name="nodeService" ref="nodeService" />
|
||||
<property name="name" value="Delete Person" />
|
||||
<property name="label" value="rm.audit.delete-person" />
|
||||
|
@@ -1516,12 +1516,11 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
|
||||
}
|
||||
else if (entry.getEvent().equals("Delete Person") && entry.getNodeRef() != null)
|
||||
{
|
||||
String userName = null;
|
||||
if (entry.getBeforeProperties() != null)
|
||||
{
|
||||
userName = (String) entry.getBeforeProperties().get(ContentModel.PROP_USERNAME);
|
||||
}
|
||||
String userName = (String) entry.getBeforeProperties().get(ContentModel.PROP_USERNAME);
|
||||
json.put("nodeName", userName == null ? "" : userName);
|
||||
}
|
||||
json.put("deletePerson", true);
|
||||
}
|
||||
else
|
||||
|
@@ -29,14 +29,12 @@ package org.alfresco.module.org_alfresco_module_rm.audit.event;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
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.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
@@ -50,25 +48,24 @@ import org.alfresco.service.namespace.QName;
|
||||
@BehaviourBean
|
||||
public class DeletePersonAuditEvent extends AuditEvent implements BeforeDeleteNodePolicy
|
||||
{
|
||||
|
||||
/** Node Service*/
|
||||
private NodeService nodeService;
|
||||
|
||||
private DictionaryService dictionaryService;
|
||||
|
||||
/**
|
||||
* Sets the node service
|
||||
*
|
||||
* @param nodeService nodeService to set
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy#(org.alfresco.service.cmr.repository.ChildAssociationRef)
|
||||
* Behaviour that will audit cm:person type when the user is deletedF
|
||||
* @param nodeRef the node to be deleted
|
||||
*
|
||||
*/
|
||||
|
||||
@Override
|
||||
@Behaviour
|
||||
(
|
||||
@@ -77,21 +74,12 @@ public class DeletePersonAuditEvent extends AuditEvent implements BeforeDeleteNo
|
||||
)
|
||||
public void beforeDeleteNode(NodeRef nodeRef)
|
||||
{
|
||||
//get the cm:person properties
|
||||
Set<QName> properties = dictionaryService.getPropertyDefs(ContentModel.TYPE_PERSON).keySet();
|
||||
//retrive the properties and the values
|
||||
Map<QName, Serializable> result = new HashMap<>();
|
||||
for (QName property : properties)
|
||||
{
|
||||
Serializable values = nodeService.getProperty(nodeRef, property);
|
||||
if (values != null)
|
||||
{
|
||||
result.put(property, values);
|
||||
}
|
||||
}
|
||||
//retrieve the username property to be audited
|
||||
Map<QName, Serializable> userName = new HashMap<>();
|
||||
userName.put(ContentModel.PROP_USERNAME, nodeService.getProperty(nodeRef, ContentModel.PROP_USERNAME));
|
||||
|
||||
//audit the property values before the delete event
|
||||
recordsManagementAuditService.auditEvent(nodeRef, getName(), result, null, true, false);
|
||||
recordsManagementAuditService.auditEvent(nodeRef, getName(), userName, null, true, false);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -465,7 +465,7 @@ public class RecordsManagementAuditServiceImplTest extends BaseRMTestCase
|
||||
* Given I have deleted a user
|
||||
* When I will get the RM audit filter by delete user event
|
||||
* Then there will be an entry for the deleted user
|
||||
* And the audit entry has the properties specific to cm:person type audited
|
||||
* And the audit entry has the username property value audited
|
||||
* @throws Exception
|
||||
*/
|
||||
@org.junit.Test
|
||||
@@ -476,7 +476,6 @@ public class RecordsManagementAuditServiceImplTest extends BaseRMTestCase
|
||||
final static String DELETE_USER_AUDIT_EVENT = "Delete Person";
|
||||
String userName = "auditDeleteUser";
|
||||
NodeRef user;
|
||||
long nrOfPropertiesAudited;
|
||||
List<RecordsManagementAuditEntry> entry;
|
||||
|
||||
@Override
|
||||
@@ -484,10 +483,6 @@ public class RecordsManagementAuditServiceImplTest extends BaseRMTestCase
|
||||
{
|
||||
// create a user
|
||||
user = createPerson(userName);
|
||||
// count the cm:person properties with non null values
|
||||
nrOfPropertiesAudited = dictionaryService.getPropertyDefs(ContentModel.TYPE_PERSON).keySet()
|
||||
.stream().filter(prop -> nodeService.getProperty(user, prop) != null)
|
||||
.count();
|
||||
personService.deletePerson(userName);
|
||||
}
|
||||
|
||||
@@ -500,7 +495,6 @@ public class RecordsManagementAuditServiceImplTest extends BaseRMTestCase
|
||||
|
||||
// get the audit events for "Delete Person"
|
||||
entry = getAuditTrail(params, 1, ADMIN_USER);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -509,7 +503,7 @@ public class RecordsManagementAuditServiceImplTest extends BaseRMTestCase
|
||||
assertEquals("Delete user event is not audited.", DELETE_USER_AUDIT_EVENT, entry.get(0).getEvent());
|
||||
assertEquals(user.getId(), entry.get(0).getNodeName());
|
||||
assertEquals("Unexpected nr of properties audited for cm:person type when deleting a user.",
|
||||
nrOfPropertiesAudited, entry.get(0).getBeforeProperties().size());
|
||||
1, entry.get(0).getBeforeProperties().size());
|
||||
assertEquals("Wrong value for username property is audited",
|
||||
userName, entry.get(0).getBeforeProperties().get(ContentModel.PROP_USERNAME));
|
||||
}
|
||||
|
Reference in New Issue
Block a user