RM-1098: Behaviour refactoring

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@58609 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2013-12-05 06:15:12 +00:00
parent c7a6c9350d
commit ff657db151
9 changed files with 349 additions and 274 deletions

View File

@@ -35,11 +35,7 @@ import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
import org.alfresco.repo.policy.BehaviourFilter;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -59,8 +55,7 @@ import org.apache.commons.logging.LogFactory;
*/
public class DispositionServiceImpl implements
DispositionService,
RecordsManagementModel,
NodeServicePolicies.OnAddAspectPolicy
RecordsManagementModel
{
/** Logger */
private static Log logger = LogFactory.getLog(DispositionServiceImpl.class);
@@ -89,15 +84,9 @@ public class DispositionServiceImpl implements
/** Record Service */
private RecordService recordService;
/** Policy component */
private PolicyComponent policyComponent;
/** Disposition properties */
private Map<QName, DispositionProperty> dispositionProperties = new HashMap<QName, DispositionProperty>(4);
/** Behaviours */
private JavaBehaviour onAddAspect;
/**
* Set node service
*
@@ -138,14 +127,6 @@ public class DispositionServiceImpl implements
this.serviceRegistry = serviceRegistry;
}
/**
* @param policyComponent policy component
*/
public void setPolicyComponent(PolicyComponent policyComponent)
{
this.policyComponent = policyComponent;
}
/**
* @param filePlanService file plan service
*/
@@ -180,27 +161,6 @@ public class DispositionServiceImpl implements
this.dispositionSelectionStrategy = dispositionSelectionStrategy;
}
/**
* Bean initialisation
*/
public void init()
{
onAddAspect = new JavaBehaviour(this, "onAddAspect", NotificationFrequency.FIRST_EVENT);
policyComponent.bindClassBehaviour(NodeServicePolicies.OnAddAspectPolicy.QNAME, ASPECT_DISPOSITION_LIFECYCLE, onAddAspect);
}
/**
* Initialises the details of the disposition life cycle
*/
@Override
public void onAddAspect(NodeRef nodeRef, QName aspect)
{
if (nodeService.exists(nodeRef) == true)
{
refreshDispositionAction(nodeRef);
}
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#refreshDispositionAction(NodeRef)
*/

View File

@@ -34,13 +34,7 @@ import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService;
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.repo.security.permissions.AccessDeniedException;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -62,8 +56,7 @@ import org.springframework.extensions.surf.util.I18NUtil;
*/
public class FreezeServiceImpl extends ServiceBaseImpl
implements FreezeService,
RecordsManagementModel,
NodeServicePolicies.BeforeDeleteNodePolicy
RecordsManagementModel
{
/** Logger */
private static Log logger = LogFactory.getLog(FreezeServiceImpl.class);
@@ -75,9 +68,6 @@ public class FreezeServiceImpl extends ServiceBaseImpl
/** Hold node reference key */
private static final String KEY_HOLD_NODEREF = "holdNodeRef";
/** Policy Component */
protected PolicyComponent policyComponent;
/** Record service */
protected RecordService recordService;
@@ -92,15 +82,7 @@ public class FreezeServiceImpl extends ServiceBaseImpl
/** Record folder service */
protected RecordFolderService recordFolderService;
/**
* @param policyComponent policy component
*/
public void setPolicyComponent(PolicyComponent policyComponent)
{
this.policyComponent = policyComponent;
}
/**
* @param recordService record service
*/
@@ -141,71 +123,6 @@ public class FreezeServiceImpl extends ServiceBaseImpl
this.recordFolderService = recordFolderService;
}
/**
* Init service
*/
public void init()
{
policyComponent.bindClassBehaviour(
NodeServicePolicies.BeforeDeleteNodePolicy.QNAME,
this,
new JavaBehaviour(this, "beforeDeleteNode", NotificationFrequency.FIRST_EVENT));
}
/**
* @see org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy#beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
public void beforeDeleteNode(final NodeRef nodeRef)
{
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
{
@Override
public Void doWork() throws Exception
{
if (nodeService.exists(nodeRef) == true &&
filePlanService.isFilePlanComponent(nodeRef) == true)
{
if (isFrozen(nodeRef) == true)
{
// never allowed to delete a frozen node
throw new AccessDeniedException("Frozen nodes can not be deleted.");
}
// check children
checkChildren(nodeService.getChildAssocs(nodeRef));
}
return null;
}
});
}
/**
* Checks the children for frozen nodes. Throws security error if any are
* found.
*
* @param assocs
*/
private void checkChildren(List<ChildAssociationRef> assocs)
{
for (ChildAssociationRef assoc : assocs)
{
// we only care about primary children
if (assoc.isPrimary() == true)
{
NodeRef nodeRef = assoc.getChildRef();
if (isFrozen(nodeRef) == true)
{
// never allowed to delete a node with a frozen child
throw new AccessDeniedException("Can not delete node, because it contains a frozen child node.");
}
// check children
checkChildren(nodeService.getChildAssocs(nodeRef));
}
}
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService#isHold(org.alfresco.service.cmr.repository.NodeRef)
*/

View File

@@ -18,13 +18,19 @@
*/
package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
import org.alfresco.repo.copy.CopyBehaviourCallback;
import org.alfresco.repo.copy.CopyDetails;
import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
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.repository.NodeRef;
import org.alfresco.service.namespace.QName;
/**
@@ -38,7 +44,19 @@ import org.alfresco.service.namespace.QName;
defaultType = "rma:dispositionLifecycle"
)
public class DispositionLifecycleAspect extends BaseBehaviourBean
implements NodeServicePolicies.OnAddAspectPolicy
{
/** disposition service */
protected DispositionService dispositionService;
/**
* @param dispositionService disposition service
*/
public void setDispositionService(DispositionService dispositionService)
{
this.dispositionService = dispositionService;
}
/**
* Copy callback for disposition lifecycle
*/
@@ -50,5 +68,30 @@ public class DispositionLifecycleAspect extends BaseBehaviourBean
public CopyBehaviourCallback getCopyCallback(QName classRef, CopyDetails copyDetails)
{
return new DoNothingCopyBehaviourCallback();
}
/**
* @see org.alfresco.repo.node.NodeServicePolicies.OnAddAspectPolicy#onAddAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
*/
@Override
@Behaviour
(
kind = BehaviourKind.CLASS,
notificationFrequency = NotificationFrequency.FIRST_EVENT
)
public void onAddAspect(final NodeRef nodeRef, final QName aspect)
{
if (nodeService.exists(nodeRef) == true)
{
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
{
@Override
public Void doWork() throws Exception
{
dispositionService.refreshDispositionAction(nodeRef);
return null;
}
});
}
}
}

