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

Question on user comparisons with JIRA 6+

William Crighton _CCC_
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.
May 31, 2013

Since users are now 'identified' by their 'id' value instead of their login name is this statement still a valid one to use when trying to determine if two users are the same account?

if(reporter.getName().equals(currentUser.getName()))
{
    // do something
}

or do we need to reference the com.atlassian.crowd.embedded.api.User id attribute and compare with that?

If the answer to the above is 'Yes' do we need to go and refactor every user comparison we've written to reference the new id value?

Thanks.

3 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
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.
June 1, 2013
As far as I understand, you should still be able to do this because usernames will continue to be unique. It is just that the name might be changed in future as renaming is allowed. But that should be fine for you as both reporter and current user name will change if the renaming is done.
William Crighton _CCC_
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.
June 6, 2013

Jobin,

Thank you very much for your reply. I'm considering it at the moment and will accept it if I can't think of an edge case where that doesn't hold. However, I'm skeptical that I'll think of such a thing.

-wc

2 votes
William Crighton _CCC_
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.
July 19, 2015

{major edit here}

William Crighton [CCC] ·

YUK! I totally mis-understood your question. Rereading it now I believe you are asking where I sourced the information that you quoted...that is:

Since users are now 'identified' by their 'id' value instead of their login name

That information came from this Atlassian Doc page:

https://developer.atlassian.com/display/JIRADEV/Renamable+Users+in+JIRA+6.0

Specifically - and going through this exercise illuminates why you asked your question - Atlassian is calling it a 'key', not an 'id'...my bad:

We have introduced a new field called "key" to users that is a case-sensitive String and will never change (also referred to as the "userkey").
In order to correctly support systems with multiple directories, this key is applicable at the application level, not at the user directory level.

Existing users will get allocated a key that is equal to the lowercase of the username.
This means there is no need to migrate existing data: the stored value is the user key and even if the user's username is later edited, this stored key will remain correct.
(This assumes that you are already lower-casing the stored usernames which was required in order to avoid case-sensitivity bugs).

When to use the key, when to use the username

The userkey should be considered the primary key of the user.
Anytime you want to store a reference to a user in long term storage (eg the DB or Lucene index) you should use the key because it can never change.

However, the userkey should never be exposed to the end user; only the username should be displayed.
The username is a unique secondary key, but should not be stored in long-term storage because it can change over time.

{end}

{original dumbass answer...}

I don't understand the question...are you asking where the 4 lines of code came from? If so I just plucked them from the ether surrounding a discussion I had with a coworker on JIRA 6 changes. More formally, I guess, the code would look like this:

.....

{end}
0 votes
Timothy
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.
May 31, 2013

Since users are now 'identified' by their 'id' value instead of their login name

Where did you source this from?

William Crighton _CCC_
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.
January 19, 2014

YUK! I totally mis-understood your question. Rereading it now I believe you are asking where I sourced the information that you quoted...that is:

Since users are now 'identified' by their 'id' value instead of their login name

That information came from this Atlassian Doc page:

https://developer.atlassian.com/display/JIRADEV/Renamable+Users+in+JIRA+6.0

Specifically - and going through this exercise illuminates why you asked your question - Atlassian is calling it a 'key', not an 'id'...my bad:

We have introduced a new field called "key" to users that is a case-sensitive String and will never change (also referred to as the "userkey").
In order to correctly support systems with multiple directories, this key is applicable at the application level, not at the user directory level.

Existing users will get allocated a key that is equal to the lowercase of the username.
This means there is no need to migrate existing data: the stored value is the user key and even if the user's username is later edited, this stored key will remain correct.
(This assumes that you are already lower-casing the stored usernames which was required in order to avoid case-sensitivity bugs).

When to use the key, when to use the username

The userkey should be considered the primary key of the user.
Anytime you want to store a reference to a user in long term storage (eg the DB or Lucene index) you should use the key because it can never change.

However, the userkey should never be exposed to the end user; only the username should be displayed.
The username is a unique secondary key, but should not be stored in long-term storage because it can change over time.

TAGS
AUG Leaders

Atlassian Community Events