Examples of WebResource


Examples of com.dotcms.repackage.com.sun.jersey.api.client.WebResource

                form.field("ENDPOINT_ID", endpoint.getId());
                form.bodyPart(new FileDataBodyPart("bundle", bundle, MediaType.MULTIPART_FORM_DATA_TYPE));


                //Sending bundle to endpoint
                WebResource resource = client.resource(endpoint.toURL()+"/api/bundlePublisher/publish");

                ClientResponse response =
                    resource.type(MediaType.MULTIPART_FORM_DATA).post(ClientResponse.class, form);


                if(response.getClientResponseStatus().getStatusCode() == HttpStatus.SC_OK)
                {
                  detail.setStatus(PublishAuditStatus.Status.BUNDLE_SENT_SUCCESSFULLY.getCode());
View Full Code Here

Examples of com.sun.jersey.api.client.WebResource

  }

  protected Document sendGetRequest(String url) {
    LOGGER.debug("calling: {}", url);
    try {
      WebResource webResource = httpClient.resource(url);
      Document response = webResource.get(Document.class);

      logXmlDocumentToDebug("Got response", response);
      return response;
    } catch (Exception e) {
      if(e instanceof SocketTimeoutException) {
View Full Code Here

Examples of com.sun.jersey.api.client.WebResource

  }

  protected ClientResponse sendPutRequest(String url) {
    LOGGER.debug("calling: {}", url);
    try {
      WebResource webResource = httpClient.resource(url);
      ClientResponse response = webResource.put(ClientResponse.class);

      LOGGER.debug("Got response: {}", response);
      return response;
    } catch (Exception e) {
      if(e instanceof SocketTimeoutException) {
View Full Code Here

Examples of com.sun.jersey.api.client.WebResource

  }

  protected Document sendPostRequest(String url, Document xml) {
    logXmlDocumentToDebug("submitting", xml);
    try {
      WebResource webResource = httpClient.resource(url);
      Document response = webResource.accept(MediaType.APPLICATION_XML)
          .header("Content-Type", "application/xml")
          .post(Document.class, xml);
      logXmlDocumentToDebug("Got response", response);
      return response;
    } catch (UniformInterfaceException e) {
View Full Code Here

Examples of com.sun.jersey.api.client.WebResource

    client = Client.create(clientConfig);
  }

  @Override
  public <T> OpenStackResponse request(OpenStackRequest<T> request) {
    WebResource target = client.resource(request.endpoint()).path(request.path());
    for(Map.Entry<String, List<Object> > entry : request.queryParams().entrySet()) {
      for (Object o : entry.getValue()) {
        target = target.queryParam(entry.getKey(), String.valueOf(o));
      }
    }
    target.addFilter(logger);
    MultivaluedMap<String, Object> headers = new OutBoundHeaders();
    for(Map.Entry<String, List<Object>> h : request.headers().entrySet()) {
      for(Object v : h.getValue()) {
        headers.add(h.getKey(), v);
      }
    }
    if(request.entity() != null && request.entity().getContentType() != null) {
      headers.add("Content-Type", request.entity().getContentType());
    } else {
      headers.add("Content-Type", "application/json");
    }
    try {
      ClientResponse response = null;
      if (request.entity() != null && request.entity().getEntity() != null) {
        response = target.getHeadHandler().handle(new ClientRequestImpl(target.getURI(), request.method().name(), request.entity().getEntity(), headers));
      } else {
        response = target.getHeadHandler().handle(new ClientRequestImpl(target.getURI(), request.method().name(), null, headers));
      }
      return new JerseyResponse(response);
    } catch (UniformInterfaceException e) {
      throw new OpenStackResponseException(e.getResponse().getClientResponseStatus().getReasonPhrase(), e.getResponse().getStatus());
    }
View Full Code Here

Examples of com.sun.jersey.api.client.WebResource

    super("mjg");
  }

  @Test
  public void testShow() {
    WebResource webResource = resource();
    String responseMsg = webResource.path("helloworld").get(String.class);
    assertEquals("Hello, World!", responseMsg);
  }
View Full Code Here

Examples of com.sun.jersey.api.client.WebResource

     * Test if a WADL document is available at the relative path
     * "application.wadl".
     */
    @Test
    public void testApplicationWadl() {
        WebResource webResource = resource();
        String serviceWadl = webResource.path("application.wadl").
                accept(MediaTypes.WADL).get(String.class);
        assertTrue(serviceWadl.length() > 0);
    }
View Full Code Here

Examples of com.sun.jersey.api.client.WebResource

     * a list of properties that contains the "java.class.path"
     * property.
     */
    @Test
    public void testPropertiesResource() throws IOException {
        WebResource webResource = resource();
        String sProperties = webResource.path("properties")
                .accept(MediaType.TEXT_PLAIN)
                .get(String.class);
        Properties properties = new Properties();
        properties.load(new ByteArrayInputStream(sProperties.getBytes()));
        assertNotNull("Properties does not contain 'java.class.path' property",
View Full Code Here

Examples of com.sun.jersey.api.client.WebResource

     * Test checks that a GET request on "data" resource gives back a reponse
     * with status "OK".
     */
    @Test
    public void testGetOnDataResource() {
        WebResource webResource = resource();
        ClientResponse response = webResource.path("data")
                .accept(MediaType.TEXT_HTML)
                .get(ClientResponse.class);
        assertEquals("Request for data doesn't give expected response.",
                Response.Status.OK, response.getResponseStatus());
    }
View Full Code Here

Examples of com.sun.jersey.api.client.WebResource

    @Test
    public void testPostOnDataResource() {
        Form formData = new Form();
        formData.add("name", "testName");
        formData.add("value", "testValue");
        WebResource webResource = resource();
        ClientResponse response = webResource.path("data")
                .type(MediaType.APPLICATION_FORM_URLENCODED)
                .post(ClientResponse.class, formData);
        assertEquals(Response.Status.OK, response.getResponseStatus());
        String responseMsg = webResource.path("data").type(MediaType.TEXT_HTML).get(String.class);
        assertTrue("Submitted data did not get added to the list...",
                responseMsg.contains("testName") && responseMsg.contains("testValue"));

    }
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.