Fix for ALF-5032: findAuthorities() getting slow when many groups are created.

- moved to PARENT driven queries where possible in preference to PATH

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@23246 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Andrew Hind
2010-10-25 09:40:00 +00:00
parent 1856b4eeae
commit d6ab28e189

View File

@@ -360,16 +360,38 @@ public class AuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.Befor
}
if (parentAuthority != null)
{
query.append(" AND PATH:\"/sys:system/sys:authorities/cm:").append(ISO9075.encode(parentAuthority));
if (!immediate)
if(immediate)
{
query.append('/');
// use PARENT
NodeRef parentAuthorityNodeRef = getAuthorityNodeRefOrNull(parentAuthority);
if(parentAuthorityNodeRef != null)
{
query.append(" AND PARENT:\"").append(LuceneQueryParser.escape(parentAuthorityNodeRef.toString())).append("\"");
}
else
{
throw new UnknownAuthorityException("An authority was not found for " + parentAuthority);
}
}
else
{
// use PATH
query.append(" AND PATH:\"/sys:system/sys:authorities/cm:").append(ISO9075.encode(parentAuthority));
query.append("//*\"");
}
query.append("/*\"");
}
if (zoneName != null)
{
query.append(" AND PATH:\"/sys:system/sys:zones/cm:").append(ISO9075.encode(zoneName)).append("/*\"");
// Zones are all direct links to those within so it is safe to use PARENT to look them up
NodeRef zoneNodeRef = getZone(zoneName);
if (zoneNodeRef != null)
{
query.append(" AND PARENT:\"").append(LuceneQueryParser.escape(zoneNodeRef.toString())).append("\"");
}
else
{
throw new UnknownAuthorityException("A zone was not found for " + zoneName);
}
}
sp.setQuery(query.toString());
sp.setMaxItems(100);