cancel
Showing results for 
Search instead for 
Did you mean: 

Javascript API - group membership

stebans
Champ in-the-making
Champ in-the-making
Hi,

I would like to make a user member of a group depending on information extracted from ldap.
I use Alfresco 2.0 CE and I think the people API doesn't (yet?) support a setMember method, nor a createGroup method. Or this could maybe be accomplished through the Node API?

If not, what best alternative do I have? Is there a way to call the Alfresco repository API or the JCR API to add user to a group? it's impossible to script Java classes with importClass or importPackage, so do I need to add a custom Script API ?

Thanks!
stephane
5 REPLIES 5

kevinr
Star Contributor
Star Contributor
The good news is that Create Group and Add User/Group to a Group has been added to the JavaScript API for Alfresco 2.1.

For 2.0 now, you would need to create a java class that performs the service calls you need and configure that in as a custom javascript object using Spring:
http://wiki.alfresco.com/wiki/JavaScript_API#Adding_custom_Script_APIs
You can then call that object from javascript until you upgrade to 2.1. You can get the code out from our public SVN if you want to see how the API has been expanded on the People object in JavaScript for 2.1 - then you can make your custom object very similar so the transition is easy for you when 2.1 comes out.

Hope this helps,

Kevin

stebans
Champ in-the-making
Champ in-the-making
Thanks a lot for your answer.
Stéphane

stebans
Champ in-the-making
Champ in-the-making
Hi,

In Javascript API of Alfresco-dev 11-June-2007, I have seen the extension of the people API with createGroup(groupName) method. But I haven't found how to add a person to a group… Is it not implemented yet (or hidden somewhere else :wink: )?

Thanks
Stéphane

PS. Where to put/check issues/remarks about nightly builds releases? in Jira or it does pollute Jira repository?

kevinr
Star Contributor
Star Contributor
The API you want is: people.addAuthority(groupNode, authorityNode)
It can be used to add a person or a group to an existing group. Note that you will need to retrieve the authority (i.e. person) with the people.getPerson(username) or people.getGroup(groupname) first.

Thanks,

Kevin

stebans
Champ in-the-making
Champ in-the-making
I should have guessed, tsss!

Thanks a lot,
Stéphane