Hi,
from JIRA SDK release 3.7.3 I can see that the following methods has been depreciated
List<String> userGroups = authenticationContext.getUser().getGroups(); //Bold bits depreciated
and as a consequence my code does not work properly for JIRA 5.0.
I can also see that the documentation is referring to use the "getLoggedInUser()" method but there is no "getGroups()" method to call in the hiearchy
I can't see that the "getGroups()" method being depreciated or moved in the documenation, any idea how to get around the problem?
I would prefer to make use of a method that returns a String list of the currently logged in user's groups
Would appreciate some feedback on this
BR
Lars Brodén
Community moderators have prevented the ability to post new answers.
Code reworked with "appreciated" classes for 3.7.3
Use getLoggedInUser. That will return the user name. Then use GroupManager to retrieve the groups.
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.
You haven't instantiated GroupManager anywhere! Inject it in the cosntructor or use the following:
GroupManager usersGroup = (GroupManager) ComponentManager.getComponentInstanceOfType(GroupManager.class);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Jobin I got it to work now!!.
On another matter, I have been running my plugin through the Atlassian Plugin Checkup for JIRA 5.0 and I do get some deprecated method calls and other stuff but the are not "striked through" in Eclipse, indicating that they are about to go.
Would you know why this is?, or if they still will work?, I notice while running the "Plugin Checkup" that there was only support for 5.0RC3, does this have anything to do with it?
Cheers
Lars
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have no idea. Maybe someone from Atlassian will comment on this!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Lars,
I need to get the current user and list of groups where the user belong to and tried to implement it in the was similar to yours described above.
import com.atlassian.jira.security.groups.GroupManager GroupManager usersGroup = (GroupManager) ComponentManager.getComponentInstanceOfType(GroupManager.class); String currentUser= authenticationContext.getLoggedInUser().toString(); String currentUserGroups = usersGroup.getGroupNamesForUser(currentUser).toString();
but i've got following error
2012-05-21 17:10:17,189 http-80-2 ERROR admin 1030x8516x1 18v94zm 10.161.201.37 /secure/QuickCreateIssue.jspa [onresolve.jira.groovy.GroovyRunner] The script failed : javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: authenticationContext for class: Script24
2012-05-21 17:10:17,189 http-80-2 ERROR admin 1030x8516x1 18v94zm 10.161.201.37 /secure/QuickCreateIssue.jspa [onresolve.jira.groovy.GroovyFunctionPlugin] Error executing post-function
javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: authenticationContext for class: Script24
do you know what might be wrong in my code?
Thank you in advance.
Best regards, Georgiy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
authenticationContext = ComponentAccessor.getJiraAuthenticationContext()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That helped :) and i had to add extra import
import com.atlassian.jira.component.ComponentAccessor
Thank you very much!
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.