Class JiraUrl

java.lang.Object
org.apache.commons.httpclient.URI
org.apache.commons.httpclient.HttpURL
com.atlassian.jira.util.http.JiraUrl
All Implemented Interfaces:
Serializable, Cloneable, Comparable

public class JiraUrl extends org.apache.commons.httpclient.HttpURL
Simple helper class to help create a well-formed URLs. Also gives us a central point to do any encoding related stuff
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.apache.commons.httpclient.URI

    org.apache.commons.httpclient.URI.DefaultCharsetChanged, org.apache.commons.httpclient.URI.LocaleToCharsetMap
  • Field Summary

    Fields inherited from class org.apache.commons.httpclient.HttpURL

    _default_port, _default_scheme, DEFAULT_PORT, DEFAULT_SCHEME

    Fields inherited from class org.apache.commons.httpclient.URI

    _authority, _fragment, _host, _is_abs_path, _is_hier_part, _is_hostname, _is_IPv4address, _is_IPv6reference, _is_net_path, _is_opaque_part, _is_reg_name, _is_rel_path, _is_server, _opaque, _path, _port, _query, _scheme, _uri, _userinfo, abs_path, absoluteURI, allowed_abs_path, allowed_authority, allowed_fragment, allowed_host, allowed_IPv6reference, allowed_opaque_part, allowed_query, allowed_reg_name, allowed_rel_path, allowed_userinfo, allowed_within_authority, allowed_within_path, allowed_within_query, allowed_within_userinfo, alpha, alphanum, authority, control, defaultDocumentCharset, defaultDocumentCharsetByLocale, defaultDocumentCharsetByPlatform, defaultProtocolCharset, delims, digit, disallowed_opaque_part, disallowed_rel_path, domainlabel, escaped, fragment, hash, hex, hier_part, host, hostname, hostport, IPv4address, IPv6address, IPv6reference, mark, net_path, opaque_part, param, path, path_segments, pchar, percent, port, protocolCharset, query, reg_name, rel_path, rel_segment, relativeURI, reserved, rootPath, scheme, segment, server, space, toplabel, unreserved, unwise, URI_reference, uric, uric_no_slash, userinfo, within_userinfo
  • Constructor Summary

    Constructors
    Constructor
    Description
    JiraUrl(String baseUrl)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    constructBaseUrl(javax.servlet.http.HttpServletRequest request)
    Attempts to construct a baseUrl using the HttpServletRequest object.
    static String
    Extracts the action (e.g.
    void
    setQuery(List<org.apache.commons.httpclient.NameValuePair> nameValuePairs)
    Sets the query string from the list of NameValuePair objects.

    Methods inherited from class org.apache.commons.httpclient.HttpURL

    checkValid, getEscapedPassword, getEscapedUser, getPassword, getPort, getRawAboveHierPath, getRawCurrentHierPath, getRawPassword, getRawPath, getRawScheme, getRawUser, getScheme, getUser, setEscapedPassword, setEscapedUser, setEscapedUserinfo, setPassword, setQuery, setQuery, setRawPassword, setRawUser, setRawUserinfo, setURI, setUser, setUserinfo, toUserinfo

    Methods inherited from class org.apache.commons.httpclient.URI

    clone, compareTo, decode, decode, encode, equals, equals, getAboveHierPath, getAuthority, getCurrentHierPath, getDefaultDocumentCharset, getDefaultDocumentCharsetByLocale, getDefaultDocumentCharsetByPlatform, getDefaultProtocolCharset, getEscapedAboveHierPath, getEscapedAuthority, getEscapedCurrentHierPath, getEscapedFragment, getEscapedName, getEscapedPath, getEscapedPathQuery, getEscapedQuery, getEscapedURI, getEscapedURIReference, getEscapedUserinfo, getFragment, getHost, getName, getPath, getPathQuery, getProtocolCharset, getQuery, getRawAuthority, getRawCurrentHierPath, getRawFragment, getRawHost, getRawName, getRawPathQuery, getRawQuery, getRawURI, getRawURIReference, getRawUserinfo, getURI, getURIReference, getUserinfo, hasAuthority, hasFragment, hashCode, hasQuery, hasUserinfo, indexFirstOf, indexFirstOf, indexFirstOf, indexFirstOf, isAbsoluteURI, isAbsPath, isHierPart, isHostname, isIPv4address, isIPv6reference, isNetPath, isOpaquePart, isRegName, isRelativeURI, isRelPath, isServer, normalize, normalize, parseAuthority, parseUriReference, prevalidate, removeFragmentIdentifier, resolvePath, setDefaultDocumentCharset, setDefaultProtocolCharset, setEscapedAuthority, setEscapedFragment, setEscapedPath, setEscapedQuery, setFragment, setPath, setQuery, setRawAuthority, setRawFragment, setRawPath, setRawQuery, toString, validate, validate

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • JiraUrl

      public JiraUrl(String baseUrl) throws org.apache.commons.httpclient.URIException
      Throws:
      org.apache.commons.httpclient.URIException
  • Method Details

    • setQuery

      public void setQuery(List<org.apache.commons.httpclient.NameValuePair> nameValuePairs) throws org.apache.commons.httpclient.URIException
      Sets the query string from the list of NameValuePair objects. Both name & value are encoded in the default encoding. Null or empty list will clear the query string.
      Throws:
      org.apache.commons.httpclient.URIException
    • constructBaseUrl

      public static String constructBaseUrl(javax.servlet.http.HttpServletRequest request)
      Attempts to construct a baseUrl using the HttpServletRequest object.
      Parameters:
      request - The incoming http request
      Returns:
      a string containing the absolute base URL
    • extractActionFromURL

      public static String extractActionFromURL(String url)
      Extracts the action (e.g. AdminSummary.jspa) from a URL
      Parameters:
      url - A URL (or partial URL) like "/secure/AdminSummary.jspa"
      Returns:
      Returns the original URL if an action is not found