View File

@@ -0,0 +1,133 @@
/*
* Copyright (C) 2005-2013 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect;
import java.util.List;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService;
import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
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.security.permissions.AccessDeniedException;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* rma:frozen behaviour bean
*
* @author Roy Wetherall
* @since 2.2
*/
@BehaviourBean
(
defaultType = "rma:frozen"
)
public class FrozenAspect extends BaseBehaviourBean
implements NodeServicePolicies.BeforeDeleteNodePolicy
{
/** file plan service */
protected FilePlanService filePlanService;
/** freeze service */
protected FreezeService freezeService;
/**
* @param filePlanService file plan service
*/
public void setFilePlanService(FilePlanService filePlanService)
{
this.filePlanService = filePlanService;
}
/**
* @param freezeService freeze service
*/
public void setFreezeService(FreezeService freezeService)
{
this.freezeService = freezeService;
}
/**
* Ensure that no frozen node is deleted.
*
* @see org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy#beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
@Behaviour
(
kind = BehaviourKind.CLASS,
notificationFrequency = NotificationFrequency.FIRST_EVENT
)
public void beforeDeleteNode(final NodeRef nodeRef)
{
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
{
@Override
public Void doWork() throws Exception
{
if (nodeService.exists(nodeRef) == true &&
filePlanService.isFilePlanComponent(nodeRef) == true)
{
if (freezeService.isFrozen(nodeRef) == true)
{
// never allowed to delete a frozen node
throw new AccessDeniedException("Frozen nodes can not be deleted.");
}
// check children
checkChildren(nodeService.getChildAssocs(nodeRef));
}
return null;
}
});
}
/**
* Checks the children for frozen nodes. Throws security error if any are
* found.
*
* @param assocs
*/
private void checkChildren(List<ChildAssociationRef> assocs)
{
for (ChildAssociationRef assoc : assocs)
{
// we only care about primary children
if (assoc.isPrimary() == true)
{
NodeRef nodeRef = assoc.getChildRef();
if (freezeService.isFrozen(nodeRef) == true)
{
// never allowed to delete a node with a frozen child
throw new AccessDeniedException("Can not delete node, because it contains a frozen child node.");
}
// check children
checkChildren(nodeService.getChildAssocs(nodeRef));
}
}
}
}

