Package com.atlassian.confluence.util
Class GeneralUtil
java.lang.Object
com.atlassian.confluence.util.VelocityUtil
com.atlassian.confluence.util.GeneralUtil
Extension of 
VelocityUtil that contain methods that are not needed or safe for use in Velocity templates.- 
Field SummaryFieldsFields inherited from class com.atlassian.confluence.util.VelocityUtilDEFAULT_CHARACTER_ENCODING, ELLIPSIS
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic StringalwaysMaskEmail(String emailAddress) Masks an email address by replacing '@' with 'at' and '.' with 'dot'.static <T,S> S applyIfNonNull(T delegate, Function<T, S> wrapper) convertBeanToMap(Object bean) Deprecated, for removal: This API element is subject to removal in a future version.static voidTakes two calendar objects and sets the Date of the second to the Date of the first.static Filestatic StringdisplayShortUrl(String url) static StringdisplayShortUrl(String url, int length) static Stringstatic StringEscapes ', " and \ with a leading \.static <T> TexecuteRetryableTransaction(com.atlassian.sal.api.rdbms.TransactionalExecutor executor, com.atlassian.sal.api.rdbms.ConnectionCallback<T> callback) Deprecated, for removal: This API element is subject to removal in a future version.static StringgetAttachmentUrl(Attachment attachment) Get the permalink URL to preview the given attachment in the previewer.static StringgetCommentUrl(Attachment attachment, Comment comment) Get the permalink URL to preview the given comment (annotation) in the previewer.static Charsetstatic StringgetEditPageUrl(AbstractPage page) Get a resume draft URL that includes the shareDraftidstatic Settingsstatic I18NBeangetI18n()static StringGet page URL that is id based (i.e.static StringgetOriginalPath(jakarta.servlet.http.HttpServletRequest request) Get the original request path, i.e.static StringgetOriginalUrl(jakarta.servlet.http.HttpServletRequest request) static CommentgetParentComment(Comment comment) Returns the top-level comment that the comment is attached tostatic @Nullable AbstractPagegetParentPageOrBlog(Contained content) returns the page or blog that the content is attached to, or null if it is not attached to a page or blog.static StringgetRequestPath(jakarta.servlet.http.HttpServletRequest request) As opposed togetOriginalPath(jakarta.servlet.http.HttpServletRequest), the returned path will be decoded.static StringgetRequestUrl(jakarta.servlet.http.HttpServletRequest request) static Longstatic booleanReturns whether container is ready and setup is complete.static booleanstatic StringTake a String which may contain characters outside of the XML character range (http://www.w3.org/TR/REC-xml/#charsets) and return a String with those characters converted to Unicode "Replacement Character"s (0xFFFD).static voidsetSystemStartupTime(Long systemStartupTime) static StringspecialToLowerCase(String str) The database lower() function in PostgreSQL only works for ASCII strings.static StringspecialToLowerCase(String str, com.atlassian.config.ApplicationConfiguration appConfig) static String[]splitCommaDelimitedString(String escapedNames) Method will turn a String of comma separated entities into a String Array.static DatetoEndOfMonth(Calendar postDate, boolean isSqlServer) Deprecated, for removal: This API element is subject to removal in a future version.since 8.6static Stringstatic StringunescapeEntities(String str) Methods inherited from class com.atlassian.confluence.util.VelocityUtilappendAmpersandOrQuestionMark, base64Decode, base64Encode, customGetPageUrl, doubleUrlEncode, elapse, escapeXml, escapeXml, findAndMaskEmail, flushResponse, getBuildNumber, getCharacterEncoding, getFormatDateSimple, getLinkLoginPath, getLinkLoginUrl, getRequestCorrelationId, getServerRenderTime, getVersionNumber, htmlEscapeQuotes, intArrayToList, isAllAscii, isAscii, isDateWithin24Hours, isInLastDays, isLicenseExpired, lookupDomainName, makeFlatSummary, makeSummary, maskEmail, plain2html, profilePop, profilePush, replaceConfluenceConstants, safeSubList, shortenString, sortList, summarise, trimDownStringToWord
- 
Field Details- 
INSTANCE
 
- 
- 
Constructor Details- 
GeneralUtilpublic GeneralUtil()
 
- 
- 
Method Details- 
setSystemStartupTime
- 
getSystemStartupTime
- 
createTempDirectoryInConfluenceTemp
- 
getRequestPathAs opposed togetOriginalPath(jakarta.servlet.http.HttpServletRequest), the returned path will be decoded.
- 
getRequestUrl
- 
getOriginalPathGet the original request path, i.e. the path that was requested by the user.
- 
getOriginalUrl
- 
getIdBasedPageUrlGet page URL that is id based (i.e. in the format /pages/viewpage.action?pageId=<pageId>)- Parameters:
- page- the page to generate a url for
- Returns:
- page URL that is id based
 
- 
getEditPageUrlGet a resume draft URL that includes the shareDraftid- Parameters:
- page- the page to generate an edit url for
- Returns:
- The edit URL for that page
- Since:
- 6.1
 
