mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
Merged DEV to HEAD (5.1)
110000: MNT-13836: Custom behaviours cannot be disabled (using disableBehaviour(QName)) - Changed class policies enabled/disabled checks. Now each behaviour at a given level must be explicitly disabled & re-enabled (unless all behaviours are disabled in the transaction). - Added JUnit tests. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@110119 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -20,6 +20,7 @@ package org.alfresco.repo.policy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
@@ -161,28 +162,16 @@ import org.alfresco.util.LockHelper;
|
||||
{
|
||||
List<BehaviourDefinition> behaviours = new ArrayList<BehaviourDefinition>();
|
||||
|
||||
// Determine if behaviour has been disabled
|
||||
boolean isEnabled = true;
|
||||
if (filter != null)
|
||||
// Find class behaviour by scanning up the class hierarchy
|
||||
List<BehaviourDefinition<B>> behaviour = null;
|
||||
while (binding != null)
|
||||
{
|
||||
NodeRef nodeRef = binding.getNodeRef();
|
||||
QName className = binding.getClassQName();
|
||||
isEnabled = (nodeRef == null) ? filter.isEnabled(className) : filter.isEnabled(nodeRef, className);
|
||||
}
|
||||
|
||||
if (isEnabled)
|
||||
{
|
||||
// Find class behaviour by scanning up the class hierarchy
|
||||
List<BehaviourDefinition<B>> behaviour = null;
|
||||
while (binding != null)
|
||||
behaviour = classMap.get(binding);
|
||||
if (behaviour != null && isEnabled(binding))
|
||||
{
|
||||
behaviour = classMap.get(binding);
|
||||
if (behaviour != null)
|
||||
{
|
||||
behaviours.addAll(0, behaviour); // note: list base/generalised before extended/specific
|
||||
}
|
||||
binding = (B)binding.generaliseBinding();
|
||||
behaviours.addAll(0, behaviour); // note: list base/generalised before extended/specific
|
||||
}
|
||||
binding = (B)binding.generaliseBinding();
|
||||
}
|
||||
|
||||
// Append all service-level behaviours
|
||||
@@ -266,4 +255,17 @@ import org.alfresco.util.LockHelper;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isEnabled(B binding)
|
||||
{
|
||||
// Determine if behaviour has been disabled
|
||||
boolean isEnabled = true;
|
||||
if (filter != null)
|
||||
{
|
||||
NodeRef nodeRef = binding.getNodeRef();
|
||||
QName className = binding.getClassQName();
|
||||
isEnabled = (nodeRef == null) ? filter.isEnabled(className) : filter.isEnabled(nodeRef, className);
|
||||
}
|
||||
|
||||
return isEnabled;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user