Interface PersonService

  • All Known Implementing Classes:
    PersonServiceImpl

    @AlfrescoPublicApi
    public interface PersonService
    This service encapsulates the management of people and groups.

    People and groups may be managed entirely in the repository or entirely in some other implementation such as LDAP or via NTLM. Some properties may in the repository and some in another store. Individual properties may or may not be mutable.

    Author:
    Andy Hind
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static class  PersonService.PersonInfo
      Data pojo to carry common person information
    • Method Summary

      All Methods Instance Methods Abstract Methods Deprecated Methods 
      Modifier and Type Method Description
      int countPeople()
      Counts the number of persons registered with the system.
      boolean createMissingPeople()
      Does this service create people on demand if they are missing.
      org.alfresco.service.cmr.repository.NodeRef createPerson​(java.util.Map<org.alfresco.service.namespace.QName,​java.io.Serializable> properties)
      Create a new person with the given properties.
      org.alfresco.service.cmr.repository.NodeRef createPerson​(java.util.Map<org.alfresco.service.namespace.QName,​java.io.Serializable> properties, java.util.Set<java.lang.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).
      void deletePerson​(java.lang.String userName)
      Delete the person identified by the given user name.
      void deletePerson​(org.alfresco.service.cmr.repository.NodeRef personRef)
      Delete the person identified by the given ref.
      void deletePerson​(org.alfresco.service.cmr.repository.NodeRef personRef, boolean deleteAuthentication)
      Delete the person identified by the given ref, and optionally delete the associated authentication, if one.
      java.util.Set<org.alfresco.service.cmr.repository.NodeRef> getAllPeople()
      java.util.Set<org.alfresco.service.namespace.QName> getMutableProperties()
      Get the list of properties that are mutable.
      org.alfresco.query.PagingResults<PersonService.PersonInfo> getPeople​(java.lang.String pattern, java.util.List<org.alfresco.service.namespace.QName> filterProps, java.util.List<org.alfresco.util.Pair<org.alfresco.service.namespace.QName,​java.lang.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
      org.alfresco.query.PagingResults<PersonService.PersonInfo> getPeople​(java.lang.String pattern, java.util.List<org.alfresco.service.namespace.QName> filterStringProps, java.util.Set<org.alfresco.service.namespace.QName> inclusiveAspects, java.util.Set<org.alfresco.service.namespace.QName> exclusiveAspects, boolean includeAdministraotrs, java.util.List<org.alfresco.util.Pair<org.alfresco.service.namespace.QName,​java.lang.Boolean>> sortProps, org.alfresco.query.PagingRequest pagingRequest)
      Get paged list of people optionally filtered and/or sorted
      org.alfresco.query.PagingResults<PersonService.PersonInfo> getPeople​(java.util.List<org.alfresco.util.Pair<org.alfresco.service.namespace.QName,​java.lang.String>> stringPropFilters, boolean filterIgnoreCase, java.util.List<org.alfresco.util.Pair<org.alfresco.service.namespace.QName,​java.lang.Boolean>> sortProps, org.alfresco.query.PagingRequest pagingRequest)
      Deprecated.
      see getPeople(String pattern, List filterProps, List> sortProps, PagingRequest pagingRequest)
      org.alfresco.service.cmr.repository.NodeRef getPeopleContainer()
      Return the container that stores people.
      java.util.Set<org.alfresco.service.cmr.repository.NodeRef> getPeopleFilteredByProperty​(org.alfresco.service.namespace.QName propertyKey, java.io.Serializable propertyValue, int count)
      Get people filtered by the given property name/value pair.
      org.alfresco.service.cmr.repository.NodeRef getPerson​(java.lang.String userName)
      Get a person by userName.
      org.alfresco.service.cmr.repository.NodeRef getPerson​(java.lang.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 setCreateMissingPeople(boolean).
      PersonService.PersonInfo getPerson​(org.alfresco.service.cmr.repository.NodeRef personRef)
      Retrieve the person info for an existing person NodeRef
      org.alfresco.service.cmr.repository.NodeRef getPersonOrNull​(java.lang.String userName)
      Get a person by userName.
      java.lang.String getUserIdentifier​(java.lang.String caseSensitiveUserName)
      Given the case sensitive user name find the approriate identifier from the person service.
      boolean getUserNamesAreCaseSensitive()
      Are user names case sensitive?
      boolean isEnabled​(java.lang.String userName)
      Is the specified user, enabled
      boolean isMutable()
      Can this service create, delete and update person information?
      void notifyPerson​(java.lang.String userName, java.lang.String password)
      Notifies a user by email that their account has been created, and the details of it.
      boolean personExists​(java.lang.String userName)
      Check if a person exists.
      void setCreateMissingPeople​(boolean createMissing)
      Set if missing people should be created.
      void setPersonProperties​(java.lang.String userName, java.util.Map<org.alfresco.service.namespace.QName,​java.io.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
      void setPersonProperties​(java.lang.String userName, java.util.Map<org.alfresco.service.namespace.QName,​java.io.Serializable> properties, boolean autoCreateHomeFolder)
      Set the properties on a person - some of these may be persisted in different locations.
    • Method Detail

      • getPerson

        @Auditable(parameters="userName")
        org.alfresco.service.cmr.repository.NodeRef getPerson​(java.lang.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.
        Parameters:
        userName - - the userName key to find the person
        Returns:
        Returns the person node, either existing or new
        Throws:
        NoSuchPersonException - if the user doesn't exist and could not be created automatically
        See Also:
        setCreateMissingPeople(boolean), createMissingPeople()
      • getPersonOrNull

        @Auditable(parameters="userName")
        org.alfresco.service.cmr.repository.NodeRef getPersonOrNull​(java.lang.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.
        Parameters:
        userName - - the userName key to find the person
        Returns:
        Returns the existing person node, or null if does not exist.
        See Also:
        createMissingPeople()
      • getPerson

        @Auditable(parameters={"userName","autoCreate"})
        org.alfresco.service.cmr.repository.NodeRef getPerson​(java.lang.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 setCreateMissingPeople(boolean). If not allowed to create missing persons and the person does not exist a NoSuchPersonException exception will be thrown.
        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
        Throws:
        NoSuchPersonException - if the person doesn't exist and can't be created
      • getPerson

        @Auditable(parameters="personRef")
        PersonService.PersonInfo getPerson​(org.alfresco.service.cmr.repository.NodeRef personRef)
                                    throws NoSuchPersonException
        Retrieve the person info for an existing person NodeRef
        Parameters:
        personRef - NodeRef
        Returns:
        PersonInfo (username, firstname, lastname)
        Throws:
        NoSuchPersonException - if the person doesn't exist
      • personExists

        @Auditable(parameters="userName")
        boolean personExists​(java.lang.String userName)
        Check if a person exists.
        Parameters:
        userName - the user name
        Returns:
        Returns true if the user exists, otherwise false
      • createMissingPeople

        @Auditable
        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.
        Returns:
        true if people are created on demand and false otherwise.
      • setCreateMissingPeople

        @Auditable(parameters="createMissing")
        void setCreateMissingPeople​(boolean createMissing)
        Set if missing people should be created.
        Parameters:
        createMissing - set to true to create people
        See Also:
        getPerson(String)
      • getMutableProperties

        @Auditable
        java.util.Set<org.alfresco.service.namespace.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.
        Returns:
        A set of QNames that identify properties that can be changed
      • setPersonProperties

        @Auditable(parameters={"userName","properties"})
        void setPersonProperties​(java.lang.String userName,
                                 java.util.Map<org.alfresco.service.namespace.QName,​java.io.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
        Parameters:
        userName - - the user for which the properties should be set.
        properties - - the map of properties to set (as the NodeService)
      • setPersonProperties

        @Auditable(parameters={"userName","properties","autoCreate"})
        void setPersonProperties​(java.lang.String userName,
                                 java.util.Map<org.alfresco.service.namespace.QName,​java.io.Serializable> properties,
                                 boolean autoCreateHomeFolder)
        Set the properties on a person - some of these may be persisted in different locations.
        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

        @Auditable
        boolean isMutable()
        Can this service create, delete and update person information?
        Returns:
        true if this service allows mutation to people.
      • createPerson

        @Auditable(parameters="properties")
        org.alfresco.service.cmr.repository.NodeRef createPerson​(java.util.Map<org.alfresco.service.namespace.QName,​java.io.Serializable> properties)
        Create a new person with the given properties. The userName is one of the properties. Users with duplicate userNames are not allowed.
        Returns:
        NodeRef
      • createPerson

        @Auditable(parameters={"properties","zones"})
        org.alfresco.service.cmr.repository.NodeRef createPerson​(java.util.Map<org.alfresco.service.namespace.QName,​java.io.Serializable> properties,
                                                                 java.util.Set<java.lang.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.
        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

        @Auditable(parameters="userName")
        void notifyPerson​(java.lang.String userName,
                          java.lang.String password)
        Notifies a user by email that their account has been created, and the details of it. Normally called after createPerson(Map) or createPerson(Map, Set) where email notifications are required.
        Parameters:
        userName - of the person to notify
        password - of the person to notify
        Throws:
        NoSuchPersonException - if the person doesn't exist
      • deletePerson

        @Auditable(parameters="userName")
        void deletePerson​(java.lang.String userName)
        Delete the person identified by the given user name.
        Parameters:
        userName - String
      • deletePerson

        @Auditable(parameters="personRef")
        void deletePerson​(org.alfresco.service.cmr.repository.NodeRef personRef)
        Delete the person identified by the given ref.
        Parameters:
        personRef - NodeRef
      • deletePerson

        @Auditable(parameters={"personRef","deleteAuthentication"})
        void deletePerson​(org.alfresco.service.cmr.repository.NodeRef personRef,
                          boolean deleteAuthentication)
        Delete the person identified by the given ref, and optionally delete the associated authentication, if one.
        Parameters:
        personRef - NodeRef
        deleteAuthentication - boolean
      • getAllPeople

        @Auditable
        java.util.Set<org.alfresco.service.cmr.repository.NodeRef> getAllPeople()
        Get all the people we know about.
        Returns:
        a set of people in no specific order.
      • getPeople

        @Auditable(parameters={"pattern","filterProps","sortProps","pagingRequest"})
        org.alfresco.query.PagingResults<PersonService.PersonInfo> getPeople​(java.lang.String pattern,
                                                                             java.util.List<org.alfresco.service.namespace.QName> filterProps,
                                                                             java.util.List<org.alfresco.util.Pair<org.alfresco.service.namespace.QName,​java.lang.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
        Parameters:
        pattern - pattern to apply to filter props - "startsWith" and "ignoreCase"
        filterProps - list of filter properties (these are OR'ed)
        sortProps - sort property, eg. cm:username ascending
        pagingRequest - skip, max + optional query execution id

        author janv
        Since:
        4.1.2
      • getPeople

        @Auditable(parameters={"stringPropFilters","filterIgnoreCase","sortProps","pagingRequest"})
        org.alfresco.query.PagingResults<PersonService.PersonInfo> getPeople​(java.util.List<org.alfresco.util.Pair<org.alfresco.service.namespace.QName,​java.lang.String>> stringPropFilters,
                                                                             boolean filterIgnoreCase,
                                                                             java.util.List<org.alfresco.util.Pair<org.alfresco.service.namespace.QName,​java.lang.Boolean>> sortProps,
                                                                             org.alfresco.query.PagingRequest pagingRequest)
        Deprecated.
        see getPeople(String pattern, List filterProps, List> sortProps, PagingRequest pagingRequest)
        Get paged list of people optionally filtered and/or sorted
        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
        Since:
        4.0
      • getPeople

        @Auditable(parameters={"stringPropFilters","filterIgnoreCase","inclusiveAspect","exclusiveAspects","sortProps","pagingRequest"})
        org.alfresco.query.PagingResults<PersonService.PersonInfo> getPeople​(java.lang.String pattern,
                                                                             java.util.List<org.alfresco.service.namespace.QName> filterStringProps,
                                                                             java.util.Set<org.alfresco.service.namespace.QName> inclusiveAspects,
                                                                             java.util.Set<org.alfresco.service.namespace.QName> exclusiveAspects,
                                                                             boolean includeAdministraotrs,
                                                                             java.util.List<org.alfresco.util.Pair<org.alfresco.service.namespace.QName,​java.lang.Boolean>> sortProps,
                                                                             org.alfresco.query.PagingRequest pagingRequest)
        Get paged list of people optionally filtered and/or sorted
        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
      • getPeopleFilteredByProperty

        @Auditable
        java.util.Set<org.alfresco.service.cmr.repository.NodeRef> getPeopleFilteredByProperty​(org.alfresco.service.namespace.QName propertyKey,
                                                                                               java.io.Serializable propertyValue,
                                                                                               int count)
        Get people filtered by the given property name/value pair.

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

        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:
        getPeople(List, boolean, List, PagingRequest)
      • getPeopleContainer

        @Auditable
        org.alfresco.service.cmr.repository.NodeRef getPeopleContainer()
        Return the container that stores people.
        Returns:
        NodeRef
      • getUserNamesAreCaseSensitive

        @Auditable
        boolean getUserNamesAreCaseSensitive()
        Are user names case sensitive?
        Returns:
        boolean
      • getUserIdentifier

        @NotAuditable
        java.lang.String getUserIdentifier​(java.lang.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;
        Parameters:
        caseSensitiveUserName - String
        Returns:
        String
      • countPeople

        @NotAuditable
        int countPeople()
        Counts the number of persons registered with the system.
        Returns:
        int
      • isEnabled

        @NotAuditable
        boolean isEnabled​(java.lang.String userName)
        Is the specified user, enabled
        Returns:
        true = enabled.
        Throws:
        NoSuchPersonException - if the user doesn't exist