- 
getAttachmentUrlGet the permalink URL to preview the given attachment in the previewer.- Parameters:
- attachment- the attachment to generate an URL for.
- Returns:
- permalink URL for the attachment.
 
- 
getCommentUrlGet the permalink URL to preview the given comment (annotation) in the previewer.- Parameters:
- attachment- the attachment that the annotation is on.
- comment- the annotation to generate the url for.
- Returns:
- permalink URL for the annotation.
 
- 
getParentPageOrBlogreturns the page or blog that the content is attached to, or null if it is not attached to a page or blog.- Parameters:
- content- content to check for containing page or blog.
- Returns:
- container page or blog.
 
- 
getParentCommentReturns the top-level comment that the comment is attached to- Parameters:
- comment- comment to check for parent comment
- Returns:
- top-level parent comment
 
- 
displayShortUrl
- 
displayShortUrl
- 
toEndOfMonth@Deprecated(forRemoval=true) public static Date toEndOfMonth(Calendar postDate, boolean isSqlServer) Deprecated, for removal: This API element is subject to removal in a future version.since 8.6Takes a Calendar object and returns the very end (last day, hour, minute, second and millisecond) of the month that the Calendar is in. The original Calendar object is left unaltered.- Parameters:
- postDate- A calendar object
- Returns:
- Date object signifying the very end of the Calendar's month
 
- 
copyDateTakes two calendar objects and sets the Date of the second to the Date of the first. Used to keep dates consistent regardless of timezones.- Parameters:
- original- The source calendar object
- copy- The destination calendar object
 
- 
getDefaultCharset
- 
escapeForJavascriptEscapes ', " and \ with a leading \.- Parameters:
- s- the string to escape
- Returns:
- the escaped string
 
- 
isSetupCompletepublic static boolean isSetupComplete()
- 
isReadyToServepublic static boolean isReadyToServe()Returns whether container is ready and setup is complete. The result is memoized once true.- Since:
- 9.0.0
 
- 
alwaysMaskEmailMasks an email address by replacing '@' with 'at' and '.' with 'dot'.- Parameters:
- emailAddress- an email address to mask, eg dwillis@atlassian.com
- Returns:
- a masked version of the email, eg dwillis at atlassian dot com
 
- 
escapeCDATA
- 
unescapeCDATA
- 
getI18n- Returns:
- The I18NBeanfor the current user
 
- 
replaceInvalidXmlCharactersTake a String which may contain characters outside of the XML character range (http://www.w3.org/TR/REC-xml/#charsets) and return a String with those characters converted to Unicode "Replacement Character"s (0xFFFD).Note that this method does not "escape" the string (e.g. "invalid input: '&'" is not converted to "&"). Similar to but converts illegals instead of throwing Exceptions.invalid referenceorg.jdom.Verifier#checkCharacterData(String)- Parameters:
- text- the input string
- Returns:
- the input string with those characters converted to Unicode "Replacement Character"s
 
- 
specialToLowerCaseThe database lower() function in PostgreSQL only works for ASCII strings. All other unicode and multibyte characters like capital umlaut are not properly converted. At the moment, when searching for pages we do the following comparison:lower(page.title) = :pageTitle(Where :pageTitle is normally .toLowerCase() first before being passed in)This special lower case function will skip the JAVA .toLowerCase() for postgres whose database lower() is ineffective. - Parameters:
- str- the string to convert to lower case
- Returns:
- the lower cased string
 
- 
specialToLowerCasepublic static String specialToLowerCase(String str, com.atlassian.config.ApplicationConfiguration appConfig) - Since:
- 9.3
 
- 
getGlobalSettings
- 
splitCommaDelimitedStringMethod will turn a String of comma separated entities into a String Array. Spaces before or after the comma will be cropped. Backslashes are treated as escaped characters. Eg when "backslash""comma" is encountered, the backslash is discarded and the comma is not treated as a delimiter.- Parameters:
- escapedNames- Comma delimited string with original commas and backslashes escaped by backslashes
- Returns:
- String[] of escapedNames
 
- 
convertBeanToMapDeprecated, for removal: This API element is subject to removal in a future version.since 8.6 useBeanUtils.describe(Object)- Parameters:
- bean- a bean to be converted to a Map.
- Returns:
- a Map where the keys are the property names from the beans, and the values are the property values. An empty Map will be returned if the bean cannot be converted.
 
- 
applyIfNonNull
- 
unescapeEntities
- 
executeRetryableTransaction@Deprecated(forRemoval=true) public static <T> T executeRetryableTransaction(com.atlassian.sal.api.rdbms.TransactionalExecutor executor, com.atlassian.sal.api.rdbms.ConnectionCallback<T> callback) Deprecated, for removal: This API element is subject to removal in a future version.Imperative alternative toRetryableTransaction.- Since:
- 9.1
 
 
- 
BeanUtils.describe(Object)