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

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 Leaders.
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())

}

Suggest an answer

Log in or Sign up to answer