com.atlassian.greenhopper.web.util
Class WebUtilities

java.lang.Object
  extended by com.atlassian.greenhopper.web.util.WebUtilities

@Service(value="gh-webUtilities")
public class WebUtilities
extends java.lang.Object

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
static java.lang.String SERVICE
          Used for dependency injection
 
Constructor Summary
WebUtilities()
           
 
Method Summary
static java.util.Collection<java.lang.Long> asLongList(java.lang.String[] values)
          TODO Should also not be in there.
 java.lang.String convertRelativeUrlToAbsolute(java.lang.String url)
          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 java.lang.String decodeHtml(java.lang.String txt)
           
static java.lang.String encodeHtml(java.lang.String txt)
          Escape HTML text
 java.lang.String encodeInlineJson(java.lang.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.
 java.lang.String encodeJavaScript(java.lang.String text)
          TODO: Use escape tools instead? Used when loading resources
 java.lang.String encodeJson(java.lang.String text)
          Escape double-quotes where necessary to produce a JSON-ready string.
 BuildProperties getBuildProperties()
          Get the GreenHopper build properties
 DatePickerHelper getDatePicker()
          Encapsulates code to work with the JIRA date picker.
 java.util.Collection<com.atlassian.jira.plugin.webfragment.model.SimpleLink> getIssueOperations()
          Used for the dot dialog functionality.
 java.util.Locale getLocale(com.atlassian.crowd.embedded.api.User user)
          Fetch the locale for the current user.
 java.lang.String getModifierKey()
          Required for keyBoard shortcuts
 java.lang.String getResourceLocation(java.lang.String moduleName, java.lang.String resourceName)
          Get the resource location for a specific module.
 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.
 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 registerKeyboardContext()
          Registers the GreenHopper keyboard context.
 void validateStringSpecialCharacters(java.lang.String str, ErrorCollection errorCollection)
          TODO Should not be in here.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SERVICE

public static final java.lang.String SERVICE
Used for dependency injection

See Also:
Constant Field Values
Constructor Detail

WebUtilities

public WebUtilities()
Method Detail

getResourceLocation

public java.lang.String getResourceLocation(java.lang.String moduleName,
                                            java.lang.String resourceName)
Get the resource location for a specific module.


getModifierKey

public java.lang.String 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.


encodeJavaScript

public java.lang.String encodeJavaScript(java.lang.String text)
TODO: Use escape tools instead? Used when loading resources

Parameters:
text -

encodeHtml

public static java.lang.String encodeHtml(java.lang.String txt)
Escape HTML text


decodeHtml

public static java.lang.String decodeHtml(java.lang.String txt)

encodeJson

public java.lang.String encodeJson(java.lang.String text)
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

public java.lang.String encodeInlineJson(java.lang.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. 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

public DatePickerHelper 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

public java.util.Locale getLocale(com.atlassian.crowd.embedded.api.User user)
Fetch the locale for the current user. Mimics the behaviour of JiraActionSupport, avoiding the webwork action dependencies.


validateStringSpecialCharacters

public void validateStringSpecialCharacters(java.lang.String str,
                                            ErrorCollection errorCollection)
TODO Should not be in here. Checks for special characters that should not be saved at all.


asLongList

public static java.util.Collection<java.lang.Long> asLongList(java.lang.String[] values)
TODO Should also not be in there. Takes an array of strings and converts it into an array of longs.


getBuildProperties

public BuildProperties getBuildProperties()
Get the GreenHopper build properties


getIssueOperations

public java.util.Collection<com.atlassian.jira.plugin.webfragment.model.SimpleLink> getIssueOperations()
Used for the dot dialog functionality. See IssueOperationsHelper for more infos


convertRelativeUrlToAbsolute

public java.lang.String convertRelativeUrlToAbsolute(java.lang.String url)
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


Copyright © 2007-2012 Atlassian. All Rights Reserved.