The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
  • Community
  • Q&A
  • Jira
  • Questions
  • Trying to get groups based on the project role. Getting error not able to resolve class RoleActor.

Trying to get groups based on the project role. Getting error not able to resolve class RoleActor.

Ankuskum
Contributor
February 24, 2022

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.project.Project;
import com.atlassian.jira.security.PermissionManager;
import com.atlassian.jira.security.roles.ProjectRole;
import com.atlassian.jira.security.roles.ProjectRoleActors;
import com.atlassian.jira.security.roles.ProjectRoleManager;
import com.atlassian.jira.user.ApplicationUser;

Set<String> projGroupNames =new HashSet<String>();
ProjectRoleManager projectRoleManager = ComponentAccessor.getComponentOfType(ProjectRoleManager.class);
ProjectRole projectRole = projectRoleManager.getProjectRole("Administrators");
ProjectRoleActors projectRoleActors = projectRoleManager.getProjectRoleActors(projectRole, project);
for(RoleActor actor : projectRoleActors.getRoleActorsByType(ProjectRoleActor.GROUP_ROLE_ACTOR_TYPE))
{

projGroupNames.add(actor.getParameter());

}

 

Getting error unable to resolve class RoleActor. Please help me to resolve this.

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Answer accepted
RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
February 24, 2022

I have modified your script but not tested..

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.project.Project
import com.atlassian.jira.security.roles.ProjectRole
import com.atlassian.jira.security.roles.ProjectRoleActor
import com.atlassian.jira.security.roles.ProjectRoleActors
import com.atlassian.jira.security.roles.ProjectRoleManager
import com.atlassian.jira.security.roles.RoleActor


Set<String> projGroupNames = new HashSet<String>()

Project project = ComponentAccessor.projectManager.getProjectObjByKey("JIRA") //change project key
ProjectRoleManager projectRoleManager = ComponentAccessor.getComponentOfType(ProjectRoleManager.class)
ProjectRole projectRole = projectRoleManager.getProjectRole("Administrators")
ProjectRoleActors projectRoleActors = projectRoleManager.getProjectRoleActors(projectRole, project)
for(RoleActor actor : projectRoleActors.getRoleActorsByType(ProjectRoleActor.GROUP_ROLE_ACTOR_TYPE))
{

projGroupNames.add(actor.getParameter())

}