mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Improvement to AuthorityDAOImpl to not perform pointless checks (DB getChildAssoc query) to see if a ROLE_ is a person, it never can be and null results aren't cached. This saves a DB query at the start of many REST API calls (as authenticated WS calls first check isGuest() etc.).
YourKit profiler results for Share READ heavy multi-user JMeter test: Before: 220s After: 200s Specifically; org.alfresco.repo.security.authority.AuthorityServiceImpl.hasGuestAuthority() - before 26.7s - after 0.041s Unit tests run: org.alfresco.repo.security.SecurityTestSuite org.alfresco.repo.security.authentication.*Test org.alfresco.repo.security.authority.*Test org.alfresco.repo.security.person.PersonTest git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@55761 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1260,34 +1260,33 @@ public class AuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.Befor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private NodeRef getAuthorityOrNull(String name)
|
private NodeRef getAuthorityOrNull(final String name)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (AuthorityType.getAuthorityType(name).equals(AuthorityType.USER))
|
final AuthorityType authType = AuthorityType.getAuthorityType(name);
|
||||||
|
switch (authType)
|
||||||
{
|
{
|
||||||
return personService.getPerson(name, false);
|
case USER:
|
||||||
}
|
return personService.getPerson(name, false);
|
||||||
else if (AuthorityType.getAuthorityType(name).equals(AuthorityType.GUEST))
|
case GUEST:
|
||||||
{
|
case ADMIN:
|
||||||
return personService.getPerson(name, false);
|
case EVERYONE:
|
||||||
}
|
case OWNER:
|
||||||
else if (AuthorityType.getAuthorityType(name).equals(AuthorityType.ADMIN))
|
return null;
|
||||||
{
|
default:
|
||||||
return personService.getPerson(name, false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Pair <String, String> cacheKey = cacheKey(name);
|
|
||||||
NodeRef result = authorityLookupCache.get(cacheKey);
|
|
||||||
if (result == null)
|
|
||||||
{
|
{
|
||||||
List<ChildAssociationRef> results = nodeService.getChildAssocs(getAuthorityContainer(),
|
Pair <String, String> cacheKey = cacheKey(name);
|
||||||
ContentModel.ASSOC_CHILDREN, QName.createQName("cm", name, namespacePrefixResolver), false);
|
NodeRef result = authorityLookupCache.get(cacheKey);
|
||||||
result = results.isEmpty() ? NULL_NODEREF :results.get(0).getChildRef();
|
if (result == null)
|
||||||
authorityLookupCache.put(cacheKey, result);
|
{
|
||||||
|
List<ChildAssociationRef> results = nodeService.getChildAssocs(getAuthorityContainer(),
|
||||||
|
ContentModel.ASSOC_CHILDREN, QName.createQName("cm", name, namespacePrefixResolver), false);
|
||||||
|
result = results.isEmpty() ? NULL_NODEREF :results.get(0).getChildRef();
|
||||||
|
authorityLookupCache.put(cacheKey, result);
|
||||||
|
}
|
||||||
|
return result.equals(NULL_NODEREF) ? null : result;
|
||||||
}
|
}
|
||||||
return result.equals(NULL_NODEREF) ? null : result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (NoSuchPersonException e)
|
catch (NoSuchPersonException e)
|
||||||
|
Reference in New Issue
Block a user