Reputation: 3597
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.
I'm creating the Project as:
project = projectManager.createProject("/contents/projects",
"Project1",
"Project Name",
"Creating a Test Project",
"/apps/myproj/projects/templates/default");
When i am trying to add Users and Roles to the Project using the method:
List<String> usersIds = ...
List<String> rolesIds = ...
project.updateMembers(userIds, roleIds);
I'm seeing the exceptions like: Caused by: com.adobe.cq.projects.impl.team.TeamException: The role role_editor is not available for admin.
I tried to map the values in lists 'usersIds' to 'rolesIds', like.. (userId)ksurendra --> (roleId) role_editor (This is another issue, maybe the API developers should have made it a Map instead of using two separate lists)
Appreciate any thoughts on this.
Upvotes: 1
Views: 751
Reputation: 3597
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.
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.
Every Project will have a Team, and a Project need to have an Owner before any other Users can be assigned.
References:
Location for "default" templates is /libs/cq/core/content/projects/templates/default
Upvotes: 0