mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-747 - PermissionService.hasPermission() takes longer as the user's group membership increases
- improved use of parentAssocsCache git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@22685 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -2622,6 +2622,8 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO
|
|||||||
return parentAssocs.getPrimaryParentAssoc();
|
return parentAssocs.getPrimaryParentAssoc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final int PARENT_ASSOCS_CACHE_FILTER_THRESHOLD = 2000;
|
||||||
|
|
||||||
public void getParentAssocs(
|
public void getParentAssocs(
|
||||||
Long childNodeId,
|
Long childNodeId,
|
||||||
QName assocTypeQName,
|
QName assocTypeQName,
|
||||||
@@ -2629,9 +2631,9 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO
|
|||||||
Boolean isPrimary,
|
Boolean isPrimary,
|
||||||
ChildAssocRefQueryCallback resultsCallback)
|
ChildAssocRefQueryCallback resultsCallback)
|
||||||
{
|
{
|
||||||
// Do we go for the cache or do we have to query
|
|
||||||
if (assocTypeQName == null && assocQName == null && isPrimary == null)
|
if (assocTypeQName == null && assocQName == null && isPrimary == null)
|
||||||
{
|
{
|
||||||
|
// Go for the cache (and return all)
|
||||||
ParentAssocsInfo parentAssocs = getParentAssocsCached(childNodeId);
|
ParentAssocsInfo parentAssocs = getParentAssocsCached(childNodeId);
|
||||||
for (ChildAssocEntity assoc : parentAssocs.getParentAssocs().values())
|
for (ChildAssocEntity assoc : parentAssocs.getParentAssocs().values())
|
||||||
{
|
{
|
||||||
@@ -2643,8 +2645,31 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// Decide whether we query or filter
|
||||||
|
ParentAssocsInfo parentAssocs = getParentAssocsCacheOnly(childNodeId);
|
||||||
|
if ((parentAssocs == null) || (parentAssocs.getParentAssocs().size() > PARENT_ASSOCS_CACHE_FILTER_THRESHOLD))
|
||||||
|
{
|
||||||
|
// Query
|
||||||
selectParentAssocs(childNodeId, assocTypeQName, assocQName, isPrimary, resultsCallback);
|
selectParentAssocs(childNodeId, assocTypeQName, assocQName, isPrimary, resultsCallback);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Go for the cache (and filter)
|
||||||
|
for (ChildAssocEntity assoc : parentAssocs.getParentAssocs().values())
|
||||||
|
{
|
||||||
|
Pair<Long, ChildAssociationRef> assocPair = assoc.getPair(qnameDAO);
|
||||||
|
if (((assocTypeQName == null) || (assocPair.getSecond().getTypeQName().equals(assocTypeQName))) &&
|
||||||
|
((assocQName == null) || (assocPair.getSecond().getQName().equals(assocQName))))
|
||||||
|
{
|
||||||
|
resultsCallback.handle(
|
||||||
|
assocPair,
|
||||||
|
assoc.getParentNode().getNodePair(),
|
||||||
|
assoc.getChildNode().getNodePair());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Path> getPaths(Pair<Long, NodeRef> nodePair, boolean primaryOnly) throws InvalidNodeRefException
|
public List<Path> getPaths(Pair<Long, NodeRef> nodePair, boolean primaryOnly) throws InvalidNodeRefException
|
||||||
@@ -2831,6 +2856,12 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO
|
|||||||
return cacheEntry.getSecond();
|
return cacheEntry.getSecond();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ParentAssocsInfo getParentAssocsCacheOnly(Long nodeId)
|
||||||
|
{
|
||||||
|
// can be null
|
||||||
|
return parentAssocsCache.getValue(nodeId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a node's parent associations.
|
* Update a node's parent associations.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user