mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-1098: Refactoring of behaviours to new annotation style to improve maintability
* moved ghosted behaviour into it's own bean * added support for annotated 'service' behaviours (ie those that have no type/aspect specified) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@58370 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -23,15 +23,11 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.model.RenditionModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
|
||||
import org.alfresco.repo.content.ContentServicePolicies;
|
||||
import org.alfresco.repo.content.cleanup.EagerContentStoreCleaner;
|
||||
import org.alfresco.repo.policy.JavaBehaviour;
|
||||
import org.alfresco.repo.policy.PolicyComponent;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
@@ -39,8 +35,6 @@ import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* Destroy action.
|
||||
@@ -48,18 +42,10 @@ import org.springframework.extensions.surf.util.I18NUtil;
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class DestroyAction extends RMDispositionActionExecuterAbstractBase
|
||||
implements ContentServicePolicies.OnContentUpdatePolicy,
|
||||
InitializingBean
|
||||
{
|
||||
/** Action name */
|
||||
public static final String NAME = "destroy";
|
||||
|
||||
/** I18N */
|
||||
private static final String MSG_GHOSTED_PROP_UPDATE = "rm.action.ghosted-prop-update";
|
||||
|
||||
/** Policy component */
|
||||
private PolicyComponent policyComponent;
|
||||
|
||||
/** Eager content store cleaner */
|
||||
private EagerContentStoreCleaner eagerContentStoreCleaner;
|
||||
|
||||
@@ -69,14 +55,6 @@ public class DestroyAction extends RMDispositionActionExecuterAbstractBase
|
||||
/** Indicates if ghosting is enabled or not */
|
||||
private boolean ghostingEnabled = true;
|
||||
|
||||
/**
|
||||
* @param policyComponent policy component
|
||||
*/
|
||||
public void setPolicyComponent(PolicyComponent policyComponent)
|
||||
{
|
||||
this.policyComponent = policyComponent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param eagerContentStoreCleaner eager content store cleaner
|
||||
*/
|
||||
@@ -259,24 +237,4 @@ public class DestroyAction extends RMDispositionActionExecuterAbstractBase
|
||||
eagerContentStoreCleaner.registerOrphanedContentUrl(contentData.getContentUrl(), true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.content.ContentServicePolicies.OnContentUpdatePolicy#onContentUpdate(org.alfresco.service.cmr.repository.NodeRef, boolean)
|
||||
*/
|
||||
public void onContentUpdate(NodeRef nodeRef, boolean newContent)
|
||||
{
|
||||
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_GHOSTED_PROP_UPDATE));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
|
||||
*/
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
// Register interest in the onContentUpdate policy
|
||||
policyComponent.bindClassBehaviour(
|
||||
ContentServicePolicies.OnContentUpdatePolicy.QNAME,
|
||||
ASPECT_GHOSTED,
|
||||
new JavaBehaviour(this, "onContentUpdate"));
|
||||
}
|
||||
}
|
||||
|
@@ -55,10 +55,12 @@ import org.alfresco.repo.dictionary.M2Model;
|
||||
import org.alfresco.repo.dictionary.M2Namespace;
|
||||
import org.alfresco.repo.dictionary.M2Property;
|
||||
import org.alfresco.repo.node.NodeServicePolicies;
|
||||
import org.alfresco.repo.policy.ClassPolicyDelegate;
|
||||
import org.alfresco.repo.policy.JavaBehaviour;
|
||||
import org.alfresco.repo.policy.PolicyComponent;
|
||||
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
|
||||
import org.alfresco.repo.policy.ClassPolicyDelegate;
|
||||
import org.alfresco.repo.policy.PolicyComponent;
|
||||
import org.alfresco.repo.policy.annotation.Behaviour;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourBean;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourKind;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||
@@ -93,6 +95,7 @@ import org.springframework.extensions.surf.util.URLDecoder;
|
||||
*
|
||||
* @author Neil McErlean, janv
|
||||
*/
|
||||
@BehaviourBean
|
||||
public class RecordsManagementAdminServiceImpl implements RecordsManagementAdminService,
|
||||
RecordsManagementCustomModel,
|
||||
NodeServicePolicies.OnAddAspectPolicy,
|
||||
@@ -221,7 +224,14 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
|
||||
beforeRemoveReferenceDelegate = policyComponent.registerClassPolicy(BeforeRemoveReference.class);
|
||||
onRemoveReferenceDelegate = policyComponent.registerClassPolicy(OnRemoveReference.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Invoke before create reference policy
|
||||
*
|
||||
* @param fromNodeRef
|
||||
* @param toNodeRef
|
||||
* @param reference
|
||||
*/
|
||||
protected void invokeBeforeCreateReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference)
|
||||
{
|
||||
// get qnames to invoke against
|
||||
@@ -231,6 +241,13 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
|
||||
policy.beforeCreateReference(fromNodeRef, toNodeRef, reference);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke on create reference policy
|
||||
*
|
||||
* @param fromNodeRef
|
||||
* @param toNodeRef
|
||||
* @param reference
|
||||
*/
|
||||
protected void invokeOnCreateReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference)
|
||||
{
|
||||
// get qnames to invoke against
|
||||
@@ -240,6 +257,13 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
|
||||
policy.onCreateReference(fromNodeRef, toNodeRef, reference);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke before remove reference policy
|
||||
*
|
||||
* @param fromNodeRef
|
||||
* @param toNodeRef
|
||||
* @param reference
|
||||
*/
|
||||
protected void invokeBeforeRemoveReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference)
|
||||
{
|
||||
// get qnames to invoke against
|
||||
@@ -250,6 +274,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke on remove reference policy
|
||||
*
|
||||
* @param fromNodeRef
|
||||
* @param toNodeRef
|
||||
@@ -268,6 +293,12 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.OnAddAspectPolicy#onAddAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
|
||||
*/
|
||||
@Override
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS,
|
||||
isService = true,
|
||||
notificationFrequency = NotificationFrequency.FIRST_EVENT
|
||||
)
|
||||
public void onAddAspect(final NodeRef nodeRef, final QName aspectTypeQName)
|
||||
{
|
||||
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
||||
@@ -291,6 +322,12 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.OnRemoveAspectPolicy#onRemoveAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
|
||||
*/
|
||||
@Override
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS,
|
||||
isService = true,
|
||||
notificationFrequency = NotificationFrequency.FIRST_EVENT
|
||||
)
|
||||
public void onRemoveAspect(final NodeRef nodeRef, final QName aspectTypeQName)
|
||||
{
|
||||
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
||||
@@ -316,6 +353,12 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy#onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef)
|
||||
*/
|
||||
@Override
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS,
|
||||
isService = true,
|
||||
notificationFrequency = NotificationFrequency.FIRST_EVENT
|
||||
)
|
||||
public void onCreateNode(final ChildAssociationRef childAssocRef)
|
||||
{
|
||||
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
||||
@@ -354,20 +397,6 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
|
||||
*/
|
||||
public void initialiseCustomModel()
|
||||
{
|
||||
// Bind class behaviours
|
||||
policyComponent.bindClassBehaviour(
|
||||
NodeServicePolicies.OnAddAspectPolicy.QNAME,
|
||||
this,
|
||||
new JavaBehaviour(this, "onAddAspect", NotificationFrequency.FIRST_EVENT));
|
||||
policyComponent.bindClassBehaviour(
|
||||
NodeServicePolicies.OnRemoveAspectPolicy.QNAME,
|
||||
this,
|
||||
new JavaBehaviour(this, "onRemoveAspect", NotificationFrequency.FIRST_EVENT));
|
||||
policyComponent.bindClassBehaviour(
|
||||
NodeServicePolicies.OnCreateNodePolicy.QNAME,
|
||||
this,
|
||||
new JavaBehaviour(this, "onCreateNode", NotificationFrequency.FIRST_EVENT));
|
||||
|
||||
// Initialise the map
|
||||
getCustomisableMap();
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2013 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -22,7 +22,6 @@ import java.util.Comparator;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
@@ -44,7 +43,7 @@ public class AuditEvent implements RecordsManagementModel, Comparator<AuditEvent
|
||||
protected RecordsManagementAuditService recordsManagementAuditService;
|
||||
|
||||
/** Policy component */
|
||||
protected PolicyComponent policyComponent;
|
||||
//protected PolicyComponent policyComponent;
|
||||
|
||||
/**
|
||||
* @param recordsManagementAuditService records management audit service
|
||||
@@ -57,10 +56,10 @@ public class AuditEvent implements RecordsManagementModel, Comparator<AuditEvent
|
||||
/**
|
||||
* @param policyComponent policy component
|
||||
*/
|
||||
public void setPolicyComponent(PolicyComponent policyComponent)
|
||||
{
|
||||
this.policyComponent = policyComponent;
|
||||
}
|
||||
// public void setPolicyComponent(PolicyComponent policyComponent)
|
||||
// {
|
||||
// this.policyComponent = policyComponent;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Init method
|
||||
|
@@ -21,7 +21,9 @@ 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.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.namespace.QName;
|
||||
|
||||
@@ -29,26 +31,27 @@ import org.alfresco.service.namespace.QName;
|
||||
* Copy audit event.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
@BehaviourBean
|
||||
public class CopyAuditEvent extends AuditEvent implements OnCopyCompletePolicy
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.audit.event.AuditEvent#init()
|
||||
* Audit copy of file plan components
|
||||
*
|
||||
* @see org.alfresco.repo.copy.CopyServicePolicies.OnCopyCompletePolicy#onCopyComplete(org.alfresco.service.namespace.QName, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, boolean, java.util.Map)
|
||||
*/
|
||||
@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)
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS,
|
||||
type = "rma:filePlanComponent"
|
||||
)
|
||||
public void onCopyComplete(QName classRef,
|
||||
NodeRef sourceNodeRef,
|
||||
NodeRef targetNodeRef,
|
||||
boolean copyToNewNode,
|
||||
Map<NodeRef, NodeRef> copyMap)
|
||||
{
|
||||
if (copyToNewNode == true)
|
||||
{
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2013 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -18,33 +18,32 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.audit.event;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy;
|
||||
import org.alfresco.repo.policy.JavaBehaviour;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Audits the creation of file plan component objects
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
@BehaviourBean
|
||||
public class CreateObjectAuditEvent extends AuditEvent implements OnCreateNodePolicy
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.audit.event.AuditEvent#init()
|
||||
*/
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
policyComponent.bindClassBehaviour(
|
||||
OnCreateNodePolicy.QNAME,
|
||||
RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT,
|
||||
new JavaBehaviour(this, "onCreateNode"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy#onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef)
|
||||
*/
|
||||
@Override
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS,
|
||||
type = "rma:filePlanComponent"
|
||||
)
|
||||
public void onCreateNode(ChildAssociationRef childAssocRef)
|
||||
{
|
||||
recordsManagementAuditService.auditEvent(childAssocRef.getChildRef(), name);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2013 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -18,28 +18,32 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.audit.event;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy;
|
||||
import org.alfresco.repo.policy.JavaBehaviour;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Audits person creation.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
@BehaviourBean
|
||||
public class CreatePersonAuditEvent extends AuditEvent implements OnCreateNodePolicy
|
||||
{
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy#onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef)
|
||||
*/
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
policyComponent.bindClassBehaviour(
|
||||
OnCreateNodePolicy.QNAME,
|
||||
ContentModel.TYPE_PERSON,
|
||||
new JavaBehaviour(this, "onCreateNode"));
|
||||
}
|
||||
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS,
|
||||
type = "cm:person"
|
||||
)
|
||||
public void onCreateNode(ChildAssociationRef childAssocRef)
|
||||
{
|
||||
recordsManagementAuditService.auditEvent(childAssocRef.getChildRef(), name);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2013 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -18,27 +18,32 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.audit.event;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy;
|
||||
import org.alfresco.repo.policy.JavaBehaviour;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Audits file plan component delete
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
@BehaviourBean
|
||||
public class DeleteObjectAuditEvent extends AuditEvent implements BeforeDeleteNodePolicy
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy#beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
policyComponent.bindClassBehaviour(
|
||||
BeforeDeleteNodePolicy.QNAME,
|
||||
RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT,
|
||||
new JavaBehaviour(this, "beforeDeleteNode"));
|
||||
}
|
||||
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS,
|
||||
type = "rma:filePlanComponent"
|
||||
)
|
||||
public void beforeDeleteNode(NodeRef nodeRef)
|
||||
{
|
||||
recordsManagementAuditService.auditEvent(nodeRef, name, null, null, true, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -22,7 +22,9 @@ import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy;
|
||||
import org.alfresco.repo.policy.JavaBehaviour;
|
||||
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.namespace.QName;
|
||||
|
||||
@@ -30,33 +32,26 @@ import org.alfresco.service.namespace.QName;
|
||||
* File audit event.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
@BehaviourBean
|
||||
public class FileAuditEvent extends AuditEvent implements OnUpdatePropertiesPolicy
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.audit.event.AuditEvent#init()
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
policyComponent.bindClassBehaviour(OnUpdatePropertiesPolicy.QNAME,
|
||||
ASPECT_RECORD,
|
||||
new JavaBehaviour(this, "onUpdateProperties"));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS,
|
||||
type = "rma:record"
|
||||
)
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -18,39 +18,30 @@
|
||||
*/
|
||||
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.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;
|
||||
|
||||
/**
|
||||
* Link audit event.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
@BehaviourBean
|
||||
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
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.ASSOCIATION,
|
||||
type = "rma:filePlanComponent"
|
||||
)
|
||||
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean isNewNode)
|
||||
{
|
||||
// only care about linking child associations
|
||||
|
@@ -19,33 +19,29 @@
|
||||
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.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;
|
||||
|
||||
/**
|
||||
* Move audit event.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
@BehaviourBean
|
||||
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
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS,
|
||||
type = "rma:filePlanComponent"
|
||||
)
|
||||
public void onMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef)
|
||||
{
|
||||
recordsManagementAuditService.auditEvent(newChildAssocRef.getChildRef(), getName());
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2013 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -21,26 +21,31 @@ package org.alfresco.module.org_alfresco_module_rm.audit.event;
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy;
|
||||
import org.alfresco.repo.policy.JavaBehaviour;
|
||||
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.namespace.QName;
|
||||
|
||||
/**
|
||||
* Audits file plan component property updates
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
@BehaviourBean
|
||||
public class UpdateObjectAuditEvent extends AuditEvent implements OnUpdatePropertiesPolicy
|
||||
{
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
policyComponent.bindClassBehaviour(
|
||||
OnUpdatePropertiesPolicy.QNAME,
|
||||
RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT,
|
||||
new JavaBehaviour(this, "onUpdateProperties"));
|
||||
}
|
||||
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS,
|
||||
type = "rma:filePlanComponent"
|
||||
)
|
||||
public void onUpdateProperties(NodeRef nodeRef, Map<QName, Serializable> before, Map<QName, Serializable> after)
|
||||
{
|
||||
recordsManagementAuditService.auditEvent(nodeRef, name, before, after, false, true);
|
||||
|
@@ -41,8 +41,9 @@ import org.alfresco.repo.cache.SimpleCache;
|
||||
import org.alfresco.repo.content.ContentServicePolicies;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.node.NodeServicePolicies;
|
||||
import org.alfresco.repo.policy.JavaBehaviour;
|
||||
import org.alfresco.repo.policy.PolicyComponent;
|
||||
import org.alfresco.repo.policy.annotation.Behaviour;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourBean;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourKind;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.version.VersionModel;
|
||||
@@ -73,14 +74,14 @@ import org.json.JSONObject;
|
||||
*
|
||||
* @author janv
|
||||
*/
|
||||
@BehaviourBean(defaultType = "rma:caveatConfig")
|
||||
public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnContentUpdatePolicy,
|
||||
NodeServicePolicies.BeforeDeleteNodePolicy,
|
||||
NodeServicePolicies.OnCreateNodePolicy,
|
||||
RMCaveatConfigComponent
|
||||
NodeServicePolicies.BeforeDeleteNodePolicy,
|
||||
NodeServicePolicies.OnCreateNodePolicy,
|
||||
RMCaveatConfigComponent
|
||||
{
|
||||
private static Log logger = LogFactory.getLog(RMCaveatConfigComponentImpl.class);
|
||||
|
||||
private PolicyComponent policyComponent;
|
||||
private ContentService contentService;
|
||||
private DictionaryService dictionaryService;
|
||||
private NamespaceService namespaceService;
|
||||
@@ -121,11 +122,6 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
|
||||
this.caveatConfig = caveatConfig;
|
||||
}
|
||||
|
||||
public void setPolicyComponent(PolicyComponent policyComponent)
|
||||
{
|
||||
this.policyComponent = policyComponent;
|
||||
}
|
||||
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
@@ -176,24 +172,6 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
|
||||
*/
|
||||
public void init()
|
||||
{
|
||||
// Register interest in the onContentUpdate policy
|
||||
policyComponent.bindClassBehaviour(
|
||||
ContentServicePolicies.OnContentUpdatePolicy.QNAME,
|
||||
RecordsManagementModel.TYPE_CAVEAT_CONFIG,
|
||||
new JavaBehaviour(this, "onContentUpdate"));
|
||||
|
||||
// Register interest in the beforeDeleteNode policy
|
||||
policyComponent.bindClassBehaviour(
|
||||
QName.createQName(NamespaceService.ALFRESCO_URI, "beforeDeleteNode"),
|
||||
RecordsManagementModel.TYPE_CAVEAT_CONFIG,
|
||||
new JavaBehaviour(this, "beforeDeleteNode"));
|
||||
|
||||
// Register interest in the onCreateNode policy
|
||||
policyComponent.bindClassBehaviour(
|
||||
QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode"),
|
||||
RecordsManagementModel.TYPE_CAVEAT_CONFIG,
|
||||
new JavaBehaviour(this, "onCreateNode"));
|
||||
|
||||
if (caveatAspectURINames.size() > 0)
|
||||
{
|
||||
for (String caveatAspectURIName : caveatAspectURINames)
|
||||
@@ -234,7 +212,12 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
|
||||
validateAndReset(caveatConfigNodeRef);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.content.ContentServicePolicies.OnContentUpdatePolicy#onContentUpdate(org.alfresco.service.cmr.repository.NodeRef, boolean)
|
||||
*/
|
||||
@Override
|
||||
@Behaviour(kind = BehaviourKind.CLASS)
|
||||
public void onContentUpdate(NodeRef nodeRef, boolean newContent)
|
||||
{
|
||||
if (logger.isInfoEnabled())
|
||||
@@ -245,6 +228,11 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
|
||||
validateAndReset(nodeRef);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy#beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
@Behaviour(kind = BehaviourKind.CLASS)
|
||||
public void beforeDeleteNode(NodeRef nodeRef)
|
||||
{
|
||||
if (logger.isInfoEnabled())
|
||||
@@ -255,6 +243,11 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
|
||||
validateAndReset(nodeRef);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy#onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef)
|
||||
*/
|
||||
@Override
|
||||
@Behaviour(kind = BehaviourKind.CLASS)
|
||||
public void onCreateNode(ChildAssociationRef childAssocRef)
|
||||
{
|
||||
if (logger.isInfoEnabled())
|
||||
|
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 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.model.rma.aspect;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
|
||||
import org.alfresco.repo.content.ContentServicePolicies;
|
||||
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.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* rma:ghosted behaviour bean
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.2
|
||||
*/
|
||||
@BehaviourBean
|
||||
(
|
||||
defaultType = "rma:ghosted"
|
||||
)
|
||||
public class GhostedAspect extends BaseBehaviourBean
|
||||
implements ContentServicePolicies.OnContentUpdatePolicy
|
||||
{
|
||||
/** I18N */
|
||||
private static final String MSG_GHOSTED_PROP_UPDATE = "rm.action.ghosted-prop-update";
|
||||
|
||||
/**
|
||||
* Ensure that the content of a ghosted node can not be updated.
|
||||
*
|
||||
* @see org.alfresco.repo.content.ContentServicePolicies.OnContentUpdatePolicy#onContentUpdate(org.alfresco.service.cmr.repository.NodeRef, boolean)
|
||||
*/
|
||||
@Override
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS
|
||||
)
|
||||
public void onContentUpdate(NodeRef Content, boolean bNew)
|
||||
{
|
||||
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_GHOSTED_PROP_UPDATE));
|
||||
}
|
||||
}
|
@@ -73,6 +73,7 @@ public class AnnotatedBehaviourPostProcessor implements BeanPostProcessor
|
||||
// register annotated behavior methods
|
||||
registerBehaviours(bean, beanName);
|
||||
|
||||
// return the bean
|
||||
return bean;
|
||||
}
|
||||
|
||||
@@ -114,52 +115,82 @@ public class AnnotatedBehaviourPostProcessor implements BeanPostProcessor
|
||||
}
|
||||
|
||||
/**
|
||||
* Register behaviour with the policy.
|
||||
*
|
||||
* @param behaviourBean
|
||||
* @param bean
|
||||
* @param beanName
|
||||
* @param method
|
||||
* @param classBehaviour
|
||||
*/
|
||||
private void registerBehaviour(BehaviourBean behaviourBean, Object bean, String beanName, Method method)
|
||||
{
|
||||
Behaviour behaviour = method.getAnnotation(Behaviour.class);
|
||||
QName policy = resolvePolicy(behaviour.policy(), method);
|
||||
QName type = resolveType(behaviourBean, behaviour.type());
|
||||
QName type = resolveType(behaviourBean, behaviour);
|
||||
|
||||
// assert that the policy and type have been set!!
|
||||
ParameterCheck.mandatory("policy", policy);
|
||||
ParameterCheck.mandatory("type", type);
|
||||
if (behaviour.isService() == false)
|
||||
{
|
||||
ParameterCheck.mandatory("type", type);
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug(" ... registering " + behaviour.kind() + " behaviour for " + beanName + "." + method.getName() +
|
||||
" for policy " + policy.toString() +
|
||||
" and type " + type.toString());
|
||||
if (behaviour.isService() == false)
|
||||
{
|
||||
logger.debug(" ... registering " + behaviour.kind() + " behaviour for " + beanName + "." + method.getName() +
|
||||
" for policy " + policy.toString() +
|
||||
" and type " + type.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.debug(" ... registering " + behaviour.kind() + " service behaviour for " + beanName + "." + method.getName() +
|
||||
" for policy " + policy.toString());
|
||||
}
|
||||
}
|
||||
|
||||
// create java behaviour object
|
||||
JavaBehaviour javaBehaviour = new JavaBehaviour(bean, method.getName(), behaviour.notificationFrequency());
|
||||
|
||||
// deal with class behaviours
|
||||
if (BehaviourKind.CLASS.equals(behaviour.kind()) == true)
|
||||
{
|
||||
policyComponent.bindClassBehaviour(policy,
|
||||
type,
|
||||
javaBehaviour);
|
||||
if (behaviour.isService() == false)
|
||||
{
|
||||
// bind class behaviour for given type
|
||||
policyComponent.bindClassBehaviour(policy, type, javaBehaviour);
|
||||
}
|
||||
else
|
||||
{
|
||||
// bind class service behaviour
|
||||
policyComponent.bindClassBehaviour(policy, bean, javaBehaviour);
|
||||
}
|
||||
}
|
||||
// deal with association behaviours
|
||||
else if (BehaviourKind.ASSOCIATION.equals(behaviour.kind()) == true)
|
||||
{
|
||||
policyComponent.bindAssociationBehaviour(policy,
|
||||
type,
|
||||
toQName(behaviour.assocType()),
|
||||
javaBehaviour);
|
||||
if (behaviour.isService() == false)
|
||||
{
|
||||
// bind association behaviour for given type and assoc type
|
||||
policyComponent.bindAssociationBehaviour(policy,
|
||||
type,
|
||||
toQName(behaviour.assocType()),
|
||||
javaBehaviour);
|
||||
}
|
||||
else
|
||||
{
|
||||
// bind association service behaviour
|
||||
policyComponent.bindAssociationBehaviour(policy, bean, javaBehaviour);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the policy qname, defaulting to the qualified name of the method if none specified.
|
||||
*
|
||||
* @param policyName
|
||||
* @param method
|
||||
* @return
|
||||
* @param policyName policy name
|
||||
* @param method method
|
||||
* @return {@link QName} qualified name of the policy
|
||||
*/
|
||||
private QName resolvePolicy(String policyName, Method method)
|
||||
{
|
||||
@@ -182,18 +213,21 @@ public class AnnotatedBehaviourPostProcessor implements BeanPostProcessor
|
||||
* @param typeName
|
||||
* @return
|
||||
*/
|
||||
private QName resolveType(BehaviourBean behaviourBean, String typeName)
|
||||
private QName resolveType(BehaviourBean behaviourBean, Behaviour behaviour)
|
||||
{
|
||||
QName type = null;
|
||||
if (typeName.isEmpty() == true)
|
||||
if (behaviour.isService() == false)
|
||||
{
|
||||
// get default
|
||||
type = toQName(behaviourBean.defaultType());
|
||||
}
|
||||
else
|
||||
{
|
||||
// convert set
|
||||
type = toQName(typeName);
|
||||
if (behaviour.type().isEmpty() == true)
|
||||
{
|
||||
// get default
|
||||
type = toQName(behaviourBean.defaultType());
|
||||
}
|
||||
else
|
||||
{
|
||||
// convert set
|
||||
type = toQName(behaviour.type());
|
||||
}
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
@@ -40,6 +40,9 @@ public @interface Behaviour
|
||||
/** qualified name of policy */
|
||||
String policy() default "";
|
||||
|
||||
/** indicates whether this is a service behaviour or not */
|
||||
boolean isService() default false;
|
||||
|
||||
/** qualified name of type/aspect */
|
||||
String type() default "";
|
||||
|
||||
|
Reference in New Issue
Block a user