mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
audit the cm:person beforeDeleteNode
This commit is contained in:
@@ -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
|
||||
|
@@ -57,6 +57,13 @@
|
||||
<property name="label" value="rm.audit.create-person"/>
|
||||
</bean>
|
||||
|
||||
<bean id="audit-event.delete-person" parent="audit-event"
|
||||
class="org.alfresco.module.org_alfresco_module_rm.audit.event.DeletePersonAuditEvent">
|
||||
<property name="nodeService" ref="nodeService" />
|
||||
<property name="name" value="Delete Person" />
|
||||
<property name="label" value="rm.audit.delete-person" />
|
||||
</bean>
|
||||
|
||||
<bean id="audit-event.login-success" parent="audit-event" class="org.alfresco.module.org_alfresco_module_rm.audit.event.AuditEvent">
|
||||
<property name="name" value="Login.Success"/>
|
||||
<property name="label" value="rm.audit.login-succeeded"/>
|
||||
|
@@ -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)
|
||||
|
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
* #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<QName, Serializable> before = nodeService.getProperties(nodeRef);
|
||||
recordsManagementAuditService.auditEvent(nodeRef, getName(), before, null, true, false);
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user