Package com.sun.jersey.api.client

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


    /** Creates a new workspace. */
    private WebResource createWorkspace(Client c) {
        WebResource r = c.resource("http://localhost:8080/client/work");
        try {
            r.post(String.class, "");
            fail("We should have been redirected to a new workspace.");
            return null; // to keep the compiler happy, it does not understand what fail() does
        }
        catch (UniformInterfaceException e) {
            return c.resource(e.getResponse().getLocation());
View Full Code Here


    /** Creates an entity. */
    private WebResource createEntity(Client c, WebResource work, String type, String data) throws IOException {
        WebResource entity = work.path(type);
        try {
            entity.post(String.class, data);
            throw new IOException("Could not create " + type + " with data " + data);
        }
        catch (UniformInterfaceException e2) {
            return c.resource(e2.getResponse().getLocation());
        }
View Full Code Here

        Link cancel = orderLinks.get("cancel");
        if (cancel != null) {
            System.out.println("** Canceling the order at URL: " + cancel.getHref());
            wr = c.resource(cancel.getHref());
            response = wr.post(ClientResponse.class);
            Assert.assertEquals(204, response.getStatus());
        }

        System.out.println();
        System.out.println("** New list of orders after cancel: ");
View Full Code Here

        System.out.println();
        Link purge = ordersLinks.get("purge");
        System.out.println("** Purge cancelled orders at URL: " + purge.getHref());
        wr = c.resource(purge.getHref());
        response = wr.post(ClientResponse.class);
        Assert.assertEquals(204, response.getStatus());

        System.out.println();
        System.out.println("** New list of orders after purge: ");
        wr = c.resource(orders.getHref());
View Full Code Here

                JSONObject fieldsJs = new IssueUpdateJsonGenerator().generate(fields);
        if (fieldsJs.keys().hasNext()) {
          jsonObject.put("fields", fieldsJs);
        }
        final WebResource issueResource = client.resource(transitionsUri);
        issueResource.post(jsonObject);
        return null;
      }
    });
  }
View Full Code Here

  public void vote(final URI votesUri, ProgressMonitor progressMonitor) {
    invoke(new Callable<Void>() {
      @Override
      public Void call() throws Exception {
        final WebResource votesResource = client.resource(votesUri);
        votesResource.post();
        return null;
      }
    });
  }
View Full Code Here

  protected <T> T postAndParse(final URI uri, @Nullable final JSONObject postEntity, final JsonObjectParser<T> parser, ProgressMonitor progressMonitor) {
    return invoke(new Callable<T>() {
      @Override
      public T call() throws Exception {
        final WebResource webResource = client.resource(uri);
        final JSONObject s = postEntity != null ? webResource.post(JSONObject.class, postEntity) : webResource.post(JSONObject.class);
        return parser.parse(s);
      }
    });
  }
View Full Code Here

  protected <T> T postAndParse(final URI uri, @Nullable final JSONObject postEntity, final JsonObjectParser<T> parser, ProgressMonitor progressMonitor) {
    return invoke(new Callable<T>() {
      @Override
      public T call() throws Exception {
        final WebResource webResource = client.resource(uri);
        final JSONObject s = postEntity != null ? webResource.post(JSONObject.class, postEntity) : webResource.post(JSONObject.class);
        return parser.parse(s);
      }
    });
  }
View Full Code Here

      @Override
      public Void call() throws Exception {
        final WebResource webResource = client.resource(uri);
        final JSONObject postEntity = callable.call();
        if (postEntity != null) {
          webResource.post(postEntity);
        } else {
          webResource.post();
        }
        return null;
      }
View Full Code Here

        final WebResource webResource = client.resource(uri);
        final JSONObject postEntity = callable.call();
        if (postEntity != null) {
          webResource.post(postEntity);
        } else {
          webResource.post();
        }
        return null;
      }
    });
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.