Class WebUtilities
java.lang.Object
com.atlassian.greenhopper.web.util.WebUtilities
This service object provides access to web utilities that don't fit anywhere else. It is available from all actions through $action.util.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Collection<Long>
asLongList
(String[] values) TODO Should also not be in there.For priorities and issue types, the icon URL may be specified either as a relative path to the context path, or a fully-qualified external URL.static String
decodeHtml
(String txt) static String
encodeHtml
(String txt) Escape HTML textencodeInlineJson
(String json) We can't inline JSON into the page, because that stuff is read by the browser's HTML interpreter first rather than the JS interpreter, as it would in AJAX.encodeJson
(String text) Escape double-quotes where necessary to produce a JSON-ready string.Get the GreenHopper build propertiesEncapsulates code to work with the JIRA date picker.Collection<com.atlassian.jira.plugin.webfragment.model.SimpleLink>
Used for the dot dialog functionality.getLocale
(com.atlassian.jira.user.ApplicationUser user) Fetch the locale for the current user.Required for keyBoard shortcutsgetResourceLocation
(String moduleName, String resourceName) Get the resource location for a specific module.void
Load additional field specific javascript files JIRA includes this on various jsp files, such as the navigator, search, issuedetails or wizards and forms.boolean
isDateOverdue
(org.joda.time.DateMidnight date) Checks whether a date is in the past currently used in boxSettings.vm, here because we don't know where else to put it.void
Registers the GreenHopper keyboard context.static String
void
validateStringSpecialCharacters
(String str, ErrorCollection errorCollection) TODO Should not be in here.
-
Field Details
-
SERVICE
Used for dependency injection- See Also:
-
-
Constructor Details
-
WebUtilities
public WebUtilities()
-
-
Method Details
-
getResourceLocation
Get the resource location for a specific module. -
getModifierKey
Required for keyBoard shortcuts -
registerKeyboardContext
public void registerKeyboardContext()Registers the GreenHopper keyboard context. -
includeFieldResourcesForCurrentUser
public void includeFieldResourcesForCurrentUser()Load additional field specific javascript files JIRA includes this on various jsp files, such as the navigator, search, issuedetails or wizards and forms. -
encodeHtml
Escape HTML text -
decodeHtml
-
urlEncode
-
encodeJson
Escape double-quotes where necessary to produce a JSON-ready string. Does NOT HTML-encode anything (unlike encodeJavascript), this has to be done by the renderer/VM when the JSON contents is intended to be rendered into the DOM. -
encodeInlineJson
We can't inline JSON into the page, because that stuff is read by the browser's HTML interpreter first rather than the JS interpreter, as it would in AJAX. This means we must escape forward slashes to prevent XSS holes, because the HTML interpreter would pick up "" which is a perfectly valid JSON string, but would terminate the script tag. Note: The "/" itself is not harmful, but in combination with a terminating script tag it is.- Parameters:
json
- : preformatted JSON text- Returns:
- String safe for inlining into a JavaScript object
-
getDatePicker
Encapsulates code to work with the JIRA date picker. -
isDateOverdue
public boolean isDateOverdue(org.joda.time.DateMidnight date) Checks whether a date is in the past currently used in boxSettings.vm, here because we don't know where else to put it.- Parameters:
date
- the date to check, can be null- Returns:
- true if the date is before today, false otherwise or if date is null
-
getLocale
Fetch the locale for the current user. Mimics the behaviour ofJiraWebActionSupport
, avoiding the webwork action dependencies. -
validateStringSpecialCharacters
TODO Should not be in here. Checks for special characters that should not be saved at all. -
asLongList
TODO Should also not be in there. Takes an array of strings and converts it into an array of longs. -
getBuildProperties
Get the GreenHopper build properties -
getIssueOperations
Used for the dot dialog functionality. See IssueOperationsHelper for more infos -
convertRelativeUrlToAbsolute
For priorities and issue types, the icon URL may be specified either as a relative path to the context path, or a fully-qualified external URL. In the former case, we should convert the URL to an absolute URL before passing it to the outside world.- Parameters:
url
- the url to change- Returns:
- the possibly changed url
-