Package com.sun.jersey.api.client

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


      }
      final Client client = Client.create();
      WebResource webResource = client.resource(getUrl("/initialization"))//
          .queryParam(StorageConstants.PARAM_AUTHENTICATION_TOKEN, this.config.getAuthenticationToken())//
          .queryParam(StorageConstants.PARAM_BASE_DIR, ConfigXml.getInstance().getApplicationHomeDir());
      ClientResponse response = webResource.accept(MediaType.TEXT_PLAIN).get(ClientResponse.class);
      if (response.getStatus() != ClientResponse.Status.OK.getStatusCode()) {
        throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
      }
      String output = response.getEntity(String.class);
      if ("OK".equals(output) == false) {
View Full Code Here


      String output = response.getEntity(String.class);
      if ("OK".equals(output) == false) {
        throw new RuntimeException("Initialization of ProjectForge's storage failed: " + output);
      }
      webResource = client.resource(getUrl("/securityCheck"));
      response = webResource.accept(MediaType.TEXT_PLAIN).get(ClientResponse.class);
      if (response.getStatus() == ClientResponse.Status.OK.getStatusCode()) {
        final String message = "Security alert: storage is available without any authentication!!!!!!!!!!!!!!!!";
        log.fatal(message);
        throw new RuntimeException(message);
      }
View Full Code Here

        log.fatal(message);
        throw new RuntimeException(message);
      }
      webResource = client.resource(getUrl("/securityCheck"));
      addAuthenticationHeader(webResource);
      response = webResource.accept(MediaType.TEXT_PLAIN).get(ClientResponse.class);
      if (response.getStatus() != ClientResponse.Status.OK.getStatusCode()) {
        throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
      }
      output = response.getEntity(String.class);
      if (output.equals("authenticated") == false) {
View Full Code Here

        response = content.path("4").type(MediaType.TEXT_PLAIN).put(ClientResponse.class,
                "Get thee to a nunnery");
        assertEquals(Response.Status.CREATED, response.getResponseStatus());

        // check that there are four items in the container "quotes"
        Container container = content.accept(MediaType.APPLICATION_XML).get(Container.class);
        int numberOfItems = container.getItem().size();
        int expectedNumber = 4;
        assertEquals("Expected: " + expectedNumber + " items, Seeing: " + numberOfItems,
                expectedNumber, numberOfItems);
View Full Code Here

        WebResource wr = r.path(path).queryParam("dataformat", encoding);
        if (data == null) {
            wr = wr.queryParam("null", "true");
        }

        Builder builder = wr.accept(accept)
            .type(MediaType.APPLICATION_OCTET_STREAM);

        ClientResponse cr;
        if (data == null) {
            cr = builder.put(ClientResponse.class);
View Full Code Here

        }
        if (sequence) {
            wr = wr.queryParam("sequence", "true");
        }

        Builder builder = wr.accept(accept);

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

                .queryParam("lastDirtyTimestamp",
                            info.getLastDirtyTimestamp().toString());
            if (overriddenStatus != null) {
                r = r.queryParam("overriddenstatus", overriddenStatus.name());
            }
            response = r.accept(MediaType.APPLICATION_JSON_TYPE).header(HEADER_REPLICATION, "true").put(
                    ClientResponse.class);
            InstanceInfo infoFromPeer = null;
            if ((response.getStatus() == Status.OK.getStatusCode())  && response.hasEntity()) {
                infoFromPeer = response
                        .getEntity(InstanceInfo.class);
View Full Code Here

    url = url.replace("{caseNumber}", caseNumber);
    url = url.replace("{attachmentUUID}", attachmentUUID);

    WebResource webResource = connectionManager.getConnection().resource(
        connectionManager.getConfig().getUrl() + url);
    ClientResponse response = webResource.accept("application/xml").get(
        ClientResponse.class);
    if (response.getStatus() != 200) {
      LOGGER.debug("Failed : HTTP error code : " + response.getStatus());
      throw new RuntimeException("Failed : HTTP error code : "
          + response.getStatus());
View Full Code Here

  @Test
  public void testInvalidUri2() throws JSONException, Exception {
    WebResource r = resource();
    String responseStr = "";
    try {
      responseStr = r.accept(MediaType.APPLICATION_JSON).get(String.class);
      fail("should have thrown exception on invalid uri");
    } catch (UniformInterfaceException ue) {
      ClientResponse response = ue.getResponse();
      assertEquals(Status.NOT_FOUND, response.getClientResponseStatus());
      WebServicesTestUtils.checkStringMatch(
View Full Code Here

    }


    private Builder builder( String path ) {
        WebResource resource = client.resource( uri( pathOrAbsolute( path ) ) );
        if (Config.streamingIsEnabled()) return resource.accept(STREAMING_JSON_TYPE).header("X-Stream","true");
        return resource.accept(APPLICATION_JSON_TYPE);
    }

    private String pathOrAbsolute( String path ) {
        if ( path.startsWith( "http://" ) ) return path;
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.