Package org.cyclos.impl.utils
Class RichTextHandlerImpl
- java.lang.Object
-
- org.cyclos.impl.AbstractServerComponent
-
- org.cyclos.impl.AbstractNetworkedServerComponent
-
- org.cyclos.impl.BaseNetworkedHandlerImpl
-
- org.cyclos.impl.utils.RichTextHandlerImpl
-
- All Implemented Interfaces:
RichTextHandler
@Component public class RichTextHandlerImpl extends BaseNetworkedHandlerImpl implements RichTextHandler
Implementation forRichTextHandler
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRichTextHandlerImpl.URLTag
-
Field Summary
-
Fields inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
authHandler, conversionHandler, customFieldValueHandler, entityManagerHandler, groupsHandler, productsHandler, restBeanPropertyMapping, userLocatorHandler
-
Fields inherited from class org.cyclos.impl.AbstractServerComponent
accountHandler, configurationHandler, dataTranslationHandler, notificationHandler, profileFieldHandler, transactionHandler, translationHandler
-
Fields inherited from interface org.cyclos.impl.utils.RichTextHandler
TAG_PATTERN, URL_TAG_PREFIX, URL_TAG_SEPARATOR, URL_TAG_SUFFIX
-
-
Constructor Summary
Constructors Constructor Description RichTextHandlerImpl()
-
Method Summary
All Methods Instance Methods Concrete 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 asRichTextHandler.replaceTagsByUrls(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 asRichTextHandler.replaceUrlsByTags(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 ofRichTextHandler.escapeTags(String)-
Methods inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
canManage, checkManagesUser, checkPermission, checkRelatesToUser, checkValue, clearAlreadyValidated, getBaseEntityManagerHandler, getConfiguration, getLoggedBasicUser, getLoggedUser, getProducts, getTranslatedName, getTranslatedValue, hasPermission, hasValue, inSameNetwork, inSameNetworkOrGlobal, isAdmin, isAlreadyValidated, isBroker, isGlobalAdmin, isGlobalAdminInNetwork, isGuest, isLoggedIn, isMember, isMemberOnly, isNetworkAdmin, isOperator, isRelatedToUser, isSystem, isUserManager, isUserManagerOf, message, message, permission, permission, permissionOptionalValue, permissionOptionalValue, toDate, toDateTime, validate
-
Methods inherited from class org.cyclos.impl.AbstractServerComponent
dataTranslationProxy, delete, detach, find, flush, from, getApplicationContext, getFormatter, getFormatter, getFormatter, getLogger, getRemoteAddress, getSessionData, mailContentBuilder, message, message, persist, processBatch, processBatch, refresh, remove, selectFrom, subQuery, update
-
-
-
-
Method Detail
-
applyPropertyMapping
public String applyPropertyMapping(DataTranslationPropertyMapping propertyMapping, String value, boolean fromClient)
Description copied from interface:RichTextHandlerApply all property mapping definitions to the translated value according if the data is received or sent to the client- Specified by:
applyPropertyMappingin interfaceRichTextHandler
-
escapeTags
public String escapeTags(String text)
Description copied from interface:RichTextHandlerReplaces all '<' by '< ', effectively invalidating all HTML tags- Specified by:
escapeTagsin interfaceRichTextHandler
-
replaceTagsByUrls
public String replaceTagsByUrls(String html)
Description copied from interface:RichTextHandlerReplaces 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.- Specified by:
replaceTagsByUrlsin interfaceRichTextHandler- See Also:
RichTextHandler.replaceUrlsByTags(String)
-
replaceTagsByUrls
public String replaceTagsByUrls(String html, ConfigurationAccessor configuration)
Description copied from interface:RichTextHandlerSame asRichTextHandler.replaceTagsByUrls(String)but using the root url and network of the specified accessor,- Specified by:
replaceTagsByUrlsin interfaceRichTextHandlerconfiguration- If null or was obtained usingSessionData.getConfiguration()then it resolve to the loggued user.
-
replaceUrlsByTags
public String replaceUrlsByTags(String html)
Description copied from interface:RichTextHandlerReplaces URLs to to internal tags. Normally a call toRichTextHandler.sanitize(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.
- Specified by:
replaceUrlsByTagsin interfaceRichTextHandler
- {{config:<name>}}: Configuration image URL. See
-
replaceUrlsByTags
public String replaceUrlsByTags(String html, ConfigurationAccessor configuration)
Description copied from interface:RichTextHandlerSame asRichTextHandler.replaceUrlsByTags(String)but using the root url and network of the specified user,- Specified by:
replaceUrlsByTagsin interfaceRichTextHandlerconfiguration- If null or was obtained usingSessionData.getConfiguration()then it resolve to the loggued user.
-
sanitize
public String sanitize(String html)
Description copied from interface:RichTextHandlerSanitizes 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.- Specified by:
sanitizein interfaceRichTextHandler
-
unescapeTags
public String unescapeTags(String text)
Description copied from interface:RichTextHandlerReplaces all '< ' by '<', reverting the result ofRichTextHandler.escapeTags(String)- Specified by:
unescapeTagsin interfaceRichTextHandler
-
-