Package org.springframework.hateoas

Examples of org.springframework.hateoas.UriTemplate


  public void rendersMultipleCuries() throws Exception {

    Resources<Object> resources = new Resources<Object>(Collections.emptySet());
    resources.add(new Link("foo", "myrel"));

    CurieProvider provider = new DefaultCurieProvider("default", new UriTemplate("/doc{?rel}")) {
      @Override
      public Collection<? extends Object> getCurieInformation(Links links) {
        return Arrays.asList(new Curie("foo", "bar"), new Curie("bar", "foo"));
      }
    };
View Full Code Here


    return new Resources<Resource<SimplePojo>>(content);
  }

  private static ObjectMapper getCuriedObjectMapper() {

    return getCuriedObjectMapper(new DefaultCurieProvider("foo", new UriTemplate("http://localhost:8080/rels/{rel}")));
  }
View Full Code Here

    new DefaultCurieProvider("acme", null);
  }

  @Test(expected = IllegalArgumentException.class)
  public void preventsUriTemplateWithoutVariable() {
    new DefaultCurieProvider("acme", new UriTemplate("http://localhost:8080/rels"));
  }
View Full Code Here

    new DefaultCurieProvider("acme", new UriTemplate("http://localhost:8080/rels"));
  }

  @Test(expected = IllegalArgumentException.class)
  public void preventsUriTemplateWithMoreThanOneVariable() {
    new DefaultCurieProvider("acme", new UriTemplate("http://localhost:8080/rels/{rel}/{another}"));
  }
View Full Code Here

    }

    private String traverseToFinalUrl() {

      String uri = getAndFindLinkWithRel(baseUri.toString(), rels.iterator());
      return new UriTemplate(uri).expand(templateParameters).toString();
    }
View Full Code Here

      if (!rels.hasNext()) {
        return uri;
      }

      HttpEntity<?> request = prepareRequest(headers);
      UriTemplate uriTemplate = new UriTemplate(uri);

      ResponseEntity<String> responseEntity = operations.exchange(uriTemplate.expand(templateParameters), GET, request,
          String.class);
      MediaType contentType = responseEntity.getHeaders().getContentType();
      String responseBody = responseEntity.getBody();

      Rel rel = Rels.getRelFor(rels.next(), discoverers);
View Full Code Here

    TemplateVariables vars = new TemplateVariables(start, lod);
    for (CompletionKind k : CompletionKind.values()) {
      Object mi = ControllerLinkBuilder.methodOn(CompletionsController.class).completions(k, "", 42);
      Link link = ControllerLinkBuilder.linkTo(mi).withRel(String.format("completions/%s", k));
      String href = link.getHref().substring(0, link.getHref().lastIndexOf('?'));
      UriTemplate template = new UriTemplate(href, vars);
      Link copy = new Link(template, link.getRel());

      xdRuntime.add(copy);
    }
View Full Code Here

    super(other);
  }

  @Override
  public List<String> completions(CompletionKind kind, String start, int lod) {
    UriTemplate template = resources.get(String.format("completions/%s", kind));
    URI expanded = template.expand(start, lod);
    return Arrays.asList(restTemplate.getForObject(expanded, String[].class));
  }
View Full Code Here

  public SpringXDTemplate(ClientHttpRequestFactory factory, URI baseURI) {
    super(factory);
    XDRuntime xdRuntime = restTemplate.getForObject(baseURI, XDRuntime.class);

    resources.put("streams/definitions", new UriTemplate(xdRuntime.getLink("streams").getHref() + "/definitions"));
    resources.put("streams/deployments", new UriTemplate(xdRuntime.getLink("streams").getHref() + "/deployments"));
    resources.put("jobs", new UriTemplate(xdRuntime.getLink("jobs").getHref()));
    resources.put("jobs/definitions", new UriTemplate(xdRuntime.getLink("jobs").getHref() + "/definitions"));
    resources.put("jobs/deployments", new UriTemplate(xdRuntime.getLink("jobs").getHref() + "/deployments"));
    resources.put("modules", new UriTemplate(xdRuntime.getLink("modules").getHref()));

    resources.put("jobs/configurations", new UriTemplate(xdRuntime.getLink("jobs/configurations").getHref()));
    resources.put("jobs/executions", new UriTemplate(xdRuntime.getLink("jobs/executions").getHref()));
    resources.put("jobs/instances", new UriTemplate(xdRuntime.getLink("jobs/instances").getHref()));

    resources.put("runtime/containers", new UriTemplate(xdRuntime.getLink("runtime/containers").getHref()));
    resources.put("runtime/modules", new UriTemplate(xdRuntime.getLink("runtime/modules").getHref()));

    resources.put("completions/stream", new UriTemplate(xdRuntime.getLink("completions/stream").getHref()));
    resources.put("completions/job", new UriTemplate(xdRuntime.getLink("completions/job").getHref()));
    resources.put("completions/module", new UriTemplate(xdRuntime.getLink("completions/module").getHref()));

    resources.put("counters", new UriTemplate(xdRuntime.getLink("counters").getHref()));
    resources.put("field-value-counters", new UriTemplate(xdRuntime.getLink("field-value-counters").getHref()));
    resources.put("aggregate-counters", new UriTemplate(xdRuntime.getLink("aggregate-counters").getHref()));
    resources.put("gauges", new UriTemplate(xdRuntime.getLink("gauges").getHref()));
    resources.put("rich-gauges", new UriTemplate(xdRuntime.getLink("rich-gauges").getHref()));


    streamOperations = new StreamTemplate(this);
    jobOperations = new JobTemplate(this);
    counterOperations = new CounterTemplate(this);
View Full Code Here

TOP

Related Classes of org.springframework.hateoas.UriTemplate

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.