Hello,
Using jira 4.4.4 and Behaviours Plugin 0.5.0.
Trying to write a serverside script in Behaviours Plugin interface that tests to see if current user is in a certain group before making something read-only. Why does the compiler return this error:
unable to resolve class com.atlassian.jira.security.groups.GroupManager
even though it imports other classes like com.atlassian.jira.security.roles.ProjectRole ?
Relevant script snippet:
import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.MutableIssue import com.atlassian.jira.security.groups.GroupManager import com.atlassian.jira.security.roles.ProjectRoleManager import com.atlassian.jira.security.roles.ProjectRole FormField fieldClients=getFieldByName("Clients") def componentManager = ComponentManager.getInstance() def currentUser = componentManager.jiraAuthenticationContext?.user GroupManager groupManager = ComponentManager.getComponentInstanceOfType(GroupManager.class) if ( groupManager.isUserInGroup(currentUser.name, "Developers") ) { fieldClients.setReadOnly(true) } // do other project-related stuff
Community moderators have prevented the ability to post new answers.
I tried a turnaround solution. do the same if you did'nt find a better one:
Go to your \installed-plugins\ and get the plugin.104507584462513390.Behaviours-jira-0.5.0-jira5.jar
Open it and modify in the atlassian-plugin.xml the following,
<!-- Add to the import package list your custom classes, if you have them --> <Import-Package>com.atlassian.jira.security.groups,com.atlassian.jira.component,com.atlassian.jira.jql.builder,com.atlassian.query,com.atlassian.jira.security.roles.actor,com.atlassian.jira.issue.link,com.atlassian.core.ofbiz,com.atlassian.jira.issue.security,com.atlassian.core.ofbiz.util,*;resolution:=optional</Import-Package>
by adding the missing packages.
in your case, add
com.atlassian.jira.security.groups
Hope this will help,
Yousef
This seems to have gotten me at least past the error of an unresolved class reference. Of course now I get the error "Found class but could not find method run" when trying to make this call:
issue.getProjectObject()
Since I know that this code works in a script post function, I'm wondering if the Behaviours plugin is referencing a different set of classes than the scripts plugin?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
didn't realize that in Behaviours, issue is not something defined by default. You have to get the issue first with a call to getFieldById("id") and then grab the ProjectObject from it. I've embedded that call within the entire call to grab the ProjectObject like so:
ComponentManager.getInstance().getIssueManager().getIssueObject(Long.parseLong(getFieldById("id").value)).getProjectObject()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
encountered the same problem :(, trying to do the same thing!!!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.