Example usage for org.apache.commons.httpclient.util URIUtil encodePathQuery

List of usage examples for org.apache.commons.httpclient.util URIUtil encodePathQuery

Introduction

In this page you can find the example usage for org.apache.commons.httpclient.util URIUtil encodePathQuery.

Prototype

public static String encodePathQuery(String unescaped) throws URIException 

Source Link

Document

Escape and encode a string regarded as the path and query components of an URI with the default protocol charset.

Usage

From source file:org.codinjutsu.tools.jenkins.logic.UrlBuilder.java

public URL createRunJobUrl(String jobBuildUrl, JenkinsAppSettings configuration) {
    try {/*from   w  w w  .  j a  v  a 2s  .co m*/
        String s = jobBuildUrl + URIUtil
                .encodePathQuery(String.format("%s?delay=%dsec", BUILD, configuration.getBuildDelay()));
        return new URL(s);
    } catch (Exception ex) {
        handleException(ex);
    }
    return null;
}

From source file:org.codinjutsu.tools.jenkins.logic.UrlBuilder.java

public URL createRunParameterizedJobUrl(String jobUrl, JenkinsAppSettings configuration,
        Map<String, String> paramValueMap) {
    StringBuilder strBuilder = new StringBuilder(
            String.format("%s?delay=%dsec", PARAMETERIZED_BUILD, configuration.getBuildDelay()));
    for (Map.Entry<String, String> valueByName : paramValueMap.entrySet()) {
        strBuilder.append("&").append(valueByName.getKey()).append("=").append(valueByName.getValue());
    }//from w  ww. j a va 2  s.  c  o m
    try {
        return new URL(jobUrl + URIUtil.encodePathQuery(strBuilder.toString()));
    } catch (Exception ex) {
        handleException(ex);
    }
    return null;
}

From source file:org.codinjutsu.tools.jenkins.logic.UrlBuilder.java

public URL createJenkinsWorkspaceUrl(JenkinsAppSettings configuration) {
    try {//from   w  ww.j  a va  2s .  c  o  m
        return new URL(URIUtil
                .encodePathQuery(configuration.getServerUrl() + API_JSON + TREE_PARAM + BASIC_JENKINS_INFO));
    } catch (Exception ex) {
        handleException(ex);
    }
    return null;
}

From source file:org.codinjutsu.tools.jenkins.logic.UrlBuilder.java

public URL createViewUrl(JenkinsPlateform jenkinsPlateform, String viewUrl) {
    String basicViewInfo = BASIC_VIEW_INFO;
    if (JenkinsPlateform.CLOUDBEES.equals(jenkinsPlateform)) {
        basicViewInfo = CLOUDBEES_VIEW_INFO;
    }/*from ww  w .  ja  v a 2  s  .  c om*/
    try {
        return new URL(viewUrl + URIUtil.encodePathQuery(API_JSON + TREE_PARAM + basicViewInfo));
    } catch (Exception ex) {
        handleException(ex);
    }

    return null;
}

From source file:org.codinjutsu.tools.jenkins.logic.UrlBuilder.java

public URL createJobUrl(String jobUrl) {
    try {//  w w  w . j av a2 s .  c  o  m
        return new URL(jobUrl + URIUtil.encodePathQuery(API_JSON + TREE_PARAM + BASIC_JOB_INFO));
    } catch (Exception ex) {
        handleException(ex);
    }
    return null;
}

From source file:org.codinjutsu.tools.jenkins.logic.UrlBuilder.java

public URL createBuildUrl(String buildUrl) {
    try {//from   w w w .  j  a  v  a 2  s. c o m
        return new URL(buildUrl + URIUtil.encodePathQuery(API_JSON + TREE_PARAM + BASIC_BUILD_INFO));
    } catch (Exception ex) {
        handleException(ex);
    }
    return null;
}

From source file:org.eclipse.smila.connectivity.framework.crawler.web.http.HttpResponse.java

/**
 * Gets the HTTP method.// w  w  w .  ja  v a  2  s.  com
 * 
 * @return the HTTP method
 * 
 * @throws IOException
 *           Signals that an I/O exception has occurred.
 * @throws URISyntaxException
 *           URISyntaxException
 */
private HttpMethodBase getHttpMethod() throws IOException, URISyntaxException {
    URI uri;
    try {
        uri = new URI(_urlString);
    } catch (URISyntaxException exception) {
        uri = new URI(URIUtil.encodePathQuery(_urlString));
    }
    final List<HtmlFormAuthentication> authentications = _http._authentication.getHtmlFormAuthentications();
    for (HtmlFormAuthentication auth : authentications) {
        if (auth.getCredentialDomain().equals(uri.toString())) {
            // get login page in order to set required cookies
            final GetMethod getMethod = new GetMethod(uri.toString());
            setHttpParameters(_http, getMethod);
            try {
                final int result = Http.getClient().executeMethod(getMethod);
                LOG.debug("Response status code from login page: " + result);
            } catch (ProtocolException exception) {
                if (LOG.isErrorEnabled()) {
                    LOG.error(exception);
                }
                throw new IOException(exception.toString());
            } finally {
                getMethod.releaseConnection();
            }
            // remove used authentication from the list
            authentications.remove(auth);
            // prepare authentication method
            return getAuthenticationMethod(auth);
        }
    }
    try {
        return new GetMethod(uri.toString());
    } catch (IllegalArgumentException exception) {
        throw new IOException("Can't get method. " + exception.getMessage());
    }
}

From source file:org.eclipse.smila.connectivity.framework.crawler.web.parse.Outlink.java

/**
 * Creates new OutLink./*from   w ww  .  j  a  v  a  2  s.co m*/
 * 
 * @param urlString
 *          URL of the link.
 * @param anchor
 *          text anchor that is associated with this link
 * @param conf
 *          crawler configuration
 * @throws MalformedURLException
 *           if URL is broken
 * @throws URISyntaxException
 * @throws URIException
 * @throws URIException
 */
public Outlink(final String urlString, final String anchor, final Configuration conf)
        throws MalformedURLException {
    _urlString = new UrlNormalizerFactory(conf).getNormalizer().normalize(urlString);
    _url = new URL(_urlString);
    _anchor = anchor;
    try {
        _uri = new URI(_urlString);
    } catch (final URISyntaxException exception) {
        try {
            _uri = new URI(URIUtil.encodePathQuery(_urlString));
        } catch (final URIException e) {
            _uri = null;
        } catch (final URISyntaxException e) {
            _uri = null;
        }

    }

}

From source file:org.elasticsearch.hadoop.util.StringUtils.java

public static String encodeUri(String uri) {
    try {/* w w  w  .ja va 2  s. co  m*/
        return URIUtil.encodePathQuery(uri);
    } catch (URIException ex) {
        throw new EsHadoopIllegalArgumentException("Cannot escape uri" + uri);
    }
}