Class MentionUtils

java.lang.Object
org.exoplatform.social.core.utils.MentionUtils

public class MentionUtils extends Object
  • Method Details

    • getMentionedUsernames

      public static Set<String> getMentionedUsernames(String message)
      Gives the usernames mentioned as @username in a message, a mention ending on a whitespace, the end of the text or the < of a tag, and keeps only the enabled, non-deleted users.
      Parameters:
      message - the message text or HTML
      Returns:
      the mentioned usernames, empty when none
    • getMentionedRoles

      public static Set<String> getMentionedRoles(String message, String identityId)
      Gives the space roles mentioned as @role:spaceIdentityId in a message for the given space, a mention ending on a whitespace, the end of the text or the < of a tag.
      Parameters:
      message - the message text or HTML
      identityId - the identity id of the space whose role mentions are kept
      Returns:
      the mentioned roles, empty when none
    • substituteUsernames

      public static String substituteUsernames(String message)
    • substituteUsernames

      public static String substituteUsernames(String message, Locale locale)
    • substituteUsernames

      public static String substituteUsernames(String portalOwner, String message)
    • substituteUsernames

      public static String substituteUsernames(String portalOwner, String message, Locale locale)
    • substituteUsernames

      public static void substituteUsernames(org.exoplatform.social.core.activity.model.ExoSocialActivity activity, String portalOwner)
    • substituteUsernames

      public static void substituteUsernames(org.exoplatform.social.core.activity.model.ExoSocialActivity activity, List<String> templateParamKeys, String portalOwner)
    • substituteUsernames

      public static String substituteUsernames(org.exoplatform.social.core.manager.IdentityManager identityManager, String portalOwner, String message)
    • substituteUsernames

      public static String substituteUsernames(org.exoplatform.social.core.manager.IdentityManager identityManager, String portalOwner, String message, Locale locale)
      Replaces every @username mention of an enabled user by the user's profile link, then every role mention by its role link (see substituteRoles(IdentityManager, String, Locale)). The link is followed by the < of the tag the mention preceded, or by a single space.
      Parameters:
      identityManager - the service resolving the mentioned identities
      portalOwner - the portal owner used to build the profile URLs
      message - the message text or HTML
      locale - the locale of the role labels
      Returns:
      the message with its mentions substituted
    • substituteRoles

      public static String substituteRoles(org.exoplatform.social.core.manager.IdentityManager identityManager, String message, Locale locale)
      Replaces every @role:spaceIdentityId mention of an enabled space by the space role link, followed by the < of the tag the mention preceded, or by a single space.
      Parameters:
      identityManager - the service resolving the space identities
      message - the message text or HTML
      locale - the locale of the role labels
      Returns:
      the message with its role mentions substituted
    • substituteRoleWithLocale

      public static void substituteRoleWithLocale(org.exoplatform.social.core.activity.model.ExoSocialActivity activity, Locale locale)
    • substituteRoleWithLocale

      public static String substituteRoleWithLocale(String message, Locale locale)