Minor collection size tweaks, removal of unused oncreate node policy handler, cleanup.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@17046 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2009-10-20 13:48:04 +00:00
parent f8a8a7a036
commit 24792204ba
3 changed files with 14 additions and 31 deletions

View File

@@ -60,8 +60,7 @@ import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.util.EqualsHelper; import org.alfresco.util.EqualsHelper;
import org.alfresco.util.SearchLanguageConversion; import org.alfresco.util.SearchLanguageConversion;
public class AuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.OnCreateNodePolicy, NodeServicePolicies.BeforeDeleteNodePolicy, public class AuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.BeforeDeleteNodePolicy, NodeServicePolicies.OnUpdatePropertiesPolicy
NodeServicePolicies.OnUpdatePropertiesPolicy
{ {
private StoreRef storeRef; private StoreRef storeRef;
@@ -81,16 +80,16 @@ public class AuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.OnCre
private TenantService tenantService; private TenantService tenantService;
private SimpleCache<CacheKey, HashSet<String>> authorityLookupCache; private SimpleCache<CacheKey, Set<String>> authorityLookupCache;
/** System Container ref cache (Tennant aware) */ /** System Container ref cache (Tennant aware) */
private Map<String, NodeRef> systemContainerRefs = new ConcurrentHashMap<String, NodeRef>(4); private Map<String, NodeRef> systemContainerRefs = new ConcurrentHashMap<String, NodeRef>(4);
private AclDaoComponent aclDao; private AclDaoComponent aclDao;
private PolicyComponent policyComponent; private PolicyComponent policyComponent;
public AuthorityDAOImpl() public AuthorityDAOImpl()
{ {
super(); super();
@@ -119,7 +118,7 @@ public class AuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.OnCre
this.nodeService = nodeService; this.nodeService = nodeService;
} }
public void setUserToAuthorityCache(SimpleCache<CacheKey, HashSet<String>> userToAuthorityCache) public void setUserToAuthorityCache(SimpleCache<CacheKey, Set<String>> userToAuthorityCache)
{ {
this.authorityLookupCache = userToAuthorityCache; this.authorityLookupCache = userToAuthorityCache;
} }
@@ -287,11 +286,12 @@ public class AuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.OnCre
CacheKey key = new CacheKey(type, name, tenantService.getCurrentUserDomain(), false, !immediate); CacheKey key = new CacheKey(type, name, tenantService.getCurrentUserDomain(), false, !immediate);
HashSet<String> authorities = authorityLookupCache.get(key); Set<String> authorities = authorityLookupCache.get(key);
if (authorities == null) if (authorities == null)
{ {
authorities = new HashSet<String>(); authorities = new HashSet<String>(64);
findAuthorities(type, null, nodeRef, authorities, false, !immediate, false); findAuthorities(type, null, nodeRef, authorities, false, !immediate, false);
authorities = (Set<String>)Collections.unmodifiableSet(authorities);
authorityLookupCache.put(key, authorities); authorityLookupCache.put(key, authorities);
} }
return authorities; return authorities;
@@ -318,15 +318,15 @@ public class AuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.OnCre
{ {
CacheKey key = new CacheKey(type, name, tenantService.getCurrentUserDomain(), true, !immediate); CacheKey key = new CacheKey(type, name, tenantService.getCurrentUserDomain(), true, !immediate);
HashSet<String> authorities = authorityLookupCache.get(key); Set<String> authorities = authorityLookupCache.get(key);
if (authorities == null) if (authorities == null)
{ {
authorities = new HashSet<String>(); authorities = new HashSet<String>(64);
findAuthorities(type, name, authorities, true, !immediate); findAuthorities(type, name, authorities, true, !immediate);
authorities = (Set<String>)Collections.unmodifiableSet(authorities);
authorityLookupCache.put(key, authorities); authorityLookupCache.put(key, authorities);
} }
return authorities; return authorities;
} }
private void addAuthorityNameIfMatches(Set<String> authorities, String authorityName, AuthorityType type, Pattern pattern) private void addAuthorityNameIfMatches(Set<String> authorities, String authorityName, AuthorityType type, Pattern pattern)
@@ -659,7 +659,7 @@ public class AuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.OnCre
return Collections.<String> emptySet(); return Collections.<String> emptySet();
} }
Collection<ChildAssociationRef> childRefs = nodeService.getChildAssocsWithoutParentAssocsOfType(container, ContentModel.ASSOC_MEMBER); Collection<ChildAssociationRef> childRefs = nodeService.getChildAssocsWithoutParentAssocsOfType(container, ContentModel.ASSOC_MEMBER);
Set<String> authorities = new HashSet<String>(childRefs.size() * 2); Set<String> authorities = new HashSet<String>(childRefs.size() << 1);
for (ChildAssociationRef childRef : childRefs) for (ChildAssociationRef childRef : childRefs)
{ {
addAuthorityNameIfMatches(authorities, childRef.getQName().getLocalName(), type, null); addAuthorityNameIfMatches(authorities, childRef.getQName().getLocalName(), type, null);
@@ -671,7 +671,7 @@ public class AuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.OnCre
/** /**
* CacheKey class for getContainedAuthorities() parent Group cache. * CacheKey class for getContainedAuthorities() parent Group cache.
*/ */
private static class CacheKey implements Serializable private final static class CacheKey implements Serializable
{ {
private static final long serialVersionUID = -3787608436067567757L; private static final long serialVersionUID = -3787608436067567757L;
@@ -741,16 +741,6 @@ public class AuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.OnCre
} }
} }
public void onCreateNode(ChildAssociationRef childAssocRef)
{
NodeRef authRef = childAssocRef.getChildRef();
String authority = (String) this.nodeService.getProperty(authRef, ContentModel.PROP_AUTHORITY_NAME);
// Make sure there is an authority entry - with a DB constraint for uniqueness
// aclDao.createAuthority(authority);
}
public void beforeDeleteNode(NodeRef nodeRef) public void beforeDeleteNode(NodeRef nodeRef)
{ {
authorityLookupCache.clear(); authorityLookupCache.clear();
@@ -779,17 +769,13 @@ public class AuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.OnCre
throw new UnsupportedOperationException("The name of an authority can not be changed"); throw new UnsupportedOperationException("The name of an authority can not be changed");
} }
} }
} }
public void init() public void init()
{ {
this.policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode"), ContentModel.TYPE_AUTHORITY_CONTAINER, new JavaBehaviour(this,
"onCreateNode"));
this.policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "beforeDeleteNode"), ContentModel.TYPE_AUTHORITY_CONTAINER, new JavaBehaviour( this.policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "beforeDeleteNode"), ContentModel.TYPE_AUTHORITY_CONTAINER, new JavaBehaviour(
this, "beforeDeleteNode")); this, "beforeDeleteNode"));
this.policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"), ContentModel.TYPE_AUTHORITY_CONTAINER, new JavaBehaviour( this.policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"), ContentModel.TYPE_AUTHORITY_CONTAINER, new JavaBehaviour(
this, "onUpdateProperties")); this, "onUpdateProperties"));
} }
} }

