RM-853: File Record audit event is absent

* file, move, copy and link are all now present in the event drop down
  * they are all audited as separate events



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@54738 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2013-09-02 05:38:26 +00:00
parent fb7b363eb1
commit fb07d9e266
11 changed files with 405 additions and 99 deletions

View File

@@ -10,8 +10,8 @@ alfrescoEnterpriseMavenUrl=https://artifacts.alfresco.com/nexus/content/groups/i
# set credentials for protected maven repo or pass on command line:
# -PalfrescoEnterpriseMavenUser=userName -PalfrescoEnterpriseMavenPwd=password
alfrescoEnterpriseMavenUser=
alfrescoEnterpriseMavenPwd=
alfrescoEnterpriseMavenUser=rwetherall
alfrescoEnterpriseMavenPwd=m1ch3113
# set to org.alfresco.enterprise when enterprise version required
alfrescoGroupId=org.alfresco

View File

@@ -4,3 +4,7 @@ rm.audit.delte-object=Delete Object
rm.audit.login-succeeded=Login Succeeded
rm.audit.login-failed=Login Failed
rm.audit.create-person=Create Person
rm.audit.link=Link
rm.audit.move=Move
rm.audit.copy=Copy
rm.audit.file=File

View File

@@ -66,4 +66,24 @@
<property name="label" value="rm.audit.login-failed"/>
</bean>
<bean id="audit-event.link" parent="audit-event" class="org.alfresco.module.org_alfresco_module_rm.audit.event.LinkAuditEvent">
<property name="name" value="link"/>
<property name="label" value="rm.audit.link"/>
</bean>
<bean id="audit-event.move" parent="audit-event" class="org.alfresco.module.org_alfresco_module_rm.audit.event.MoveAuditEvent">
<property name="name" value="move"/>
<property name="label" value="rm.audit.move"/>
</bean>
<bean id="audit-event.copy" parent="audit-event" class="org.alfresco.module.org_alfresco_module_rm.audit.event.CopyAuditEvent">
<property name="name" value="copy"/>
<property name="label" value="rm.audit.copy"/>
</bean>
<bean id="audit-event.file" parent="audit-event" class="org.alfresco.module.org_alfresco_module_rm.audit.event.FileAuditEvent">
<property name="name" value="file"/>
<property name="label" value="rm.audit.file"/>
</bean>
</beans>

View File

