Package com.sun.jersey.api.client

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


    HeartBeatResponse response;
    ClientConfig clientConfig = new DefaultClientConfig();
    clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
    client = Client.create(clientConfig);
    WebResource webResource = client.resource("http://localhost:9998/heartbeat/dummyhost");
    response = webResource.type(MediaType.APPLICATION_JSON)
        .post(HeartBeatResponse.class, createDummyHeartBeat());
    LOG.info("Returned from Server: "
        + " response=" + response);
    Assert.assertEquals(response.getResponseId(), 0L);
  }
View Full Code Here


    HeartBeatResponse response;
    ClientConfig clientConfig = new DefaultClientConfig();
    clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
    client = Client.create(clientConfig);
    WebResource webResource = client.resource("http://localhost:9998/heartbeat/dummyhost");
    response = webResource.type(MediaType.APPLICATION_JSON)
        .post(HeartBeatResponse.class, createDummyHeartBeatWithAgentEnv());
    LOG.info("Returned from Server: "
        + " response=" + response);
    Assert.assertEquals(response.getResponseId(), 0L);
  }
View Full Code Here

        WebResource webResource = client.resource(engineRootResource + "content/" + cmsObject.getID());
        String content = getTextContent(cmsObject);

        if (!content.contentEquals("")) {
            try {
                webResource.type(MediaType.TEXT_PLAIN_TYPE).put(content.getBytes());
                addContentItemRelation(cmsObject.getID(),
                    engineRootResource + "metadata/" + cmsObject.getID(), engine);
            } catch (Exception e) {
                logger.warn("Failed to create content item for cms object: {}", cmsObject.getName());
                return;
View Full Code Here

    private ClientResponse postNewApplication(Client httpClient) {
        String host = platform.getHost();
        WebResource applicationApi = httpClient.resource(host + APPLICATIONS_URI);
        String applicationJson = "{\"name\" : \"" + appName + "\", " +
                "\"key\" : \"" + platform.getApplicationKey() + "\"}";
        return applicationApi.type(APPLICATION_MIME_TYPE).accept(APPLICATION_MIME_TYPE).post(ClientResponse.class, applicationJson);
    }

    private String getApplicationId(Client httpClient, String appName) {
        List<ApplicationRepresentation> applications = getApplicationsByName(httpClient, appName);
        return applications.get(0).getId();
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 +=
View Full Code Here

        // If the import service needs the file name do the following.
        part.getField( "metadataFile" ).setContentDisposition(
            FormDataContentDisposition.name( "metadataFile" ).fileName( metadataFileInZip.getName() ).build() );

        // Response response
        ClientResponse response = resource.type( MediaType.MULTIPART_FORM_DATA ).post( ClientResponse.class, part );
        if ( response != null ) {
          String message = response.getEntity( String.class );
          System.out.println( Messages.getInstance().getString( "CommandLineProcessor.INFO_REST_RESPONSE_RECEIVED",
              message ) );
        }
View Full Code Here

        // If the import service needs the file name do the following.
        part.getField( "metadataFile" ).setContentDisposition(
            FormDataContentDisposition.name( "metadataFile" ).fileName( metadataDatasourceFile.getName() ).build() );

        // Response response
        ClientResponse response = resource.type( MediaType.MULTIPART_FORM_DATA ).post( ClientResponse.class, part );
        if ( response != null ) {
          String message = response.getEntity( String.class );
          System.out.println( Messages.getInstance().getString( "CommandLineProcessor.INFO_REST_RESPONSE_RECEIVED",
              message ) );
        }
View Full Code Here

    // If the import service needs the file name do the following.
    part.getField( "uploadAnalysis" ).setContentDisposition(
        FormDataContentDisposition.name( "uploadAnalysis" ).fileName( analysisDatasourceFile.getName() ).build() );

    // Response response
    ClientResponse response = resource.type( MediaType.MULTIPART_FORM_DATA ).post( ClientResponse.class, part );
    if ( response != null ) {
      String message = response.getEntity( String.class );
      response.close();
      System.out.println( Messages.getInstance()
          .getString( "CommandLineProcessor.INFO_REST_RESPONSE_RECEIVED", message ) );
View Full Code Here

        part.field( "fileNameOverride", fileIS.getName(), MediaType.MULTIPART_FORM_DATA_TYPE );
        part.getField( "fileUpload" ).setContentDisposition(
            FormDataContentDisposition.name( "fileUpload" ).fileName( fileIS.getName() ).build() );

        // Response response
        ClientResponse response = resource.type( MediaType.MULTIPART_FORM_DATA ).post( ClientResponse.class, part );
        if ( response != null ) {
          String message = response.getEntity( String.class );
          System.out.println( Messages.getInstance().getString( "CommandLineProcessor.INFO_REST_RESPONSE_RECEIVED",
              message ) );
          if ( logFile != null && !"".equals( logFile ) ) {
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 );
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.