Class MentionUtils
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.cms.repository.mentions.MentionUtils
- All Implemented Interfaces:
LogEnabled
,Component
,Serviceable
Utils for Mentions
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Regex used to extract mentions from a text.static final String
Regex used to extract mentions from a text.protected I18nUtils
The i18n utils.protected UserManager
The user managerstatic final String
Avalon role -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionextractMentionedUsersFromRichText
(String content) Extract mentioned users from rich text contentstatic Set
<UserIdentity> Extract mentioned users from simple text contentvoid
service
(ServiceManager manager) transformRichTextToReadableText
(String syntaxText, UserIdentity recipient) Transform syntax text of a rich text to display text using a regex to find the parts to transform and a function to transform themtransformTextToReadableText
(String syntaxText, UserIdentity recipient) Transform syntax text of a simple text to display text using a regex to find the parts to transform and a function to transform themMethods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
Avalon role -
__EXTRACT_MENTIONS_REGEX_SIMPLE_TEXT
Regex used to extract mentions from a text. A mention is inside a @()- See Also:
-
__EXTRACT_MENTIONS_REGEX_RICH_TEXT
Regex used to extract mentions from a text. A mention is inside a @()- See Also:
-
_userManager
The user manager -
_i18nUtils
The i18n utils.
-
-
Constructor Details
-
MentionUtils
public MentionUtils()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
extractMentionedUsersFromSimpleText
Extract mentioned users from simple text content- Parameters:
content
- the simple text content- Returns:
- the set of mentioned users
-
extractMentionedUsersFromRichText
Extract mentioned users from rich text content- Parameters:
content
- the rich text content- Returns:
- the set of mentioned users
-
transformRichTextToReadableText
Transform syntax text of a rich text to display text using a regex to find the parts to transform and a function to transform them- Parameters:
syntaxText
- the syntax textrecipient
- the recipient of the mail, for mail purposes- Returns:
- the transformed text with colors according to the recipient
-
transformTextToReadableText
Transform syntax text of a simple text to display text using a regex to find the parts to transform and a function to transform them- Parameters:
syntaxText
- the syntax textrecipient
- the recipient of the mail, for mail purposes, can be null for any other purposes- Returns:
- the transformed text with colors according to the recipient if not null, with full name in plain text otherwise
-