Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

error importing GroupManager in behaviours plugin server side script

neil1967 October 21, 2012

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

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Yousef Hammouda October 23, 2012

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

neil1967 October 29, 2012

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?

neil1967 October 29, 2012

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

0 votes
Yousef Hammouda October 23, 2012

encountered the same problem :(, trying to do the same thing!!!!

TAGS
AUG Leaders

Atlassian Community Events