Package org.apache.http.client.utils

Examples of org.apache.http.client.utils.URIBuilder


   * @param projectId
   * @param cacheName
   * @throws URISyntaxException
   */
  public CacheUrl(final String hostName, final String projectId, final String cacheName) throws URISyntaxException {
    super(new URIBuilder()
        .setScheme("https")
        .setHost(String.format(Constants.IRON_IO_HOST_TEMPLATE, hostName))
        .setPath(
            new StringBuilder().append("/1/projects/").append(projectId).append("/caches/")
                .append(cacheName).toString()).build());
View Full Code Here


   * @param hostName
   * @param projectId
   * @throws URISyntaxException
   */
  public CachesUrl(final String hostName, final String projectId) throws URISyntaxException {
    super(new URIBuilder().setScheme("https").setHost(String.format(Constants.IRON_IO_HOST_TEMPLATE, hostName))
        .setPath(new StringBuilder().append("/1/projects/").append(projectId).append("/caches").toString())
        .build());
    log.trace("Creating request {}", this.toString());
  }
View Full Code Here

   * @param key
   * @throws URISyntaxException
   */
  public IncrementCacheItemUrl(final String hostName, final String projectId, final String cacheName, final String key)
      throws URISyntaxException {
    super(new URIBuilder()
        .setScheme("https")
        .setHost(String.format(Constants.IRON_IO_HOST_TEMPLATE, hostName))
        .setPath(
            new StringBuilder().append("/1/projects/").append(projectId).append("/caches/")
                .append(cacheName).append("/items/").append(key).append("/increment").toString())
View Full Code Here

    private URI buildUri(HttpRequest request, Joiner joiner) {
        URI requestUri = request.getUri();

        Map<String, Collection<String>> queryParams = request.getQueryParams();
        if (queryParams != null && !queryParams.isEmpty()) {
            URIBuilder uriBuilder = new URIBuilder();
            for (Map.Entry<String, Collection<String>> stringCollectionEntry : queryParams.entrySet()) {
                String key = stringCollectionEntry.getKey();
                Collection<String> stringCollection = stringCollectionEntry.getValue();
                String value = joiner.join(stringCollection);
                uriBuilder.addParameter(key, value);
            }
            uriBuilder.setFragment(requestUri.getFragment());
            uriBuilder.setHost(requestUri.getHost());
            uriBuilder.setPath(requestUri.getPath());
            uriBuilder.setPort(requestUri.getPort());
            uriBuilder.setScheme(requestUri.getScheme());
            uriBuilder.setUserInfo(requestUri.getUserInfo());
            try {
                requestUri = uriBuilder.build();
            } catch (URISyntaxException e) {
                LOGGER.warn("could not update uri: {}", requestUri);
            }
        }
        return requestUri;
View Full Code Here

                final HttpResponse response,
                final HttpContext context) throws HttpException, IOException {
            final ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
            String location;
            try {
                final URIBuilder uribuilder = new URIBuilder(request.getRequestLine().getUri());
                uribuilder.setScheme(this.host.getSchemeName());
                uribuilder.setHost(this.host.getHostName());
                uribuilder.setPort(this.host.getPort());
                uribuilder.setPath("/random/1024");
                location = uribuilder.build().toASCIIString();
            } catch (final URISyntaxException ex) {
                throw new ProtocolException("Invalid request URI", ex);
            }
            response.setStatusLine(ver, HttpStatus.SC_TEMPORARY_REDIRECT);
            response.addHeader(new BasicHeader("Location", location));
View Full Code Here

    /**
     * @since 4.1
     */
    protected URI createLocationURI(final String location) throws ProtocolException {
        try {
            final URIBuilder b = new URIBuilder(new URI(location).normalize());
            final String host = b.getHost();
            if (host != null) {
                b.setHost(host.toLowerCase(Locale.ROOT));
            }
            final String path = b.getPath();
            if (TextUtils.isEmpty(path)) {
                b.setPath("/");
            }
            return b.build();
        } catch (final URISyntaxException ex) {
            throw new ProtocolException("Invalid redirect URI: " + location, ex);
        }
    }
View Full Code Here

          StringWriter writer = new StringWriter();
          StreamResult result = new StreamResult( writer );
          DOMSource source = new DOMSource( document );
          transformer.transform( source, result );

          URIBuilder uri = uri( HBase.SERVICE_PATH, "/", tableName, "/false-row-key" );
          HttpPost request = new HttpPost( uri.build() );
          HttpEntity entity = new StringEntity( writer.toString(), ContentType.create( "text/xml", "UTF-8" ) );
          request.setEntity( entity );

          return new Response( execute( request ) );
        }
View Full Code Here

          String timeURIPart = "";
          if( time != null ) {
            timeURIPart = time.toString();
          }

          URIBuilder uri = uri( HBase.SERVICE_PATH, "/", tableName, "/", rowsIdToQuery, columnsURIPart.toString(), timeURIPart );
          HttpDelete delete = new HttpDelete( uri.build() );
          return new Response( execute( delete ) );
        }
      };
    }
View Full Code Here

          StringBuilder versionURIPart = new StringBuilder();
          if( numVersions != null ) {
            versionURIPart.append( "?v=" ).append( numVersions );
          }

          URIBuilder uri = uri( HBase.SERVICE_PATH, "/", tableName, "/", rowsIdToQuery, columnsURIPart.toString(), timesURIPart.toString(), versionURIPart.toString() );
          HttpGet get = new HttpGet( uri.build() );
          get.setHeader( "Accept", "application/json" );
          return new Response( execute( get ) );
        }
      };
    }
View Full Code Here

    protected Callable<Response> callable() {
      return new Callable<Response>() {
        @Override
        public Response call() throws Exception {
          URIBuilder uri = uri( HBase.SERVICE_PATH );
          HttpGet get = new HttpGet( uri.build() );
          get.setHeader( "Accept", "application/json" );
          return new Response( execute( get ) );
        }
      };
    }
View Full Code Here

TOP

Related Classes of org.apache.http.client.utils.URIBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.