From a6426f716f27c815edc1178af688ed467c2202b9 Mon Sep 17 00:00:00 2001 From: Derek Hulley Date: Mon, 5 Jul 2010 11:46:40 +0000 Subject: [PATCH] SAIL-373 (SAIL-294): Enable shared cache for ACLEntity - Used by PermissionService.hasPermission - ACLCrudDAO cache names match bean names git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@20931 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/cache-context.xml | 4 -- config/alfresco/dao/dao-context.xml | 6 +- .../permissions/AbstractAclCrudDAOImpl.java | 70 +++++++++---------- 3 files changed, 38 insertions(+), 42 deletions(-) diff --git a/config/alfresco/cache-context.xml b/config/alfresco/cache-context.xml index da807c154f..151488b4cd 100644 --- a/config/alfresco/cache-context.xml +++ b/config/alfresco/cache-context.xml @@ -728,9 +728,6 @@ - - - diff --git a/config/alfresco/dao/dao-context.xml b/config/alfresco/dao/dao-context.xml index 0079d94e0d..5de38b1db8 100644 --- a/config/alfresco/dao/dao-context.xml +++ b/config/alfresco/dao/dao-context.xml @@ -225,9 +225,9 @@ - - - + + + diff --git a/source/java/org/alfresco/repo/domain/permissions/AbstractAclCrudDAOImpl.java b/source/java/org/alfresco/repo/domain/permissions/AbstractAclCrudDAOImpl.java index 483f878508..1732c99a05 100644 --- a/source/java/org/alfresco/repo/domain/permissions/AbstractAclCrudDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/permissions/AbstractAclCrudDAOImpl.java @@ -98,7 +98,7 @@ public abstract class AbstractAclCrudDAOImpl implements AclCrudDAO * VALUE: AclEntity
* VALUE KEY: None
*/ - private EntityLookupCache aclCache; + private EntityLookupCache aclEntityCache; /** * Cache for the Authority entity:
@@ -106,7 +106,7 @@ public abstract class AbstractAclCrudDAOImpl implements AclCrudDAO * VALUE: AuthorityEntity
* VALUE KEY: Name
*/ - private EntityLookupCache authorityCache; + private EntityLookupCache authorityEntityCache; /** * Cache for the Permission entity:
@@ -114,17 +114,17 @@ public abstract class AbstractAclCrudDAOImpl implements AclCrudDAO * VALUE: PermissionEntity
* VALUE KEY: PermissionEntity (compound key: qnameId + name)
*/ - private EntityLookupCache permissionCache; + private EntityLookupCache permissionEntityCache; /** * Set the cache to use for alf_access_control_list lookups (optional). * - * @param aclCache the cache of IDs to AclEntities + * @param aclEntityCache the cache of IDs to AclEntities */ - public void setAclCache(SimpleCache aclCache) + public void setAclEntityCache(SimpleCache aclEntityCache) { - this.aclCache = new EntityLookupCache( - aclCache, + this.aclEntityCache = new EntityLookupCache( + aclEntityCache, CACHE_REGION_ACL, aclEntityDaoCallback); } @@ -132,12 +132,12 @@ public abstract class AbstractAclCrudDAOImpl implements AclCrudDAO /** * Set the cache to use for alf_authority lookups (optional). * - * @param authorityCache the cache of IDs to AclEntities + * @param authorityEntityCache the cache of IDs to AclEntities */ - public void setAuthorityCache(SimpleCache authorityCache) + public void setAuthorityEntityCache(SimpleCache authorityEntityCache) { - this.authorityCache = new EntityLookupCache( - authorityCache, + this.authorityEntityCache = new EntityLookupCache( + authorityEntityCache, CACHE_REGION_AUTHORITY, authorityEntityDaoCallback); } @@ -145,12 +145,12 @@ public abstract class AbstractAclCrudDAOImpl implements AclCrudDAO /** * Set the cache to use for alf_permission lookups (optional). * - * @param permissionCache the cache of IDs to PermissionEntities + * @param permissionEntityCache the cache of IDs to PermissionEntities */ - public void setPermissionCache(SimpleCache permissionCache) + public void setPermissionEntityCache(SimpleCache permissionEntityCache) { - this.permissionCache = new EntityLookupCache( - permissionCache, + this.permissionEntityCache = new EntityLookupCache( + permissionEntityCache, CACHE_REGION_PERMISSION, permissionEntityDaoCallback); } @@ -165,13 +165,13 @@ public abstract class AbstractAclCrudDAOImpl implements AclCrudDAO public AbstractAclCrudDAOImpl() { this.aclEntityDaoCallback = new AclEntityCallbackDAO(); - this.aclCache = new EntityLookupCache(aclEntityDaoCallback); + this.aclEntityCache = new EntityLookupCache(aclEntityDaoCallback); this.authorityEntityDaoCallback = new AuthorityEntityCallbackDAO(); - this.authorityCache = new EntityLookupCache(authorityEntityDaoCallback); + this.authorityEntityCache = new EntityLookupCache(authorityEntityDaoCallback); this.permissionEntityDaoCallback = new PermissionEntityCallbackDAO(); - this.permissionCache = new EntityLookupCache(permissionEntityDaoCallback); + this.permissionEntityCache = new EntityLookupCache(permissionEntityDaoCallback); } // @@ -187,7 +187,7 @@ public abstract class AbstractAclCrudDAOImpl implements AclCrudDAO entity.setVersion(0L); - Pair entityPair = aclCache.getOrCreateByValue(entity); + Pair entityPair = aclEntityCache.getOrCreateByValue(entity); return entityPair.getSecond(); } @@ -198,7 +198,7 @@ public abstract class AbstractAclCrudDAOImpl implements AclCrudDAO private AclEntity getAclImpl(long id) { - Pair entityPair = aclCache.getByKey(id); + Pair entityPair = aclEntityCache.getByKey(id); if (entityPair == null) { return null; @@ -261,7 +261,7 @@ public abstract class AbstractAclCrudDAOImpl implements AclCrudDAO ParameterCheck.mandatory("entity.aclVersion", entity.getAclVersion()); ParameterCheck.mandatory("entity.version", entity.getVersion()); - int updated = aclCache.updateValue(entity.getId(), entity); + int updated = aclEntityCache.updateValue(entity.getId(), entity); if (updated < 1) { throw new ConcurrencyFailureException("AclEntity with ID (" + entity.getId() + ") no longer exists or has been updated concurrently"); @@ -270,13 +270,13 @@ public abstract class AbstractAclCrudDAOImpl implements AclCrudDAO public void deleteAcl(long id) { - Pair entityPair = aclCache.getByKey(id); + Pair entityPair = aclEntityCache.getByKey(id); if (entityPair == null) { return; } - int deleted = aclCache.deleteByKey(id); + int deleted = aclEntityCache.deleteByKey(id); if (deleted < 1) { throw new ConcurrencyFailureException("AclEntity with ID " + id + " no longer exists"); @@ -640,7 +640,7 @@ public abstract class AbstractAclCrudDAOImpl implements AclCrudDAO entity.setVersion(0L); - Pair entityPair = permissionCache.getOrCreateByValue(entity); + Pair entityPair = permissionEntityCache.getOrCreateByValue(entity); entity = entityPair.getSecond(); } return entity; @@ -648,7 +648,7 @@ public abstract class AbstractAclCrudDAOImpl implements AclCrudDAO public Permission getPermission(long id) { - Pair entityPair = permissionCache.getByKey(id); + Pair entityPair = permissionEntityCache.getByKey(id); if (entityPair == null) { return null; @@ -674,7 +674,7 @@ public abstract class AbstractAclCrudDAOImpl implements AclCrudDAO Long qnameId = qnamePair.getFirst(); PermissionEntity permission = new PermissionEntity(qnameId, permissionReference.getName()); - Pair entityPair = permissionCache.getByValue(permission); + Pair entityPair = permissionEntityCache.getByValue(permission); if (entityPair != null) { entity = entityPair.getSecond(); @@ -727,7 +727,7 @@ public abstract class AbstractAclCrudDAOImpl implements AclCrudDAO permission.setTypeQNameId(newTypeQNameId); permission.setName(newName); - int updated = permissionCache.updateValue(permission.getId(), permission); + int updated = permissionEntityCache.updateValue(permission.getId(), permission); if (updated < 1) { throw new ConcurrencyFailureException("PermissionEntity with ID (" + permission.getId() + ") no longer exists or has been updated concurrently"); @@ -737,13 +737,13 @@ public abstract class AbstractAclCrudDAOImpl implements AclCrudDAO public void deletePermission(long id) { - Pair entityPair = permissionCache.getByKey(id); + Pair entityPair = permissionEntityCache.getByKey(id); if (entityPair == null) { return; } - int deleted = permissionCache.deleteByKey(id); + int deleted = permissionEntityCache.deleteByKey(id); if (deleted < 1) { throw new ConcurrencyFailureException("PermissionEntity with ID " + id + " no longer exists"); @@ -829,13 +829,13 @@ public abstract class AbstractAclCrudDAOImpl implements AclCrudDAO entity.setVersion(0L); - Pair entityPair = authorityCache.getOrCreateByValue(entity); + Pair entityPair = authorityEntityCache.getOrCreateByValue(entity); return entityPair.getSecond(); } public Authority getAuthority(long id) { - Pair entityPair = authorityCache.getByKey(id); + Pair entityPair = authorityEntityCache.getByKey(id); if (entityPair == null) { return null; @@ -855,7 +855,7 @@ public abstract class AbstractAclCrudDAOImpl implements AclCrudDAO AuthorityEntity authority = new AuthorityEntity(); authority.setAuthority(authorityName); - Pair entityPair = authorityCache.getByValue(authority); + Pair entityPair = authorityEntityCache.getByValue(authority); if (entityPair == null) { return null; @@ -904,7 +904,7 @@ public abstract class AbstractAclCrudDAOImpl implements AclCrudDAO entity.setAuthority(after); entity.setCrc(CrcHelper.getStringCrcPair(after, 32, true, true).getSecond()); - int updated = authorityCache.updateValue(entity.getId(), entity); + int updated = authorityEntityCache.updateValue(entity.getId(), entity); if (updated < 1) { throw new ConcurrencyFailureException("AuthorityEntity with ID (" + entity.getId() + ") no longer exists or has been updated concurrently"); @@ -914,13 +914,13 @@ public abstract class AbstractAclCrudDAOImpl implements AclCrudDAO public void deleteAuthority(long id) { - Pair entityPair = authorityCache.getByKey(id); + Pair entityPair = authorityEntityCache.getByKey(id); if (entityPair == null) { return; } - int deleted = authorityCache.deleteByKey(id); + int deleted = authorityEntityCache.deleteByKey(id); if (deleted < 1) { throw new ConcurrencyFailureException("AuthorityEntity with ID " + id + " no longer exists");