@PublicApi public interface

MessageUserProcessor

com.atlassian.jira.service.util.handler.MessageUserProcessor
Known Indirect Subclasses

@PublicApi

This interface is designed for plugins to consume (call its methods).

Clients of @PublicApi can expect that programs compiled against a given version will remain binary compatible with later versions of the @PublicApi as per each product's API policy as long as the client does not implement/extend @PublicApi interfaces or classes (refer to each product's API policy for the exact guarantee---usually binary compatibility is guaranteed at least across minor versions).

Note: since @PublicApi interfaces and classes are not designed to be implemented or extended by clients, we may perform certain types of binary-incompatible changes to these classes and interfaces, but these will not affect well-behaved clients that do not extend/implement these types (in general, only classes and interfaces annotated with @PublicSpi are safe to extend/implement).

Class Overview

A set of User-related util methods which can be useful while processing Message objects.

Summary

Public Methods
@Nullable User findUserByEmail(String emailAddress)
Returns the first User found with an email address that equals the given emailAddress case insensitively.
@Nullable User findUserByUsername(String username)
Finds the user with the given username or returns null if there is no such User.
@Nullable User getAuthorFromSender(Message message)
For each sender of the given message in turn, look up a User first with a case-insensitively equal email address, and failing that, with a username equal to the email address.

Public Methods

@Nullable public User findUserByEmail (String emailAddress)

Returns the first User found with an email address that equals the given emailAddress case insensitively.

Parameters
emailAddress the email address to match.
Returns
  • the User.

@Nullable public User findUserByUsername (String username)

Finds the user with the given username or returns null if there is no such User. Convenience method which doesn't throw up.

Parameters
username the username.
Returns
  • the User or null.

@Nullable public User getAuthorFromSender (Message message)

For each sender of the given message in turn, look up a User first with a case-insensitively equal email address, and failing that, with a username equal to the email address.

JIRA wants to do this because when we create users in email handlers, we set email and username equal. If a user subsequently changes their email address, we must not assume they don't exist and create them with the email address as the username.

Parameters
message the message from which to get the User.
Returns
  • the User matching the sender of the message or null if none found.
Throws
MessagingException if there's strife getting the message sender.