Example usage for org.apache.http.client.utils URIBuilder setPort

List of usage examples for org.apache.http.client.utils URIBuilder setPort

Introduction

In this page you can find the example usage for org.apache.http.client.utils URIBuilder setPort.

Prototype

public URIBuilder setPort(final int port) 

Source Link

Document

Sets URI port.

Usage

From source file:com.vmware.identity.rest.core.client.AffinitizedHostRetriever.java

@Override
public URIBuilder getURIBuilder() throws ClientException {
    CdcDCEntry entry = getAvailableDomainController();

    URIBuilder builder = new URIBuilder().setScheme(getScheme()).setHost(entry.dcName);

    if (hasPort()) {
        builder.setPort(port);
    }/*from  ww  w . j  a va  2s  .  c om*/

    return builder;
}

From source file:de.devbliss.apitester.dummyserver.DummyApiServer.java

public URI buildRequestUri(String pathOnServer) throws URISyntaxException {
    URIBuilder uriBuilder = new URIBuilder();
    uriBuilder.setScheme("http");
    uriBuilder.setHost("localhost");
    uriBuilder.setPort(port);
    uriBuilder.setPath(pathOnServer);/*from w w w . ja  v a  2  s.  c o m*/
    return uriBuilder.build();
}

From source file:fr.insalyon.creatis.vip.query.server.rpc.EndPointSparqlServiceImpl.java

public String getUrlResult(String param1, String param2) {
    String url = null;//from w w w .j a  v  a 2 s.c  o  m
    String k = null;
    URIBuilder builder = new URIBuilder();
    builder.setHost("ginseng.unice.fr");
    builder.setPort(9000);
    builder.setPath("/sparql");

    builder.setParameter("query", param1);

    builder.setParameter("format", param2);
    try {
        url = builder.build().toString();

    } catch (URISyntaxException ex) {
        Logger.getLogger(EndPointSparqlServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
    }

    return url;

}

From source file:org.mobicents.servlet.restcomm.http.client.HttpRequestDescriptor.java

private URI base(final URI uri) {
    try {//from w  w w .  j  av  a  2s  .com
        URIBuilder uriBuilder = new URIBuilder();
        uriBuilder.setScheme(uri.getScheme());
        uriBuilder.setHost(uri.getHost());
        uriBuilder.setPort(uri.getPort());
        uriBuilder.setPath(uri.getPath());

        if (uri.getUserInfo() != null) {
            uriBuilder.setUserInfo(uri.getUserInfo());
        }
        return uriBuilder.build();
    } catch (final URISyntaxException ignored) {
        // This should never happen since we are using a valid URI to construct ours.
        return null;
    }
}

From source file:org.apache.streams.riak.http.RiakHttpClient.java

public void start() throws Exception {
    Objects.nonNull(config);// ww  w. ja  v a2 s. c o m
    assert (config.getScheme().startsWith("http"));
    URIBuilder uriBuilder = new URIBuilder();
    uriBuilder.setScheme(config.getScheme());
    uriBuilder.setHost(config.getHosts().get(0));
    uriBuilder.setPort(config.getPort().intValue());
    baseURI = uriBuilder.build();
    client = HttpClients.createDefault();
}

From source file:com.blackducksoftware.tools.scmconnector.integrations.mercurial.MercurialConnector.java

/**
 * Constructs a valid HTTP url if a user *and* password is provided.
 *
 * @throws Exception/*from  w w w.ja v a  2s  .c om*/
 */
private void buildURL() throws Exception {
    if (StringUtils.isNotEmpty(user) && StringUtils.isNotEmpty(password)) {
        URL url = new URL(repositoryURL);
        String protocol = url.getProtocol();
        int port = url.getPort();
        String host = url.getHost();
        String path = url.getPath();

        URIBuilder builder = new URIBuilder();
        builder.setScheme(protocol);
        builder.setHost(host);
        builder.setPort(port);
        builder.setPath(path);
        builder.setUserInfo(user, password);

        repositoryURL = builder.toString();
        // log.info("Using path: " + repositoryURL); // Reveals password
    }
}

From source file:webrequester.AbstractWebRequest.java

protected URI buildURI() {
    try {/*from   w w w.j  a  v a 2  s  .  c  o  m*/
        URIBuilder uriB = new URIBuilder();
        uriB.setScheme(scheme).setHost(host);
        if (port > 0) {
            uriB.setPort(port);
        }

        uriB.setPath(path);
        for (NameValuePair pair : listParameters) {
            uriB.setParameter(pair.getName(), pair.getValue());
        }
        return uriB.build();
    } catch (URISyntaxException ex) {
        return null;
    }
}

From source file:com.jkoolcloud.tnt4j.streams.inputs.HttpStreamTest.java

private URI makeURI() throws URISyntaxException {
    URIBuilder uriBuilder = new URIBuilder("http://localhost"); // NON-NLS
    uriBuilder.setHost("localhost"); // NON-NLS
    uriBuilder.setPort(TEST_PORT);
    URI url = uriBuilder.build();
    return url;//from  w ww  . ja  va  2s.  c  om
}

From source file:com.fredhopper.core.connector.index.upload.impl.RestPublishingStrategy.java

protected URI createUri(final String scheme, final String host, final Integer port, final String servername,
        final String path, final List<NameValuePair> params) {
    Preconditions.checkArgument(StringUtils.isNotBlank(scheme));
    Preconditions.checkArgument(StringUtils.isNotBlank(host));
    Preconditions.checkArgument(port != null);
    Preconditions.checkArgument(StringUtils.isNotBlank(servername));
    Preconditions.checkArgument(StringUtils.isNotBlank(path));

    final URIBuilder uriBuilder = new URIBuilder();
    uriBuilder.setScheme(scheme);//from w  w  w  . ja  v a 2  s.  co m
    uriBuilder.setHost(host);
    uriBuilder.setPort(port.intValue());
    uriBuilder.setPath("/".concat(servername).concat(path));
    if (CollectionUtils.isNotEmpty(params)) {
        uriBuilder.setParameters(params);
    }
    try {
        return uriBuilder.build();
    } catch (final URISyntaxException ex) {
        throw new IllegalArgumentException(ex);
    }
}

From source file:com.intuit.wasabi.export.rest.impl.DefaultRestEndPoint.java

@Override
public URI getRestEndPointURI() {
    URI assignmentURI = null;/*from w  ww . j  av  a 2s.c  om*/
    try {
        URIBuilder uriBuilder = new URIBuilder().setScheme(configuration.getScheme())
                .setHost(configuration.getHost()).setPath(configuration.getPath());
        int port = configuration.getPort();
        if (port != 0) {
            uriBuilder.setPort(port);
        }
        assignmentURI = uriBuilder.build();
    } catch (URISyntaxException e) {
        LOGGER.error("URL Syntax Error: ", e);
    }
    return assignmentURI;
}