Package org.jclouds.http.Uris

Examples of org.jclouds.http.Uris.UriBuilder


      baseuri = new URI(URI_SCHEME, this.profile, this.name, null);
    } catch (URISyntaxException e) {
      throw new IllegalArgumentException("Invalid blob profile or path: ", e);
    }

    UriBuilder ub = Uris.uriBuilder(baseuri);

    if (this.compression != null) {
      ub.addQuery(URI_PARAM_COMPRESSION, this.compression);
    }
   
    if (this.encryptionKey != null) {
      ub.addQuery(URI_PARAM_ENCRYPTION_KEY, this.encryptionKey);
    }

    if (this.blockCount != null) {
      ub.addQuery(URI_PARAM_BLOCK_COUNT, Integer.toString(this.blockCount));
    }

    return ub.build();
  }
View Full Code Here


      Multimap<String, Object> tokenValues = LinkedHashMultimap.create();

      tokenValues.put(Constants.PROPERTY_API_VERSION, apiVersion);
      tokenValues.put(Constants.PROPERTY_BUILD_VERSION, buildVersion);
      // URI template in rfc6570 form
      UriBuilder uriBuilder = uriBuilder(endpoint.get().toString());

      overridePathEncoding(uriBuilder, invocation);

      if (caller != null)
         tokenValues.putAll(addPathAndGetTokens(caller, uriBuilder));
      tokenValues.putAll(addPathAndGetTokens(invocation, uriBuilder));
      Multimap<String, Object> formParams;
      if (caller != null) {
         formParams = addFormParams(tokenValues, caller);
         formParams.putAll(addFormParams(tokenValues, invocation));
      } else {
         formParams = addFormParams(tokenValues, invocation);
      }     
      Multimap<String, Object> queryParams = addQueryParams(tokenValues, invocation);
      Multimap<String, String> headers = buildHeaders(tokenValues, invocation);

      if (r != null)
         headers.putAll(r.getHeaders());

      if (shouldAddHostHeader(invocation)) {
         StringBuilder hostHeader = new StringBuilder(endpoint.get().getHost());
         if (endpoint.get().getPort() != -1)
            hostHeader.append(":").append(endpoint.get().getPort());
         headers.put(HOST, hostHeader.toString());
      }

      Payload payload = null;
      for (HttpRequestOptions options : findOptionsIn(invocation)) {
         injector.injectMembers(options);// TODO test case
         for (Entry<String, String> header : options.buildRequestHeaders().entries()) {
            headers.put(header.getKey(), replaceTokens(header.getValue(), tokenValues));
         }
         for (Entry<String, String> query : options.buildQueryParameters().entries()) {
            queryParams.put(query.getKey(), replaceTokens(query.getValue(), tokenValues));
         }
         for (Entry<String, String> form : options.buildFormParameters().entries()) {
            formParams.put(form.getKey(), replaceTokens(form.getValue(), tokenValues));
         }

         String pathSuffix = options.buildPathSuffix();
         if (pathSuffix != null) {
            uriBuilder.appendPath(pathSuffix);
         }
         String stringPayload = options.buildStringPayload();
         if (stringPayload != null)
            payload = Payloads.newStringPayload(stringPayload);
      }

      if (queryParams.size() > 0) {
         uriBuilder.query(queryParams);
      }

      requestBuilder.headers(filterOutContentHeaders(headers));

      requestBuilder.endpoint(uriBuilder.build(convertUnsafe(tokenValues)));

      if (payload == null) {
         PayloadEnclosing payloadEnclosing = findOrNull(invocation.getArgs(), PayloadEnclosing.class);
         payload = (payloadEnclosing != null) ? payloadEnclosing.getPayload() : findOrNull(invocation.getArgs(),
               Payload.class);
View Full Code Here

      Multimap<String, Object> tokenValues = LinkedHashMultimap.create();

      tokenValues.put(Constants.PROPERTY_API_VERSION, apiVersion);
      tokenValues.put(Constants.PROPERTY_BUILD_VERSION, buildVersion);
      // URI template in rfc6570 form
      UriBuilder uriBuilder = uriBuilder(endpoint.get().toString());

      overridePathEncoding(uriBuilder, invocation);

      if (caller != null)
         tokenValues.putAll(addPathAndGetTokens(caller, uriBuilder));
      tokenValues.putAll(addPathAndGetTokens(invocation, uriBuilder));
      Multimap<String, Object> formParams;
      if (caller != null) {
         formParams = addFormParams(tokenValues, caller);
         formParams.putAll(addFormParams(tokenValues, invocation));
      } else {
         formParams = addFormParams(tokenValues, invocation);
      }     
      Multimap<String, Object> queryParams = addQueryParams(tokenValues, invocation);
      Multimap<String, String> headers = buildHeaders(tokenValues, invocation);

      if (r != null)
         headers.putAll(r.getHeaders());

      if (shouldAddHostHeader(invocation)) {
         StringBuilder hostHeader = new StringBuilder(endpoint.get().getHost());
         if (endpoint.get().getPort() != -1)
            hostHeader.append(":").append(endpoint.get().getPort());
         headers.put(HOST, hostHeader.toString());
      }

      Payload payload = null;
      for (HttpRequestOptions options : findOptionsIn(invocation)) {
         injector.injectMembers(options);// TODO test case
         for (Entry<String, String> header : options.buildRequestHeaders().entries()) {
            headers.put(header.getKey(), replaceTokens(header.getValue(), tokenValues));
         }
         for (Entry<String, String> query : options.buildQueryParameters().entries()) {
            queryParams.put(query.getKey(), replaceTokens(query.getValue(), tokenValues));
         }
         for (Entry<String, String> form : options.buildFormParameters().entries()) {
            formParams.put(form.getKey(), replaceTokens(form.getValue(), tokenValues));
         }

         String pathSuffix = options.buildPathSuffix();
         if (pathSuffix != null) {
            uriBuilder.appendPath(pathSuffix);
         }
         String stringPayload = options.buildStringPayload();
         if (stringPayload != null)
            payload = Payloads.newStringPayload(stringPayload);
      }

      if (queryParams.size() > 0) {
         uriBuilder.query(queryParams);
      }

      requestBuilder.headers(filterOutContentHeaders(headers));

      requestBuilder.endpoint(uriBuilder.build(convertUnsafe(tokenValues)));

      if (payload == null) {
         PayloadEnclosing payloadEnclosing = findOrNull(invocation.getArgs(), PayloadEnclosing.class);
         payload = (payloadEnclosing != null) ? payloadEnclosing.getPayload() : findOrNull(invocation.getArgs(),
               Payload.class);
View Full Code Here

      Multimap<String, Object> tokenValues = LinkedHashMultimap.create();

      tokenValues.put(Constants.PROPERTY_API_VERSION, apiVersion);
      tokenValues.put(Constants.PROPERTY_BUILD_VERSION, buildVersion);
      // URI template in rfc6570 form
      UriBuilder uriBuilder = uriBuilder(endpoint.get().toString());

      overridePathEncoding(uriBuilder, invocation);

      if (caller != null)
         tokenValues.putAll(addPathAndGetTokens(caller, uriBuilder));
      tokenValues.putAll(addPathAndGetTokens(invocation, uriBuilder));
      Multimap<String, Object> formParams;
      if (caller != null) {
         formParams = addFormParams(tokenValues, caller);
         formParams.putAll(addFormParams(tokenValues, invocation));
      } else {
         formParams = addFormParams(tokenValues, invocation);
      }     
      Multimap<String, Object> queryParams = addQueryParams(tokenValues, invocation);
      Multimap<String, String> headers = buildHeaders(tokenValues, invocation);

      if (r != null)
         headers.putAll(r.getHeaders());

      if (shouldAddHostHeader(invocation)) {
         StringBuilder hostHeader = new StringBuilder(endpoint.get().getHost());
         if (endpoint.get().getPort() != -1)
            hostHeader.append(":").append(endpoint.get().getPort());
         headers.put(HOST, hostHeader.toString());
      }

      Payload payload = null;
      for (HttpRequestOptions options : findOptionsIn(invocation)) {
         injector.injectMembers(options);// TODO test case
         for (Entry<String, String> header : options.buildRequestHeaders().entries()) {
            headers.put(header.getKey(), replaceTokens(header.getValue(), tokenValues));
         }
         for (Entry<String, String> query : options.buildQueryParameters().entries()) {
            queryParams.put(query.getKey(), replaceTokens(query.getValue(), tokenValues));
         }
         for (Entry<String, String> form : options.buildFormParameters().entries()) {
            formParams.put(form.getKey(), replaceTokens(form.getValue(), tokenValues));
         }

         String pathSuffix = options.buildPathSuffix();
         if (pathSuffix != null) {
            uriBuilder.appendPath(pathSuffix);
         }
         String stringPayload = options.buildStringPayload();
         if (stringPayload != null)
            payload = Payloads.newStringPayload(stringPayload);
      }

      if (queryParams.size() > 0) {
         uriBuilder.query(queryParams);
      }

      requestBuilder.headers(filterOutContentHeaders(headers));

      requestBuilder.endpoint(uriBuilder.build(convertUnsafe(tokenValues)));

      if (payload == null) {
         PayloadEnclosing payloadEnclosing = findOrNull(invocation.getArgs(), PayloadEnclosing.class);
         payload = (payloadEnclosing != null) ? payloadEnclosing.getPayload() : findOrNull(invocation.getArgs(),
               Payload.class);
View Full Code Here

      Multimap<String, Object> tokenValues = LinkedHashMultimap.create();

      tokenValues.put(Constants.PROPERTY_API_VERSION, apiVersion);
      tokenValues.put(Constants.PROPERTY_BUILD_VERSION, buildVersion);
      // URI template in rfc6570 form
      UriBuilder uriBuilder = uriBuilder(endpoint.get().toString());

      overridePathEncoding(uriBuilder, invocation);

      if (caller != null)
         tokenValues.putAll(addPathAndGetTokens(caller, uriBuilder));
      tokenValues.putAll(addPathAndGetTokens(invocation, uriBuilder));
      Multimap<String, Object> formParams;
      if (caller != null) {
         formParams = addFormParams(tokenValues, caller);
         formParams.putAll(addFormParams(tokenValues, invocation));
      } else {
         formParams = addFormParams(tokenValues, invocation);
      }

      Multimap<String, Object> queryParams = addQueryParams(tokenValues, invocation);

      Multimap<String, String> headers;
      if (caller != null) {
         headers = buildHeaders(tokenValues, caller);
         headers.putAll(buildHeaders(tokenValues, invocation));
      } else {
         headers = buildHeaders(tokenValues, invocation);
      }

      if (r != null)
         headers.putAll(r.getHeaders());

      if (shouldAddHostHeader(invocation)) {
         StringBuilder hostHeader = new StringBuilder(endpoint.get().getHost());
         if (endpoint.get().getPort() != -1)
            hostHeader.append(":").append(endpoint.get().getPort());
         headers.put(HOST, hostHeader.toString());
      }

      Payload payload = null;
      for (HttpRequestOptions options : findOptionsIn(invocation)) {
         injector.injectMembers(options);// TODO test case
         for (Entry<String, String> header : options.buildRequestHeaders().entries()) {
            headers.put(header.getKey(), replaceTokens(header.getValue(), tokenValues));
         }
         for (Entry<String, String> query : options.buildQueryParameters().entries()) {
            queryParams.put(query.getKey(), replaceTokens(query.getValue(), tokenValues));
         }
         for (Entry<String, String> form : options.buildFormParameters().entries()) {
            formParams.put(form.getKey(), replaceTokens(form.getValue(), tokenValues));
         }

         String pathSuffix = options.buildPathSuffix();
         if (pathSuffix != null) {
            uriBuilder.appendPath(pathSuffix);
         }
         String stringPayload = options.buildStringPayload();
         if (stringPayload != null)
            payload = Payloads.newStringPayload(stringPayload);
      }

      if (queryParams.size() > 0) {
         uriBuilder.query(queryParams);
      }

      requestBuilder.headers(filterOutContentHeaders(headers));

      requestBuilder.endpoint(uriBuilder.build(convertUnsafe(tokenValues)));

      if (payload == null) {
         PayloadEnclosing payloadEnclosing = findOrNull(invocation.getArgs(), PayloadEnclosing.class);
         payload = (payloadEnclosing != null) ? payloadEnclosing.getPayload() : findOrNull(invocation.getArgs(),
               Payload.class);
View Full Code Here

      Multimap<String, Object> tokenValues = LinkedHashMultimap.create();

      tokenValues.put(Constants.PROPERTY_API_VERSION, apiVersion);
      tokenValues.put(Constants.PROPERTY_BUILD_VERSION, buildVersion);
      // URI template in rfc6570 form
      UriBuilder uriBuilder = uriBuilder(endpoint.get().toString());

      overridePathEncoding(uriBuilder, invocation);

      if (caller != null)
         tokenValues.putAll(addPathAndGetTokens(caller, uriBuilder));
      tokenValues.putAll(addPathAndGetTokens(invocation, uriBuilder));
      Multimap<String, Object> formParams;
      if (caller != null) {
         formParams = addFormParams(tokenValues, caller);
         formParams.putAll(addFormParams(tokenValues, invocation));
      } else {
         formParams = addFormParams(tokenValues, invocation);
      }

      Multimap<String, Object> queryParams = addQueryParams(tokenValues, invocation);

      Multimap<String, String> headers;
      if (caller != null) {
         headers = buildHeaders(tokenValues, caller);
         headers.putAll(buildHeaders(tokenValues, invocation));
      } else {
         headers = buildHeaders(tokenValues, invocation);
      }

      if (r != null)
         headers.putAll(r.getHeaders());

      if (shouldAddHostHeader(invocation)) {
         StringBuilder hostHeader = new StringBuilder(endpoint.get().getHost());
         if (endpoint.get().getPort() != -1)
            hostHeader.append(":").append(endpoint.get().getPort());
         headers.put(HOST, hostHeader.toString());
      }

      Payload payload = null;
      for (HttpRequestOptions options : findOptionsIn(invocation)) {
         injector.injectMembers(options);// TODO test case
         for (Entry<String, String> header : options.buildRequestHeaders().entries()) {
            headers.put(header.getKey(), replaceTokens(header.getValue(), tokenValues));
         }
         for (Entry<String, String> query : options.buildQueryParameters().entries()) {
            queryParams.put(query.getKey(), replaceTokens(query.getValue(), tokenValues));
         }
         for (Entry<String, String> form : options.buildFormParameters().entries()) {
            formParams.put(form.getKey(), replaceTokens(form.getValue(), tokenValues));
         }

         String pathSuffix = options.buildPathSuffix();
         if (pathSuffix != null) {
            uriBuilder.appendPath(pathSuffix);
         }
         String stringPayload = options.buildStringPayload();
         if (stringPayload != null)
            payload = Payloads.newStringPayload(stringPayload);
      }

      if (queryParams.size() > 0) {
         uriBuilder.query(queryParams);
      }

      requestBuilder.headers(filterOutContentHeaders(headers));

      requestBuilder.endpoint(uriBuilder.build(convertUnsafe(tokenValues)));

      if (payload == null) {
         PayloadEnclosing payloadEnclosing = findOrNull(invocation.getArgs(), PayloadEnclosing.class);
         payload = (payloadEnclosing != null) ? payloadEnclosing.getPayload() : findOrNull(invocation.getArgs(),
               Payload.class);
View Full Code Here

      Multimap<String, Object> tokenValues = LinkedHashMultimap.create();

      tokenValues.put(Constants.PROPERTY_API_VERSION, apiVersion);
      tokenValues.put(Constants.PROPERTY_BUILD_VERSION, buildVersion);
      // URI template in rfc6570 form
      UriBuilder uriBuilder = uriBuilder(endpoint.get().toString());

      overridePathEncoding(uriBuilder, invocation);

      if (caller != null)
         tokenValues.putAll(addPathAndGetTokens(caller, uriBuilder));
      tokenValues.putAll(addPathAndGetTokens(invocation, uriBuilder));
      Multimap<String, Object> formParams;
      if (caller != null) {
         formParams = addFormParams(tokenValues, caller);
         formParams.putAll(addFormParams(tokenValues, invocation));
      } else {
         formParams = addFormParams(tokenValues, invocation);
      }     
      Multimap<String, Object> queryParams = addQueryParams(tokenValues, invocation);
      Multimap<String, String> headers = buildHeaders(tokenValues, invocation);

      if (r != null)
         headers.putAll(r.getHeaders());

      if (shouldAddHostHeader(invocation)) {
         StringBuilder hostHeader = new StringBuilder(endpoint.get().getHost());
         if (endpoint.get().getPort() != -1)
            hostHeader.append(":").append(endpoint.get().getPort());
         headers.put(HOST, hostHeader.toString());
      }

      Payload payload = null;
      for (HttpRequestOptions options : findOptionsIn(invocation)) {
         injector.injectMembers(options);// TODO test case
         for (Entry<String, String> header : options.buildRequestHeaders().entries()) {
            headers.put(header.getKey(), replaceTokens(header.getValue(), tokenValues));
         }
         for (Entry<String, String> query : options.buildQueryParameters().entries()) {
            queryParams.put(query.getKey(), replaceTokens(query.getValue(), tokenValues));
         }
         for (Entry<String, String> form : options.buildFormParameters().entries()) {
            formParams.put(form.getKey(), replaceTokens(form.getValue(), tokenValues));
         }

         String pathSuffix = options.buildPathSuffix();
         if (pathSuffix != null) {
            uriBuilder.appendPath(pathSuffix);
         }
         String stringPayload = options.buildStringPayload();
         if (stringPayload != null)
            payload = Payloads.newStringPayload(stringPayload);
      }

      if (queryParams.size() > 0) {
         uriBuilder.query(queryParams);
      }

      requestBuilder.headers(filterOutContentHeaders(headers));

      requestBuilder.endpoint(uriBuilder.build(convertUnsafe(tokenValues)));

      if (payload == null) {
         PayloadEnclosing payloadEnclosing = findOrNull(invocation.getArgs(), PayloadEnclosing.class);
         payload = (payloadEnclosing != null) ? payloadEnclosing.getPayload() : findOrNull(invocation.getArgs(),
               Payload.class);
View Full Code Here

      Multimap<String, Object> tokenValues = LinkedHashMultimap.create();

      tokenValues.put(Constants.PROPERTY_API_VERSION, apiVersion);
      tokenValues.put(Constants.PROPERTY_BUILD_VERSION, buildVersion);
      // URI template in rfc6570 form
      UriBuilder uriBuilder = uriBuilder(endpoint.get().toString());

      overridePathEncoding(uriBuilder, invocation);

      if (caller != null)
         tokenValues.putAll(addPathAndGetTokens(caller, uriBuilder));
      tokenValues.putAll(addPathAndGetTokens(invocation, uriBuilder));
      Multimap<String, Object> formParams;
      if (caller != null) {
         formParams = addFormParams(tokenValues, caller);
         formParams.putAll(addFormParams(tokenValues, invocation));
      } else {
         formParams = addFormParams(tokenValues, invocation);
      }

      Multimap<String, Object> queryParams = addQueryParams(tokenValues, invocation);

      Multimap<String, String> headers;
      if (caller != null) {
         headers = buildHeaders(tokenValues, caller);
         headers.putAll(buildHeaders(tokenValues, invocation));
      } else {
         headers = buildHeaders(tokenValues, invocation);
      }

      if (r != null)
         headers.putAll(r.getHeaders());

      if (shouldAddHostHeader(invocation)) {
         StringBuilder hostHeader = new StringBuilder(endpoint.get().getHost());
         if (endpoint.get().getPort() != -1)
            hostHeader.append(":").append(endpoint.get().getPort());
         headers.put(HOST, hostHeader.toString());
      }

      Payload payload = null;
      for (HttpRequestOptions options : findOptionsIn(invocation)) {
         injector.injectMembers(options)// TODO test case
         for (Entry<String, String> header : options.buildRequestHeaders().entries()) {
            headers.put(header.getKey(), replaceTokens(header.getValue(), tokenValues));
         }
         for (Entry<String, String> query : options.buildQueryParameters().entries()) {
            queryParams.put(query.getKey(), replaceTokens(query.getValue(), tokenValues));
         }
         for (Entry<String, String> form : options.buildFormParameters().entries()) {
            formParams.put(form.getKey(), replaceTokens(form.getValue(), tokenValues));
         }

         String pathSuffix = options.buildPathSuffix();
         if (pathSuffix != null) {
            uriBuilder.appendPath(pathSuffix);
         }
         String stringPayload = options.buildStringPayload();
         if (stringPayload != null)
            payload = Payloads.newStringPayload(stringPayload);
      }

      if (!queryParams.isEmpty()) {
         uriBuilder.query(queryParams);
      }

      requestBuilder.headers(filterOutContentHeaders(headers));

      requestBuilder.endpoint(uriBuilder.build(convertUnsafe(tokenValues)));

      if (payload == null) {
         PayloadEnclosing payloadEnclosing = findOrNull(invocation.getArgs(), PayloadEnclosing.class);
         payload = (payloadEnclosing != null) ? payloadEnclosing.getPayload() : findOrNull(invocation.getArgs(),
               Payload.class);
View Full Code Here

TOP

Related Classes of org.jclouds.http.Uris.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.