org.alfresco.repo.jscript
Class People

java.lang.Object
  extended by org.alfresco.repo.processor.BaseProcessorExtension
      extended by org.alfresco.repo.jscript.BaseScopableProcessorExtension
          extended by org.alfresco.repo.jscript.People
All Implemented Interfaces:
org.alfresco.processor.ProcessorExtension, Scopeable, org.springframework.beans.factory.InitializingBean

public final class People
extends BaseScopableProcessorExtension
implements org.springframework.beans.factory.InitializingBean

Scripted People service for describing and executing actions against People & Groups.


Constructor Summary
People()
           
 
Method Summary
 void addAuthority(ScriptNode parentGroup, ScriptNode authority)
          Add an authority (a user or group) to a group container as a new child
 void afterPropertiesSet()
           
 void changePassword(java.lang.String oldPassword, java.lang.String newPassword)
          Change the password for the currently logged in user.
 ScriptNode createGroup(ScriptNode parentGroup, java.lang.String groupName)
          Create a new group with the specified unique name
 ScriptNode createGroup(java.lang.String groupName)
          Create a new root level group with the specified unique name
 ScriptNode createPerson(java.lang.String userName)
          Create a Person with the given user name
 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
 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.
 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
 void deleteGroup(ScriptNode group)
          Deletes a group from the system.
 void deletePerson(java.lang.String username)
          Delete a Person with the given username
 void disableAccount(java.lang.String userName)
          Disable user account.
 void enableAccount(java.lang.String userName)
          Enable user account.
 java.util.Map getCapabilities(ScriptNode person)
          Gets a map of capabilities (boolean assertions) for the given person.
 org.mozilla.javascript.Scriptable getContainerGroups(ScriptNode person)
          Gets the groups that contain the specified authority
 ScriptNode getGroup(java.lang.String groupName)
          Gets the Group given the group name
 ScriptableHashMap getImmutableProperties(java.lang.String username)
          Return a map of the Person properties that are marked as immutable for the given user.
 org.mozilla.javascript.Scriptable getMembers(ScriptNode group)
          Gets the members (people) of a group (including all sub-groups)
 org.mozilla.javascript.Scriptable getMembers(ScriptNode group, boolean recurse)
          Gets the members (people) of a group
 org.mozilla.javascript.Scriptable getPeople(java.lang.String filter)
          Get the collection of people stored in the repository.
 org.mozilla.javascript.Scriptable getPeople(java.lang.String filter, int maxResults)
          Get the collection of people stored in the repository.
 ScriptNode getPerson(java.lang.String username)
          Gets the Person given the username
 boolean isAccountEnabled(java.lang.String userName)
          Return true if the specified user account is enabled.
 boolean isAdmin(ScriptNode person)
          Return true if the specified user is an Administrator authority.
 boolean isGuest(ScriptNode person)
          Return true if the specified user is an guest authority.
 void removeAuthority(ScriptNode parentGroup, ScriptNode authority)
          Remove an authority (a user or group) from a group
 void setAuthenticationService(MutableAuthenticationService authenticationService)
          Sets the authentication service.
 void setAuthorityDAO(AuthorityDAO authorityDAO)
          Set the authority DAO
 void setAuthorityService(AuthorityService authorityService)
          Set the authority service
 void setContentUsageService(ContentUsageService contentUsageService)
           
 void setNamespaceService(org.alfresco.service.namespace.NamespaceService namespaceService)
           
 void setPassword(java.lang.String userName, java.lang.String password)
          Set a password for the given user.
 void setPersonService(PersonService personService)
          Set the person service
 void setQuota(ScriptNode person, java.lang.String quota)
          Set the content quota in bytes for a person.
 void setServiceRegistry(ServiceRegistry serviceRegistry)
          Set the service registry
 void setStoreUrl(java.lang.String storeRef)
          Set the default store reference
 void setTenantService(org.alfresco.repo.tenant.TenantService tenantService)
           
 void setUserNameGenerator(UserNameGenerator userNameGenerator)
          Set the user name generator service
 void setUserRegistrySynchronizer(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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

People

public People()
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Specified by:
afterPropertiesSet in interface org.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.

setNamespaceService

public void setNamespaceService(org.alfresco.service.namespace.NamespaceService namespaceService)

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 -

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 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(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 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(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 password
newPassword - 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 for
password - 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)
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(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. 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

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

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 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
recurse - recurse into sub-groups
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 java.util.Map 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 -
Returns:
ScriptableHashMap


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.