getAuditEvents();
/**
- * Register audit event
+ * Register audit event.
+ *
+ * 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);
/**
- *
- * @param nodeRef
- * @param eventName
+ * Audits an event, assumes no properties where modified and that the event should not be audited
+ * immediately.
+ *
+ * @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 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,
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java
index 3fcbf8371b..299663b33f 100644
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java
@@ -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}
*/
@@ -355,16 +315,7 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
auditService.clearAudit(RecordsManagementAuditService.RM_AUDIT_APPLICATION_NAME, null, null);
if (logger.isInfoEnabled())
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,17 +386,12 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
/**
* {@inheritDoc}
- * @since 3.2
- * @deprecated since 2.1
*/
@Deprecated
- public void auditRMAction(
- RecordsManagementAction action,
- NodeRef nodeRef,
- Map parameters)
+ public void clear()
{
- auditEvent(nodeRef, action.getName());
- }
+ clearAuditLog(getDefaultFilePlan());
+ }
@Override
public void auditEvent(NodeRef nodeRef, String eventName)
@@ -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 parameters)
+ {
+ auditEvent(nodeRef, action.getName());
+ }
}
\ No newline at end of file
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/AuditEvent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/AuditEvent.java
index d5fa10cf11..385d9572c5 100644
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/AuditEvent.java
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/AuditEvent.java
@@ -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;
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/CopyAuditEvent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/CopyAuditEvent.java
new file mode 100644
index 0000000000..edd0cefef6
--- /dev/null
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/CopyAuditEvent.java
@@ -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 .
+ */
+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 copyMap)
+ {
+ if (copyToNewNode == true)
+ {
+ recordsManagementAuditService.auditEvent(targetNodeRef, getName());
+ }
+ }
+}
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/FileAuditEvent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/FileAuditEvent.java
new file mode 100644
index 0000000000..bb6f14b85e
--- /dev/null
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/FileAuditEvent.java
@@ -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 .
+ */
+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 before, Map 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());
+ }
+
+ }
+
+
+}
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/LinkAuditEvent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/LinkAuditEvent.java
new file mode 100644
index 0000000000..0bcbe7fff8
--- /dev/null
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/LinkAuditEvent.java
@@ -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 .
+ */
+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());
+ }
+ }
+
+}
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/MoveAuditEvent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/MoveAuditEvent.java
new file mode 100644
index 0000000000..fd7634d84f
--- /dev/null
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/MoveAuditEvent.java
@@ -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 .
+ */
+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());
+ }
+
+}
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AuditLogGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AuditLogGet.java
index 4ab3f4263e..a31568b173 100644
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AuditLogGet.java
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AuditLogGet.java
@@ -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