Expand my Community achievements bar.

SOLVED

How to add Users and Roles to a Project created using AEM 6.2 Project API?

Avatar

Level 3

I'm trying to create Projects in AEM 6.2 using the new Project API [ https://docs.adobe.com/docs/en/aem/6-2/develop/ref/javadoc/com/adobe/cq/projects/api/Project.html ]

I am able to create the Project and also use a Template that i developed for that Project.

When i am trying to add Users and Roles to the Project using the method 

project = projectManager.createProject("/contents/projects", "Project1", "Project Name", "Creating a Test Project", "/apps/myproj/projects/templates/default"); ... List<String> usersIds = ... List<String> rolesIds = ... project.updateMembers(userIds, roleIds);

   

I tried to map the values in lists 'usersIds' to 'rolesIds', like..

(userId)ksurendra --> (roleId) role_editor 

I'm seeing the exceptions like:
Caused by: com.adobe.cq.projects.impl.team.TeamException: The role role_editor is not available for admin.

Appreciate any thoughts on this.

1 Accepted Solution

Avatar

Correct answer by
Level 3

After some research and testing, i found the solution.

The Solution is to add an Owner to the Project before any Users are assigned to the project.

So when you call

project.updateMembers(userIds, roleIds);

make sure the first values for the userIds and roleIds lists' are of the owner, and then the other users will follow.

For example:

List<String> userIds = new ArrayList<String>{}; userIds.add("suren"); userIds.add("vassu"); List<String> roleIds = new ArrayList<String>{}; userIds.add("owner"); userIds.add("designer");


Some background to the solution.

  1. When we create a Project using the API, we need to use a Template. And each of these Templates will have a pre-defined set of Roles. And these Roles will be assigned to the Project (see below).
  2. When we add a User to the above Project, we need to define the "Role" that user will have on the Project. This is the key thing.
  3. Every Project will have a Team, and a Project need to have an Owner before any other Users can be assigned.

View solution in original post

2 Replies

Avatar

Correct answer by
Level 3

After some research and testing, i found the solution.

The Solution is to add an Owner to the Project before any Users are assigned to the project.

So when you call

project.updateMembers(userIds, roleIds);

make sure the first values for the userIds and roleIds lists' are of the owner, and then the other users will follow.

For example:

List<String> userIds = new ArrayList<String>{}; userIds.add("suren"); userIds.add("vassu"); List<String> roleIds = new ArrayList<String>{}; userIds.add("owner"); userIds.add("designer");


Some background to the solution.

  1. When we create a Project using the API, we need to use a Template. And each of these Templates will have a pre-defined set of Roles. And these Roles will be assigned to the Project (see below).
  2. When we add a User to the above Project, we need to define the "Role" that user will have on the Project. This is the key thing.
  3. Every Project will have a Team, and a Project need to have an Owner before any other Users can be assigned.

Avatar

Administrator

ksuren wrote...

After some research and testing, i found the solution.

The Solution is to add an Owner to the Project before any Users are assigned to the project.

So when you call

  1. project.updateMembers(userIds, roleIds);

make sure the first values for the userIds and roleIds lists' are of the owner, and then the other users will follow.

For example:

 
  1. List<String> userIds = new ArrayList<String>{};
  2. userIds.add("suren");
  3. userIds.add("vassu");
  4.  
  5. List<String> roleIds = new ArrayList<String>{};
  6. userIds.add("owner");
  7. userIds.add("designer");


Some background to the solution.

  1. When we create a Project using the API, we need to use a Template. And each of these Templates will have a pre-defined set of Roles. And these Roles will be assigned to the Project (see below).
  2. When we add a User to the above Project, we need to define the "Role" that user will have on the Project. This is the key thing.
  3. Every Project will have a Team, and a Project need to have an Owner before any other Users can be assigned.

 

Thank you for posting solution here.

~kautuk



Kautuk Sahni