From 966dfd2566defef9d35e1866054a5f1d77dbf8f3 Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Fri, 14 Sep 2012 10:07:01 +0000 Subject: [PATCH] =?UTF-8?q?Community=20profiling=20-=20repository=20contai?= =?UTF-8?q?ner=20WebScript=20auth=20txn=20improvements:=20=20-=20Fix=20to?= =?UTF-8?q?=20return=20null=20when=20a=20ROLE=5F=20authority=20is=20reques?= =?UTF-8?q?ted=20from=20AuthorityDAO=20-=20was=20making=20needless=20query?= =?UTF-8?q?=20to=20DB=20that=20always=20returned=20empty=20and=20missing?= =?UTF-8?q?=20caches=20due=20to=20null=20return=20value=20=20-=20Repositor?= =?UTF-8?q?yContainer=20improvements=20-=20reduce=20number=20of=20txns=20r?= =?UTF-8?q?equired=20during=20init=20from=202=20to=201,=20optimized=20code?= =?UTF-8?q?=20path=20when=20runAs()=20user=20is=20the=20same=20as=20curren?= =?UTF-8?q?tly=20authenticated=20user=20=20-=20Optimized=20code=20paths=20?= =?UTF-8?q?through=20hot=20Dictionary/Namespace=20methods=20when=20MT=20is?= =?UTF-8?q?=20disabled=20=20-=20Javadoc=20corrections=20=20-=20small=20mea?= =?UTF-8?q?surable=20difference=20to=20large=20scale=20Share=20test=20=20-?= =?UTF-8?q?=20notable=20improvement=20to=20=E2=80=9Cshort=E2=80=9D=20websc?= =?UTF-8?q?ript=20tests=20=E2=80=93=20round=20trip=20time=20for=20a=20sing?= =?UTF-8?q?le=20low=20impact=20WebScript=20request=20improved?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@41585 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../security/authority/AuthorityDAOImpl.java | 10 +++------- .../security/authority/AuthorityServiceImpl.java | 16 +++++++++------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/source/java/org/alfresco/repo/security/authority/AuthorityDAOImpl.java b/source/java/org/alfresco/repo/security/authority/AuthorityDAOImpl.java index 08c246f524..a095063d3f 100644 --- a/source/java/org/alfresco/repo/security/authority/AuthorityDAOImpl.java +++ b/source/java/org/alfresco/repo/security/authority/AuthorityDAOImpl.java @@ -1026,7 +1026,7 @@ public class AuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.Befor } } - private NodeRef getAuthorityOrNull(String name) + private NodeRef getAuthorityOrNull(final String name) { try { @@ -1034,13 +1034,9 @@ public class AuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.Befor { return personService.getPerson(name, false); } - else if (AuthorityType.getAuthorityType(name).equals(AuthorityType.GUEST)) + else if (AuthorityType.getAuthorityType(name).equals(AuthorityType.GUEST) || AuthorityType.getAuthorityType(name).equals(AuthorityType.ADMIN)) { - return personService.getPerson(name, false); - } - else if (AuthorityType.getAuthorityType(name).equals(AuthorityType.ADMIN)) - { - return personService.getPerson(name, false); + return null; } else { diff --git a/source/java/org/alfresco/repo/security/authority/AuthorityServiceImpl.java b/source/java/org/alfresco/repo/security/authority/AuthorityServiceImpl.java index d732b13853..3beb8fac9b 100644 --- a/source/java/org/alfresco/repo/security/authority/AuthorityServiceImpl.java +++ b/source/java/org/alfresco/repo/security/authority/AuthorityServiceImpl.java @@ -199,7 +199,7 @@ public class AuthorityServiceImpl implements AuthorityService, InitializingBean canonicalName = authorityName; } - // Determine whether the administrator role is mapped to this user or one of their groups + // Determine whether the guest role is mapped to this user or one of their groups return getAuthoritiesForUser(canonicalName).contains(PermissionService.GUEST_AUTHORITY); } @@ -286,18 +286,20 @@ public class AuthorityServiceImpl implements AuthorityService, InitializingBean tenantService.getBaseNameUser(currentUserName).equalsIgnoreCase(AuthenticationUtil.getGuestUserName())) { isGuestUser = true; - } // Check if any of the user's groups are listed as guest groups if (!isAdminUser && !isGuestUser) { - for (String authority : guestGroups) + if (guestGroups.size() != 0) { - if (hasAuthority(currentUserName, authority) || hasAuthority(currentUserName, tenantService.getBaseNameUser(authority))) + for (String authority : guestGroups) { - isGuestUser = true; - break; + if (hasAuthority(currentUserName, authority) || hasAuthority(currentUserName, tenantService.getBaseNameUser(authority))) + { + isGuestUser = true; + break; + } } } } @@ -310,7 +312,7 @@ public class AuthorityServiceImpl implements AuthorityService, InitializingBean // Give all non-guest users the ALL authorities if (!isGuestUser) { - authorities.addAll(allSet); + authorities.addAll(allSet); } else {