View File

@@ -0,0 +1,104 @@
/*
* Copyright (C) 2005-2013 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect;
import java.io.Serializable;
import java.util.Map;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService;
import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
import org.alfresco.module.org_alfresco_module_rm.security.FilePlanAuthenticationService;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
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.RunAsWork;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.PropertyMap;
/**
* rma:ghosted behaviour bean
*
* @author Roy Wetherall
* @since 2.2
*/
@BehaviourBean
(
defaultType = "rma:vitalRecordDefinition"
)
public class VitalRecordDefinitionAspect extends BaseBehaviourBean
implements NodeServicePolicies.OnUpdatePropertiesPolicy
{
/** file plan authentication service */
protected FilePlanAuthenticationService filePlanAuthenticationService;
/** records management action service */
protected RecordsManagementActionService recordsManagementActionService;
/**
* @param filePlanAuthenticationService file plan authentication service
*/
public void setFilePlanAuthenticationService(FilePlanAuthenticationService filePlanAuthenticationService)
{
this.filePlanAuthenticationService = filePlanAuthenticationService;
}
/**
* @param recordsManagementActionService records management action service
*/
public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService)
{
this.recordsManagementActionService = recordsManagementActionService;
}
/**
* @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map)
*/
@Override
@Behaviour
(
kind = BehaviourKind.CLASS,
notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT
)
public void onUpdateProperties(final NodeRef nodeRef, Map<QName, Serializable> before, Map<QName, Serializable> after)
{
if (nodeService.exists(nodeRef) == true &&
nodeService.hasAspect(nodeRef, ASPECT_FILE_PLAN_COMPONENT) == true)
{
// check that vital record definition has been changed in the first place
Map<QName, Serializable> changedProps = PropertyMap.getChangedProperties(before, after);
if (changedProps.containsKey(PROP_VITAL_RECORD_INDICATOR) == true ||
changedProps.containsKey(PROP_REVIEW_PERIOD) == true)
{
filePlanAuthenticationService.runAsRmAdmin(new RunAsWork<Void>()
{
@Override
public Void doWork() throws Exception
{
recordsManagementActionService.executeRecordsManagementAction(nodeRef, "broadcastVitalRecordDefinition");
return null;
}}
);
}
}
}
}

View File

