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

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


        return responseParser;
    }

    public <T extends ResourceRepresentation> T get(String path, CumulocityMediaType mediaType,
            Class<T> responseType) throws SDKException {
         Builder builder = client.resource(path).accept(mediaType);
         builder = addApplicationKeyHeader(builder);
         ClientResponse response = builder.get(ClientResponse.class);
        return responseParser.parse(response, OK.getStatusCode(), responseType);
    }
View Full Code Here


        builder = addApplicationKeyHeader(builder);
        return builder.put(ClientResponse.class, representation);
    }

    public void delete(String path) throws SDKException {
        Builder builder = client.resource(path).getRequestBuilder();
       
        builder = addApplicationKeyHeader(builder);
        ClientResponse response = builder.delete(ClientResponse.class);
        responseParser.checkStatus(response, NO_CONTENT.getStatusCode());
    }
View Full Code Here

    initRestService();
    WebResource resource = client.resource( exportURL );

    // Response response
    Builder builder = resource.type( MediaType.APPLICATION_JSON ).type( MediaType.TEXT_XML_TYPE );
    ClientResponse response = builder.put( ClientResponse.class );
    if ( response != null && response.getStatus() == 200 ) {

      String message = Messages.getInstance().getString( "CommandLineProcessor.INFO_REST_COMPLETED" ).concat( "\n" );
      message +=
          Messages.getInstance().getString( "CommandLineProcessor.INFO_REST_RESPONSE_STATUS", response.getStatus() );
View Full Code Here

    initRestService();
    WebResource resource = client.resource( exportURL );

    // Response response
    Builder builder = resource.type( MediaType.MULTIPART_FORM_DATA ).accept( MediaType.TEXT_HTML_TYPE );
    ClientResponse response = builder.get( ClientResponse.class );
    if ( response != null && response.getStatus() == 200 ) {
      String filename =
          getOptionValue( Messages.getInstance().getString( "CommandLineProcessor.INFO_OPTION_FILEPATH_KEY" ), Messages
              .getInstance().getString( "CommandLineProcessor.INFO_OPTION_FILEPATH_NAME" ), true, false );
      final InputStream input = response.getEntityInputStream();
View Full Code Here

    WebResource webResource = client.resource(restEndpointUrl + String.format("/containers/%s/start", containerId));

    try {
      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 Builder createRequest() {
    Client client = Client.create();
    addAuthentication( client );
    WebResource resource = client.resource( url );
    String type = mediaType != null ? mediaType : MediaType.WILDCARD;
    Builder builder = resource.type( type );
    builder = addHeaders( builder );
    return builder;
  }
View Full Code Here

      client.addFilter( filter );
    }
  }

  private Builder addHeaders( Builder builder ) {
    Builder result = builder;
    Set<String> keySet = headers.keySet();
    for( String key : keySet ) {
      List<String> values = headers.get( key );
      for( String value : values ) {
        result = result.header( key, value );
      }
    }
    return result;
  }
View Full Code Here

  private Builder createRequest() {
    Client client = createIgnoreHttpsValidationClient();
    addAuthentication( client );
    WebResource resource = client.resource( url );
    String type = mediaType != null ? mediaType : MediaType.WILDCARD;
    Builder builder = resource.type( type );
    builder = addHeaders( builder );
    return builder;
  }
View Full Code Here

      client.addFilter( filter );
    }
  }

  private Builder addHeaders( Builder builder ) {
    Builder result = builder;
    Set<String> keySet = headers.keySet();
    for( String key : keySet ) {
      List<String> values = headers.get( key );
      for( String value : values ) {
        result = result.header( key, value );
      }
    }
    return result;
  }
View Full Code Here

            //stopServer();
        }
    }
   
    private void sendXRequests(String uri, int numRequests) {
        Builder resource = Client.create().resource(uri).accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON);
        for(int i=0;i<numRequests;i++) {
            ClientResponse response = resource.get(ClientResponse.class);
        }
    }
View Full Code Here

TOP

Related Classes of com.sun.jersey.api.client.WebResource.Builder

Copyright © 2018 www.massapicom. 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.