RM-1098: RM behvaiour refactoring

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@58640 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2013-12-06 00:35:57 +00:00
parent 077f5839f4
commit a5fcf3ff1e
8 changed files with 179 additions and 230 deletions

View File

@@ -121,14 +121,12 @@
<property name="referenceName" value="{http://www.alfresco.org/model/rmcustom/1.0}supersedes"/>
<property name="dispositionService" ref="dispositionService"/>
<property name="recordsManagementActionService" ref="recordsManagementActionService"/>
<property name="policyComponent" ref="policyComponent"/>
</bean>
<bean id="rmEventType.obsolete" class="org.alfresco.module.org_alfresco_module_rm.event.OnReferenceCreateEventType" parent="rmEventType">
<property name="referenceName" value="{http://www.alfresco.org/model/rmcustom/1.0}obsoletes"/>
<property name="dispositionService" ref="dispositionService"/>
<property name="recordsManagementActionService" ref="recordsManagementActionService"/>
<property name="policyComponent" ref="policyComponent"/>
</bean>
<bean id="rmEventType.crossReferencedRecordTransfered" class="org.alfresco.module.org_alfresco_module_rm.event.OnReferencedRecordActionedUpon" parent="rmEventType">
@@ -138,7 +136,6 @@
<property name="dispositionService" ref="dispositionService"/>
<property name="recordsManagementAdminService" ref="recordsManagementAdminService"/>
<property name="recordsManagementActionService" ref="recordsManagementActionService"/>
<property name="policyComponent" ref="policyComponent"/>
<property name="recordService" ref="recordService" />
<property name="recordFolderService" ref="RecordFolderService"/>
</bean>

View File

@@ -133,6 +133,10 @@
<property name="recordsManagementActionService" ref="RecordsManagementActionService"/>
<property name="filePlanAuthenticationService" ref="FilePlanAuthenticationService" />
</bean>
<bean id="rma.extendedSecurity" class="org.alfresco.module.org_alfresco_module_rm.model.rma.aspect.ExtendedSecurityAspect" parent="rm.baseBehaviour">
<property name="extendedSecurityService" ref="ExtendedSecurityService"/>
</bean>
<!-- Base bean definition for customisable types bootstrap -->
<bean id="customisableTypesBootstrap"

View File

@@ -632,9 +632,7 @@
<bean id="extendedSecurityService"
class="org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityServiceImpl"
init-method="init"
parent="baseService">
<property name="policyComponent" ref="policyComponent"/>
<property name="recordService" ref="recordService"/>
<property name="nodeService" ref="nodeService"/>
<property name="filePlanService" ref="filePlanService" />
@@ -673,12 +671,10 @@
<bean id="modelSecurityService"
class="org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityServiceImpl"
init-method="init">
parent = "rm.baseBehaviour">
<property name="enabled" value="true" />
<property name="policyComponent" ref="policyComponent" />
<property name="nodeService" ref="NodeService" />
<property name="namespaceService" ref="namespaceService" />
<property name="filePlanService" ref="FilePlanService" />
<property name="namespaceService" ref="namespaceService" />
<property name="filePlanService" ref="FilePlanService" />
</bean>
<bean id="ModelSecurityService" class="org.springframework.aop.framework.ProxyFactoryBean">

View File

