|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.atlassian.confluence.util.GeneralUtil
public final class GeneralUtil
Constructor Summary | |
---|---|
GeneralUtil()
|
Method Summary | ||
---|---|---|
static java.lang.String |
alwaysMaskEmail(java.lang.String emailAddress)
Masks an email address by replacing '@' with 'at' and '.' with 'dot'. |
|
static java.lang.String |
appendAmpsandOrQuestionMark(java.lang.String str)
|
|
int |
arraySize(int[] array)
convenience method to allow us to determine the size of an int array a velocity file |
|
static java.lang.String |
base64Decode(java.lang.String s)
|
|
static java.lang.String |
base64Encode(java.lang.String s)
|
|
static java.lang.String |
checkPartnerDetails(com.atlassian.license.License license,
java.lang.String buildPartnerName)
|
|
static java.lang.String |
completeUrlEncode(java.lang.String url)
A utility method to encode the given url for protocols which the CompleteURLEncoder supports. |
|
static java.lang.String |
constrainLength(java.lang.String s,
int length)
Truncate a string after n characters |
|
static java.util.Map |
convertBeanToMap(java.lang.Object bean)
|
|
static java.util.Date |
convertMailFormatDate(java.lang.String date)
|
|
static java.lang.Boolean |
convertToBoolean(java.lang.Object obj)
|
|
static boolean |
convertToBoolean(java.lang.Object bool,
boolean defaultValue)
|
|
static java.lang.Character |
convertToCharacter(java.lang.Object obj)
|
|
static java.lang.Integer |
convertToInteger(java.lang.Object obj)
|
|
static java.lang.String |
convertToString(java.lang.Object obj)
|
|
static java.io.File |
createTempDirectoryInConfluenceTemp(java.lang.String prefix)
|
|
static java.io.File |
createTempFile(java.lang.String directory)
|
|
static java.lang.String |
customGetPageUrl(AbstractPage page)
Need a special case of generalutils getpageurl that appends ? or ampersand smartly this is used to prefix url parameters that are appended after this path like: showcomments=true#addcomment |
|
static java.lang.String |
displayShortUrl(java.lang.String url)
|
|
static java.lang.String |
displayShortUrl(java.lang.String url,
int length)
|
|
static java.lang.String |
doubleUrlEncode(java.lang.String s)
|
|
static java.lang.String |
escapeCDATA(java.lang.String s)
|
|
static java.util.List |
escapeCommas(java.util.List toEscape)
Escape commas on each entry in the given list of strings. |
|
static java.lang.String |
escapeCommas(java.lang.String toEscape)
Escapes commas and backslashes with leading backslashes. |
|
static java.lang.String |
escapeForJavascript(java.lang.String s)
Escapes ', " and \ with a leading \. |
|
static java.lang.String |
escapeXml(java.lang.String stringToEscape)
|
|
static java.lang.String |
escapeXMLCharacters(java.lang.String input)
Take a String which may contain <, > or & and return an XML string containing entities |
|
static java.util.List |
filterNulls(java.util.Collection in)
Return a List with no null entries |
|
static java.lang.String |
findAndMaskEmail(java.lang.String text,
com.atlassian.user.User currentUser)
|
|
static java.lang.String |
format(java.util.Date date)
Deprecated. since 2.3. Provided for pre-2.3 themes and layouts only. New themes and layouts should use $dateFormatter.format(Date) in the Velocity context or ConfluenceUserPreferences.getDateFormatter(FormatSettingsManager) . |
|
static java.lang.String |
format(java.lang.Number number)
TODO: Replace with a NumberFormatter, similar to DateFormatter |
|
static java.lang.String |
format(java.lang.Object obj)
|
|
static java.lang.String |
format(java.lang.String str)
|
|
static java.lang.String |
formatBlogDate(java.util.Date date)
Deprecated. since 2.3. Provided for pre-2.3 themes and layouts only. New themes and layouts should use $dateFormatter.formatBlogDate(Date) in the Velocity context or ConfluenceUserPreferences.getDateFormatter(FormatSettingsManager) . |
|
static java.lang.String |
formatDateFull(java.util.Date date)
|
|
static java.lang.String |
formatDateTime(java.util.Date date)
Deprecated. since 2.3. Provided for pre-2.3 themes and layouts only. New themes and layouts should use $dateFormatter.formatDateTime(Date) in the Velocity context or ConfluenceUserPreferences.getDateFormatter(FormatSettingsManager) . |
|
static java.lang.String |
formatLongTime(long time)
|
|
static java.lang.String |
formatTime(java.util.Date date)
Deprecated. since 2.3. Provided for pre-2.3 themes and layouts only. New themes and layouts should use $dateFormatter.formatTime(Date) in the Velocity context or ConfluenceUserPreferences.getDateFormatter(FormatSettingsManager) . |
|
static java.util.Date |
getBuildDate()
|
|
static java.lang.String |
getBuildDateString()
|
|
static java.lang.String |
getBuildExcludedLocale()
|
|
static java.lang.String |
getBuildNumber()
|
|
static java.lang.String |
getBuildPartner()
|
|
static java.lang.String |
getCharacterEncoding()
|
|
static java.lang.String |
getCompactDuration(long time)
Returns the duration in a compact HH:mm:ss format. |
|
static java.io.File |
getConfluenceTempDirectory()
|
|
static java.lang.String |
getConfluenceTempDirectoryPath()
Checks if temp directory exists before returning the path. |
|
static java.lang.String |
getCookieValue(java.lang.String key)
|
|
static java.util.ResourceBundle |
getDefaultResourceBundle()
|
|
static java.lang.String |
getFormatDateSimple(java.util.Date date)
|
|
static Settings |
getGlobalSettings()
|
|
static I18NBean |
getI18n()
|
|
static java.lang.String |
getIdBasedPageUrl(AbstractPage page)
Get page URL that is id based (i.e. |
|
static com.atlassian.core.util.ImageInfo |
getImageInfo(java.io.File pathToImage)
|
|
static java.lang.String |
getNiceDuration(int minutes,
int seconds)
|
|
static java.lang.String |
getPageUrl(AbstractPage page)
|
|
static java.lang.String |
getPageUrl(VersionHistorySummary summary)
|
|
long |
getPercentage(long numerator,
long denom)
converts a fraction into a percentage |
|
long |
getPercentage(java.lang.String numeratorAsString,
java.lang.String denomAsString)
|
|
static java.util.Properties |
getProperties(java.lang.String resource,
java.lang.Class callingClass)
Deprecated. since 2.3 use PropertyUtils.getProperties(String, Class) instead |
|
static java.util.Properties |
getPropertiesFromFile(java.io.File file)
Deprecated. since 2.3 use PropertyUtils.getProperties(String, Class) instead |
|
static java.util.Properties |
getPropertiesFromStream(java.io.InputStream is)
Deprecated. since 2.3 use PropertyUtils.getProperties(String, Class) instead |
|
static
|
getRandomSubSet(java.util.List<T> list,
int sizeOfSubset,
java.util.Random random)
Returns a randomised subset of the list provided. |
|
static java.lang.String |
getRelativeTime(java.util.Date date)
Deprecated. since 2.7 use FriendlyDateFormatter |
|
static java.lang.String |
getStackTrace(java.lang.Throwable t)
|
|
static java.lang.Long |
getSystemStartupTime()
|
|
static java.lang.String |
getUploadFileTooLargeMessage(java.lang.String errorMessage)
if this error message is of the type: "java.io.IOException: Content Length Error" convert it to something nicer |
|
static UserAccessor |
getUserAccessor()
|
|
static java.lang.String |
getVersionNumber()
|
|
static java.lang.String |
hackSingleQuotes(java.lang.String s)
hack to make strings that contain singles compatible with javascript (which also uses single quotes denote strings) |
|
static boolean |
hasTooManyUsers()
Check if the current installation has more active users than is allowed by the license |
|
static java.lang.String |
highlight(java.lang.String content,
java.lang.String searchwords)
|
|
static java.lang.String |
htmlEncode(java.lang.String text)
|
|
static java.lang.String |
htmlEscapeQuotes(java.lang.String input)
Take a string and escape the quotes in it with \" and HTML escape them afterwards. |
|
static boolean |
isAllAscii(java.lang.String s)
|
|
static boolean |
isAllLettersOrNumbers(java.lang.String s)
|
|
static boolean |
isDefaultUserProfilePicture(java.lang.String username)
Deprecated. This method must not be used anymore, it is horribly inefficient. Rather use the ProfilePictureInfo: since it is never null, you can ask that object is the user has a default profile picture or not |
|
static boolean |
isGlobalAdministrator(java.lang.Object notUsedAnyMore,
com.atlassian.user.User user)
Deprecated. since 2.0 use PermissionManager directly, or use the $permissionHelper from velocity |
|
static boolean |
isInLastDays(java.util.Date date,
int maxDays)
|
|
static boolean |
isLicenseExpired()
|
|
static boolean |
isOutgoingMailConfigured()
|
|
static boolean |
isSafeTitleForFilesystem(java.lang.String title)
Ensure the title is safe to be written to the file system. |
|
static boolean |
isSafeTitleForUrl(java.lang.String title)
Is "title" something we can safely put in a /foo/bar/title URL? Or should we reference this thing by ID just to be safe? |
|
static boolean |
isSetupComplete()
|
|
static boolean |
isSuperUser(com.atlassian.user.User user)
|
|
static void |
loadDefaultProperties()
Deprecated. since 3.0 because it doesn't do anything |
|
static java.lang.String |
lookupDomainName(javax.servlet.http.HttpServletRequest request)
Get the default domain name. |
|
static java.lang.String |
makeFlatSummary(java.lang.String content)
Create a summary of this content fragment. |
|
static java.lang.String |
makeFlatSummary(java.lang.String content,
java.lang.String query)
Create a summary of this content fragment given a query |
|
static com.atlassian.bonnie.search.summary.Summary |
makeSummary(java.lang.String content)
Create a proper summary of this content fragment. |
|
static com.atlassian.bonnie.search.summary.Summary |
makeSummary(java.lang.String content,
java.lang.String query)
Create a proper summary of this content fragment given a query |
|
static java.lang.String |
maskEmail(java.lang.String emailAddress)
If configured, masks an email address to defeat the most simplistic spam bots. |
|
static ConfluenceActionSupport |
newWiredConfluenceActionSupport()
|
|
static java.lang.String |
personalSpaceUrl(java.lang.String contextPath,
java.lang.String username)
|
|
static java.lang.String |
plain2html(java.lang.String text)
|
|
static java.lang.String |
populateSimpleMessage(java.lang.String template,
java.util.List<java.lang.String> values)
Populate the template String supplied using the given values. |
|
static java.util.Map |
prefixAllMapKeys(java.lang.String prefix,
java.util.Map map)
Convert the supplied Map so that all of the keys in the Map are prefixed by the supplied String followed by a full stop. |
|
static void |
profilePop(java.lang.String s)
|
|
static void |
profilePush(java.lang.String s)
|
|
static java.lang.String |
rdfEncode(java.lang.String s)
A fairly evil hack to work around CONF-10364. |
|
static java.lang.String |
replaceConfluenceHomeConstant(java.lang.String in,
java.lang.String confHome)
|
|
static java.util.List |
safeSubList(java.util.List list,
int max)
|
|
static javax.servlet.http.Cookie |
setCookie(java.lang.String key,
java.lang.String value)
Sets a cookie. |
|
static void |
setSystemStartupTime(java.lang.Long systemStartupTime)
|
|
static void |
setUserAccessor(UserAccessor userAcc)
|
|
static java.lang.String |
shortenString(java.lang.String str,
int max)
Returns a substring of the specified string if it is longer than max. |
|
static boolean |
shouldUrlDecode(java.lang.String str)
|
|
static java.util.Collection |
specialLowerCaseCollection(java.util.Collection collection)
Takes a collection of Strings and lowercases the entries. |
|
static java.lang.String |
specialToLowerCase(java.lang.String str)
the database lower() function in PostgreSQL only works for ASCII strings. |
|
static java.lang.String[] |
splitCommaDelimitedString(java.lang.String escapedNames)
Method will turn a String of comma seperated entities into a String Array. |
|
static boolean |
stringSet(java.lang.String str)
|
|
long |
subtract(long a,
long b)
|
|
long |
subtract(java.lang.String firstOperandAsString,
java.lang.String secondOperandAsString)
|
|
static java.lang.String |
summarise(java.lang.String content)
Deprecated. since 2.0 use RendererUtil.summarise(String) instead. |
|
static java.lang.String |
trimDownStringToWord(java.lang.String s)
|
|
static java.lang.String |
unescapeCDATA(java.lang.String s)
|
|
static java.lang.String |
unescapeEntities(java.lang.String str)
|
|
static void |
unzipFile(java.io.File zipFile,
java.io.File dirToExtractTo)
Unzips the zip file to a folder in temp and returns the File pointing to that expanded folder. |
|
static void |
unzipUrl(java.net.URL zipUrl,
java.io.File dirToExtractTo)
Unzips the zip url to a folder in temp and returns the File pointing to that expanded folder. |
|
static java.lang.String |
urlDecode(java.lang.String url)
|
|
static java.lang.String |
urlEncode(java.lang.String url)
A utility method to encode HTTP form parameter/values. |
|
static java.lang.String |
wordWrap(java.lang.String str,
int max)
For really long strings that have no spaces or line breaks, browsers such as firefox, Netscape, have difficulty wrapping them inside a table cell, and so these strings end up stretching the cell longer than its suppose to be = ugly we want to simulate IE's word-wrap/break function here |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GeneralUtil()
Method Detail |
---|
public static void loadDefaultProperties()
BuildInformation
public static java.lang.String getStackTrace(java.lang.Throwable t)
public static java.lang.String format(java.lang.Number number)
DateFormatter
public static java.lang.String format(java.util.Date date)
ConfluenceUserPreferences.getDateFormatter(FormatSettingsManager)
.
DateFormatter.format(Date)
public static java.lang.String format(java.lang.String str)
public static java.lang.String format(java.lang.Object obj)
public static java.lang.String formatDateTime(java.util.Date date)
ConfluenceUserPreferences.getDateFormatter(FormatSettingsManager)
.
DateFormatter.formatDateTime(Date)
public static java.lang.String formatTime(java.util.Date date)
ConfluenceUserPreferences.getDateFormatter(FormatSettingsManager)
.
DateFormatter.formatTime(Date)
public static java.lang.String formatBlogDate(java.util.Date date)
ConfluenceUserPreferences.getDateFormatter(FormatSettingsManager)
.
DateFormatter.formatBlogDate(Date)
public static java.util.Date convertMailFormatDate(java.lang.String date) throws java.text.ParseException
java.text.ParseException
public static java.lang.Character convertToCharacter(java.lang.Object obj)
public static java.lang.Integer convertToInteger(java.lang.Object obj)
public static java.lang.Boolean convertToBoolean(java.lang.Object obj)
public static boolean convertToBoolean(java.lang.Object bool, boolean defaultValue)
public static java.lang.String convertToString(java.lang.Object obj)
public static java.lang.String completeUrlEncode(java.lang.String url)
url
- - the entire URL to encode
public static java.lang.String urlEncode(java.lang.String url)
url
- - part of the url to encode
public static java.lang.String urlDecode(java.lang.String url)
public static boolean shouldUrlDecode(java.lang.String str)
public static java.lang.String getPageUrl(VersionHistorySummary summary)
public static java.lang.String getPageUrl(AbstractPage page)
public static java.lang.String getIdBasedPageUrl(AbstractPage page)
page
- the page to generate a url for
public static boolean isSafeTitleForUrl(java.lang.String title)
public static boolean isSafeTitleForFilesystem(java.lang.String title)
title
-
public static java.lang.String customGetPageUrl(AbstractPage page)
public static java.lang.String appendAmpsandOrQuestionMark(java.lang.String str)
public static java.lang.String wordWrap(java.lang.String str, int max)
str
- max
- - max length of string allowed per linepublic static java.lang.String highlight(java.lang.String content, java.lang.String searchwords)
public static java.lang.String doubleUrlEncode(java.lang.String s)
public static boolean isAllAscii(java.lang.String s)
public static boolean isAllLettersOrNumbers(java.lang.String s)
public static java.lang.String getVersionNumber()
public static java.util.Date getBuildDate()
public static java.lang.String getBuildDateString()
public static java.lang.String getBuildNumber()
public static java.lang.String getBuildPartner()
public static java.lang.String getBuildExcludedLocale()
public static java.lang.Long getSystemStartupTime()
public static void setSystemStartupTime(java.lang.Long systemStartupTime)
public static boolean isLicenseExpired()
public static java.lang.String checkPartnerDetails(com.atlassian.license.License license, java.lang.String buildPartnerName)
public static boolean hasTooManyUsers()
public static boolean stringSet(java.lang.String str)
public static java.lang.String formatLongTime(long time)
public static java.lang.String displayShortUrl(java.lang.String url)
public static java.lang.String displayShortUrl(java.lang.String url, int length)
public static java.lang.String formatDateFull(java.util.Date date)
public static boolean isSuperUser(com.atlassian.user.User user)
public static java.lang.String getCharacterEncoding()
public static java.lang.String escapeXml(java.lang.String stringToEscape)
public static java.lang.String escapeForJavascript(java.lang.String s)
public static boolean isSetupComplete()
public static java.lang.String maskEmail(java.lang.String emailAddress)
emailAddress
- the email address to mask
public static java.lang.String alwaysMaskEmail(java.lang.String emailAddress)
emailAddress
- an email address to mask, eg dwillis@atlassian.com
public static java.lang.String findAndMaskEmail(java.lang.String text, com.atlassian.user.User currentUser)
public static java.lang.String escapeCDATA(java.lang.String s)
public static java.lang.String unescapeCDATA(java.lang.String s)
public static java.io.File createTempDirectoryInConfluenceTemp(java.lang.String prefix)
public static java.io.File createTempFile(java.lang.String directory)
public static java.lang.String unescapeEntities(java.lang.String str)
public static java.lang.String base64Decode(java.lang.String s)
public static java.lang.String base64Encode(java.lang.String s)
public static java.lang.String hackSingleQuotes(java.lang.String s)
s
- public static boolean isInLastDays(java.util.Date date, int maxDays)
date
- the date to checkmaxDays
- the number of days into the past the date can fall
public static java.lang.String getRelativeTime(java.util.Date date)
FriendlyDateFormatter
public static java.lang.String getFormatDateSimple(java.util.Date date)
public static javax.servlet.http.Cookie setCookie(java.lang.String key, java.lang.String value)
key
- value
- public static java.lang.String getCookieValue(java.lang.String key)
public static java.lang.String htmlEncode(java.lang.String text)
public static boolean isGlobalAdministrator(java.lang.Object notUsedAnyMore, com.atlassian.user.User user)
PermissionManager
directly, or use the $permissionHelper from velocity
public static java.lang.String plain2html(java.lang.String text)
PlainTextToHtmlConverter
public static java.util.Properties getProperties(java.lang.String resource, java.lang.Class callingClass)
PropertyUtils.getProperties(String, Class)
instead
public static java.util.Properties getPropertiesFromFile(java.io.File file)
PropertyUtils.getProperties(String, Class)
instead
public static java.util.Properties getPropertiesFromStream(java.io.InputStream is)
PropertyUtils.getProperties(String, Class)
instead
public static void unzipFile(java.io.File zipFile, java.io.File dirToExtractTo) throws java.lang.Exception
java.lang.Exception
public static void unzipUrl(java.net.URL zipUrl, java.io.File dirToExtractTo) throws java.lang.Exception
java.lang.Exception
public static java.lang.String getUploadFileTooLargeMessage(java.lang.String errorMessage)
errorMessage
- public static java.util.ResourceBundle getDefaultResourceBundle()
public static I18NBean getI18n()
I18NBean
for the current userpublic int arraySize(int[] array)
array
- public static java.lang.String escapeXMLCharacters(java.lang.String input)
public static java.lang.String htmlEscapeQuotes(java.lang.String input)
null
input will be returned as an empty String.
public static java.util.List filterNulls(java.util.Collection in)
public static java.lang.String shortenString(java.lang.String str, int max)
public static java.lang.String specialToLowerCase(java.lang.String str)
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.
str
- public static java.lang.String replaceConfluenceHomeConstant(java.lang.String in, java.lang.String confHome)
public static java.util.Collection specialLowerCaseCollection(java.util.Collection collection)
collection
-
public static java.util.List safeSubList(java.util.List list, int max)
public static java.lang.String summarise(java.lang.String content)
RendererUtil.summarise(String)
instead.
public static com.atlassian.bonnie.search.summary.Summary makeSummary(java.lang.String content)
Summarizer
public static com.atlassian.bonnie.search.summary.Summary makeSummary(java.lang.String content, java.lang.String query)
Summarizer
public static java.lang.String makeFlatSummary(java.lang.String content)
Summarizer
public static java.lang.String makeFlatSummary(java.lang.String content, java.lang.String query)
Summarizer
public static UserAccessor getUserAccessor()
public static void setUserAccessor(UserAccessor userAcc)
public static com.atlassian.core.util.ImageInfo getImageInfo(java.io.File pathToImage)
public static java.lang.String getNiceDuration(int minutes, int seconds)
public static java.lang.String getCompactDuration(long time)
time
- duration in milliseconds
public static ConfluenceActionSupport newWiredConfluenceActionSupport()
public static void profilePush(java.lang.String s)
public static void profilePop(java.lang.String s)
public static java.lang.String lookupDomainName(javax.servlet.http.HttpServletRequest request)
request
-
public static Settings getGlobalSettings()
public static java.lang.String personalSpaceUrl(java.lang.String contextPath, java.lang.String username)
public long getPercentage(long numerator, long denom)
numerator
- denom
- public long subtract(long a, long b)
public long getPercentage(java.lang.String numeratorAsString, java.lang.String denomAsString)
public long subtract(java.lang.String firstOperandAsString, java.lang.String secondOperandAsString)
public static java.lang.String getConfluenceTempDirectoryPath()
public static java.io.File getConfluenceTempDirectory()
public static java.lang.String[] splitCommaDelimitedString(java.lang.String escapedNames)
escapedNames
- Comma delimited string with original commas and backslashes escaped by backslashes
public static java.util.List escapeCommas(java.util.List toEscape)
toEscape
- String
s to escape
String
spublic static java.lang.String escapeCommas(java.lang.String toEscape)
toEscape
- string to escape. If null, then null will be returned.public static java.lang.String constrainLength(java.lang.String s, int length)
s
- The String to truncatelength
- The maximum length allowed.
public static boolean isOutgoingMailConfigured()
public static java.util.Map convertBeanToMap(java.lang.Object bean)
bean
- a bean to be converted to a Map.
public static java.util.Map prefixAllMapKeys(java.lang.String prefix, java.util.Map map)
If any of the keys in the Map are not Strings then they will be ignored.
prefix
- the prefix to be pre-pended to each Map key, if null then the original Map will be returned.map
- the Map to be modified. If null, then an empty Map will be returned.
public static boolean isDefaultUserProfilePicture(java.lang.String username)
public static java.lang.String rdfEncode(java.lang.String s)
s
- to encode
public static java.lang.String populateSimpleMessage(java.lang.String template, java.util.List<java.lang.String> values)
Populate the template String supplied using the given values. The template may contain place holders which are
denoted numerically in the form {n}
where n is an index into the supplied values list.
e.g. "The template called {1} will expects a colour here {0}".
This template will use value 0 and value 1 from the supplied values array. If the referenced value cannot be found then the place holder will simply be removed.
template
- the template to be populatedvalues
- the values used to populate the template
public static <T> java.util.List<T> getRandomSubSet(java.util.List<T> list, int sizeOfSubset, java.util.Random random)
list
- - the list to subsetsizeOfSubset
- - the size of the subset to returnrandom
- - the source of randomness
public static java.lang.String trimDownStringToWord(java.lang.String s)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |