Examples of UriComponentsBuilder


Examples of org.springframework.web.util.UriComponentsBuilder

    if (TemplateVariables.NONE.equals(variables)) {
      return URI.create(baseUri);
    }

    UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(baseUri);
    Iterator<Object> iterator = Arrays.asList(parameters).iterator();

    for (TemplateVariable variable : variables) {

      Object value = iterator.hasNext() ? iterator.next() : null;
      appendToBuilder(builder, variable, value);
    }

    return builder.build().toUri();
  }
View Full Code Here

Examples of org.springframework.web.util.UriComponentsBuilder

    if (TemplateVariables.NONE.equals(variables)) {
      return URI.create(baseUri);
    }

    Assert.notNull(parameters, "Parameters must not be null!");
    UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(baseUri);

    for (TemplateVariable variable : variables) {
      appendToBuilder(builder, variable, parameters.get(variable.getName()));
    }

    return builder.build().toUri();
  }
View Full Code Here

Examples of org.springframework.web.util.UriComponentsBuilder

    if (!StringUtils.hasText(path)) {
      return getThis();
    }

    String uriString = uriComponents.toUriString();
    UriComponentsBuilder builder = uriString.isEmpty() ? fromUri(uriComponents.toUri())
        : fromUriString(uriString);

    UriComponents components = UriComponentsBuilder.fromUriString(path).build();

    for (String pathSegment : components.getPathSegments()) {
      builder.pathSegment(pathSegment);
    }

    String fragment = components.getFragment();
    if (StringUtils.hasText(fragment)) {
      builder.fragment(fragment);
    }

    return createNewInstance(builder.query(components.getQuery()));
  }
View Full Code Here

Examples of org.springframework.web.util.UriComponentsBuilder

    if (!StringUtils.hasText(path)) {
      return getThis();
    }

    String uriString = uriComponents.toUriString();
    UriComponentsBuilder builder = uriString.isEmpty() ? fromUri(uriComponents.toUri())
        : fromUriString(uriString);

    UriComponents components = UriComponentsBuilder.fromUriString(path).build();

    for (String pathSegment : components.getPathSegments()) {
      builder.pathSegment(pathSegment);
    }

    String fragment = components.getFragment();
    if (StringUtils.hasText(fragment)) {
      builder.fragment(fragment);
    }

    return createNewInstance(builder.query(components.getQuery()));
  }
View Full Code Here

Examples of org.springframework.web.util.UriComponentsBuilder

    MethodInvocation invocation = invocations.getLastInvocation();
    Iterator<Object> classMappingParameters = invocations.getObjectParameters();
    Method method = invocation.getMethod();

    String mapping = DISCOVERER.getMapping(invocation.getTargetType(), method);
    UriComponentsBuilder builder = ControllerLinkBuilder.getBuilder().path(mapping);

    UriTemplate template = new UriTemplate(mapping);
    Map<String, Object> values = new HashMap<String, Object>();

    Iterator<String> names = template.getVariableNames().iterator();
    while (classMappingParameters.hasNext()) {
      values.put(names.next(), classMappingParameters.next());
    }

    for (BoundMethodParameter parameter : PATH_VARIABLE_ACCESSOR.getBoundParameters(invocation)) {
      values.put(parameter.getVariableName(), parameter.asString());
    }

    for (BoundMethodParameter parameter : REQUEST_PARAM_ACCESSOR.getBoundParameters(invocation)) {

      Object value = parameter.getValue();
      String key = parameter.getVariableName();

      if (value instanceof Collection) {
        for (Object element : (Collection<?>) value) {
          builder.queryParam(key, element);
        }
      } else {
        builder.queryParam(key, parameter.asString());
      }
    }

    UriComponents components = applyUriComponentsContributer(builder, invocation).buildAndExpand(values);
    return new ControllerLinkBuilder(UriComponentsBuilder.fromUriString(components.toUriString()));
View Full Code Here

Examples of org.springframework.web.util.UriComponentsBuilder

  public static UriComponentsBuilder fromMethod(Method method, Object... argumentValues) {
    String typePath = getTypeRequestMapping(method.getDeclaringClass());
    String methodPath = getMethodRequestMapping(method);
    String path = pathMatcher.combine(typePath, methodPath);

    UriComponentsBuilder builder = ServletUriComponentsBuilder.fromCurrentServletMapping().path(path);
    UriComponents uriComponents = applyContributors(builder, method, argumentValues);
    return ServletUriComponentsBuilder.newInstance().uriComponents(uriComponents);
  }
View Full Code Here

Examples of org.springframework.web.util.UriComponentsBuilder

  }

  @Override
  public IResponse geocode(IGeocodeRequest request) {

    UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(URL);

    for (Map.Entry<String, String> entry : request.getParameters().entrySet())
      builder.queryParam(entry.getKey(), entry.getValue());

    URI uri = builder.buildAndExpand(request.getParameters()).toUri();

    return restTemplate.getForObject(uri, Response.class);
  }
View Full Code Here

Examples of org.springframework.web.util.UriComponentsBuilder

  }

  @Override
  public IResponse reverseGeocode(IReverseGeocodeRequest request) {

    UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(URL);

    for (Map.Entry<String, String> entry : request.getParameters().entrySet())
      builder.queryParam(entry.getKey(), entry.getValue());

    URI uri = builder.buildAndExpand(request.getParameters()).toUri();

    return restTemplate.getForObject(uri, Response.class);
  }
View Full Code Here

Examples of org.springframework.web.util.UriComponentsBuilder

                                       .build()
                                       .toUri();
    }

    if(null != params) {
      UriComponentsBuilder urib = UriComponentsBuilder.fromUri(requestUri);
      for(Object key : params.keySet()) {
        urib.queryParam(key.toString(), params.get(key));
      }
      requestUri = urib.build().toUri();
    }

    ExtractLinksHelper elh = new ExtractLinksHelper();
    List<Link> links = client.execute(requestUri, HttpMethod.GET, elh, elh);
View Full Code Here

Examples of org.springframework.web.util.UriComponentsBuilder

                 mandatory = false,
                 help = "The path to dump the output to.") String outputPath) {

    outputPath = contextCmds.evalAsString(outputPath);

    UriComponentsBuilder ucb = createUriComponentsBuilder(path.getPath());
    if (null != params) {
      for (Object key : params.keySet()) {
        Object o = params.get(key);
        ucb.queryParam(key.toString(), encode(o.toString()));
      }
    }
    requestUri = ucb.build().toUri();

    return execute(HttpMethod.GET, null, follow, outputPath);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.