mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-16 17:55:15 +00:00
Added createPerson() and deletePerson() methods to People JavaScript API - needed by 3.0 Invite Workflow
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9280 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
parent
95a622444e
commit
e09ae51c1d
@ -34,6 +34,7 @@ import org.alfresco.service.cmr.security.AuthorityService;
|
|||||||
import org.alfresco.service.cmr.security.AuthorityType;
|
import org.alfresco.service.cmr.security.AuthorityType;
|
||||||
import org.alfresco.service.cmr.security.PersonService;
|
import org.alfresco.service.cmr.security.PersonService;
|
||||||
import org.alfresco.util.ParameterCheck;
|
import org.alfresco.util.ParameterCheck;
|
||||||
|
import org.alfresco.util.PropertyMap;
|
||||||
import org.mozilla.javascript.Context;
|
import org.mozilla.javascript.Context;
|
||||||
import org.mozilla.javascript.Scriptable;
|
import org.mozilla.javascript.Scriptable;
|
||||||
|
|
||||||
@ -77,6 +78,44 @@ public final class People extends BaseScopableProcessorExtension
|
|||||||
this.authorityService = authorityService;
|
this.authorityService = authorityService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a Person with the given username
|
||||||
|
*
|
||||||
|
* @param username the username of the person to delete
|
||||||
|
*/
|
||||||
|
public void deletePerson(String username)
|
||||||
|
{
|
||||||
|
PersonService personService = services.getPersonService();
|
||||||
|
personService.deletePerson(username);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a Person with the given username and password
|
||||||
|
*
|
||||||
|
* @param username the username of the person to be created
|
||||||
|
* @param password the password of the person to be created
|
||||||
|
* @return the person node (type cm:person) created or null if the person already exists
|
||||||
|
*/
|
||||||
|
public ScriptNode createPerson(String username, String password)
|
||||||
|
{
|
||||||
|
ParameterCheck.mandatoryString("Username", username);
|
||||||
|
ParameterCheck.mandatoryString("Password", password);
|
||||||
|
|
||||||
|
ScriptNode person = null;
|
||||||
|
|
||||||
|
PropertyMap properties = new PropertyMap();
|
||||||
|
properties.put(ContentModel.PROP_USERNAME, username);
|
||||||
|
properties.put(ContentModel.PROP_PASSWORD, password);
|
||||||
|
PersonService personService = services.getPersonService();
|
||||||
|
if (!personService.personExists(username))
|
||||||
|
{
|
||||||
|
NodeRef personRef = personService.createPerson(properties);
|
||||||
|
person = new ScriptNode(personRef, services, getScope());
|
||||||
|
}
|
||||||
|
|
||||||
|
return person;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Person given the username
|
* Gets the Person given the username
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user