Examples of UriComponents


Examples of org.springframework.web.util.UriComponents

        Method method = info.getControllerMethod();
        Object[] argumentValues = info.getArgumentValues();

        UriComponentsBuilder builder = ServletUriComponentsBuilder.newInstance().path(getMethodRequestMapping(method));
        UriComponents uriComponents = applyContributors(builder, method, argumentValues);

        String typeMapping = getTypeRequestMapping(method.getDeclaringClass());
        String methodMapping = uriComponents.getPath();
        String path = pathMatcher.combine(typeMapping, methodMapping);

        return ServletUriComponentsBuilder.fromCurrentServletMapping().path(
                path).queryParams(uriComponents.getQueryParams());
    }
View Full Code Here

Examples of org.springframework.web.util.UriComponents

        if (tags.length > 0) {
            String tagsString = StringUtils.arrayToDelimitedString(tags, ";");
            builder = builder.queryParam(TAGGED_PARAM, tagsString);
        }

        UriComponents uriComponents = builder.build();

        Questions result = restClient.get(restOperations, uriComponents.toUriString(), Questions.class);

        return result.items;
    }
View Full Code Here

Examples of org.springframework.web.util.UriComponents

  @Test
  public void addsRequestParametersHandedIntoSlashCorrectly() {

    Link link = linkTo(PersonController.class).slash("?foo=bar").withSelfRel();

    UriComponents components = toComponents(link);
    assertThat(components.getQuery(), is("foo=bar"));
  }
View Full Code Here

Examples of org.springframework.web.util.UriComponents

  @Test
  public void linksToMethodWithPathVariableAndRequestParams() {

    Link link = linkTo(methodOn(ControllerWithMethods.class).methodForNextPage("1", 10, 5)).withSelfRel();

    UriComponents components = toComponents(link);
    assertThat(components.getPath(), is("/something/1/foo"));

    MultiValueMap<String, String> queryParams = components.getQueryParams();
    assertThat(queryParams.get("limit"), contains("5"));
    assertThat(queryParams.get("offset"), contains("10"));
  }
View Full Code Here

Examples of org.springframework.web.util.UriComponents

    Link link = linkTo(
        methodOn(ControllerWithMethods.class).methodWithMultiValueRequestParams("1", Arrays.asList(3, 7), 5))
        .withSelfRel();

    UriComponents components = toComponents(link);
    assertThat(components.getPath(), is("/something/1/foo"));

    MultiValueMap<String, String> queryParams = components.getQueryParams();
    assertThat(queryParams.get("limit"), contains("5"));
    assertThat(queryParams.get("items"), containsInAnyOrder("3", "7"));
  }
View Full Code Here

Examples of org.springframework.web.util.UriComponents

   * @see #26, #39
   */
  @Test
  public void returnsUriComponentsBuilder() {

    UriComponents components = linkTo(PersonController.class).slash("something?foo=bar").toUriComponentsBuilder()
        .build();

    assertThat(components.getPath(), is("/people/something"));
    assertThat(components.getQuery(), is("foo=bar"));
  }
View Full Code Here

Examples of org.springframework.web.util.UriComponents

    if (variables == null) {
      return this;
    }

    UriComponents components = UriComponentsBuilder.fromUriString(baseUri).build();
    List<TemplateVariable> result = new ArrayList<TemplateVariable>();

    for (TemplateVariable variable : variables) {

      boolean isRequestParam = variable.isRequestParameterVariable();
      boolean alreadyPresent = components.getQueryParams().containsKey(variable.getName());

      if (isRequestParam && alreadyPresent) {
        continue;
      }

      if (variable.isFragment() && StringUtils.hasText(components.getFragment())) {
        continue;
      }

      result.add(variable);
    }
View Full Code Here

Examples of org.springframework.web.util.UriComponents

   * @see java.lang.Object#toString()
   */
  @Override
  public String toString() {

    UriComponents components = UriComponentsBuilder.fromUriString(baseUri).build();
    boolean hasQueryParameters = !components.getQueryParams().isEmpty();

    return baseUri + getOptionalVariables().toString(hasQueryParameters);
  }
View Full Code Here

Examples of org.springframework.web.util.UriComponents

    Assert.notNull(controller);

    ControllerLinkBuilder builder = new ControllerLinkBuilder(getBuilder());
    String mapping = DISCOVERER.getMapping(controller);

    UriComponents uriComponents = UriComponentsBuilder.fromUriString(mapping == null ? "/" : mapping).build();
    UriComponents expandedComponents = uriComponents.expand(parameters);

    return builder.slash(expandedComponents);
  }
View Full Code Here

Examples of org.springframework.web.util.UriComponents

    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
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.