Package com.atlassian.confluence.util
Class GeneralUtil
- java.lang.Object
-
- com.atlassian.confluence.util.VelocityUtil
-
- com.atlassian.confluence.util.GeneralUtil
-
public final class GeneralUtil extends VelocityUtil
Extension ofVelocityUtilthat contain methods that are not safe for use in Velocity templates. These methods may mutate their input, application state, or returns an object which can.
-
-
Field Summary
Fields Modifier and Type Field Description static GeneralUtilINSTANCE-
Fields inherited from class com.atlassian.confluence.util.VelocityUtil
systemStartupTime
-
-
Constructor Summary
Constructors Constructor Description GeneralUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static FilecreateTempDirectoryInConfluenceTemp(String prefix)static FilecreateTempFile(String directory)static FilegetConfluenceTempDirectory()Deprecated.since 5.5.static FilegetLocalTempDirectory()Deprecated.since 7.12static StringgetOriginalPath(javax.servlet.http.HttpServletRequest request)Get the original request path, i.e.static StringgetOriginalUrl(javax.servlet.http.HttpServletRequest request)static StringgetRequestPath(javax.servlet.http.HttpServletRequest request)As opposed togetOriginalPath(javax.servlet.http.HttpServletRequest), the returned path will be decoded.static StringgetRequestUrl(javax.servlet.http.HttpServletRequest request)static FilegetSharedTempDirectory()Deprecated.since 7.12static UnzippergetUnzipper(File zipFile, File dirToExtractTo)static UnzippergetUnzipper(URL zipUrl, File dirToExtractTo)static UserAccessorgetUserAccessor()Deprecated.since 7.3.0, use component injectionstatic booleanisReadyToServe()Returns whether container is ready and setup is complete.static ConfluenceActionSupportnewWiredConfluenceActionSupport()Deprecated.since 8.0 no replacementstatic ConfluenceActionSupportnewWiredConfluenceActionSupport(@Nullable Space space)Deprecated.since 8.0 no replacementstatic javax.servlet.http.CookiesetCookie(String key, String value)Sets a cookie.static voidsetSystemStartupTime(Long systemStartupTime)static voidunzipFile(File zipFile, File dirToExtractTo)Unzips the zip file to the destination directorystatic voidunzipUrl(URL zipUrl, File dirToExtractTo)Unzips the zip url to the destination directory.-
Methods inherited from class com.atlassian.confluence.util.VelocityUtil
alwaysMaskEmail, appendAmpersandOrQuestionMark, applyIfNonNull, arraySize, base64Decode, base64Encode, cleanQuietly, completeUrlEncode, constrainLength, convertBeanToMap, convertMailFormatDate, convertToBoolean, convertToBoolean, convertToCharacter, convertToInteger, convertToString, copyDate, customGetPageUrl, displayShortUrl, displayShortUrl, doubleUrlEncode, elapse, escapeCDATA, escapeCommas, escapeCommas, escapeForHtmlAttribute, escapeForJavascript, escapeXml, escapeXml, escapeXMLCharacters, filterNulls, findAndMaskEmail, flushResponse, formatLongTime, getAttachmentUrl, getBuildDate, getBuildDateString, getBuildNumber, getCharacterEncoding, getCommentUrl, getCompactDuration, getConfluenceTempDirectoryPath, getCookieValue, getCookieValue, getDefaultCharset, getDefaultResourceBundle, getEditPageUrl, getFormatDateSimple, getGlobalSettings, getI18n, getIdBasedPageUrl, getImageInfo, getNiceDuration, getPageUrl, getPageUrl, getParentComment, getParentPageOrBlog, getPercentage, getPercentage, getRandomSubSet, getRelativeTime, getRequestCorrelationId, getServerRenderTime, getStackTrace, getSystemStartupTime, getVersionNumber, hackSingleQuotes, hasTooManyUsers, highlight, htmlEncode, htmlEncodeAndReplaceSpaces, htmlEscapeQuotes, isAllAscii, isAllLettersOrNumbers, isDateWithin24Hours, isInLastDays, isLicenseExpired, isSafeTitleForFilesystem, isSafeTitleForUrl, isSetupComplete, lookupDomainName, makeFlatSummary, makeFlatSummary, makeSummary, makeSummary, maskEmail, maskEmail, maskEmail, plain2html, populateSimpleMessage, prefixAllMapKeys, profilePop, profilePush, rdfEncode, refineOsDestination, removeEmailsFromString, replaceConfluenceConstants, replaceConfluenceHomeConstant, replaceInvalidXmlCharacters, safeSubList, shortenString, shouldUrlDecode, sortList, specialLowerCaseCollection, specialToLowerCase, splitCommaDelimitedString, stringSet, summarise, toEndOfMonth, trimDownStringToWord, unescapeCDATA, unescapeEntities, urlDecode, urlEncode, urlEncode, wordWrap
-
-
-
-
Field Detail
-
INSTANCE
public static final GeneralUtil INSTANCE
-
-
Method Detail
-
setSystemStartupTime
public static void setSystemStartupTime(Long systemStartupTime)
-
createTempDirectoryInConfluenceTemp
public static File createTempDirectoryInConfluenceTemp(String prefix)
-
getRequestPath
public static String getRequestPath(javax.servlet.http.HttpServletRequest request)
As opposed togetOriginalPath(javax.servlet.http.HttpServletRequest), the returned path will be decoded.
-
getRequestUrl
public static String getRequestUrl(javax.servlet.http.HttpServletRequest request)
-
getOriginalPath
public static String getOriginalPath(javax.servlet.http.HttpServletRequest request)
Get the original request path, i.e. the path that was requested by the user.
-
getOriginalUrl
public static String getOriginalUrl(javax.servlet.http.HttpServletRequest request)
-
setCookie
public static javax.servlet.http.Cookie setCookie(String key, String value)
Sets a cookie. set to use a default cookie age of one year and the context path as the default path- Parameters:
key- the key of the cookievalue- the value of the cookie- Returns:
- the new Cookie object
-
unzipFile
public static void unzipFile(File zipFile, File dirToExtractTo) throws IOException
Unzips the zip file to the destination directory- Parameters:
zipFile- the zip file to extractdirToExtractTo- the directory to extract the zip file to- Throws:
IOException- if an IOException occurs
-
getUnzipper
public static Unzipper getUnzipper(File zipFile, File dirToExtractTo) throws IOException
- Throws:
IOException
-
unzipUrl
public static void unzipUrl(URL zipUrl, File dirToExtractTo) throws IOException
Unzips the zip url to the destination directory.- Parameters:
zipUrl- the URL of the zip file to extractdirToExtractTo- the directory to extract the zip file to- Throws:
IOException- if an IOException occurs
-
getUserAccessor
@Deprecated public static UserAccessor getUserAccessor()
Deprecated.since 7.3.0, use component injection
-
isReadyToServe
public static boolean isReadyToServe()
Returns whether container is ready and setup is complete. The result is memoized once true.- Since:
- 9.0.0
-
newWiredConfluenceActionSupport
@Deprecated(since="8.0") public static ConfluenceActionSupport newWiredConfluenceActionSupport()
Deprecated.since 8.0 no replacement
-
newWiredConfluenceActionSupport
@Deprecated(since="8.0") public static ConfluenceActionSupport newWiredConfluenceActionSupport(@Nullable Space space)
Deprecated.since 8.0 no replacementCreate a wiredConfluenceActionSupportto be used for rendering a decorator.- Parameters:
space- A space to add to the rendering context, if provided.- Since:
- 7.5.0
-
getConfluenceTempDirectory
@Deprecated public static File getConfluenceTempDirectory()
Deprecated.since 5.5. UsegetLocalTempDirectory()instead.
-
getLocalTempDirectory
@Deprecated public static File getLocalTempDirectory()
Deprecated.since 7.12Checks if local temp directory exists before returning the path. Create it if it doesn't already exist.- Returns:
- path to temp directory inside local home
- Since:
- 5.5
-
getSharedTempDirectory
@Deprecated public static File getSharedTempDirectory()
Deprecated.since 7.12Checks if shared temp directory exists before returning the path. Create it if it doesn't already exist.- Returns:
- path to temp directory inside shared home
- Since:
- 5.5
-
-