Missed Team ’24? Catch up on announcements here.

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

Change user's display name

sri.sankaran November 3, 2011

JIRA version: 4.4.3

How does one change the the display name of a User from within a custom service? Javadocs lead me to CrowdService.updateUser. However that method requires a User object and the User object doesn't provide any setters.

Sri

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
Raju
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.
November 3, 2011

Sri,

You need to use com.atlassian.crowd.model.user.UserTemplate

Here is the example code: I'm assuming you already injected crowdService.

UserManager userManager = ComponentAccessor.getUserManager();
com.atlassian.crowd.embedded.api.User user = userManager.getUser("admin");

UserTemplate userTemplate = new UserTemplate(user);
userTemplate.setDisplayName("A.D. Mean");


  try
  {
    crowdService.updateUser(userTemplate);
  }
   catch (Exception e)
  {
    //Handle exceptions properly.
     e.printStackTrace();
  }

Hope this helps,

Raju

0 votes
Jobin Kuruvilla [Adaptavist]
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.
November 3, 2011

Maybe use getUser method to get the User object given the name?

TAGS
AUG Leaders

Atlassian Community Events