Package org.alfresco.repo.jscript
Class People
java.lang.Object
org.alfresco.repo.processor.BaseProcessorExtension
org.alfresco.repo.jscript.BaseScopableProcessorExtension
org.alfresco.repo.jscript.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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAuthority(ScriptNode parentGroup, ScriptNode authority) Add an authority (a user or group) to a group container as a new childvoidvoidchangePassword(String oldPassword, String newPassword) Change the password for the currently logged in user.createGroup(String groupName) Create a new root level group with the specified unique namecreateGroup(ScriptNode parentGroup, String groupName) Create a new group with the specified unique namecreatePerson(String userName) Create a Person with the given user namecreatePerson(String userName, String firstName, String lastName, String emailAddress) Create a Person with the given user name, firstName, lastName and emailAddresscreatePerson(String userName, String firstName, String lastName, String emailAddress, String password, boolean setAccountEnabled) Create a Person with an optionally generated user name.createPerson(String userName, String firstName, String lastName, String emailAddress, String password, boolean setAccountEnabled, boolean notifyByEmail) Create a Person with an optionally generated user namevoiddeleteGroup(ScriptNode group) Deletes a group from the system.voiddeletePerson(String username) Delete a Person with the given usernamevoiddisableAccount(String userName) Disable user account.voidenableAccount(String userName) Enable user account.getCapabilities(ScriptNode person) Gets a map of capabilities (boolean assertions) for the given person.org.mozilla.javascript.ScriptablegetContainerGroups(ScriptNode person) Gets the groups that contain the specified authoritybooleanGets the Group given the group namegetImmutableProperties(String username) Return a map of the Person properties that are marked as immutable for the given user.org.mozilla.javascript.ScriptablegetMembers(ScriptNode group) Gets the members (people) of a group (including all sub-groups)org.mozilla.javascript.ScriptablegetMembers(ScriptNode group, boolean recurse) Gets the members (people) of a grouporg.mozilla.javascript.ScriptableDeprecated.recated see getPeople(filter, maxResults)org.mozilla.javascript.ScriptableGet the collection of people stored in the repository.org.mozilla.javascript.ScriptableGet the collection of people stored in the repository.protected List<PersonService.PersonInfo>getPeopleImpl(String filter, ScriptPagingDetails pagingRequest, String sortBy, Boolean sortAsc) protected List<PersonService.PersonInfo>getPeopleImplDB(String filter, ScriptPagingDetails pagingRequest, String sortBy, Boolean sortAsc) getPeopleImplSearch(String term, String[] tokens, ScriptPagingDetails pagingRequest, String sortBy, Boolean sortAsc) org.mozilla.javascript.ScriptablegetPeoplePaging(String filter, ScriptPagingDetails pagingRequest, String sortBy, Boolean sortAsc) Gets the Person given the usernamegetPersonFullName(String username) Faster helper when the script just wants to build the Full name for a person.booleanisAccountEnabled(String userName) Return true if the specified user account is enabled.booleanisAdmin(ScriptNode person) Return true if the specified user is an Administrator authority.booleanisGuest(ScriptNode person) Return true if the specified user is an guest authority.voidremoveAuthority(ScriptNode parentGroup, ScriptNode authority) Remove an authority (a user or group) from a groupvoidsetAuthenticationService(MutableAuthenticationService authenticationService) Sets the authentication service.voidsetAuthorityDAO(AuthorityDAO authorityDAO) Set the authority DAOvoidsetAuthorityService(AuthorityService authorityService) Set the authority servicevoidsetContentUsageService(ContentUsageService contentUsageService) voidsetDefaultListMaxResults(int defaultListMaxResults) voidsetHonorHintUseCQ(boolean honorHintUseCQ) Allows customers to choose to use Solr or Lucene rather than a canned query ingetPeople(String, int, String, boolean)when" [hint:useCQ]"is appended to the search term (currently Share's User Console does this).voidsetPassword(String userName, String password) Set a password for the given user.voidsetPersonService(PersonService personService) Set the person servicevoidsetQuota(ScriptNode person, String quota) Set the content quota in bytes for a person.voidsetServiceRegistry(ServiceRegistry serviceRegistry) Set the service registryvoidsetStoreUrl(String storeRef) Set the default store referencevoidsetTenantService(TenantService tenantService) voidsetUserNameGenerator(UserNameGenerator userNameGenerator) Set the user name generator servicevoidsetUserRegistrySynchronizer(UserRegistrySynchronizer userRegistrySynchronizer) Set the UserRegistrySynchronizerMethods inherited from class org.alfresco.repo.jscript.BaseScopableProcessorExtension
getScope, setScopeMethods inherited from class org.alfresco.repo.processor.BaseProcessorExtension
getExtensionName, register, setExtensionName, setProcessor
-
Field Details
-
tenantService
-
HINT_CQ_SUFFIX
- See Also:
-
-
Constructor Details
-
People
public People()
-
-
Method Details
-
afterPropertiesSet
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-
setStoreUrl
Set the default store reference- Parameters:
storeRef- the default store reference
-
setAuthenticationService
Sets the authentication service.- Parameters:
authenticationService- the authentication service
-
setServiceRegistry
Set the service registry- Parameters:
serviceRegistry- the service registry
-
setAuthorityDAO
Set the authority DAO- Parameters:
authorityDAO- authority dao
-
setAuthorityService
Set the authority service- Parameters:
authorityService- The authorityService to set.
-
setPersonService
Set the person service- Parameters:
personService- The personService to set.
-
setContentUsageService
- Parameters:
contentUsageService- the ContentUsageService to set
-
setTenantService
- Parameters:
tenantService- the tenantService to set
-
setUserNameGenerator
Set the user name generator service- Parameters:
userNameGenerator- the user name generator
-
setUserRegistrySynchronizer
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 ingetPeople(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 propertypeople.search.honor.hint.useCQis used to set this value (default is true). -
deletePerson
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 namefirstName- firstNamelastName- lastNameemailAddress- emailAddresspassword- 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 namefirstName- firstNamelastName- lastNameemailAddress- emailAddresspassword- 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
Enable user account. Can only be called by an Admin authority.- Parameters:
userName- user name for which to enable user account
-
disableAccount
Disable user account. Can only be called by an Admin authority.- Parameters:
userName- user name for which to disable user account
-
isAccountEnabled
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
Change the password for the currently logged in user. Old password must be supplied.- Parameters:
oldPassword- Old user passwordnewPassword- New user password
-
setPassword
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 forpassword- Password to set
-
createPerson
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
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
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. Ifnullthen all people stored in the repository are returned- Returns:
- people collection as a JavaScript array
-
getPeople
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. Ifnullthen all people stored in the repository are returnedmaxResults- 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. Ifnullthen all people stored in the repository are returnedmaxResults- maximum results to return or all if <= 0sortBy- field for sortingsortAsc- 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
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
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
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
Deletes a group from the system.- Parameters:
group- The group to delete
-
createGroup
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
Create a new group with the specified unique name- Parameters:
parentGroup- The parent group node - can be null for a root level groupgroupName- The unique group name to create - NOTE: do not prefix with "GROUP_"- Returns:
- the group reference if successful or null if failed
-
addAuthority
Add an authority (a user or group) to a group container as a new child- Parameters:
parentGroup- The parent container groupauthority- The authority (user or group) to add
-
removeAuthority
Remove an authority (a user or group) from a group- Parameters:
parentGroup- The parent container groupauthority- The authority (user or group) to remove
-
getMembers
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
Gets the members (people) of a group- Parameters:
group- the group to retrieve members forrecurse- recurse into sub-groups- Returns:
- the members of the group as a JavaScript array
-
getContainerGroups
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
Return true if the specified user is an Administrator authority.- Parameters:
person- to test- Returns:
- true if an admin, false otherwise
-
isGuest
Return true if the specified user is an guest authority.- Parameters:
person- to test- Returns:
- true if an admin, false otherwise
-
getCapabilities
Gets a map of capabilities (boolean assertions) for the given person.- Parameters:
person- the person- Returns:
- the capability map
-
getImmutableProperties
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
-