@@ -73,7 +73,10 @@ public interface RecordsManagementAuditService extends RecordsManagementAuditSer
List<AuditEvent> getAuditEvents();
/**
* Register audit event
* Register audit event.
* <p>
* Creates an instance of a simple audit event and registers it with
* the service.
*
* @param name name of audit event
* @param label display label of audit event
@@ -81,25 +84,29 @@ public interface RecordsManagementAuditService extends RecordsManagementAuditSer
void registerAuditEvent(String name, String label);
/**
* Register audit event.
*
* @param auditEvent
* @param auditEvent audit event
*/
void registerAuditEvent(AuditEvent auditEvent);
/**
* Audits an event, assumes no properties where modified and that the event should not be audited
* immediately.
*
* @param nodeRef
* @param eventName
* @param nodeRef node reference
* @param eventName event name
*/
void auditEvent(NodeRef nodeRef,
String eventName);
/**
* Audits an event, assumes that the event should not be audited immediately.
*
* @param nodeRef
* @param eventName
* @param before
* @param after
* @param nodeRef node reference
* @param eventName event name
* @param before property values before event
* @param after property values after event
*/
void auditEvent(NodeRef nodeRef,
String eventName,
@@ -107,12 +114,13 @@ public interface RecordsManagementAuditService extends RecordsManagementAuditSer
Map<QName, Serializable> after);
/**
* Audit event.
*
* @param nodeRef
* @param eventName
* @param before
* @param after
* @param immediate
* @param nodeRef node reference
* @param eventName event name
* @param before property values before event
* @param after property values after event
* @param immediate true if event is to be audited immediately, false otherwise
*/
void auditEvent(NodeRef nodeRef,
String eventName,

View File

@@ -200,12 +200,18 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
this.filePlanService = filePlanService;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService#registerAuditEvent(java.lang.String, java.lang.String)
*/
@Override
public void registerAuditEvent(String name, String label)
{
registerAuditEvent(new AuditEvent(name, label));
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService#registerAuditEvent(org.alfresco.module.org_alfresco_module_rm.audit.event.AuditEvent)
*/
@Override
public void registerAuditEvent(AuditEvent auditEvent)
{
@@ -234,43 +240,24 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
PropertyCheck.mandatory(this, "filePlanService", filePlanService);
}
/**
* @see org.springframework.extensions.surf.util.AbstractLifecycleBean#onBootstrap(org.springframework.context.ApplicationEvent)
*/
@Override
protected void onBootstrap(ApplicationEvent event)
{
shutdown = false;
}
/**
* @see org.springframework.extensions.surf.util.AbstractLifecycleBean#onShutdown(org.springframework.context.ApplicationEvent)
*/
@Override
protected void onShutdown(ApplicationEvent event)
{
shutdown = true;
}
/**
* Helper method to get the default file plan
*
* @return NodRef default file plan
*/
private NodeRef getDefaultFilePlan()
{
NodeRef defaultFilePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
if (defaultFilePlan == null)
{
throw new AlfrescoRuntimeException("Default file plan could not be found.");
}
return defaultFilePlan;
}
/**
* {@inheritDoc}
*/
@Override
@Deprecated
public boolean isEnabled()
{
return isAuditLogEnabled(getDefaultFilePlan());
}
/**
* {@inheritDoc}
*/
@@ -284,15 +271,6 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
RecordsManagementAuditService.RM_AUDIT_PATH_ROOT);
}
/**
* {@inheritDoc}
*/
@Deprecated
public void start()
{
startAuditLog(getDefaultFilePlan());
}
/**
* {@inheritDoc}
*/
@@ -311,15 +289,6 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
}
}
/**
* {@inheritDoc}
*/
@Deprecated
public void stop()
{
stopAuditLog(getDefaultFilePlan());
}
/**
* {@inheritDoc}
*/
@@ -335,15 +304,6 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
logger.info("Stopped Records Management auditing");
}
/**
* {@inheritDoc}
*/
@Deprecated
public void clear()
{
clearAuditLog(getDefaultFilePlan());
}
/**
* {@inheritDoc}
*/
@@ -357,15 +317,6 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
logger.debug("Records Management audit log has been cleared");
}
/**
* {@inheritDoc}
*/
@Deprecated
public Date getDateLastStarted()
{
return getDateAuditLogLastStarted(getDefaultFilePlan());
}
/**
* {@inheritDoc}
*/
@@ -378,15 +329,6 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
return getStartOfDay(new Date());
}
/**
* {@inheritDoc}
*/
@Deprecated
public Date getDateLastStopped()
{
return getDateAuditLogLastStopped(getDefaultFilePlan());
}
/**
* {@inheritDoc}
*/
@@ -444,16 +386,11 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
/**
* {@inheritDoc}
* @since 3.2
* @deprecated since 2.1
*/
@Deprecated
public void auditRMAction(
RecordsManagementAction action,
NodeRef nodeRef,
Map<String, Serializable> parameters)
public void clear()
{
auditEvent(nodeRef, action.getName());
clearAuditLog(getDefaultFilePlan());
}
@Override
@@ -1445,4 +1382,81 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
return label;
}
/** Deprecated Method Implementations **/
/**
* Helper method to get the default file plan
*
* @return NodRef default file plan
*/
private NodeRef getDefaultFilePlan()
{
NodeRef defaultFilePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
if (defaultFilePlan == null)
{
throw new AlfrescoRuntimeException("Default file plan could not be found.");
}
return defaultFilePlan;
}
/**
* {@inheritDoc}
*/
@Override
@Deprecated
public boolean isEnabled()
{
return isAuditLogEnabled(getDefaultFilePlan());
}
/**
* {@inheritDoc}
*/
@Deprecated
public void start()
{
startAuditLog(getDefaultFilePlan());
}
/**
* {@inheritDoc}
*/
@Deprecated
public void stop()
{
stopAuditLog(getDefaultFilePlan());
}
/**
* {@inheritDoc}
*/
@Deprecated
public Date getDateLastStarted()
{
return getDateAuditLogLastStarted(getDefaultFilePlan());
}
/**
* {@inheritDoc}
*/
@Deprecated
public Date getDateLastStopped()
{
return getDateAuditLogLastStopped(getDefaultFilePlan());
}
/**
* {@inheritDoc}
* @since 3.2
* @deprecated since 2.1
*/
@Deprecated
public void auditRMAction(
RecordsManagementAction action,
NodeRef nodeRef,
Map<String, Serializable> parameters)
{
auditEvent(nodeRef, action.getName());
}
}

View File

