diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/log4j.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/log4j.properties index 369d7ae1bd..232fb9847f 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/log4j.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/log4j.properties @@ -24,5 +24,5 @@ log4j.logger.org.alfresco.module.org_alfresco_module_rm.patch=info # # Behaviour debug # -#log4j.logger.org.alfresco.repo.policy.annotation.AnnotatedBehaviourPostProcessor=debug -#log4j.logger.org.alfresco.module.org_alfresco_module_rm.behaviour.BaseBehaviourBean=debug \ No newline at end of file +log4j.logger.org.alfresco.repo.policy.annotation.AnnotatedBehaviourPostProcessor=debug +log4j.logger.org.alfresco.module.org_alfresco_module_rm.behaviour.BaseBehaviourBean=debug \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml index 5a23b9d351..663b511a55 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml @@ -255,7 +255,6 @@ - diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-audit-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-audit-context.xml index e514a2f7b7..2624de2910 100755 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-audit-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-audit-context.xml @@ -33,7 +33,6 @@ - diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-service-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-service-context.xml index 0b7dcb74e0..87f794d81d 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-service-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-service-context.xml @@ -1395,20 +1395,18 @@ - - + - - - diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DestroyAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DestroyAction.java index 586afa2f79..79bbe51268 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DestroyAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DestroyAction.java @@ -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")); - } } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/RecordsManagementAdminServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/RecordsManagementAdminServiceImpl.java index afe04b98bc..e0967f59dd 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/RecordsManagementAdminServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/admin/RecordsManagementAdminServiceImpl.java @@ -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() @@ -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() @@ -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() @@ -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(); } 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 ec27ed893b..08b65e580b 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 @@ -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 copyMap) + @Behaviour + ( + kind = BehaviourKind.CLASS, + type = "rma:filePlanComponent" + ) + public void onCopyComplete(QName classRef, + NodeRef sourceNodeRef, + NodeRef targetNodeRef, + boolean copyToNewNode, + Map copyMap) { if (copyToNewNode == true) { diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/CreateObjectAuditEvent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/CreateObjectAuditEvent.java index 77797db62c..410457c032 100755 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/CreateObjectAuditEvent.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/CreateObjectAuditEvent.java @@ -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); } - } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/CreatePersonAuditEvent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/CreatePersonAuditEvent.java index a7b82dcf27..f32bb6b09c 100755 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/CreatePersonAuditEvent.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/CreatePersonAuditEvent.java @@ -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); } - } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/DeleteObjectAuditEvent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/DeleteObjectAuditEvent.java index c00ac43811..db9c595354 100755 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/DeleteObjectAuditEvent.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/DeleteObjectAuditEvent.java @@ -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); } - } 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 index bb6f14b85e..48a6f6e262 100644 --- 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 @@ -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 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 index 0bcbe7fff8..b9e6537cfe 100644 --- 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 @@ -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 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 index fd7634d84f..6c50dd2812 100644 --- 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 @@ -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()); diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/UpdateObjectAuditEvent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/UpdateObjectAuditEvent.java index 9693b8180e..300012e612 100755 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/UpdateObjectAuditEvent.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/UpdateObjectAuditEvent.java @@ -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 before, Map after) { recordsManagementAuditService.auditEvent(nodeRef, name, before, after, false, true); diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigComponentImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigComponentImpl.java index 759a88f2ca..fdb49a7d95 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigComponentImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigComponentImpl.java @@ -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()) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/GhostedAspect.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/GhostedAspect.java new file mode 100644 index 0000000000..168a6cfdee --- /dev/null +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/GhostedAspect.java @@ -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 . + */ +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)); + } +} diff --git a/rm-server/source/java/org/alfresco/repo/policy/annotation/AnnotatedBehaviourPostProcessor.java b/rm-server/source/java/org/alfresco/repo/policy/annotation/AnnotatedBehaviourPostProcessor.java index 84b0b56189..3a11c873e5 100644 --- a/rm-server/source/java/org/alfresco/repo/policy/annotation/AnnotatedBehaviourPostProcessor.java +++ b/rm-server/source/java/org/alfresco/repo/policy/annotation/AnnotatedBehaviourPostProcessor.java @@ -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; } diff --git a/rm-server/source/java/org/alfresco/repo/policy/annotation/Behaviour.java b/rm-server/source/java/org/alfresco/repo/policy/annotation/Behaviour.java index 619677be13..7fc6b7ecdc 100644 --- a/rm-server/source/java/org/alfresco/repo/policy/annotation/Behaviour.java +++ b/rm-server/source/java/org/alfresco/repo/policy/annotation/Behaviour.java @@ -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 "";