@@ -28,6 +28,7 @@ import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
import org.alfresco.module.org_alfresco_module_rm.model.behaviour.RecordsManagementSearchBehaviour;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService;
import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService;
import org.alfresco.repo.copy.CopyBehaviourCallback;
import org.alfresco.repo.copy.CopyDetails;
import org.alfresco.repo.copy.DefaultCopyBehaviourCallback;
@@ -37,6 +38,7 @@ 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.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
@@ -74,6 +76,9 @@ public class RecordFolderType extends BaseBehaviourBean
/** disposition service */
private DispositionService dispositionService;
/** vital record service */
protected VitalRecordService vitalRecordService;
/**
* @param recordService record service
*/
@@ -98,6 +103,14 @@ public class RecordFolderType extends BaseBehaviourBean
this.dispositionService = dispositionService;
}
/**
* @param vitalRecordService vital record service
*/
public void setVitalRecordService(VitalRecordService vitalRecordService)
{
this.vitalRecordService = vitalRecordService;
}
/**
* Record folder move behaviour
*
@@ -242,6 +255,42 @@ public class RecordFolderType extends BaseBehaviourBean
}
}
/**
* On transaction commit
*
* @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean)
*/
@Behaviour
(
kind = BehaviourKind.ASSOCIATION,
policy = "alf:onCreateChildAssociation",
notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT
)
public void onCreateChildAssociationOnCommit(ChildAssociationRef childAssocRef, boolean bNew)
{
final NodeRef recordFolder = childAssocRef.getChildRef();
behaviourFilter.disableBehaviour();
try
{
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
{
@Override
public Void doWork() throws Exception
{
// setup vital record definition
vitalRecordService.setupVitalRecordDefinition(recordFolder);
return null;
}
});
}
finally
{
behaviourFilter.enableBehaviour();
}
}
/**
* Removes unwanted aspects
*

View File

@@ -23,26 +23,14 @@ import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService;
import org.alfresco.module.org_alfresco_module_rm.security.FilePlanAuthenticationService;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.Period;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.ParameterCheck;
import org.alfresco.util.PropertyMap;
/**
* Vital record service interface implementation.
@@ -51,21 +39,11 @@ import org.alfresco.util.PropertyMap;
* @since 2.0
*/
public class VitalRecordServiceImpl implements VitalRecordService,
RecordsManagementModel,
NodeServicePolicies.OnUpdatePropertiesPolicy,
NodeServicePolicies.OnCreateChildAssociationPolicy
RecordsManagementModel
{
/** Services */
private NodeService nodeService;
private PolicyComponent policyComponent;
private RecordsManagementActionService rmActionService;
private FilePlanAuthenticationService filePlanAuthenticationService;
private FilePlanService filePlanService;
private RecordFolderService recordFolderService;
/** Behaviours */
private JavaBehaviour onUpdateProperties;
private JavaBehaviour onCreateChildAssociation;
/**
* @param nodeService node service
@@ -75,27 +53,6 @@ public class VitalRecordServiceImpl implements VitalRecordService,
this.nodeService = nodeService;
}
/**
* @param policyComponent policy component
*/
public void setPolicyComponent(PolicyComponent policyComponent)
{
this.policyComponent = policyComponent;
}
/**
* @param rmActionService records management action service
*/
public void setRecordsManagementActionService(RecordsManagementActionService rmActionService)
{
this.rmActionService = rmActionService;
}
public void setFilePlanAuthenticationService(FilePlanAuthenticationService filePlanAuthenticationService)
{
this.filePlanAuthenticationService = filePlanAuthenticationService;
}
/**
* @param filePlanService file plan service
*/
@@ -104,98 +61,6 @@ public class VitalRecordServiceImpl implements VitalRecordService,
this.filePlanService = filePlanService;
}
/**
* @param recordFolderService
*/
public void setRecordFolderService(RecordFolderService recordFolderService)
{
this.recordFolderService = recordFolderService;
}
/**
* Init method.
*/
public void init()
{
onUpdateProperties = new JavaBehaviour(this, "onUpdateProperties", NotificationFrequency.TRANSACTION_COMMIT);
policyComponent.bindClassBehaviour(
NodeServicePolicies.OnUpdatePropertiesPolicy.QNAME,
ASPECT_VITAL_RECORD_DEFINITION,
onUpdateProperties);
onCreateChildAssociation = new JavaBehaviour(this, "onCreateChildAssociation", NotificationFrequency.TRANSACTION_COMMIT);
policyComponent.bindAssociationBehaviour(
NodeServicePolicies.OnCreateChildAssociationPolicy.QNAME,
TYPE_RECORD_FOLDER,
ContentModel.ASSOC_CONTAINS,
onCreateChildAssociation);
}
/**
* @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map)
*/
@Override
public void onUpdateProperties(final NodeRef nodeRef, Map<QName, Serializable> before, Map<QName, Serializable> after)
{
if (nodeService.exists(nodeRef) == true &&
nodeService.hasAspect(nodeRef, ASPECT_FILE_PLAN_COMPONENT) == true)
{
// check that vital record definition has been changed in the first place
Map<QName, Serializable> changedProps = PropertyMap.getChangedProperties(before, after);
if (changedProps.containsKey(PROP_VITAL_RECORD_INDICATOR) == true ||
changedProps.containsKey(PROP_REVIEW_PERIOD) == true)
{
filePlanAuthenticationService.runAsRmAdmin(new RunAsWork<Void>()
{
@Override
public Void doWork() throws Exception
{
rmActionService.executeRecordsManagementAction(nodeRef, "broadcastVitalRecordDefinition");
return null;
}}
);
}
}
}
/**
* @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean)
*/
public void onCreateChildAssociation(ChildAssociationRef childAssociationRef, boolean bNew)
{
if (childAssociationRef != null)
{
final NodeRef nodeRef = childAssociationRef.getChildRef();
if (nodeService.exists(nodeRef) == true)
{
onCreateChildAssociation.disable();
onUpdateProperties.disable();
try
{
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
{
@Override
public Void doWork() throws Exception
{
if (filePlanService.isRecordCategory(nodeRef) == true ||
recordFolderService.isRecordFolder(nodeRef) == true)
{
setupVitalRecordDefinition(nodeRef);
}
return null;
}
});
}
finally
{
onCreateChildAssociation.enable();
onUpdateProperties.enable();
}
}
}
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService#setupVitalRecordDefinition(org.alfresco.service.cmr.repository.NodeRef)
*/