Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Ankuskum
Contributor
February 24, 2022 edited

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
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Atlassian Community Events