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 Modifier and Type Field Description protected static java.lang.StringHINT_CQ_SUFFIXprotected org.alfresco.repo.tenant.TenantServicetenantService
-
Constructor Summary
Constructors Constructor Description People()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddAuthority(ScriptNode parentGroup, ScriptNode authority)Add an authority (a user or group) to a group container as a new childvoidafterPropertiesSet()voidchangePassword(java.lang.String oldPassword, java.lang.String newPassword)Change the password for the currently logged in user.ScriptNodecreateGroup(java.lang.String groupName)Create a new root level group with the specified unique nameScriptNodecreateGroup(ScriptNode parentGroup, java.lang.String groupName)Create a new group with the specified unique nameScriptNodecreatePerson(java.lang.String userName)Create a Person with the given user nameScriptNodecreatePerson(java.lang.String userName, java.lang.String firstName, java.lang.String lastName, java.lang.String emailAddress)Create a Person with the given user name, firstName, lastName and emailAddressScriptNodecreatePerson(java.lang.String userName, java.lang.String firstName, java.lang.String lastName, java.lang.String emailAddress, java.lang.String password, boolean setAccountEnabled)Create a Person with an optionally generated user name.ScriptNodecreatePerson(java.lang.String userName, java.lang.String firstName, java.lang.String lastName, java.lang.String emailAddress, java.lang.String password, boolean setAccountEnabled, boolean notifyByEmail)Create a Person with an optionally generated user namevoiddeleteGroup(ScriptNode group)Deletes a group from the system.voiddeletePerson(java.lang.String username)Delete a Person with the given usernamevoiddisableAccount(java.lang.String userName)Disable user account.voidenableAccount(java.lang.String userName)Enable user account.java.util.Map<java.lang.String,java.lang.Boolean>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 authoritybooleangetExcludeTenantFilter()ScriptNodegetGroup(java.lang.String groupName)Gets the Group given the group nameScriptableHashMapgetImmutableProperties(java.lang.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.ScriptablegetPeople(java.lang.String filter)Deprecated.recated see getPeople(filter, maxResults)org.mozilla.javascript.ScriptablegetPeople(java.lang.String filter, int maxResults)Get the collection of people stored in the repository.org.mozilla.javascript.ScriptablegetPeople(java.lang.String filter, int maxResults, java.lang.String sortBy, boolean sortAsc)Get the collection of people stored in the repository.protected java.util.List<PersonService.PersonInfo>getPeopleImpl(java.lang.String filter, ScriptPagingDetails pagingRequest, java.lang.String sortBy, java.lang.Boolean sortAsc)protected java.util.List<PersonService.PersonInfo>getPeopleImplDB(java.lang.String filter, ScriptPagingDetails pagingRequest, java.lang.String sortBy, java.lang.Boolean sortAsc)protected java.util.List<org.alfresco.service.cmr.repository.NodeRef>getPeopleImplSearch(java.lang.String term, java.lang.String[] tokens, ScriptPagingDetails pagingRequest, java.lang.String sortBy, java.lang.Boolean sortAsc)org.mozilla.javascript.ScriptablegetPeoplePaging(java.lang.String filter, ScriptPagingDetails pagingRequest, java.lang.String sortBy, java.lang.Boolean sortAsc)org.alfresco.service.cmr.search.PermissionEvaluationModegetPermissionEvaluationMode()ScriptNodegetPerson(java.lang.String username)Gets the Person given the usernamejava.lang.StringgetPersonFullName(java.lang.String username)Faster helper when the script just wants to build the Full name for a person.booleanisAccountEnabled(java.lang.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(java.lang.String userName, java.lang.String password)Set a password for the given user.voidsetPersonService(PersonService personService)Set the person servicevoidsetQuota(ScriptNode person, java.lang.String quota)Set the content quota in bytes for a person.voidsetServiceRegistry(ServiceRegistry serviceRegistry)Set the service registryvoidsetStoreUrl(java.lang.String storeRef)Set the default store referencevoidsetTenantService(org.alfresco.repo.tenant.TenantService tenantService)voidsetUserNameGenerator(UserNameGenerator userNameGenerator)Set the user name generator servicevoidsetUserRegistrySynchronizer(UserRegistrySynchronizer userRegistrySynchronizer)Set the UserRegistrySynchronizer-
Methods inherited from class org.alfresco.repo.jscript.BaseScopableProcessorExtension
getScope, setScope
-
Methods inherited from class org.alfresco.repo.processor.BaseProcessorExtension
getExtensionName, register, setExtensionName, setProcessor
-
-
-
-
Field Detail
-
tenantService
protected org.alfresco.repo.tenant.TenantService tenantService
-
HINT_CQ_SUFFIX
protected static final java.lang.String HINT_CQ_SUFFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
afterPropertiesSet
public void afterPropertiesSet() throws java.lang.Exception- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
java.lang.Exception
-
setStoreUrl
public void setStoreUrl(java.lang.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(org.alfresco.repo.tenant.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 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
public void deletePerson(java.lang.String username)
Delete a Person with the given username- Parameters:
username- the username of the person to delete
-
createPerson
public ScriptNode createPerson(java.lang.String userName, java.lang.String firstName, java.lang.String lastName, java.lang.String emailAddress, java.lang.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(java.lang.String userName, java.lang.String firstName, java.lang.String lastName, java.lang.String emailAddress, java.lang.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
public void enableAccount(java.lang.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(java.lang.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(java.lang.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(java.lang.String oldPassword, java.lang.String newPassword)Change the password for the currently logged in user. Old password must be supplied.- Parameters:
oldPassword- Old user passwordnewPassword- New user password
-
setPassword
public void setPassword(java.lang.String userName, java.lang.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 forpassword- Password to set
-
createPerson
public ScriptNode createPerson(java.lang.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(java.lang.String userName, java.lang.String firstName, java.lang.String lastName, java.lang.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, java.lang.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(java.lang.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. Ifnull
then all people stored in the repository are returned- Returns:
- people collection as a JavaScript array
-
getPeople
public org.mozilla.javascript.Scriptable getPeople(java.lang.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. Ifnull
then 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(java.lang.String filter, int maxResults, java.lang.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. Ifnull
then 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(java.lang.String filter, ScriptPagingDetails pagingRequest, java.lang.String sortBy, java.lang.Boolean sortAsc)
-
getPeopleImpl
protected java.util.List<PersonService.PersonInfo> getPeopleImpl(java.lang.String filter, ScriptPagingDetails pagingRequest, java.lang.String sortBy, java.lang.Boolean sortAsc)
-
getPeopleImplDB
protected java.util.List<PersonService.PersonInfo> getPeopleImplDB(java.lang.String filter, ScriptPagingDetails pagingRequest, java.lang.String sortBy, java.lang.Boolean sortAsc)
-
getPeopleImplSearch
protected java.util.List<org.alfresco.service.cmr.repository.NodeRef> getPeopleImplSearch(java.lang.String term, java.lang.String[] tokens, ScriptPagingDetails pagingRequest, java.lang.String sortBy, java.lang.Boolean sortAsc) throws java.lang.Throwable- Throws:
java.lang.Throwable
-
getPerson
public ScriptNode getPerson(java.lang.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 java.lang.String getPersonFullName(java.lang.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(java.lang.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(java.lang.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, java.lang.String groupName)
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
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 groupauthority- 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 groupauthority- 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 forrecurse- 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 java.util.Map<java.lang.String,java.lang.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(java.lang.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 org.alfresco.service.cmr.search.PermissionEvaluationMode getPermissionEvaluationMode()
-
-