cancel
Showing results for 
Search instead for 
Did you mean: 

Troble adding new user using Person webscript

alextave
Champ in-the-making
Champ in-the-making
Hi everybody, I am working on a web application that uses Alfresco andd I have some trouble adding an user specifing the group which the user belongs to.
I'm calling the webscript using Java in this way:

String url="http://localhost:8080/alfresco/service/api/people?alf_ticket='+this.TICKET;
DettagliUtente du=new DettagliUtente(nome, cnome, email, uname, pwd, da, quota, array_groups, titolo, orga, jobtitolo);
         
HttpClient client = HttpClientBuilder.create().build();
HttpPost post=new HttpPost(url);
StringEntity entity=new StringEntity( gson.toJson(du) );
post.setEntity(entity);
post.setHeader("Content-type", "application/json");
HttpResponse risposta=client.execute(post);


DettagliUtente
is a simple POJO class I made to store some information about the user. This information are retrieved from a jsp page.
In this class I store the groups in which the user belongs to, but I can't understand which Java object type I have to use to correctly send the groups in JSON format. You can see I convert my POJO class in JSON object using Gson.

I used an array of String that contains the name (shortName) of the group but it didn't work. I tried again a Vector of class Gruppo, which is this:

public class Gruppo {
    private String displayName;
    private String itemName;
}

but again I hadn't success. The user is created correctly but the groups are completly ignored.

So this is my question: How can I pass the groups to this webscript? I mean, which object I have to use to store groups information and pass them.

I hope I explain myself in a good way, if not tell me what is not clear.

Thank you
Andrea
2 REPLIES 2

rahulmackdani
Champ in-the-making
Champ in-the-making
Hi Andrea

Can you append preix "GROUP_" before your group name and try.Groups are stored in format GROUP_groupName where groupName is displayed.

Regards

Thanks, you were right I had to use the prefix "GROUP_".

In Java I use a simple String array like this
String groups={"GROUP_GruppoTest3", "GROUP_GruppoTest4"};

in which GruppoTest3 or GruppoTest4 are the groups's displayedName.

Thank you