Package org.springframework.web.util

Examples of org.springframework.web.util.UriTemplate


    assertEquals(entity, requestEntity.getBody());
  }

  @Test
  public void uriVariablesExpansion() throws URISyntaxException {
    URI uri = new UriTemplate("http://example.com/{foo}").expand("bar");
    RequestEntity.get(uri).accept(MediaType.TEXT_PLAIN).build();

    String url = "http://www.{host}.com/{path}";
    String host = "example";
    String path = "foo/bar";
    URI expected = new URI("http://www.example.com/foo/bar");

    uri = new UriTemplate(url).expand(host, path);
    RequestEntity<?> entity = RequestEntity.get(uri).build();
    assertEquals(expected, entity.getUrl());

    Map<String, String> uriVariables = new HashMap<>(2);
    uriVariables.put("host", host);
    uriVariables.put("path", path);

    uri = new UriTemplate(url).expand(uriVariables);
    entity = RequestEntity.get(uri).build();
    assertEquals(expected, entity.getUrl());
  }
View Full Code Here


  // general execution

  public <T> T execute(String url, HttpMethod method, RequestCallback requestCallback,
      ResponseExtractor<T> responseExtractor, Object... urlVariables) throws RestClientException {

    UriTemplate uriTemplate = new UriTemplate(url);
    URI expanded = uriTemplate.expand(urlVariables);
    return doExecute(expanded, method, requestCallback, responseExtractor);
  }
View Full Code Here

  }

  public <T> T execute(String url, HttpMethod method, RequestCallback requestCallback,
      ResponseExtractor<T> responseExtractor, Map<String, ?> urlVariables) throws RestClientException {

    UriTemplate uriTemplate = new UriTemplate(url);
    URI expanded = uriTemplate.expand(urlVariables);
    return doExecute(expanded, method, requestCallback, responseExtractor);
  }
View Full Code Here

  // general execution

  public <T> T execute(String url, HttpMethod method, RequestCallback requestCallback,
      ResponseExtractor<T> responseExtractor, Object... urlVariables) throws RestClientException {

    UriTemplate uriTemplate = new HttpUrlTemplate(url);
    URI expanded = uriTemplate.expand(urlVariables);
    return doExecute(expanded, method, requestCallback, responseExtractor);
  }
View Full Code Here

  }

  public <T> T execute(String url, HttpMethod method, RequestCallback requestCallback,
      ResponseExtractor<T> responseExtractor, Map<String, ?> urlVariables) throws RestClientException {

    UriTemplate uriTemplate = new HttpUrlTemplate(url);
    URI expanded = uriTemplate.expand(urlVariables);
    return doExecute(expanded, method, requestCallback, responseExtractor);
  }
View Full Code Here

   * @param model the model to add item into
   * @param url the URL
   * @param sourceModel the source model
   */
  private void addUriTemplateParameters(Map<String, Object> model, String url, Map<String, ?> sourceModel) {
    UriTemplate uriTemplate = new UriTemplate(url);
    for (String name : uriTemplate.getVariableNames()) {
      if (!model.containsKey(name)) {
        Assert.state(sourceModel.containsKey(name), "Unable to find URL template variable '" + name
            + "' in source model");
        model.put(name, sourceModel.get(name));
      }
View Full Code Here

    // API

    public static URI createSearchUri(final String uriBase, final String paramToExpand) {
        URL url = null;
        try {
            url = new UriTemplate(uriBase).expand(paramToExpand).toURL();
        } catch (final MalformedURLException ex) {
            throw new IllegalArgumentException(ex);
        }

        try {
View Full Code Here

                         && mediaType.getSubtype().equals("plain");
             }
         }, new MappingJackson2HttpMessageConverter()));
        this.clientId = clientId;
        this.clientSecret = clientSecret;
        this.authorizeUrlTemplate = new UriTemplate(authorizeUrl);
        this.accessTokenUrl = accessTokenUrl;
    }
View Full Code Here

                new StringHttpMessageConverter(), new FormHttpMessageConverter()));
        this.consumerKey = consumerKey;
        this.consumerSecret = consumerSecret;
        this.requestTokenUrl = requestTokenUrl;
        this.oauth10a = oauth10a;
        this.authorizeUrlTemplate = new UriTemplate(authorizeUrl);
        this.accessTokenUrl = accessTokenUrl;

    }
View Full Code Here

    @RequestMapping(value = "admin", method = RequestMethod.GET)
    @ResponseStatus(value = HttpStatus.NO_CONTENT)
    public void adminRoot(final HttpServletRequest request, final HttpServletResponse response) {
        final String rootUri = request.getRequestURL().toString();

        final URI fooUri = new UriTemplate("{rootUri}/{resource}").expand(rootUri, "foo");
        final String linkToFoo = LinkUtil.createLinkHeader(fooUri.toASCIIString(), "collection");
        response.addHeader("Link", linkToFoo);
    }
View Full Code Here

TOP

Related Classes of org.springframework.web.util.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.