@@ -24,7 +24,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnCreateReference;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService;
import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction;
@@ -32,8 +31,9 @@ import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
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.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
@@ -43,6 +43,7 @@ import org.alfresco.service.namespace.QName;
*
* @author Roy Wetherall
*/
@BehaviourBean
public class OnReferenceCreateEventType extends SimpleRecordsManagementEventTypeImpl
implements RecordsManagementModel,
OnCreateReference
@@ -53,9 +54,6 @@ public class OnReferenceCreateEventType extends SimpleRecordsManagementEventType
/** Disposition service */
private DispositionService dispositionService;
/** Policy component */
private PolicyComponent policyComponent;
/** Reference */
private QName reference;
@@ -75,16 +73,6 @@ public class OnReferenceCreateEventType extends SimpleRecordsManagementEventType
this.recordsManagementActionService = recordsManagementActionService;
}
/**
* Set policy components
*
* @param policyComponent policy component
*/
public void setPolicyComponent(PolicyComponent policyComponent)
{
this.policyComponent = policyComponent;
}
/**
* Set the reference
*
@@ -95,19 +83,6 @@ public class OnReferenceCreateEventType extends SimpleRecordsManagementEventType
this.reference = QName.createQName(reference);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.event.SimpleRecordsManagementEventTypeImpl#init()
*/
public void init()
{
super.init();
// Register interest in the on create reference policy
policyComponent.bindClassBehaviour(RecordsManagementPolicies.ON_CREATE_REFERENCE,
ASPECT_RECORD,
new JavaBehaviour(this, "onCreateReference", NotificationFrequency.TRANSACTION_COMMIT));
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.event.SimpleRecordsManagementEventTypeImpl#isAutomaticEvent()
*/
@@ -120,6 +95,13 @@ public class OnReferenceCreateEventType extends SimpleRecordsManagementEventType
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnCreateReference#onCreateReference(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
*/
@Override
@Behaviour
(
kind = BehaviourKind.CLASS,
type = "rma:record",
notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT
)
public void onCreateReference(final NodeRef fromNodeRef, final NodeRef toNodeRef, final QName reference)
{
AuthenticationUtil.RunAsWork<Object> work = new AuthenticationUtil.RunAsWork<Object>()

View File

@@ -24,7 +24,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService;
import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction;
import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService;
@@ -34,8 +33,9 @@ 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.policy.Behaviour.NotificationFrequency;
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.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
@@ -49,6 +49,7 @@ import org.alfresco.service.namespace.RegexQNamePattern;
*
* @author Roy Wetherall
*/
@BehaviourBean
public class OnReferencedRecordActionedUpon extends SimpleRecordsManagementEventTypeImpl
implements RecordsManagementModel
@@ -65,9 +66,6 @@ public class OnReferencedRecordActionedUpon extends SimpleRecordsManagementEvent
/** Node service */
private NodeService nodeService;
/** Policy component */
private PolicyComponent policyComponent;
/** Record service */
private RecordService recordService;
@@ -128,14 +126,6 @@ public class OnReferencedRecordActionedUpon extends SimpleRecordsManagementEvent
this.recordFolderService = recordFolderService;
}
/**
* @param policyComponent policy component
*/
public void setPolicyComponent(PolicyComponent policyComponent)
{
this.policyComponent = policyComponent;
}
/**
* @param reference reference name
*/
@@ -152,19 +142,6 @@ public class OnReferencedRecordActionedUpon extends SimpleRecordsManagementEvent
this.actionName = actionName;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.event.SimpleRecordsManagementEventTypeImpl#init()
*/
public void init()
{
super.init();
// Register interest in the on create reference policy
policyComponent.bindClassBehaviour(RecordsManagementPolicies.BEFORE_RM_ACTION_EXECUTION,
ASPECT_FILE_PLAN_COMPONENT,
new JavaBehaviour(this, "beforeActionExecution", NotificationFrequency.FIRST_EVENT));
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.event.SimpleRecordsManagementEventTypeImpl#isAutomaticEvent()
*/
@@ -181,6 +158,12 @@ public class OnReferencedRecordActionedUpon extends SimpleRecordsManagementEvent
* @param name
* @param parameters
*/
@Behaviour
(
kind = BehaviourKind.CLASS,
type = "rma:filePlanComponent",
notificationFrequency = NotificationFrequency.FIRST_EVENT
)
public void beforeActionExecution(final NodeRef nodeRef, final String name, final Map<String, Serializable> parameters)
{
AuthenticationUtil.RunAsWork<Object> work = new AuthenticationUtil.RunAsWork<Object>()

View File

@@ -0,0 +1,92 @@
/*
* 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.Set;
import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService;
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.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* rma:extendedSecurity behaviour bean
*
* @author Roy Wetherall
* @since 2.2
*/
@BehaviourBean
(
defaultType = "rma:extendedSecurity"
)
public class ExtendedSecurityAspect extends BaseBehaviourBean
implements NodeServicePolicies.OnMoveNodePolicy
{
/** extended security service */
protected ExtendedSecurityService extendedSecurityService;
/**
* @param extendedSecurityService extended security service
*/
public void setExtendedSecurityService(ExtendedSecurityService extendedSecurityService)
{
this.extendedSecurityService = extendedSecurityService;
}
/**
* Update extended security when moving a node.
*
* @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,
notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT
)
public void onMoveNode(final ChildAssociationRef origAssoc, final ChildAssociationRef newAssoc)
{
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
{
@Override
public Void doWork() throws Exception
{
NodeRef record = newAssoc.getChildRef();
NodeRef newParent = newAssoc.getParentRef();
NodeRef oldParent = origAssoc.getParentRef();
Set<String> readers = extendedSecurityService.getExtendedReaders(record);
Set<String> writers = extendedSecurityService.getExtendedWriters(record);
extendedSecurityService.addExtendedSecurity(newParent, readers, writers);
extendedSecurityService.removeExtendedSecurity(oldParent, readers, writers);
return null;
}
});
}
}

View File

@@ -26,14 +26,13 @@ import java.util.Set;
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
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.model.BaseBehaviourBean;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;
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.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
@@ -48,8 +47,9 @@ import org.alfresco.util.EqualsHelper;
* @author Roy Wetherall
* @since 2.1
*/
public class ModelSecurityServiceImpl implements ModelSecurityService,
RecordsManagementModel,
@BehaviourBean
public class ModelSecurityServiceImpl extends BaseBehaviourBean
implements ModelSecurityService,
NodeServicePolicies.BeforeAddAspectPolicy,
NodeServicePolicies.BeforeRemoveAspectPolicy,
NodeServicePolicies.OnUpdatePropertiesPolicy
@@ -57,12 +57,6 @@ public class ModelSecurityServiceImpl implements ModelSecurityService,
/** Indicates whether model security is enabled or not */
private boolean enabled = true;
/** Policy component */
private PolicyComponent policyComponent;
/** Node service */
private NodeService nodeService;
/** Namespace service */
private NamespaceService namespaceService;
@@ -75,17 +69,6 @@ public class ModelSecurityServiceImpl implements ModelSecurityService,
/** Map of protected aspects keyed by name */
private Map<QName, ProtectedAspect> protectedAspects= new HashMap<QName, ProtectedAspect>(21);
/** Behaviour instances */
private JavaBehaviour beforeAddAspectBehaviour = new JavaBehaviour(this,
"beforeAddAspect",
NotificationFrequency.EVERY_EVENT);
private JavaBehaviour beforeRemoveAspectBehaviour = new JavaBehaviour(this,
"beforeRemoveAspect",
NotificationFrequency.EVERY_EVENT);
private JavaBehaviour onUpdatePropertiesBehaviour = new JavaBehaviour(this,
"onUpdateProperties",
NotificationFrequency.EVERY_EVENT);
/**
* @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#setEnabled(boolean)
*/
@@ -102,22 +85,6 @@ public class ModelSecurityServiceImpl implements ModelSecurityService,
return enabled;
}
/**
* @param policyComponent policy component
*/
public void setPolicyComponent(PolicyComponent policyComponent)
{
this.policyComponent = policyComponent;
}
/**
* @param nodeService node service
*/
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
/**
* @param namespaceService namespace service
*/
@@ -133,26 +100,6 @@ public class ModelSecurityServiceImpl implements ModelSecurityService,
{
this.filePlanService = filePlanService;
}
/**
* Init method
*/
public void init()
{
// bind model security behaviours to all records management artifacts components
policyComponent.bindClassBehaviour(
NodeServicePolicies.BeforeAddAspectPolicy.QNAME,
this,
beforeAddAspectBehaviour);
policyComponent.bindClassBehaviour(
NodeServicePolicies.BeforeRemoveAspectPolicy.QNAME,
this,
beforeRemoveAspectBehaviour);
policyComponent.bindClassBehaviour(
NodeServicePolicies.OnUpdatePropertiesPolicy.QNAME,
this,
onUpdatePropertiesBehaviour);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#disable()
@@ -160,9 +107,9 @@ public class ModelSecurityServiceImpl implements ModelSecurityService,
@Override
public void disable()
{
beforeAddAspectBehaviour.disable();
beforeRemoveAspectBehaviour.disable();
onUpdatePropertiesBehaviour.disable();
getBehaviour("beforeAddAspect").disable();
getBehaviour("beforeRemoveAspect").disable();
getBehaviour("onUpdateProperties").disable();
}
/**
@@ -171,9 +118,9 @@ public class ModelSecurityServiceImpl implements ModelSecurityService,
@Override
public void enable()
{
beforeAddAspectBehaviour.enable();
beforeRemoveAspectBehaviour.enable();
onUpdatePropertiesBehaviour.enable();
getBehaviour("beforeAddAspect").enable();
getBehaviour("beforeRemoveAspect").enable();
getBehaviour("onUpdateProperties").enable();
}
/**
@@ -322,6 +269,12 @@ public class ModelSecurityServiceImpl implements ModelSecurityService,
* @see org.alfresco.repo.node.NodeServicePolicies.BeforeAddAspectPolicy#beforeAddAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
*/
@Override
@Behaviour
(
kind = BehaviourKind.CLASS,
isService = true,
name = "beforeAddAspect"
)
public void beforeAddAspect(NodeRef nodeRef, QName aspect)
{
if (enabled == true)
@@ -345,6 +298,12 @@ public class ModelSecurityServiceImpl implements ModelSecurityService,
* @see org.alfresco.repo.node.NodeServicePolicies.BeforeRemoveAspectPolicy#beforeRemoveAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
*/
@Override
@Behaviour
(
kind = BehaviourKind.CLASS,
isService = true,
name = "beforeRemoveAspect"
)
public void beforeRemoveAspect(NodeRef nodeRef, QName aspect)
{
if (enabled == true)
@@ -368,6 +327,12 @@ public class ModelSecurityServiceImpl implements ModelSecurityService,
* @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,
isService = true,
name = "onUpdateProperties"
)
public void onUpdateProperties(NodeRef nodeRef, Map<QName, Serializable> before, Map<QName, Serializable> after)
{
if (enabled == true)

View File

@@ -30,12 +30,6 @@ 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.role.FilePlanRoleService;
import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
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.security.PermissionService;
@@ -51,16 +45,12 @@ import org.alfresco.util.ParameterCheck;
*/
public class ExtendedSecurityServiceImpl extends ServiceBaseImpl
implements ExtendedSecurityService,
RecordsManagementModel,
NodeServicePolicies.OnMoveNodePolicy
RecordsManagementModel
{
/** Ad hoc properties used for reference counting */
private final static QName PROP_EXTENDED_READER_ROLE = QName.createQName(RM_URI, "extendedReaderRole");
private final static QName PROP_EXTENDED_WRITER_ROLE = QName.createQName(RM_URI, "extendedWriterRole");
/** Policy component */
private PolicyComponent policyComponent;
/** Record service */
private RecordService recordService;
@@ -70,14 +60,6 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl
/** File plan role service */
private FilePlanRoleService filePlanRoleService;
/**
* @param policyComponent policy component
*/
public void setPolicyComponent(PolicyComponent policyComponent)
{
this.policyComponent = policyComponent;
}
/**
* @param recordService record service
*/
@@ -102,17 +84,6 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl
this.filePlanRoleService = filePlanRoleService;
}
/**
* Init method
*/
public void init()
{
policyComponent.bindClassBehaviour(
NodeServicePolicies.OnMoveNodePolicy.QNAME,
ASPECT_EXTENDED_SECURITY,
new JavaBehaviour(this, "onMoveNode", NotificationFrequency.TRANSACTION_COMMIT));
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService#hasExtendedSecurity(org.alfresco.service.cmr.repository.NodeRef)
*/
@@ -181,6 +152,14 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl
}
}
/**
* Add extended security implementation method
*
* @param nodeRef
* @param readers
* @param writers
* @param applyToParents
*/
@SuppressWarnings("unchecked")
private void addExtendedSecurityImpl(NodeRef nodeRef, Set<String> readers, Set<String> writers, boolean applyToParents)
{
@@ -288,47 +267,6 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl
}
}
// private void removeExtendedSecurityRoles(NodeRef nodeRef, Set<String> readers, Set<String> writers)
// {
// NodeRef filePlan = filePlanService.getFilePlan(nodeRef);
//
// removeExtendedSecurityRolesImpl(filePlan, readers, PROP_EXTENDED_READER_ROLE, FilePlanRoleService.ROLE_EXTENDED_READERS);
// removeExtendedSecurityRolesImpl(filePlan, writers, PROP_EXTENDED_WRITER_ROLE, FilePlanRoleService.ROLE_EXTENDED_WRITERS);
// }
//
// private void removeExtendedSecurityRolesImpl(NodeRef filePlan, Set<String> authorities, QName propertyName, String roleName)
// {
// if (authorities != null)
// {
// // get the reference count
// Map<String, Integer> referenceCountMap = (Map<String, Integer>)nodeService.getProperty(filePlan, propertyName);
//
// for (String authority : authorities)
// {
// if (authority.equals(PermissionService.ALL_AUTHORITIES) == false)
// {
// if (referenceCountMap == null)
// {
// // remove the authority from the role
// filePlanRoleService.unassignRoleFromAuthority(filePlan, roleName, authority);
// }
// else
// {
// Integer count = referenceCountMap.get(authority);
// if (count == null || count == 1)
// {
// // remove the authority from the role
// filePlanRoleService.unassignRoleFromAuthority(filePlan, roleName, authority);
// }
// }
// }
// }
//
// // update the reference count
// nodeService.setProperty(filePlan, propertyName, (Serializable)removeFromMap(referenceCountMap, authorities));
// }
// }
/**
*
* @param map
@@ -364,13 +302,18 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl
return map;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService#removeExtendedSecurity(org.alfresco.service.cmr.repository.NodeRef, java.util.Set, java.util.Set)
*/
@Override
public void removeExtendedSecurity(NodeRef nodeRef, Set<String> readers, Set<String> writers)
{
removeExtendedSecurity(nodeRef, readers, writers, true);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService#removeExtendedSecurity(org.alfresco.service.cmr.repository.NodeRef, java.util.Set, java.util.Set, boolean)
*/
@Override
public void removeExtendedSecurity(NodeRef nodeRef, Set<String> readers, Set<String>writers, boolean applyToParents)
{
@@ -428,6 +371,13 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl
}
}
/**
* Helper method to remove items from map or reduce reference count
*
* @param map ref count map
* @param keys keys
* @return Map<String, Integer> ref count map
*/
private Map<String, Integer> removeFromMap(Map<String, Integer> map, Set<String> keys)
{
if (map != null && keys != null && keys.size() != 0)
@@ -464,12 +414,18 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl
return map;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService#removeAllExtendedSecurity(org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
public void removeAllExtendedSecurity(NodeRef nodeRef)
{
removeAllExtendedSecurity(nodeRef, true);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService#removeAllExtendedSecurity(org.alfresco.service.cmr.repository.NodeRef, boolean)
*/
@Override
public void removeAllExtendedSecurity(NodeRef nodeRef, boolean applyToParents)
{
@@ -478,30 +434,4 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl
removeExtendedSecurity(nodeRef, getExtendedReaders(nodeRef), getExtendedWriters(nodeRef));
}
}
/**
* @see org.alfresco.repo.node.NodeServicePolicies.OnMoveNodePolicy#onMoveNode(org.alfresco.service.cmr.repository.ChildAssociationRef, org.alfresco.service.cmr.repository.ChildAssociationRef)
*/
@Override
public void onMoveNode(final ChildAssociationRef origAssoc, final ChildAssociationRef newAssoc)
{
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
{
@Override
public Void doWork() throws Exception
{
NodeRef record = newAssoc.getChildRef();
NodeRef newParent = newAssoc.getParentRef();
NodeRef oldParent = origAssoc.getParentRef();
Set<String> readers = getExtendedReaders(record);
Set<String> writers = getExtendedWriters(record);
addExtendedSecurity(newParent, readers, writers);
removeExtendedSecurity(oldParent, readers, writers);
return null;
}
});
}
}