com.atlassian.jira.util
Class EmailFormatterImpl

java.lang.Object
  extended by com.atlassian.jira.util.EmailFormatterImpl
All Implemented Interfaces:
EmailFormatter

public class EmailFormatterImpl
extends Object
implements EmailFormatter


Constructor Summary
EmailFormatterImpl(ApplicationProperties applicationProperties)
           
 
Method Summary
 boolean emailVisible(com.atlassian.crowd.embedded.api.User user)
          Emails are visible by user if email visibility is set to show (public) or mask (masked) or user (show to logged in users only)
 String formatEmail(String email, boolean isCurrentUserLoggedIn)
          Formats an email address for the purpose of displaying it to a user as determined by the APKeys.JIRA_OPTION_EMAIL_VISIBLE setting.
 String formatEmail(String email, com.atlassian.crowd.embedded.api.User currentUser)
          Formats an email address for the purpose of displaying it to a user as determined by the APKeys.JIRA_OPTION_EMAIL_VISIBLE setting.
 String formatEmail(com.atlassian.crowd.embedded.api.User user, com.atlassian.crowd.embedded.api.User currentUser)
          Formats user's email address for the purpose of displaying it to currentUser, as determined by the APKeys.JIRA_OPTION_EMAIL_VISIBLE setting.
 String formatEmailAsLink(String email, com.atlassian.crowd.embedded.api.User currentUser)
          Returns a HTML link for the e-mail if appropriate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EmailFormatterImpl

public EmailFormatterImpl(ApplicationProperties applicationProperties)
Method Detail

emailVisible

public boolean emailVisible(com.atlassian.crowd.embedded.api.User user)
Emails are visible by user if email visibility is set to show (public) or mask (masked) or user (show to logged in users only)

Specified by:
emailVisible in interface EmailFormatter
Parameters:
user - the user to which email addresses will be shown, or null if no user is logged in (browsing anonymously)
Returns:
true if email addresses should be visible (even if they will be masked); false otherwise

formatEmail

public String formatEmail(com.atlassian.crowd.embedded.api.User user,
                          com.atlassian.crowd.embedded.api.User currentUser)
Description copied from interface: EmailFormatter
Formats user's email address for the purpose of displaying it to currentUser, as determined by the APKeys.JIRA_OPTION_EMAIL_VISIBLE setting.

This convenience method is exactly equivalent to formatEmail(user.getEmailAddress(), currentUser != null), except that it is null-safe.

Specified by:
formatEmail in interface EmailFormatter
Parameters:
user - owner of the email address to format and display (null is permitted)
currentUser - the user to which email addresses will be shown, or null if no user is logged in (browsing anonymously)
Returns:
the formatted email address; null if either user is null or currentUser is not permitted to see email addresses

formatEmail

public String formatEmail(String email,
                          boolean isCurrentUserLoggedIn)
Description copied from interface: EmailFormatter
Formats an email address for the purpose of displaying it to a user as determined by the APKeys.JIRA_OPTION_EMAIL_VISIBLE setting.

SettingBehaviour
"show"The email is shown as-is to everyone.
"user"The email is shown as-is to users that are logged in, but not shown to anonymous users.
"mask"The email is shown to all users with the e-mail address slightly obscured, such that "user@example.com" appears as "user at example dot com", instead

Specified by:
formatEmail in interface EmailFormatter
Parameters:
email - The email address to show/mask/hide.
isCurrentUserLoggedIn - true if a user is currently logged in; false if the user is browsing anonymously
Returns:
the formatted email address; null if either email is null or the user is not permitted to see email addresses

formatEmail

public String formatEmail(String email,
                          @Nullable
                          com.atlassian.crowd.embedded.api.User currentUser)
Description copied from interface: EmailFormatter
Formats an email address for the purpose of displaying it to a user as determined by the APKeys.JIRA_OPTION_EMAIL_VISIBLE setting.

This convenience method is exactly equivalent to formatEmail(email, currentUser != null).

Specified by:
formatEmail in interface EmailFormatter
Parameters:
email - The email address to show/mask/hide.
currentUser - The user viewing the email address.
Returns:
the formatted email address; null if either email is null or the user is not permitted to see email addresses

formatEmailAsLink

@Nonnull
public String formatEmailAsLink(String email,
                                        @Nullable
                                        com.atlassian.crowd.embedded.api.User currentUser)
Returns a HTML link for the e-mail if appropriate. REMEMBER not to escape the string returned by this method as this method does this already!

Specified by:
formatEmailAsLink in interface EmailFormatter
Returns:
<a href="foo@bar.com">foo@bar.com</a> (public), foo at bar.com (masked), or an empty string ("") if either email is null or the user is not permitted to see email addresses


Copyright © 2002-2014 Atlassian. All Rights Reserved.