Hello everyone,
I'm fairly new to Groovy for Jira, and I came across a strange case
I need to know if an user has rights to a given project/issue. I then created following code :
///
But when I execute I got
groovy.lang.MissingMethodException: No signature of method: static com.atlassian.jira.user.ApplicationUser.hasPermission() is applicable for argument types: (com.atlassian.jira.security.plugin.ProjectPermissionKey, com.atlassian.jira.issue.IssueImpl) values: [BROWSE_PROJECTS, BLA-136] Possible solutions: hasPermission(com.atlassian.jira.security.plugin.ProjectPermissionKey, com.atlassian.jira.project.Project), hasPermission(com.atlassian.jira.security.plugin.ProjectPermissionKey, com.atlassian.jira.issue.Issue), hasPermission(com.atlassian.jira.permission.GlobalPermissionKey) at Script460.run(Script460.groovy:12)
I don't know how to hop from com.atlassian.jira.issue.IssueImpl to com.atlassian.jira.issue.Issue. It's the same if I try to load the project, I even tried mutableIssue but still the same result. I tried to use directly issueobj but same result too.
Do you have any indication or documentation I may have missed on how to convert that into the type I need ?
Regards,
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.PermissionManager
import com.atlassian.jira.security.plugin.ProjectPermissionKey
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.user.util.UserManager
IssueManager issueManager = ComponentAccessor.getIssueManager()
UserManager userManager = ComponentAccessor.getUserManager()
PermissionManager permissionManager = ComponentAccessor.getPermissionManager()
Issue issue = issueManager.getIssueObject('ABC-123') as Issue
ApplicationUser appUser = userManager.getUserByName('dummy')
boolean hasPerm = permissionManager.hasPermission(new ProjectPermissionKey("BROWSE_PROJECTS"), issue, appUser)
No, it will work and without "as Issue"
Your errors are:
- wrong way of getting issue object
- wrong way of checking permissions.
ApplicationUser - is abstract and don't have hasPermission function. You have to add new variable with object type Application User, what I made at line 14.
And then you have to use permissionManager, that checks permissions of user
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.