Examples of UriComponentsBuilder


Examples of org.springframework.web.util.UriComponentsBuilder

   * @param rel must not be {@literal null} or empty.
   * @return
   */
  private Link createLink(UriTemplate base, Pageable pageable, String rel) {

    UriComponentsBuilder builder = fromUri(base.expand());
    pageableResolver.enhance(builder, getMethodParameter(), pageable);

    UriComponents components = builder.build();
    TemplateVariables variables = new TemplateVariables(base.getVariables());
    variables = variables.concat(pageableResolver.getPaginationTemplateVariables(getMethodParameter(), components));

    return new Link(new UriTemplate(components.toString()).with(variables), rel);
  }
View Full Code Here

Examples of org.springframework.web.util.UriComponentsBuilder

   * @param rel must not be {@literal null} or empty.
   * @return
   */
  private Link createLink(UriTemplate base, Pageable pageable, String rel) {

    UriComponentsBuilder builder = fromUri(base.expand());
    pageableResolver.enhance(builder, getMethodParameter(), pageable);

    UriComponents components = builder.build();
    TemplateVariables variables = new TemplateVariables(base.getVariables());
    variables = variables.concat(pageableResolver.getPaginationTemplateVariables(getMethodParameter(), components));

    return new Link(new UriTemplate(components.toString()).with(variables), rel);
  }
View Full Code Here

Examples of org.springframework.web.util.UriComponentsBuilder

    assertUriStringFor(sort, expected, "/");
  }

  private void assertUriStringFor(Sort sort, String expected, String baseUri) throws Exception {

    UriComponentsBuilder builder = UriComponentsBuilder.fromUri(new URI(baseUri));
    MethodParameter parameter = getParameterOfMethod("supportedMethod");

    new HateoasSortHandlerMethodArgumentResolver().enhance(builder, parameter, sort);

    assertThat(builder.build().toUriString(), endsWith(expected));
  }
View Full Code Here

Examples of org.springframework.web.util.UriComponentsBuilder

  @Test
  public void replacesExistingPaginationInformation() throws Exception {

    MethodParameter parameter = new MethodParameter(Sample.class.getMethod("supportedMethod", Pageable.class), 0);
    UriComponentsContributor resolver = new HateoasPageableHandlerMethodArgumentResolver();
    UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080?page=0&size=10");
    resolver.enhance(builder, parameter, new PageRequest(1, 20));

    MultiValueMap<String, String> params = builder.build().getQueryParams();

    List<String> page = params.get("page");
    assertThat(page.size(), is(1));
    assertThat(page.get(0), is("1"));
View Full Code Here

Examples of org.springframework.web.util.UriComponentsBuilder

    return resolver;
  }

  protected void assertUriStringFor(Pageable pageable, String expected) {

    UriComponentsBuilder builder = UriComponentsBuilder.fromPath("/");
    MethodParameter parameter = getParameterOfMethod("supportedMethod");

    getResolver().enhance(builder, parameter, pageable);

    assertThat(builder.build().toUriString(), endsWith(expected));
  }
View Full Code Here

Examples of org.springframework.web.util.UriComponentsBuilder

  public void buildAuthRequestUrl() {

    String requestUri = urlBuilder.buildAuthRequestUrl(serverConfig, clientConfig, redirectUri, nonce, state, options);

    // parsing the result
    UriComponentsBuilder builder = null;

    try {
      builder = UriComponentsBuilder.fromUri(new URI(requestUri));
    } catch (URISyntaxException e1) {
      fail("URISyntaxException was thrown.");
    }

    UriComponents components = builder.build();
    String jwtString = components.getQueryParams().get("request").get(0);
    ReadOnlyJWTClaimsSet claims = null;

    try {
      SignedJWT jwt = SignedJWT.parse(jwtString);
View Full Code Here

Examples of org.springframework.web.util.UriComponentsBuilder

   * @param operationPath
   * @return the relative path to the api operation
   * @see this.getApplicationBasePath()
   */
  public String getOperationPath(String operationPath) {
    UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/");
    if (!isBlank(apiResourcePrefix)) {
      uriComponentsBuilder.path(apiResourcePrefix);
    }
    return uriComponentsBuilder.path(operationPath).build().toString();
  }
View Full Code Here

Examples of org.springframework.web.util.UriComponentsBuilder

            .build()
            .toString();
  }

  private UriComponentsBuilder agnosticUriComponentBuilder(String url) {
    UriComponentsBuilder uriComponentsBuilder;
    if (url.startsWith("http")) {
      uriComponentsBuilder = UriComponentsBuilder.fromHttpUrl(url);
    } else {
      uriComponentsBuilder = UriComponentsBuilder.fromPath(url);
    }
View Full Code Here

Examples of org.springframework.web.util.UriComponentsBuilder

  public String encodeRedirectURL(String baseUrl, Map<String, List<String>> parameters) {
    return response.encodeURL(encodeUrl(baseUrl, parameters));
  }

  private String encodeUrl(String baseUrl, Map<String, List<String>> parameters) {
    UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(baseUrl);
    for (Map.Entry<String, List<String>> entry : parameters.entrySet()) {
      builder.queryParam(entry.getKey(), entry.getValue().toArray());
    }
    return builder.buildAndExpand().toUriString();
  }
View Full Code Here

Examples of org.springframework.web.util.UriComponentsBuilder

      logger.warn("Can't normalize null or empty URI: " + identifier);
      return null; // nothing we can do
    } else {

      //UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(identifier);
      UriComponentsBuilder builder = UriComponentsBuilder.newInstance();

      Matcher m = pattern.matcher(identifier);
      if (m.matches()) {
        builder.scheme(m.group(2));
        builder.userInfo(m.group(6));
        builder.host(m.group(8));
        String port = m.group(10);
        if (!Strings.isNullOrEmpty(port)) {
          builder.port(Integer.parseInt(port));
        }
        builder.path(m.group(11));
        builder.query(m.group(13));
        builder.fragment(m.group(15)); // we throw away the hash, but this is the group it would be if we kept it
      } else {
        // doesn't match the pattern, throw it out
        logger.warn("Parser couldn't match input: " + identifier);
        return null;
      }

      UriComponents n = builder.build();

      if (Strings.isNullOrEmpty(n.getScheme())) {
        if (!Strings.isNullOrEmpty(n.getUserInfo())
            && Strings.isNullOrEmpty(n.getPath())
            && Strings.isNullOrEmpty(n.getQuery())
            && n.getPort() < 0) {

          // scheme empty, userinfo is not empty, path/query/port are empty
          // set to "acct" (rule 2)
          builder.scheme("acct");

        } else {
          // scheme is empty, but rule 2 doesn't apply
          // set scheme to "https" (rule 3)
          builder.scheme("https");
        }
      }

      // fragment must be stripped (rule 4)
      builder.fragment(null);

      return builder.build();
    }


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