Class PersonServiceImpl

java.lang.Object
org.alfresco.repo.transaction.TransactionListenerAdapter
org.alfresco.repo.security.person.PersonServiceImpl
All Implemented Interfaces:
NodeServicePolicies.BeforeCreateNodePolicy, NodeServicePolicies.BeforeDeleteNodePolicy, NodeServicePolicies.OnCreateNodePolicy, NodeServicePolicies.OnUpdatePropertiesPolicy, ClassPolicy, Policy, TransactionListener, PersonService, org.alfresco.util.transaction.TransactionListener

  • Field Details

  • Constructor Details

    • PersonServiceImpl

      public PersonServiceImpl()
  • Method Details

    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • init

      public void init()
      Spring bean init method
    • setCreateMissingPeople

      public void setCreateMissingPeople(boolean createMissingPeople)
      Set if missing people should be created.
      Specified by:
      setCreateMissingPeople in interface PersonService
      Parameters:
      createMissingPeople - set to true to create people
      See Also:
    • setNamespacePrefixResolver

      public void setNamespacePrefixResolver(NamespacePrefixResolver namespacePrefixResolver)
    • setAuthorityService

      public void setAuthorityService(AuthorityService authorityService)
    • setAuthenticationService

      public void setAuthenticationService(MutableAuthenticationService authenticationService)
    • setDictionaryService

      public void setDictionaryService(DictionaryService dictionaryService)
    • setPermissionServiceSPI

      public void setPermissionServiceSPI(PermissionServiceSPI permissionServiceSPI)
    • setTransactionService

      public void setTransactionService(TransactionService transactionService)
    • setServiceRegistry

      public void setServiceRegistry(ServiceRegistry serviceRegistry)
    • setNodeService

      public void setNodeService(NodeService nodeService)
    • setTenantService

      public void setTenantService(TenantService tenantService)
    • setSingletonCache

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

      public void setSearchService(SearchService searchService)
    • setRepoAdminService

      public void setRepoAdminService(RepoAdminService repoAdminService)
    • setPolicyComponent

      public void setPolicyComponent(PolicyComponent policyComponent)
    • setStoreUrl

      public void setStoreUrl(String storeUrl)
    • setUserNameMatcher

      public void setUserNameMatcher(UserNameMatcher userNameMatcher)
    • setDuplicateMode

      public void setDuplicateMode(String duplicateMode)
    • setIncludeAutoCreated

      public void setIncludeAutoCreated(boolean includeAutoCreated)
    • setLastIsBest

      public void setLastIsBest(boolean lastIsBest)
    • setProcessDuplicates

      public void setProcessDuplicates(boolean processDuplicates)
    • setHomeFolderManager

      public void setHomeFolderManager(HomeFolderManager homeFolderManager)
    • setHomeFolderCreationEager

      public void setHomeFolderCreationEager(boolean homeFolderCreationEager)
      Indicates if home folders should be created when the person is created or delayed until first accessed.
    • setHomeFolderCreationDisabled

      public void setHomeFolderCreationDisabled(boolean homeFolderCreationDisabled)
      Indicates if home folder creation should be disabled.
    • setAclDAO

      public void setAclDAO(AclDAO aclDao)
    • setPermissionsManager

      public void setPermissionsManager(PermissionsManager permissionsManager)
    • setCannedQueryRegistry

      public void setCannedQueryRegistry(org.alfresco.util.registry.NamedObjectRegistry<org.alfresco.query.CannedQueryFactory<NodeRef>> cannedQueryRegistry)
      Set the registry of canned queries
    • setPersonCache

      public void setPersonCache(SimpleCache<String,Set<NodeRef>> personCache)
      Set the username to person cache.
    • getPerson

      public NodeRef getPerson(String userName)
      Get a person by userName. The person is store in the repository. The person may be created as a side effect of this call, depending on the setting of to create missing people or not. The home folder will also be created as a side effect if it does not exist.
      Specified by:
      getPerson in interface PersonService
      Parameters:
      userName - - the userName key to find the person
      Returns:
      Returns the person node, either existing or new
      See Also:
    • getPerson

      public PersonService.PersonInfo getPerson(NodeRef personRef) throws NoSuchPersonException
      Retrieve the person info for an existing person NodeRef
      Specified by:
      getPerson in interface PersonService
      Parameters:
      personRef - NodeRef
      Returns:
      PersonInfo (username, firstname, lastname)
      Throws:
      NoSuchPersonException - if the person doesn't exist
    • getPersonOrNull

      public NodeRef getPersonOrNull(String userName)
      Get a person by userName. The person is store in the repository. No missing person objects will be created as a side effect of this call. If the person is missing from the repository null will be returned.
      Specified by:
      getPersonOrNull in interface PersonService
      Parameters:
      userName - - the userName key to find the person
      Returns:
      Returns the existing person node, or null if does not exist.
      See Also:
    • getPerson

      public NodeRef getPerson(String userName, boolean autoCreateHomeFolderAndMissingPersonIfAllowed)
      Retrieve the person NodeRef for a username, optionally creating the home folder if it does not exist and optionally creating the person if they don't exist AND the PersonService is configured to allow the creation of missing persons PersonService.setCreateMissingPeople(boolean). If not allowed to create missing persons and the person does not exist a NoSuchPersonException exception will be thrown.
      Specified by:
      getPerson in interface PersonService
      Parameters:
      userName - of the person NodeRef to retrieve
      autoCreateHomeFolderAndMissingPersonIfAllowed - If the person exits: should we create the home folder if it does not exist? If the person exists AND the creation of missing persons is allowed should we create both the person and home folder.
      Returns:
      NodeRef of the person as specified by the username
    • personExists

      public boolean personExists(String caseSensitiveUserName)
      Check if a person exists.
      Specified by:
      personExists in interface PersonService
      Parameters:
      caseSensitiveUserName - the user name
      Returns:
      Returns true if the user exists, otherwise false
    • afterCommit

      public void afterCommit()
      Process clean up any duplicates that were flagged during the transaction.
      Specified by:
      afterCommit in interface TransactionListener
      Specified by:
      afterCommit in interface org.alfresco.util.transaction.TransactionListener
      Overrides:
      afterCommit in class TransactionListenerAdapter
    • createMissingPeople

      public boolean createMissingPeople()
      Does this service create people on demand if they are missing. If this is true, a call to getPerson() will create a person if they are missing.
      Specified by:
      createMissingPeople in interface PersonService
      Returns:
      true if people are created on demand and false otherwise.
    • getMutableProperties

      public Set<QName> getMutableProperties()
      Get the list of properties that are mutable. Some service may only allow a limited list of properties to be changed. This may be those persisted in the repository or those that can be changed in some other implementation such as LDAP.
      Specified by:
      getMutableProperties in interface PersonService
      Returns:
      A set of QNames that identify properties that can be changed
    • setPersonProperties

      public void setPersonProperties(String userName, Map<QName,Serializable> properties)
      Set the properties on a person - some of these may be persisted in different locations - the home folder is created if it doesn't exist
      Specified by:
      setPersonProperties in interface PersonService
      Parameters:
      userName - - the user for which the properties should be set.
      properties - - the map of properties to set (as the NodeService)
    • setPersonProperties

      public void setPersonProperties(String userName, Map<QName,Serializable> properties, boolean autoCreateHomeFolder)
      Set the properties on a person - some of these may be persisted in different locations.
      Specified by:
      setPersonProperties in interface PersonService
      Parameters:
      userName - - the user for which the properties should be set.
      properties - - the map of properties to set (as the NodeService)
      autoCreateHomeFolder - should we auto-create the home folder if it doesn't exist.
    • isMutable

      public boolean isMutable()
      Can this service create, delete and update person information?
      Specified by:
      isMutable in interface PersonService
      Returns:
      true if this service allows mutation to people.
    • createPerson

      public NodeRef createPerson(Map<QName,Serializable> properties)
      Create a new person with the given properties. The userName is one of the properties. Users with duplicate userNames are not allowed.
      Specified by:
      createPerson in interface PersonService
      Returns:
      NodeRef
    • createPerson

      public NodeRef createPerson(Map<QName,Serializable> properties, Set<String> zones)
      Create a new person with the given properties, recording them against the given zone name (usually identifying an external user registry from which the details were obtained). The userName is one of the properties. Users with duplicate userNames are not allowed.
      Specified by:
      createPerson in interface PersonService
      Parameters:
      properties - the properties
      zones - a set if zones including the identifier for the external user registry owning the person information, or null or an empty set
      Returns:
      the node ref
    • notifyPerson

      public void notifyPerson(String userName, String password)
      Notifies a user by email that their account has been created, and the details of it. Normally called after PersonService.createPerson(Map) or PersonService.createPerson(Map, Set) where email notifications are required.
      Specified by:
      notifyPerson in interface PersonService
      Parameters:
      userName - of the person to notify
      password - of the person to notify
    • getPeopleContainer

      public NodeRef getPeopleContainer()
      Return the container that stores people.
      Specified by:
      getPeopleContainer in interface PersonService
      Returns:
      NodeRef
    • deletePerson

      public void deletePerson(String userName)
      Delete the person identified by the given user name.
      Specified by:
      deletePerson in interface PersonService
      Parameters:
      userName - String
    • deletePerson

      public void deletePerson(NodeRef personRef)
      Delete the person identified by the given ref.
      Specified by:
      deletePerson in interface PersonService
      Parameters:
      personRef - NodeRef
    • deletePerson

      public void deletePerson(NodeRef personRef, boolean deleteAuthentication)
      Delete the person identified by the given ref, and optionally delete the associated authentication, if one.
      Specified by:
      deletePerson in interface PersonService
      Parameters:
      personRef - NodeRef
      deleteAuthentication - boolean
    • getAllPeople

      public Set<NodeRef> getAllPeople()
      Deprecated.
      see getPeople
      Get all the people we know about.
      Specified by:
      getAllPeople in interface PersonService
      Returns:
      a set of people in no specific order.
    • getPeople

      public org.alfresco.query.PagingResults<PersonService.PersonInfo> getPeople(String pattern, List<QName> filterStringProps, List<Pair<QName,Boolean>> sortProps, org.alfresco.query.PagingRequest pagingRequest)
      Get paged list of people optionally filtered and/or sorted Note: the pattern is applied to filter props (0 to 3) as startsWithIgnoreCase, which are OR'ed together, for example: cm:userName or cm:firstName or cm:lastName
      Specified by:
      getPeople in interface PersonService
      Parameters:
      pattern - pattern to apply to filter props - "startsWith" and "ignoreCase"
      filterStringProps - list of filter properties (these are OR'ed)
      sortProps - sort property, eg. cm:username ascending
      pagingRequest - skip, max + optional query execution id

      author janv
    • getPeople

      public org.alfresco.query.PagingResults<PersonService.PersonInfo> getPeople(String pattern, List<QName> filterStringProps, Set<QName> inclusiveAspects, Set<QName> exclusiveAspects, boolean includeAdministraotrs, List<Pair<QName,Boolean>> sortProps, org.alfresco.query.PagingRequest pagingRequest)
      Get paged list of people optionally filtered and/or sorted
      Specified by:
      getPeople in interface PersonService
      Parameters:
      pattern - String
      filterStringProps - list of filter properties (with "startsWith" values), eg. cm:username "al" might match "alex", "alice", ...
      inclusiveAspects - if set, filter out any people that don't have one of these aspects
      exclusiveAspects - if set, filter out any people that do have one of these aspects
      includeAdministraotrs - true to include administrators in the results.
      sortProps - sort property, eg. cm:username ascending
      pagingRequest - skip, max + optional query execution id
    • getPeople

      public org.alfresco.query.PagingResults<PersonService.PersonInfo> getPeople(List<Pair<QName,String>> stringPropFilters, boolean filterIgnoreCase, List<Pair<QName,Boolean>> sortProps, org.alfresco.query.PagingRequest pagingRequest)
      Deprecated.
      see getPeople(String pattern, List filterProps, List<Pair<QName, Boolean>> sortProps, PagingRequest pagingRequest)
      Get paged list of people optionally filtered and/or sorted
      Specified by:
      getPeople in interface PersonService
      Parameters:
      stringPropFilters - list of filter properties (with "startsWith" values), eg. cm:username "al" might match "alex", "alice", ...
      filterIgnoreCase - true to ignore case when filtering, false to be case-sensitive when filtering
      sortProps - sort property, eg. cm:username ascending
      pagingRequest - skip, max + optional query execution id

      author janv
    • getPeopleFilteredByProperty

      public Set<NodeRef> getPeopleFilteredByProperty(QName propertyKey, Serializable propertyValue, int count)
      Get people filtered by the given property name/value pair.

      In order to get paging, use PersonService.getPeople(List, boolean, List, PagingRequest)

      Specified by:
      getPeopleFilteredByProperty in interface PersonService
      Parameters:
      propertyKey - property key of property to filter people by
      propertyValue - property value of property to filter people by
      count - the number of results to retrieve, up to a maximum of 1000
      Returns:
      people filtered by the given property name/value pair
      See Also:
    • onCreateNode

      public void onCreateNode(ChildAssociationRef childAssocRef)
      Called when a new node has been created.
      Specified by:
      onCreateNode in interface NodeServicePolicies.OnCreateNodePolicy
      Parameters:
      childAssocRef - the created child association reference
    • beforeCreateNode

      public void beforeCreateNode(NodeRef parentRef, QName assocTypeQName, QName assocQName, QName nodeTypeQName)
      Description copied from interface: NodeServicePolicies.BeforeCreateNodePolicy
      Called before a new node is created.
      Specified by:
      beforeCreateNode in interface NodeServicePolicies.BeforeCreateNodePolicy
      Parameters:
      parentRef - the parent node reference
      assocTypeQName - the association type qualified name
      assocQName - the association qualified name
      nodeTypeQName - the node type qualified name
    • beforeCreateNodeValidation

      public void beforeCreateNodeValidation(NodeRef parentRef, QName assocTypeQName, QName assocQName, QName nodeTypeQName)
    • beforeDeleteNode

      public void beforeDeleteNode(NodeRef nodeRef)
      Description copied from interface: NodeServicePolicies.BeforeDeleteNodePolicy
      Called before a node is deleted.
      Specified by:
      beforeDeleteNode in interface NodeServicePolicies.BeforeDeleteNodePolicy
      Parameters:
      nodeRef - the node reference
    • beforeDeleteNodeValidation

      public void beforeDeleteNodeValidation(NodeRef nodeRef)
    • getUserIdentifier

      public String getUserIdentifier(String caseSensitiveUserName)
      Given the case sensitive user name find the approriate identifier from the person service. If the system is case sensitive it will return the same string. If case insentive it will return the common object. If the user does not exist it will return null;
      Specified by:
      getUserIdentifier in interface PersonService
      Parameters:
      caseSensitiveUserName - String
      Returns:
      String
    • getUserNamesAreCaseSensitive

      public boolean getUserNamesAreCaseSensitive()
      Are user names case sensitive?
      Specified by:
      getUserNamesAreCaseSensitive in interface PersonService
      Returns:
      boolean
    • onUpdateProperties

      public void onUpdateProperties(NodeRef nodeRef, Map<QName,Serializable> before, Map<QName,Serializable> after)
      When a uid is changed we need to create an alias for the old uid so permissions are not broken. This can happen when an already existing user is updated via LDAP e.g. migration to LDAP, or when a user is auto created and then updated by LDAP This is probably less likely after 3.2 and sync on missing person See https://issues.alfresco.com/jira/browse/ETWOTWO-389 (non-Javadoc)
      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
    • onUpdatePropertiesUser

      public void onUpdatePropertiesUser(NodeRef nodeRef, Map<QName,Serializable> before, Map<QName,Serializable> after)
      Track the enabled/disabled flag on cm:user.
    • countPeople

      public int countPeople()
      Description copied from interface: PersonService
      Counts the number of persons registered with the system.
      Specified by:
      countPeople in interface PersonService
      Returns:
      int
    • updateUsernameForTenancy

      public static String updateUsernameForTenancy(String username, TenantService tenantService) throws TenantDomainMismatchException
      Helper for when creating new users and people: Updates the supplied username with any required tenant details, and ensures that the tenant domains match. If Multi-Tenant is disabled, returns the same username.
      Throws:
      TenantDomainMismatchException
    • isEnabled

      public boolean isEnabled(String userName)
      Description copied from interface: PersonService
      Is the specified user, enabled
      Specified by:
      isEnabled in interface PersonService
      Returns:
      true = enabled.
    • setEventPublisher

      public void setEventPublisher(org.alfresco.sync.repo.events.EventPublisher eventPublisher)