Package com.sun.jersey.api.client.WebResource

Examples of com.sun.jersey.api.client.WebResource.Builder.post()


    public RequestResult post( String path, String data ) {
        Builder builder = builder( path );
        if ( data != null ) {
            builder = builder.entity( data, MediaType.APPLICATION_JSON_TYPE );
        }
        return RequestResult.extractFrom(builder.post(ClientResponse.class));
    }

    public void put( String path, String data ) {
        Builder builder = builder( path );
        if ( data != null ) {
View Full Code Here


      LOGGER.trace("POST: {}", webResource);
      Builder builder = webResource.accept(MediaType.TEXT_PLAIN);
      if (hostConfig != null) {
        builder.type(MediaType.APPLICATION_JSON).post(hostConfig);
      } else {
        builder.post((HostConfig) null);
      }
    } catch (UniformInterfaceException exception) {
      if (exception.getResponse().getStatus() == 404) {
        throw new NotFoundException(String.format("No such container %s", containerId));
      } else if (exception.getResponse().getStatus() == 204) {
View Full Code Here

      LOGGER.trace("POST: {}", webResource);
      Builder builder = webResource.accept(MediaType.TEXT_PLAIN);
      if (hostConfig != null) {
        builder.type(MediaType.APPLICATION_JSON).post(hostConfig);
      } else {
        builder.post((HostConfig) null);
      }
    } catch (UniformInterfaceException exception) {
      if (exception.getResponse().getStatus() == 404) {
        throw new NotFoundException(String.format("No such container %s", containerId));
      } else if (exception.getResponse().getStatus() == 204) {
View Full Code Here

    private ZSession createSession(String expire) {
        WebResource wr = sessionsr.queryParam("op", "create")
            .queryParam("expire", expire);
        Builder b = wr.accept(MediaType.APPLICATION_JSON);

        ClientResponse cr = b.post(ClientResponse.class, null);
        assertEquals(ClientResponse.Status.CREATED, cr
                .getClientResponseStatus());

        return cr.getEntity(ZSession.class);
    }
View Full Code Here

            .queryParam("ephemeral", "true")
            .queryParam("session", session.id)
            .queryParam("null", "true");
       
        Builder b = wr.accept(MediaType.APPLICATION_JSON);
        ClientResponse cr = b.post(ClientResponse.class);
        assertEquals(ClientResponse.Status.CREATED, cr.getClientResponseStatus());
       
        Stat stat = new Stat();
        zk.getData("/ephemeral-test", false, stat);
       
View Full Code Here

        WebResource wr = znodesr.path(path).queryParam("dataformat", "utf8")
            .queryParam("name", name);
        Builder builder = wr.accept(MediaType.APPLICATION_JSON);

        ClientResponse cr;
        cr = builder.post(ClientResponse.class, data);
        assertEquals(ClientResponse.Status.CREATED, cr.getClientResponseStatus());

        ZPath zpath = cr.getEntity(ZPath.class);
        assertEquals(new ZPath(path + name), zpath);
        assertEquals(znodesr.path(path).toString(), zpath.uri);
View Full Code Here

        Builder builder = wr.accept(accept);

        ClientResponse cr;
        if (data == null) {
            cr = builder.post(ClientResponse.class);
        } else {
            cr = builder.post(ClientResponse.class, data);
        }
        assertEquals(expectedStatus, cr.getClientResponseStatus());
View Full Code Here

        ClientResponse cr;
        if (data == null) {
            cr = builder.post(ClientResponse.class);
        } else {
            cr = builder.post(ClientResponse.class, data);
        }
        assertEquals(expectedStatus, cr.getClientResponseStatus());

        if (expectedPath == null) {
            return;
View Full Code Here

      LOGGER.trace("POST: {}", webResource);
      Builder builder = webResource.accept(MediaType.TEXT_PLAIN);
      if (hostConfig != null) {
        builder.type(MediaType.APPLICATION_JSON).post(hostConfig);
      } else {
        builder.post((HostConfig) null);
      }
    } catch (UniformInterfaceException exception) {
      if (exception.getResponse().getStatus() == 404) {
        throw new NotFoundException(String.format("No such container %s", containerId));
      } else if (exception.getResponse().getStatus() == 204) {
View Full Code Here

        Builder builder = wr.accept(accept);

        ClientResponse cr;
        if (data == null) {
            cr = builder.post(ClientResponse.class);
        } else {
            cr = builder.post(ClientResponse.class, data);
        }
        assertEquals(expectedStatus, cr.getResponseStatus());
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.