Class People

All Implemented Interfaces:
org.alfresco.processor.ProcessorExtension, Scopeable, org.springframework.beans.factory.InitializingBean

public class People extends BaseScopableProcessorExtension implements org.springframework.beans.factory.InitializingBean
Scripted People service for describing and executing actions against People & Groups.
Author:
davidc, kevinr
  • Field Details

  • Constructor Details

    • People

      public People()
  • Method Details

    • afterPropertiesSet

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

      public void setStoreUrl(String storeRef)
      Set the default store reference
      Parameters:
      storeRef - the default store reference
    • setAuthenticationService

      public void setAuthenticationService(MutableAuthenticationService authenticationService)
      Sets the authentication service.
      Parameters:
      authenticationService - the authentication service
    • setServiceRegistry

      public void setServiceRegistry(ServiceRegistry serviceRegistry)
      Set the service registry
      Parameters:
      serviceRegistry - the service registry
    • setAuthorityDAO

      public void setAuthorityDAO(AuthorityDAO authorityDAO)
      Set the authority DAO
      Parameters:
      authorityDAO - authority dao
    • setAuthorityService

      public void setAuthorityService(AuthorityService authorityService)
      Set the authority service
      Parameters:
      authorityService - The authorityService to set.
    • setPersonService

      public void setPersonService(PersonService personService)
      Set the person service
      Parameters:
      personService - The personService to set.
    • setContentUsageService

      public void setContentUsageService(ContentUsageService contentUsageService)
      Parameters:
      contentUsageService - the ContentUsageService to set
    • setTenantService

      public void setTenantService(TenantService tenantService)
      Parameters:
      tenantService - the tenantService to set
    • setUserNameGenerator

      public void setUserNameGenerator(UserNameGenerator userNameGenerator)
      Set the user name generator service
      Parameters:
      userNameGenerator - the user name generator
    • setUserRegistrySynchronizer

      public void setUserRegistrySynchronizer(UserRegistrySynchronizer userRegistrySynchronizer)
      Set the UserRegistrySynchronizer
      Parameters:
      userRegistrySynchronizer - UserRegistrySynchronizer
    • setDefaultListMaxResults

      public void setDefaultListMaxResults(int defaultListMaxResults)
    • setHonorHintUseCQ

      public void setHonorHintUseCQ(boolean honorHintUseCQ)
      Allows customers to choose to use Solr or Lucene rather than a canned query in getPeople(String, int, String, boolean) when " [hint:useCQ]" is appended to the search term (currently Share's User Console does this). The down side is that new users may not appear as they will not have been indexed. This is similar to what happened in 4.1.1 prior to MNT-7548 (4.1.2 and 4.1.1.1). The down side of using a canned query at the moment is that there is a bug, so that it is impossible to search for names such as "Carlos Allende GarcĂ­a" where the first or last names may contain spaces. See MNT-9719 for more details. The alfresco global property people.search.honor.hint.useCQ is used to set this value (default is true).
    • deletePerson

      public void deletePerson(String username)
      Delete a Person with the given username
      Parameters:
      username - the username of the person to delete
    • createPerson

      public ScriptNode createPerson(String userName, String firstName, String lastName, String emailAddress, String password, boolean setAccountEnabled)
      Create a Person with an optionally generated user name. This version doesn't notify them.
      Parameters:
      userName - userName or null for a generated user name
      firstName - firstName
      lastName - lastName
      emailAddress - emailAddress
      password - if not null creates a new authenticator with the given password.
      setAccountEnabled - set to 'true' to create enabled user account, or 'false' to create disabled user account for created person.
      Returns:
      the person node (type cm:person) created or null if the person could not be created
    • createPerson

      public ScriptNode createPerson(String userName, String firstName, String lastName, String emailAddress, String password, boolean setAccountEnabled, boolean notifyByEmail)
      Create a Person with an optionally generated user name
      Parameters:
      userName - userName or null for a generated user name
      firstName - firstName
      lastName - lastName
      emailAddress - emailAddress
      password - if not null creates a new authenticator with the given password.
      setAccountEnabled - set to 'true' to create enabled user account, or 'false' to create disabled user account for created person.
      notifyByEmail - set to 'true' to have the new user emailed to let them know their account details. Only applies if a username and password were supplied.
      Returns:
      the person node (type cm:person) created or null if the person could not be created
    • enableAccount

      public void enableAccount(String userName)
      Enable user account. Can only be called by an Admin authority.
      Parameters:
      userName - user name for which to enable user account
    • disableAccount

      public void disableAccount(String userName)
      Disable user account. Can only be called by an Admin authority.
      Parameters:
      userName - user name for which to disable user account
    • isAccountEnabled

      public boolean isAccountEnabled(String userName)
      Return true if the specified user account is enabled.
      Parameters:
      userName - user name to test account
      Returns:
      true if account enabled, false if disabled
    • changePassword

      public void changePassword(String oldPassword, String newPassword)
      Change the password for the currently logged in user. Old password must be supplied.
      Parameters:
      oldPassword - Old user password
      newPassword - New user password
    • setPassword

      public void setPassword(String userName, String password)
      Set a password for the given user. Note that only an administrator can perform this action, otherwise it will be ignored.
      Parameters:
      userName - Username to change password for
      password - Password to set
    • createPerson

      public ScriptNode createPerson(String userName)
      Create a Person with the given user name
      Parameters:
      userName - the user name of the person to create
      Returns:
      the person node (type cm:person) created or null if the user name already exists
    • createPerson

      public ScriptNode createPerson(String userName, String firstName, String lastName, String emailAddress)
      Create a Person with the given user name, firstName, lastName and emailAddress
      Parameters:
      userName - the user name of the person to create
      Returns:
      the person node (type cm:person) created or null if the user name already exists
    • setQuota

      public void setQuota(ScriptNode person, String quota)
      Set the content quota in bytes for a person. Only the admin authority can set this value.
      Parameters:
      person - Person to set quota against.
      quota - As a string, in bytes, a value of "-1" means no quota is set
    • getPeople

      public org.mozilla.javascript.Scriptable getPeople(String filter)
      Deprecated.
      recated see getPeople(filter, maxResults)
      Get the collection of people stored in the repository. An optional filter query may be provided by which to filter the people collection. Space separate the query terms i.e. "john bob" will find all users who's first or second names contain the strings "john" or "bob".
      Parameters:
      filter - filter query string by which to filter the collection of people. If
                  null
                  
      then all people stored in the repository are returned
      Returns:
      people collection as a JavaScript array
    • getPeople

      public org.mozilla.javascript.Scriptable getPeople(String filter, int maxResults)
      Get the collection of people stored in the repository. An optional filter query may be provided by which to filter the people collection. Space separate the query terms i.e. "john bob" will find all users who's first or second names contain the strings "john" or "bob".
      Parameters:
      filter - filter query string by which to filter the collection of people. If
                  null
                  
      then all people stored in the repository are returned
      maxResults - maximum results to return or all if <= 0
      Returns:
      people collection as a JavaScript array
    • getPeople

      public org.mozilla.javascript.Scriptable getPeople(String filter, int maxResults, String sortBy, boolean sortAsc)
      Get the collection of people stored in the repository. An optional filter query may be provided by which to filter the people collection. Space separate the query terms i.e. "john bob" will find all users who's first or second names contain the strings "john" or "bob". Method supports sorting by specifying sortBy and sortAsc params.
      Parameters:
      filter - filter query string by which to filter the collection of people. If
                  null
                  
      then all people stored in the repository are returned
      maxResults - maximum results to return or all if <= 0
      sortBy - field for sorting
      sortAsc - sort ascending or not
      Returns:
      people collection as a JavaScript array
    • getPeoplePaging

      public org.mozilla.javascript.Scriptable getPeoplePaging(String filter, ScriptPagingDetails pagingRequest, String sortBy, Boolean sortAsc)
    • getPeopleImpl

      protected List<PersonService.PersonInfo> getPeopleImpl(String filter, ScriptPagingDetails pagingRequest, String sortBy, Boolean sortAsc)
    • getPeopleImplDB

      protected List<PersonService.PersonInfo> getPeopleImplDB(String filter, ScriptPagingDetails pagingRequest, String sortBy, Boolean sortAsc)
    • getPeopleImplSearch

      protected List<NodeRef> getPeopleImplSearch(String term, String[] tokens, ScriptPagingDetails pagingRequest, String sortBy, Boolean sortAsc) throws Throwable
      Throws:
      Throwable
    • getPerson

      public ScriptNode getPerson(String username)
      Gets the Person given the username
      Parameters:
      username - the username of the person to get
      Returns:
      the person node (type cm:person) or null if no such person exists
    • getPersonFullName

      public String getPersonFullName(String username)
      Faster helper when the script just wants to build the Full name for a person. Avoids complete getProperties() retrieval for a cm:person.
      Parameters:
      username - the username of the person to get Full name for
      Returns:
      full name for a person or null if the user does not exist in the system.
    • getGroup

      public ScriptNode getGroup(String groupName)
      Gets the Group given the group name
      Parameters:
      groupName - name of group to get
      Returns:
      the group node (type usr:authorityContainer) or null if no such group exists
    • deleteGroup

      public void deleteGroup(ScriptNode group)
      Deletes a group from the system.
      Parameters:
      group - The group to delete
    • createGroup

      public ScriptNode createGroup(String groupName)
      Create a new root level group with the specified unique name
      Parameters:
      groupName - The unique group name to create - NOTE: do not prefix with "GROUP_"
      Returns:
      the group reference if successful or null if failed
    • createGroup

      public ScriptNode createGroup(ScriptNode parentGroup, String groupName)
      Create a new group with the specified unique name
      Parameters:
      parentGroup - The parent group node - can be null for a root level group
      groupName - The unique group name to create - NOTE: do not prefix with "GROUP_"
      Returns:
      the group reference if successful or null if failed
    • addAuthority

      public void addAuthority(ScriptNode parentGroup, ScriptNode authority)
      Add an authority (a user or group) to a group container as a new child
      Parameters:
      parentGroup - The parent container group
      authority - The authority (user or group) to add
    • removeAuthority

      public void removeAuthority(ScriptNode parentGroup, ScriptNode authority)
      Remove an authority (a user or group) from a group
      Parameters:
      parentGroup - The parent container group
      authority - The authority (user or group) to remove
    • getMembers

      public org.mozilla.javascript.Scriptable getMembers(ScriptNode group)
      Gets the members (people) of a group (including all sub-groups)
      Parameters:
      group - the group to retrieve members for
      Returns:
      members of the group as a JavaScript array
    • getMembers

      public org.mozilla.javascript.Scriptable getMembers(ScriptNode group, boolean recurse)
      Gets the members (people) of a group
      Parameters:
      group - the group to retrieve members for
      recurse - recurse into sub-groups
      Returns:
      the members of the group as a JavaScript array
    • getContainerGroups

      public org.mozilla.javascript.Scriptable getContainerGroups(ScriptNode person)
      Gets the groups that contain the specified authority
      Parameters:
      person - the user (cm:person) to get the containing groups for
      Returns:
      the containing groups as a JavaScript array
    • isAdmin

      public boolean isAdmin(ScriptNode person)
      Return true if the specified user is an Administrator authority.
      Parameters:
      person - to test
      Returns:
      true if an admin, false otherwise
    • isGuest

      public boolean isGuest(ScriptNode person)
      Return true if the specified user is an guest authority.
      Parameters:
      person - to test
      Returns:
      true if an admin, false otherwise
    • getCapabilities

      public Map<String,Boolean> getCapabilities(ScriptNode person)
      Gets a map of capabilities (boolean assertions) for the given person.
      Parameters:
      person - the person
      Returns:
      the capability map
    • getImmutableProperties

      public ScriptableHashMap getImmutableProperties(String username)
      Return a map of the Person properties that are marked as immutable for the given user. This enables a script to interogate which properties are dealt with by an external system such as LDAP and should not be mutable in any client UI.
      Parameters:
      username - String
      Returns:
      ScriptableHashMap
    • getExcludeTenantFilter

      public boolean getExcludeTenantFilter()
    • getPermissionEvaluationMode

      public PermissionEvaluationMode getPermissionEvaluationMode()