View File

@@ -196,7 +196,7 @@ public class AuthorityServiceImpl implements AuthorityService, InitializingBean
public Set<String> getAuthoritiesForUser(String currentUserName) public Set<String> getAuthoritiesForUser(String currentUserName)
{ {
Set<String> authorities = new HashSet<String>(); Set<String> authorities = new HashSet<String>(64);
authorities.addAll(getContainingAuthorities(null, currentUserName, false)); authorities.addAll(getContainingAuthorities(null, currentUserName, false));

View File

@@ -748,7 +748,7 @@ public class PermissionServiceImpl implements PermissionServiceSPI, Initializing
private Set<String> getDynamicAuthorities(Authentication auth, NodeRef nodeRef, PermissionReference required) private Set<String> getDynamicAuthorities(Authentication auth, NodeRef nodeRef, PermissionReference required)
{ {
HashSet<String> auths = new HashSet<String>(); HashSet<String> auths = new HashSet<String>(64);
if (auth == null) if (auth == null)
{ {
@@ -824,7 +824,6 @@ public class PermissionServiceImpl implements PermissionServiceSPI, Initializing
{ {
permissionsDaoComponent.deletePermissions(storeRef, authority); permissionsDaoComponent.deletePermissions(storeRef, authority);
accessCache.clear(); accessCache.clear();
} }
public void deletePermission(StoreRef storeRef, String authority, String perm) public void deletePermission(StoreRef storeRef, String authority, String perm)
@@ -832,7 +831,6 @@ public class PermissionServiceImpl implements PermissionServiceSPI, Initializing
deletePermission(storeRef, authority, getPermissionReference(perm)); deletePermission(storeRef, authority, getPermissionReference(perm));
} }
private void deletePermission(StoreRef storeRef, String authority, PermissionReference perm) private void deletePermission(StoreRef storeRef, String authority, PermissionReference perm)
{ {
permissionsDaoComponent.deletePermission(storeRef, authority, perm); permissionsDaoComponent.deletePermission(storeRef, authority, perm);
@@ -843,7 +841,6 @@ public class PermissionServiceImpl implements PermissionServiceSPI, Initializing
{ {
permissionsDaoComponent.deletePermissions(storeRef); permissionsDaoComponent.deletePermissions(storeRef);
accessCache.clear(); accessCache.clear();
} }
public void setPermission(StoreRef storeRef, String authority, String perm, boolean allow) public void setPermission(StoreRef storeRef, String authority, String perm, boolean allow)