How to check for user existence in jazz repository using Java API
Accepted answer
Comments
Thanks! Ralph.
Hi Ralph, your answer fits for my questions completely but I also wanted to know how to make that check in general for any other scenario? How can we check if userId exists in jazz repository or not?
As I see it, you have the teamRepository.contributorManager() available. You can either use teamRepository.contributorManager().fetchAllContributors(monitor) to fetch all contributors that are registered to the repository, this contains archived users as well. Or you have some ID and can use fetchContributorByID and you will get the contributor if one exists for the ID or an exception if not.
Or am I misunderstanding the question?
One other answer
Why the return value of fetchContributorByUserId() is not null(in fact, it is never null by design) but throwing an exception when the input parameter "userID" does not exist/match in the repository?
Comments
To document that in case of possible errors no null value is returned and to throw exceptions in error cases is a very clean design. Exceptions can also be easily used together with try/catch by a capable developer to implement control flows.
3ks, Ralph!