Package javax.ws.rs.core

Examples of javax.ws.rs.core.UriBuilder


  private static void addService(Method m, ResourceFacade<?> entity, UriInfo uriInfo,
      RESTServiceDiscovery ret, LinkResource service, String rel) {
    Map<String, ? extends Object> pathParameters = entity.pathParameters();
    // do we need any path parameters?
    UriBuilder uriBuilder = uriInfo.getBaseUriBuilder().path(m.getDeclaringClass());
    if(m.isAnnotationPresent(Path.class))
      uriBuilder.path(m);
    URI uri;
    List<String> paramNames = ((UriBuilderImpl)uriBuilder).getPathParamNamesInDeclarationOrder();
    if(paramNames.isEmpty())
      uri = uriBuilder.build();
    else if(pathParameters.size() >= paramNames.size())
      uri = uriBuilder.buildFromMap(pathParameters);
    else
      // just bail out since we don't have enough parameters, that must be an instance service
      return;
    if(rel.length() == 0){
      if (m.isAnnotationPresent(GET.class))
View Full Code Here


  }

  private static void addInstanceService(Method m, Object entity,
      UriInfo uriInfo, RESTServiceDiscovery ret, LinkResource service,
      String rel) {
    UriBuilder uriBuilder = uriInfo.getBaseUriBuilder().path(m.getDeclaringClass());
    if(m.isAnnotationPresent(Path.class))
      uriBuilder.path(m);
    URI uri = buildURI(uriBuilder, service, entity, m);

    if (rel.length() == 0) {
      if (m.isAnnotationPresent(GET.class)){
        Class<?> type = m.getReturnType();
View Full Code Here

       String response = accessEndUserResource(accessToken);
       return Response.ok().type("text/plain").entity(response).build();
   }
  
   private String getCallbackURI() {
       UriBuilder ub = ui.getBaseUriBuilder();
       return ub.path(ConsumerResource.class).path("token-authorization").build().toString();
   }
View Full Code Here

      }

      protected String getSenderLink(UriInfo info)
      {
         String basePath = info.getMatchedURIs().get(0);
         UriBuilder builder = info.getBaseUriBuilder();
         builder.path(basePath);
         builder.path("sender");
         String link = "<" + builder.build().toString() + ">; rel=\"sender\"; title=\"sender\"";
         return link;
      }
View Full Code Here

      }

      protected String getTopLink(UriInfo info)
      {
         String basePath = info.getMatchedURIs().get(0);
         UriBuilder builder = info.getBaseUriBuilder();
         builder.path(basePath);
         builder.path("poller");
         String link = "<" + builder.build().toString() + ">; rel=\"top-message\"; title=\"top-message\"";
         return link;
      }
View Full Code Here

   }

   @Test
   public void testEmoji()
   {
      UriBuilder builder = UriBuilder.fromPath("/my/url");
      builder.queryParam("msg", "emoji stuff %EE%81%96%EE%90%8F");
      URI uri = builder.build();
      System.out.println(uri);
      Assert.assertEquals("/my/url?msg=emoji+stuff+%EE%81%96%EE%90%8F", uri.toString());

   }
View Full Code Here

   }

   @Test
   public void testQuery()
   {
      UriBuilder builder = UriBuilder.fromPath("/foo");
      builder.queryParam("mama", "   ");
      Assert.assertEquals(builder.build().toString(), "/foo?mama=+++");
   }
View Full Code Here

   }

   @Test
   public void testQuery2()
   {
      UriBuilder builder = UriBuilder.fromUri("http://localhost/test");
      builder.replaceQuery("a={b}");
      URI uri = builder.build("=");
      Assert.assertEquals(uri.toString(), "http://localhost/test?a=%3D");
   }
View Full Code Here

   public void testReplaceMatrixParam()
   {
      URI bu = UriBuilder.fromUri("http://localhost:8080/a/b/c;a=x;b=y").
              replaceMatrix("x=a;y=b").build();
      Assert.assertEquals(URI.create("http://localhost:8080/a/b/c;x=a;y=b"), bu);
      UriBuilder builder = UriBuilder.fromUri("http://localhost:8080/a").path("/{b:A{0:10}}/c;a=x;b=y");
      builder.replaceMatrixParam("a", "1", "2");
      bu = builder.build("b");
      Assert.assertEquals(URI.create("http://localhost:8080/a/b/c;b=y;a=1;a=2"), bu);
   }
View Full Code Here

   {
      URI bu = UriBuilder.fromUri("http://localhost:8080/a/b/c?a=x&b=y").
              replaceQuery("x=a&y=b").build();
      Assert.assertEquals(URI.create("http://localhost:8080/a/b/c?x=a&y=b"), bu);

      UriBuilder builder = UriBuilder.fromUri("http://localhost:8080/a/b/c?a=x&b=y");
      builder.replaceQueryParam("a", "1", "2");
      bu = builder.build();
      Assert.assertEquals(URI.create("http://localhost:8080/a/b/c?b=y&a=1&a=2"), bu);

   }
View Full Code Here

TOP

Related Classes of javax.ws.rs.core.UriBuilder

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.