@@ -19,6 +19,7 @@
package org.alfresco.module.org_alfresco_module_rm.audit.event;
import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.repo.policy.PolicyComponent;
import org.springframework.extensions.surf.util.I18NUtil;
@@ -29,7 +30,7 @@ import org.springframework.extensions.surf.util.I18NUtil;
* @author Gavin Cornwell
* @author Roy Wetherall
*/
public class AuditEvent
public class AuditEvent implements RecordsManagementModel
{
/** Name */
protected String name;
@@ -37,29 +38,49 @@ public class AuditEvent
/** Label */
protected String label;
/** Records management audit service */
protected RecordsManagementAuditService recordsManagementAuditService;
/** Policy component */
protected PolicyComponent policyComponent;
/**
* @param recordsManagementAuditService records management audit service
*/
public void setRecordsManagementAuditService(RecordsManagementAuditService recordsManagementAuditService)
{
this.recordsManagementAuditService = recordsManagementAuditService;
}
/**
* @param policyComponent policy component
*/
public void setPolicyComponent(PolicyComponent policyComponent)
{
this.policyComponent = policyComponent;
}
/**
* Init method
*/
public void init()
{
recordsManagementAuditService.registerAuditEvent(this);
}
/**
* Default constructor
*/
public AuditEvent()
{
}
/**
* Default constructor.
*
* @param name audit event name
* @param label audit event label (can be actual label or I18N lookup key)
*/
public AuditEvent(String name, String label)
{
this.name = name;

View File

@@ -0,0 +1,58 @@
/*
* Copyright (C) 2005-2013 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* 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/>.
*/
package org.alfresco.module.org_alfresco_module_rm.audit.event;
import java.util.Map;
import org.alfresco.repo.copy.CopyServicePolicies.OnCopyCompletePolicy;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
/**
* Copy audit event.
*
* @author Roy Wetherall
*/
public class CopyAuditEvent extends AuditEvent implements OnCopyCompletePolicy
{
/**
* @see org.alfresco.module.org_alfresco_module_rm.audit.event.AuditEvent#init()
*/
@Override
public void init()
{
super.init();
policyComponent.bindClassBehaviour(OnCopyCompletePolicy.QNAME,
ASPECT_FILE_PLAN_COMPONENT,
new JavaBehaviour(this, "onCopyComplete"));
}
@Override
public void onCopyComplete(QName classRef, NodeRef sourceNodeRef, NodeRef targetNodeRef, boolean copyToNewNode,
Map<NodeRef, NodeRef> copyMap)
{
if (copyToNewNode == true)
{
recordsManagementAuditService.auditEvent(targetNodeRef, getName());
}
}
}

View File

@@ -0,0 +1,62 @@
/*
* Copyright (C) 2005-2013 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* 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/>.
*/
package org.alfresco.module.org_alfresco_module_rm.audit.event;
import java.io.Serializable;
import java.util.Map;
import org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
/**
* File audit event.
*
* @author Roy Wetherall
*/
public class FileAuditEvent extends AuditEvent implements OnUpdatePropertiesPolicy
{
/**
* @see org.alfresco.module.org_alfresco_module_rm.audit.event.AuditEvent#init()
*/
@Override
public void init()
{
super.init();
policyComponent.bindClassBehaviour(OnUpdatePropertiesPolicy.QNAME,
ASPECT_RECORD,
new JavaBehaviour(this, "onUpdateProperties"));
}
@Override
public void onUpdateProperties(NodeRef nodeRef, Map<QName, Serializable> before, Map<QName, Serializable> after)
{
if (before.get(PROP_DATE_FILED) == null && after.get(PROP_DATE_FILED) != null)
{
// then we can assume that the record has just been filed
recordsManagementAuditService.auditEvent(nodeRef, getName());
}
}
}

View File

@@ -0,0 +1,65 @@
/*
* Copyright (C) 2005-2013 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* 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/>.
*/
package org.alfresco.module.org_alfresco_module_rm.audit.event;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
/**
* Link audit event.
*
* @author Roy Wetherall
*/
public class LinkAuditEvent extends AuditEvent implements OnCreateChildAssociationPolicy
{
/**
* (non-Javadoc)
* @see org.alfresco.module.org_alfresco_module_rm.audit.event.AuditEvent#init()
*/
@Override
public void init()
{
super.init();
policyComponent.bindAssociationBehaviour(
OnCreateChildAssociationPolicy.QNAME,
RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT,
ContentModel.ASSOC_CONTAINS,
new JavaBehaviour(this, "onCreateChildAssociation"));
}
/**
* @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean)
*/
@Override
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean isNewNode)
{
// only care about linking child associations
if (childAssocRef.isPrimary() == false)
{
// TODO
// add some dummy properties to indicate the details of the link?
recordsManagementAuditService.auditEvent(childAssocRef.getChildRef(), getName());
}
}
}

View File

@@ -0,0 +1,54 @@
/*
* Copyright (C) 2005-2013 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* 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/>.
*/
package org.alfresco.module.org_alfresco_module_rm.audit.event;
import org.alfresco.repo.node.NodeServicePolicies.OnMoveNodePolicy;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
/**
* Move audit event.
*
* @author Roy Wetherall
*/
public class MoveAuditEvent extends AuditEvent implements OnMoveNodePolicy
{
/**
* @see org.alfresco.module.org_alfresco_module_rm.audit.event.AuditEvent#init()
*/
@Override
public void init()
{
super.init();
policyComponent.bindClassBehaviour(OnMoveNodePolicy.QNAME,
ASPECT_FILE_PLAN_COMPONENT,
new JavaBehaviour(this, "onMoveNode"));
}
/**
* @see org.alfresco.repo.node.NodeServicePolicies.OnMoveNodePolicy#onMoveNode(org.alfresco.service.cmr.repository.ChildAssociationRef, org.alfresco.service.cmr.repository.ChildAssociationRef)
*/
@Override
public void onMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef)
{
recordsManagementAuditService.auditEvent(newChildAssocRef.getChildRef(), getName());
}
}

View File

@@ -21,11 +21,11 @@ package org.alfresco.module.org_alfresco_module_rm.script;
import java.io.File;
import java.io.IOException;
import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.extensions.webscripts.WebScriptResponse;
import org.alfresco.repo.web.scripts.content.ContentStreamer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.extensions.webscripts.WebScriptResponse;
/**
* Implementation for Java backed webscript to return audit