'Parse the REDIRECT_URL tool param. Tools that send data to an external
application via a redirect must include the following 3 tool params:
1) REDIRECT_URL - the url to which the data is being sent
2) DATA_URL - the url to which the receiving application will send an
http post to retrieve the Galaxy data
3) GALAXY_URL - the url to which the external application may post
data as a response'

def parse_redirect_url(self, data, param_dict):

    redirect_url = param_dict.get('REDIRECT_URL')
    redirect_url_params = self.build_redirect_url_params(param_dict)
    params = redirect_url_params.split('**^**')
    rup_dict = {}
    for param in params:
        p_list = param.split('=')
        p_name = p_list[0]
        p_val = p_list[1]
        rup_dict[p_name] = p_val
    DATA_URL = param_dict.get('DATA_URL', None)
    assert (DATA_URL is not None), 'DATA_URL    parameter    missing    in    tool    config.'
    DATA_URL += ('/%s/display' % str(data.id))
    redirect_url += ('?DATA_URL=%s' % DATA_URL)
    for p_name in rup_dict:
        redirect_url += ('&%s=%s' % (p_name, rup_dict[p_name]))
    if data.history.user:
        USERNAME = str(data.history.user.email)
    else:
        USERNAME = 'Anonymous'
    redirect_url += ('&USERNAME=%s' % USERNAME)
    return redirect_url
