Package org.springframework.web.util

Examples of org.springframework.web.util.UriComponents$FullPathComponent


  }

  @Test
  public void usesBaseUriIfConfigured() {

    UriComponents baseUri = UriComponentsBuilder.fromUriString("http://foo:9090").build();

    PagedResourcesAssembler<Person> assembler = new PagedResourcesAssembler<Person>(resolver, baseUri);
    PagedResources<Resource<Person>> resources = assembler.toResource(createPage(1));

    assertThat(resources.getLink(Link.REL_PREVIOUS).getHref(), startsWith(baseUri.toUriString()));
    assertThat(resources.getLink(Link.REL_SELF), is(notNullValue()));
    assertThat(resources.getLink(Link.REL_NEXT).getHref(), startsWith(baseUri.toUriString()));
  }
View Full Code Here


    };

    Object result = resolver.resolveArgument(methodParameter, null, null, null);

    assertThat(result, is(instanceOf(PagedResourcesAssembler.class)));
    UriComponents uriComponents = (UriComponents) ReflectionTestUtils.getField(result, "baseUri");

    assertThat(uriComponents.getPath(), is("/foo/mapping"));
  }
View Full Code Here

   * @see DATACMNS-418
   */
  @Test
  public void returnCorrectTemplateVariables() {

    UriComponents uriComponents = UriComponentsBuilder.fromPath("/").build();

    HateoasSortHandlerMethodArgumentResolver resolver = new HateoasSortHandlerMethodArgumentResolver();
    assertThat(resolver.getSortTemplateVariables(null, uriComponents).toString(), is("{?sort}"));
  }
View Full Code Here

    Map<String, Object> extraProperties = request.getExtraProperties();

    delegate.createCluster(request.getClusterId(), request.getClusterDef(), projectionData, extraProperties);

    HttpHeaders responseHeaders = new HttpHeaders();
    UriComponents uriComponents = MvcUriComponentsBuilder
          .fromMethodCall(on(YarnContainerClusterMvcEndpoint.class).clusterInfo(request.getClusterId())).build();
    responseHeaders.setLocation(uriComponents.toUri());

    return new ResponseEntity<Void>(responseHeaders, HttpStatus.CREATED);
  }
View Full Code Here

   */
  @Override
  public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
      NativeWebRequest webRequest, WebDataBinderFactory binderFactory) {

    UriComponents fromUriString = resolveBaseUri(parameter);
    MethodParameter pageableParameter = findMatchingPageableParameter(parameter);

    if (pageableParameter != null) {
      return new MethodParameterAwarePagedResourcesAssembler<Object>(pageableParameter, resolver, fromUriString);
    } else {
View Full Code Here

  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

   * @see DATACMNS-418
   */
  @Test
  public void returnsCustomizedTemplateVariables() {

    UriComponents uriComponents = UriComponentsBuilder.fromPath("/foo").build();

    HateoasPageableHandlerMethodArgumentResolver resolver = getResolver();
    resolver.setPageParameterName("foo");
    String variables = resolver.getPaginationTemplateVariables(null, uriComponents).toString();

View Full Code Here

    assertThat(builder.build().toUriString(), endsWith(expected));
  }

  private void assertTemplateEnrichment(String baseUri, String expected) {

    UriComponents uriComponents = UriComponentsBuilder.fromUriString(baseUri).build();

    HateoasPageableHandlerMethodArgumentResolver resolver = getResolver();
    assertThat(resolver.getPaginationTemplateVariables(null, uriComponents).toString(), is(expected));
  }
View Full Code Here

      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);
      claims = jwt.getJWTClaimsSet();
View Full Code Here

  public String webfinger(@RequestParam("resource") String resource, Model model) {

    if (!resource.equals(config.getIssuer())) {
      // it's not the issuer directly, need to check other methods

      UriComponents resourceUri = WebfingerURLNormalizer.normalizeResource(resource);
      if (resourceUri != null
          && resourceUri.getScheme() != null
          && resourceUri.getScheme().equals("acct")) {
        // acct: URI

        UserInfo user = userService.getByUsername(resourceUri.getUserInfo()); // first part is the username

        if (user == null) {
          logger.info("User not found: " + resource);
          model.addAttribute("code", HttpStatus.NOT_FOUND);
          return HttpCodeView.VIEWNAME;
        }

        UriComponents issuerComponents = UriComponentsBuilder.fromHttpUrl(config.getIssuer()).build();
        if (!Strings.nullToEmpty(issuerComponents.getHost())
            .equals(Strings.nullToEmpty(resourceUri.getHost()))) {
          logger.info("Host mismatch, expected " + issuerComponents.getHost() + " got " + resourceUri.getHost());
          model.addAttribute("code", HttpStatus.NOT_FOUND);
          return HttpCodeView.VIEWNAME;
        }

View Full Code Here

TOP

Related Classes of org.springframework.web.util.UriComponents$FullPathComponent

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.