How to get a users email address?

Jon Sword
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.
September 30, 2011

I am trying to update a JIRA plugin that used to fetch and display a users email address. The user.getEmail method was depreciated and referred to user.getEmailAddress which has now been depreciated, but this is where the trail has gone cold for me. Any suggestions?

String getEmail()
Deprecated. Please use getEmailAddress().
String

getEmailAddress()
Deprecated.

1 answer

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
Pankaj Jangid
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 30, 2011
Add SAL component to your atlassian-plugin.xml.
<component-import
  name="SAL User Manager"
  key="userManager"
  interface="com.atlassian.sal.api.user.UserManager"/>
Now in the code this should do it
import com.atlassian.sal.api.user.UserManager;
import com.atlassian.sal.api.user.UserProfile;

public class MyClass
{
  private UserManager userManager;

  public void setUserManager(UserManager userManager)
  {
    this.userManager = userManager;
  }

  public void testMethod()
  {
    String username  = userManager.getRemoteUsername();
    UserProfile up = userManager.getUserProfile(username);
    String email = up.getEmail();
  }
}

Jon Sword
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 17, 2011

Hi Jangid,

I had hoped to test your solution but I have been sidelined with other work. I am going to mark your answer as correct, it looks pretty solid to me.

Thanks for your input, I was completely stumped.

TAGS
AUG Leaders

Atlassian Community Events