Class AuthorityDAOImpl

java.lang.Object
org.alfresco.repo.security.authority.AuthorityDAOImpl
All Implemented Interfaces:
NodeServicePolicies.BeforeDeleteNodePolicy, NodeServicePolicies.OnUpdatePropertiesPolicy, ClassPolicy, Policy, AuthorityDAO, org.alfresco.util.cache.RefreshableCacheListener, org.springframework.beans.factory.InitializingBean

public class AuthorityDAOImpl extends Object implements AuthorityDAO, NodeServicePolicies.BeforeDeleteNodePolicy, NodeServicePolicies.OnUpdatePropertiesPolicy, org.alfresco.util.cache.RefreshableCacheListener, org.springframework.beans.factory.InitializingBean
  • Constructor Details

    • AuthorityDAOImpl

      public AuthorityDAOImpl()
  • Method Details

    • setZoneAuthoritySampleSize

      public void setZoneAuthoritySampleSize(int zoneAuthoritySampleSize)
      Sets number of authorities in a zone to pre-cache, allowing quick generation of 'first n' results and adaption of search technique based on hit rate.
      Parameters:
      zoneAuthoritySampleSize - the zoneAuthoritySampleSize to set
    • setStoreUrl

      public void setStoreUrl(String storeUrl)
    • setDictionaryService

      public void setDictionaryService(DictionaryService dictionaryService)
    • setNamespacePrefixResolver

      public void setNamespacePrefixResolver(NamespacePrefixResolver namespacePrefixResolver)
    • setNodeService

      public void setNodeService(NodeService nodeService)
    • setSearchService

      public void setSearchService(SearchService searchService)
    • setAuthorityLookupCache

      public void setAuthorityLookupCache(SimpleCache<Pair<String,String>,NodeRef> authorityLookupCache)
    • setUserAuthorityCache

      public void setUserAuthorityCache(SimpleCache<String,Set<String>> userAuthorityCache)
    • setZoneAuthorityCache

      public void setZoneAuthorityCache(SimpleCache<Pair<String,String>,List<ChildAssociationRef>> zoneAuthorityCache)
    • setChildAuthorityCache

      public void setChildAuthorityCache(SimpleCache<NodeRef,Pair<Map<NodeRef,String>,List<NodeRef>>> childAuthorityCache)
    • setAuthorityBridgeTableCache

      public void setAuthorityBridgeTableCache(AuthorityBridgeTableAsynchronouslyRefreshedCache authorityBridgeTableCache)
    • setUseBridgeTable

      public void setUseBridgeTable(boolean useBridgeTable)
      Parameters:
      useBridgeTable - the useBridgeTable to set
    • setPersonService

      public void setPersonService(PersonService personService)
    • setTenantService

      public void setTenantService(TenantService tenantService)
    • setSingletonCache

      public void setSingletonCache(SimpleCache<String,Object> singletonCache)
    • setQnameDAO

      public void setQnameDAO(QNameDAO qnameDAO)
    • setCannedQueryDAO

      public void setCannedQueryDAO(CannedQueryDAO cannedQueryDAO)
    • setAclDAO

      public void setAclDAO(AclDAO aclDao)
    • setPolicyComponent

      public void setPolicyComponent(PolicyComponent policyComponent)
    • setCannedQueryRegistry

      public void setCannedQueryRegistry(org.alfresco.util.registry.NamedObjectRegistry<org.alfresco.query.CannedQueryFactory<?>> cannedQueryRegistry)
    • setAuthorityBridgeDAO

      public void setAuthorityBridgeDAO(AuthorityBridgeDAO authorityBridgeDAO)
      Parameters:
      authorityBridgeDAO - the authorityBridgeDAO to set
    • setFindAuthoritiesLimit

      public void setFindAuthoritiesLimit(int findAuthoritiesLimit)
    • getPersonCount

      public long getPersonCount()
      Description copied from interface: AuthorityDAO
      Count people i.e. nodes of type cm:person.
      Specified by:
      getPersonCount in interface AuthorityDAO
      Returns:
      the number of people
    • getGroupCount

      public long getGroupCount()
      Description copied from interface: AuthorityDAO
      Count groups i.e. nodes of type cm:authorityContainer.
      Specified by:
      getGroupCount in interface AuthorityDAO
      Returns:
      the number of groups
    • authorityExists

      public boolean authorityExists(String name)
      Description copied from interface: AuthorityDAO
      Test if an authority already exists.
      Specified by:
      authorityExists in interface AuthorityDAO
    • addAuthority

      public void addAuthority(Collection<String> parentNames, String childName)
      Description copied from interface: AuthorityDAO
      Add a child authority to the given parent authorities
      Specified by:
      addAuthority in interface AuthorityDAO
    • createAuthority

      public void createAuthority(String name, String authorityDisplayName, Set<String> authorityZones)
      Description copied from interface: AuthorityDAO
      Create an authority.
      Specified by:
      createAuthority in interface AuthorityDAO
    • createAuthority

      public void createAuthority(String name, String authorityDisplayName, Set<String> authorityZones, Map<QName,Serializable> properties)
      Description copied from interface: AuthorityDAO
      Create an authority with properties.
      Specified by:
      createAuthority in interface AuthorityDAO
    • deleteAuthority

      public void deleteAuthority(String name)
      Description copied from interface: AuthorityDAO
      Delete an authority.
      Specified by:
      deleteAuthority in interface AuthorityDAO
    • getAuthoritiesInfo

      public org.alfresco.query.PagingResults<AuthorityInfo> getAuthoritiesInfo(AuthorityType type, String zoneName, String displayNameFilter, String sortBy, boolean sortAscending, org.alfresco.query.PagingRequest pagingRequest)
      Description copied from interface: AuthorityDAO
      Get AuthorityInfo by type and/or zone (both cannot be null).
      Specified by:
      getAuthoritiesInfo in interface AuthorityDAO
      sortBy - either "displayName", "shortName", "authorityName" or null if no sorting.
    • getAuthorities

      public org.alfresco.query.PagingResults<String> getAuthorities(AuthorityType type, String zoneName, String displayNameFilter, boolean sortByDisplayName, boolean sortAscending, org.alfresco.query.PagingRequest pagingRequest)
      Description copied from interface: AuthorityDAO
      Get authority names by type and/or zone (both cannot be null).
      Specified by:
      getAuthorities in interface AuthorityDAO
    • getRootAuthorities

      public Set<String> getRootAuthorities(AuthorityType type, String zoneName)
      Description copied from interface: AuthorityDAO
      Get root authorities
      Specified by:
      getRootAuthorities in interface AuthorityDAO
    • findAuthorities

      public Set<String> findAuthorities(AuthorityType type, String parentAuthority, boolean immediate, String displayNamePattern, String zoneName)
      Description copied from interface: AuthorityDAO
      Find authorities by display name pattern.
      Specified by:
      findAuthorities in interface AuthorityDAO
      parentAuthority - if non-null, will look only for authorities who are a child of the named parent
      immediate - if true then only search root groups if parentAuthority is null, or immediate children of parentAuthority if it is non-null.
      zoneName - - may be null to indicate all zones
    • getContainedAuthorities

      public Set<String> getContainedAuthorities(AuthorityType type, String parentName, boolean immediate)
      Description copied from interface: AuthorityDAO
      Get contained authorities.
      Specified by:
      getContainedAuthorities in interface AuthorityDAO
      parentName - the name of the containing authority
    • removeAuthority

      public void removeAuthority(String parentName, String childName)
      Description copied from interface: AuthorityDAO
      Remove an authority.
      Specified by:
      removeAuthority in interface AuthorityDAO
    • removeAuthority

      public void removeAuthority(String parentName, String childName, boolean cacheRefresh)
      Description copied from interface: AuthorityDAO
      Remove an authority without authorityBridgeTableCache refresh.
      Specified by:
      removeAuthority in interface AuthorityDAO
    • getContainingAuthorities

      public Set<String> getContainingAuthorities(AuthorityType type, String name, boolean immediate)
      Description copied from interface: AuthorityDAO
      Get the authorities that contain the one given.
      Specified by:
      getContainingAuthorities in interface AuthorityDAO
    • getContainingAuthoritiesInZone

      public Set<String> getContainingAuthoritiesInZone(AuthorityType type, String authority, String zoneName, AuthorityService.AuthorityFilter filter, int size)
      Description copied from interface: AuthorityDAO
      Get a set of authorities with varying filter criteria
      Specified by:
      getContainingAuthoritiesInZone in interface AuthorityDAO
      Parameters:
      type - authority type or null for all types
      authority - if non-null, only return those authorities who contain this authority
      zoneName - if non-null, only include authorities in the named zone
      filter - optional callback to apply further filter criteria or null
      size - if greater than zero, the maximum results to return. The search strategy used is varied depending on this number.
      Returns:
      a set of authorities
    • getShortName

      public String getShortName(String name)
      Description copied from interface: AuthorityDAO
      Extract the short name of an authority from its full identifier.
      Specified by:
      getShortName in interface AuthorityDAO
    • getName

      public String getName(AuthorityType type, String shortName)
      Description copied from interface: AuthorityDAO
      Create the full identifier for an authority given its short name and type.
      Specified by:
      getName in interface AuthorityDAO
    • addAuthorityNameIfMatches

      protected void addAuthorityNameIfMatches(Set<String> authorities, String authorityName, AuthorityType type)
    • addAuthorityNameIfMatches

      protected void addAuthorityNameIfMatches(Set<String> authorities, String authorityName, AuthorityType type, Pattern pattern)
    • isAuthorityContained

      public boolean isAuthorityContained(String authority, String authorityToFind, Set<String> positiveHits, Set<String> negativeHits)
      Specified by:
      isAuthorityContained in interface AuthorityDAO
    • getAuthorityNodeRefOrNull

      public NodeRef getAuthorityNodeRefOrNull(String name)
      Description copied from interface: AuthorityDAO
      Get a node ref for the authority if one exists
      Specified by:
      getAuthorityNodeRefOrNull in interface AuthorityDAO
    • getAuthorityName

      public String getAuthorityName(NodeRef authorityRef)
      Description copied from interface: AuthorityDAO
      Gets the name for the given authority node
      Specified by:
      getAuthorityName in interface AuthorityDAO
      Parameters:
      authorityRef - authority node
    • getAuthorityDisplayName

      public String getAuthorityDisplayName(String authorityName)
      Description copied from interface: AuthorityDAO
      Get the display name for an authority
      Specified by:
      getAuthorityDisplayName in interface AuthorityDAO
      Returns:
      the display name
    • setAuthorityDisplayName

      public void setAuthorityDisplayName(String authorityName, String authorityDisplayName)
      Description copied from interface: AuthorityDAO
      Set the display name for an authority
      Specified by:
      setAuthorityDisplayName in interface AuthorityDAO
    • getAuthorityDisplayNameAndDescription

      public Pair<String,String> getAuthorityDisplayNameAndDescription(String authorityName)
      Description copied from interface: AuthorityDAO
      Get the display name and description for an authority
      Specified by:
      getAuthorityDisplayNameAndDescription in interface AuthorityDAO
      Returns:
      the display name and description
    • setAuthorityDisplayNameAndDescription

      public void setAuthorityDisplayNameAndDescription(String authorityName, String authorityDisplayName, String description)
      Description copied from interface: AuthorityDAO
      Set the display name and description for an authority
      Specified by:
      setAuthorityDisplayNameAndDescription in interface AuthorityDAO
    • getOrCreateZone

      public NodeRef getOrCreateZone(String zoneName)
      Description copied from interface: AuthorityDAO
      Gets or creates an authority zone node with the specified name
      Specified by:
      getOrCreateZone in interface AuthorityDAO
      Parameters:
      zoneName - the zone name
      Returns:
      reference to the zone node
    • getZone

      public NodeRef getZone(String zoneName)
      Description copied from interface: AuthorityDAO
      Gets an authority zone node with the specified name
      Specified by:
      getZone in interface AuthorityDAO
      Parameters:
      zoneName - the zone name
      Returns:
      reference to the zone node ot null if the zone does not exists
    • getAuthorityZones

      public Set<String> getAuthorityZones(String name)
      Description copied from interface: AuthorityDAO
      Gets the name of the zone containing the specified authority.
      Specified by:
      getAuthorityZones in interface AuthorityDAO
      Parameters:
      name - the authority long name
      Returns:
      the set of names of all zones containing the specified authority, an empty set if the authority exists but has no zone, or null if the authority does not exist.
    • getAllAuthoritiesInZone

      public Set<String> getAllAuthoritiesInZone(String zoneName, AuthorityType type)
      Description copied from interface: AuthorityDAO
      Gets the names of all authorities in a zone, optionally filtered by type.
      Specified by:
      getAllAuthoritiesInZone in interface AuthorityDAO
      Parameters:
      zoneName - the zone name
      type - the authority type to filter by or null for all authority types
      Returns:
      the names of all authorities in a zone, optionally filtered by type
    • addAuthorityToZones

      public void addAuthorityToZones(String authorityName, Set<String> zones)
      Description copied from interface: AuthorityDAO
      Add an authority to zones
      Specified by:
      addAuthorityToZones in interface AuthorityDAO
    • removeAuthorityFromZones

      public void removeAuthorityFromZones(String authorityName, Set<String> zones)
      Description copied from interface: AuthorityDAO
      Remove an authority from zones.
      Specified by:
      removeAuthorityFromZones in interface AuthorityDAO
    • beforeDeleteNode

      public void beforeDeleteNode(NodeRef nodeRef)
      Listen out for person removals so that we can clear cached authorities.
      Specified by:
      beforeDeleteNode in interface NodeServicePolicies.BeforeDeleteNodePolicy
      Parameters:
      nodeRef - the node reference
    • onUpdateProperties

      public void onUpdateProperties(NodeRef nodeRef, Map<QName,Serializable> before, Map<QName,Serializable> after)
      Description copied from interface: NodeServicePolicies.OnUpdatePropertiesPolicy
      Called after a node's properties have been changed.
      Specified by:
      onUpdateProperties in interface NodeServicePolicies.OnUpdatePropertiesPolicy
      Parameters:
      nodeRef - reference to the updated node
      before - the node's properties before the change
      after - the node's properties after the change
    • onCreateNode

      public void onCreateNode(ChildAssociationRef childAssocRef)
    • init

      public void init()
    • onRefreshableCacheEvent

      public void onRefreshableCacheEvent(org.alfresco.util.cache.RefreshableCacheEvent refreshableCacheEvent)
      Specified by:
      onRefreshableCacheEvent in interface org.alfresco.util.cache.RefreshableCacheListener
    • getCacheId

      public String getCacheId()
      Specified by:
      getCacheId in interface org.alfresco.util.cache.RefreshableCacheListener
    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Throws:
      Exception