Package org.cyclos.impl.utils
Interface RichTextHandler
-
- All Known Implementing Classes:
RichTextHandlerImpl
public interface RichTextHandlerContains methods to handle rich text formatting, as well as replacing image URL's with internal tags.- See Also:
RichText
-
-
Field Summary
Fields Modifier and Type Field Description static PatternTAG_PATTERNstatic StringURL_TAG_PREFIXstatic StringURL_TAG_SEPARATORstatic StringURL_TAG_SUFFIX
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description StringapplyPropertyMapping(DataTranslationPropertyMapping propertyMapping, String value, boolean fromClient)Apply all property mapping definitions to the translated value according if the data is received or sent to the clientStringescapeTags(String text)Replaces all '<' by '< ', effectively invalidating all HTML tagsStringreplaceTagsByUrls(String html)Replaces internal tags to URLs.StringreplaceTagsByUrls(String html, ConfigurationAccessor configuration)Same asreplaceTagsByUrls(String)but using the root url and network of the specified accessor,StringreplaceUrlsByTags(String html)Replaces URLs to to internal tags.StringreplaceUrlsByTags(String html, ConfigurationAccessor configuration)Same asreplaceUrlsByTags(String)but using the root url and network of the specified user,Stringsanitize(String html)Sanitizes the given HTML, removing blacklisted tags, correctly closing unclosed tags and removing leading / trailing whitespaces.StringunescapeTags(String text)Replaces all '< ' by '<', reverting the result ofescapeTags(String)
-
-
-
Field Detail
-
URL_TAG_PREFIX
static final String URL_TAG_PREFIX
- See Also:
- Constant Field Values
-
URL_TAG_SEPARATOR
static final String URL_TAG_SEPARATOR
- See Also:
- Constant Field Values
-
URL_TAG_SUFFIX
static final String URL_TAG_SUFFIX
- See Also:
- Constant Field Values
-
TAG_PATTERN
static final Pattern TAG_PATTERN
-
-
Method Detail
-
applyPropertyMapping
String applyPropertyMapping(DataTranslationPropertyMapping propertyMapping, String value, boolean fromClient)
Apply all property mapping definitions to the translated value according if the data is received or sent to the client
-
escapeTags
String escapeTags(String text)
Replaces all '<' by '< ', effectively invalidating all HTML tags
-
replaceTagsByUrls
String replaceTagsByUrls(String html)
Replaces internal tags to URLs. Should be invoked when converting a data to be sent to a client on an entity model (VO / DTO) from an entity.- See Also:
replaceUrlsByTags(String)
-
replaceTagsByUrls
String replaceTagsByUrls(String html, ConfigurationAccessor configuration)
Same asreplaceTagsByUrls(String)but using the root url and network of the specified accessor,- Parameters:
configuration- If null or was obtained usingSessionData.getConfiguration()then it resolve to the loggued user.
-
replaceUrlsByTags
String replaceUrlsByTags(String html)
Replaces URLs to to internal tags. Normally a call tosanitize(String)is sufficient, but there might be cases where an HTML sanitization is not needed, just the replacing of URL tags by full URLs. The following tags are handled:- {{config:<name>}}: Configuration image URL. See
ConfigurationImageType. - {{user:<key>:<size>}}: User profile image URL. See
UserImage. - {{usercustom:<key>:size>}}: User custom image URL. See
UserCustomImage. - {{ad:<key>:size>}}: Advertisement image URL. See
AdImage. - {{systemcustom:<key>:size>}}: System custom image URL. See
SystemCustomImage.
- {{config:<name>}}: Configuration image URL. See
-
replaceUrlsByTags
String replaceUrlsByTags(String html, ConfigurationAccessor configuration)
Same asreplaceUrlsByTags(String)but using the root url and network of the specified user,- Parameters:
configuration- If null or was obtained usingSessionData.getConfiguration()then it resolve to the loggued user.
-
sanitize
String sanitize(String html)
Sanitizes the given HTML, removing blacklisted tags, correctly closing unclosed tags and removing leading / trailing whitespaces. Administrators are allowed to use iframes and forms, but not regular users. Scripts and style tags are forbidden. Null inputs, as well as empty strings, results in null.
-
unescapeTags
String unescapeTags(String text)
Replaces all '< ' by '<', reverting the result ofescapeTags(String)
-
-