Package com.sun.jersey.api.client

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


      String dataType = "DebugProcessor", adaptorClass = "JMXAdaptor", adaptorParams = "localhost 0 60 hadoop:*", offset = "0";
      String adaptor_json = "{\"DataType\":\""+dataType+"\", \"AdaptorClass\":\""+adaptorClass+"\", \"AdaptorParams\" : \""+adaptorParams+"\", \"Offset\" : \""+offset+"\" }";
      System.out.println(adaptor_json);
      Client client = Client.create();
      WebResource resource = client.resource(rest_url);
      ClientResponse response = resource.type("application/json")
          .post(ClientResponse.class, adaptor_json);
      if (response.getStatus() != 200 && response.getStatus() != 201) {
      fail("Add adaptor through REST failed : HTTP error code : " + response.getStatus());
    }
      assertEquals(1, agent.adaptorCount());
View Full Code Here


    public void testCustomer() throws Exception {
        WebResource webResource = resource().path("customer");

        Customer customer = webResource.accept(MediaType.APPLICATION_XML).get(Customer.class);
        customer.setName("Tom Dooley");
        webResource.type(MediaType.APPLICATION_XML).put(customer);

        Customer updatedCustomer = webResource.accept(MediaType.APPLICATION_XML).get(Customer.class);
        Assert.assertEquals(customer, updatedCustomer);
    }
View Full Code Here

        WebResource webResource = resource().path("customers/1");
        webResource.addFilter(new LoggingFilter());

        Customer customer = webResource.accept(MediaType.APPLICATION_XML).get(Customer.class);
        customer.setName("Tom Dooley");
        webResource.type(MediaType.APPLICATION_XML).put(customer);

        Customer updatedCustomer = webResource.accept(MediaType.APPLICATION_XML).get(Customer.class);
        Assert.assertEquals(customer, updatedCustomer);
    }
View Full Code Here

        resource = authorisedResourceFactory.getResource(baseUri, client, pathElements);
      else
        resource = authorisedResourceFactory.getResource(client, pathElements);

        try {
            return fixStringResult(klass, resource.
                type(mediaType).
                post(klass, entity));
        } catch (UniformInterfaceException ue) {
            throw handleErrorResponse(ue, errorDeserialiser);
        }
View Full Code Here

    }
   
    public <T> T put(Class<T> klass, Object entity, String... pathElements) throws CreateSendException {
        WebResource resource = authorisedResourceFactory.getResource(client, pathElements);
        try {
            return fixStringResult(klass, resource.
                type(MediaType.APPLICATION_JSON_TYPE).
                put(klass, entity));
        } catch (UniformInterfaceException ue) {
            throw handleErrorResponse(ue, defaultDeserialiser);
        }
View Full Code Here

        if(queryString != null) {
            resource = resource.queryParams(queryString);
        }
       
        try {
            resource.
                type(MediaType.APPLICATION_JSON_TYPE).
                put(entity);
        } catch (UniformInterfaceException ue) {
            throw handleErrorResponse(ue, errorDeserialiser);
        }
View Full Code Here

                + "<state>CA</state>"
                + "<zip>94025</zip>"
                + "<country>USA</country>"
                + "</customer>";

        ClientResponse response = wr.type(MediaType.APPLICATION_XML).post(ClientResponse.class, newCustomer);

        Assert.assertEquals(201, response.getStatus()); // 201 = created
        System.out.println("Location: " + response.getHeaders().get("Location"));

        // Get the new customer
View Full Code Here

            webResource = client().resource(user.getString("bookmarks"));

            JSONObject bookmark = new JSONObject();
            bookmark.put("uri", "http://java.sun.com").put("sdesc", "test desc").put("ldesc", "long test description");
            webResource.type("application/json").post(bookmark);

            JSONArray bookmarks = webResource.accept("application/json").get(JSONArray.class);
            assertTrue(bookmarks != null);
            int bookmarksSize = bookmarks.length();
View Full Code Here

    if ( LOG.isLoggable( Level.FINE ) ) {
      LOG.fine( "PUT " + path.toString() );
    }

    ClientResponse response = path
      .type( JSON_TYPE ).accept( JSON_TYPE ).put( ClientResponse.class, content );
    return ActionResponse.create( response );
  }

  /**
 
View Full Code Here

    if ( LOG.isLoggable( Level.FINE ) ) {
      LOG.fine( "PUT " + path.toString() );
    }

    ClientResponse clientResponse = path.type( JSON_TYPE ).accept( JSON_TYPE ).put( ClientResponse.class, couchDocSerializer.serialize( doc, serializer ) );
    ActionResponse actionResponse = ActionResponse.create( clientResponse );

    //Update the rev
    doc.setRev( actionResponse.getRev() );
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.