Class WebUtilities

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

@Service("gh-webUtilities") public class WebUtilities extends 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 Details

  • Constructor Details

    • WebUtilities

      public WebUtilities()
  • Method Details

    • getResourceLocation

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

      public 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.
    • encodeHtml

      public static String encodeHtml(String txt)
      Escape HTML text
    • decodeHtml

      public static String decodeHtml(String txt)
    • urlEncode

      public static String urlEncode(String txt)
    • encodeJson

      public String encodeJson(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 String encodeInlineJson(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 Locale getLocale(com.atlassian.jira.user.ApplicationUser user)
      Fetch the locale for the current user. Mimics the behaviour of JiraWebActionSupport, avoiding the webwork action dependencies.
    • validateStringSpecialCharacters

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

      public static Collection<Long> asLongList(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 Collection<com.atlassian.jira.plugin.webfragment.model.SimpleLink> getIssueOperations()
      Used for the dot dialog functionality. See IssueOperationsHelper for more infos
    • convertRelativeUrlToAbsolute

      public String convertRelativeUrlToAbsolute(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