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

How I get ApplicationUser by name or key?

Pavol_Lackovič October 1, 2013

Hi.

I want to get ApplicationUser in Jira 6.1 by name or by key but I get DelegatingApplicationUser or BridgedDirectoryUser. How I get ApplicationUser?

I try this:

ComponentAccessor.getUserUtil().getUserByKey("key").getClass()
ComponentAccessor.getUserUtil().getUserByName("name").getClass()
ComponentAccessor.getUserUtil().getUserByKey("key").getDirectoryUser().getClass()
ComponentAccessor.getUserUtil().getUserByName("name").getDirectoryUser().getClass(
ApplicationUsers.from(ComponentAccessor.getUserUtil().getUserByKey("key").getDirectoryUser()).getClass()
ApplicationUsers.from(ComponentAccessor.getUserUtil().getUserByName("name").getDirectoryUser()).getClass()

and i get:

com.atlassian.jira.user.DelegatingApplicationUser
com.atlassian.jira.user.DelegatingApplicationUser
com.atlassian.jira.user.BridgedDirectoryUser
com.atlassian.jira.user.BridgedDirectoryUser
com.atlassian.jira.user.DelegatingApplicationUser
com.atlassian.jira.user.DelegatingApplicationUser

How I get ApplicationUser?

Thanks

4 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
Florin Manaila
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.
October 1, 2013

ApplicationUser is an interface and DelegatingApplicationUser is an implementation, which is what you want to use.

Pavol_Lackovič October 1, 2013

thanks:)

and how can I get user, which I use in method updateIssue (javascript:mctmp(0);) ?

Florin Manaila
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.
October 1, 2013

That would be the BridgedDirectoryUser which implements the old crowd User. You can get it from the Application user using getDirectoryUser().

Pavol_Lackovič October 1, 2013

When I use BridgedDirectoryUser I get

javax.script.ScriptException: java.lang.ClassCastException: com.atlassian.jira.user.BridgedDirectoryUser cannot be cast to com.atlassian.jira.user.ApplicationUser

my code:

def us = ComponentAccessor.getUserUtil().getUserByName("name").getDirectoryUser();

issueManager.updateIssue(us, issue, EventDispatchOption.DO_NOT_DISPATCH, false);

Florin Manaila
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.
October 1, 2013

That's because updateIssue() expects an ApplicationUser instead of a crowd User. Check the javadocs for the appropriate JIRA version you are developing your plugin for.

Just use one of the examples in your question that return a DelegatingApplicationUser.

0 votes
TSO Logic Admin February 4, 2014

We have effectively the same problem. We are trying to call "issueService.validateUpdate(...)", but get an exception "No signature of method... is applicable for argument types" compaining about "com.atlassian.jira.user.BridgedDirectoryUser" type (for which we cannot find any online documentation.

Code:

import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.user.ApplicationUsers
...
User loggedInUser = ApplicationUsers.toDirectoryUser(componentManager.jiraAuthenticationContext.user) as User
def updateValidationResult = issueService.validateUpdate(loggedInUser, uiip)

Logs:

java.lang.RuntimeException: No signature of method: com.atlassian.jira.bc.issue.DefaultIssueService.validateUpdate() is applicable for argument types: (com.atlassian.jira.user.BridgedDirectoryUser, com.atlassian.jira.issue.IssueInputParametersImpl)...
Possible solutions: ... validateCreate(com.atlassian.crowd.embedded.api.User, com.atlassian.jira.issue.IssueInputParameters)

-Johnny

TSO Logic Admin February 10, 2014

For the record, my particular issue got resolved.

Basically, we did not notice that the "Possible solutions" was actually recommending a different method entirely, namely "validateCreate". "validateUpdate" now always takes the ID of the issue you are updating, which we were not passing as an arg in our call.

-Johnny

0 votes
Pavol_Lackovič October 7, 2013

why doesnt updateIssue method accept DelegatingApplicationUser as input parameter?

0 votes
Pavol_Lackovič October 1, 2013

I use DelegatingApplicationUser and I get:

The script failed : javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.managers.DefaultIssueManager.updateIssue() is applicable for argument types: (com.atlassian.jira.user.DelegatingApplicationUser, com.atlassian.jira.issue.IssueImpl, com.atlassian.jira.event.type.EventDispatchOption$EventDispatchOptionImpl, java.lang.Boolean)

Possible solutions: updateIssue(com.atlassian.crowd.embedded.api.User, com.atlassian.jira.issue.MutableIssue, com.atlassian.jira.event.type.EventDispatchOption, boolean)

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events