Return-Path: X-Original-To: apmail-ambari-user-archive@www.apache.org Delivered-To: apmail-ambari-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 02EC611B2D for ; Thu, 12 Jun 2014 04:13:14 +0000 (UTC) Received: (qmail 22411 invoked by uid 500); 12 Jun 2014 04:13:13 -0000 Delivered-To: apmail-ambari-user-archive@ambari.apache.org Received: (qmail 22380 invoked by uid 500); 12 Jun 2014 04:13:13 -0000 Mailing-List: contact user-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@ambari.apache.org Delivered-To: mailing list user@ambari.apache.org Received: (qmail 22372 invoked by uid 99); 12 Jun 2014 04:13:13 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Jun 2014 04:13:13 +0000 X-ASF-Spam-Status: No, hits=-2.8 required=5.0 tests=HTML_MESSAGE,NORMAL_HTTP_TO_IP,RCVD_IN_DNSWL_HI,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of chiq@vmware.com designates 208.91.2.13 as permitted sender) Received: from [208.91.2.13] (HELO smtp-outbound-2.vmware.com) (208.91.2.13) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Jun 2014 04:13:07 +0000 Received: from sc9-mailhost2.vmware.com (sc9-mailhost2.vmware.com [10.113.161.72]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id 10099995B0 for ; Wed, 11 Jun 2014 21:12:47 -0700 (PDT) Received: from EX13-CAS-001.vmware.com (EX13-CAS-001.vmware.com [10.113.191.51]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id 046B8906B3; Wed, 11 Jun 2014 21:12:47 -0700 (PDT) Received: from EX13-MBX-022.vmware.com (10.113.191.42) by EX13-MBX-002.vmware.com (10.113.191.22) with Microsoft SMTP Server (TLS) id 15.0.775.38; Wed, 11 Jun 2014 21:12:46 -0700 Received: from EX13-MBX-010.vmware.com (10.113.191.30) by EX13-MBX-022.vmware.com (10.113.191.42) with Microsoft SMTP Server (TLS) id 15.0.775.38; Wed, 11 Jun 2014 21:12:46 -0700 Received: from EX13-MBX-010.vmware.com ([fe80::c937:743c:749c:829b]) by EX13-MBX-010.vmware.com ([fe80::c937:743c:749c:829b%15]) with mapi id 15.00.0775.031; Wed, 11 Jun 2014 21:12:34 -0700 From: Qing Chi 79624 To: "user@ambari.apache.org" CC: Emma Lin , Xiaoding Bian Subject: Why the Content-Type always is text/plain using ambari REST API? Thread-Topic: Why the Content-Type always is text/plain using ambari REST API? Thread-Index: AQHPhfSJ3Q9fCOvhw0WINtrtIhcf7A== Date: Thu, 12 Jun 2014 04:12:33 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Microsoft-MacOutlook/14.0.0.100825 x-originating-ip: [10.113.160.246] Content-Type: multipart/alternative; boundary="_000_CFBF48416703chiqvmwarecom_" MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org --_000_CFBF48416703chiqvmwarecom_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi guys, Following is content of TestAmbariRestApi class. Why the Content-Type alway= s is text/plain on the response using ambari REST API? import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter; import com.sun.jersey.api.json.JSONConfiguration; import com.vmware.bdd.api.model.ApiClusterList; import java.net.URI; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriBuilder; public class TestAmbariRestApi { private static URI getBaseURI() { return UriBuilder.fromUri("http://10.141.73.63:8080/api/v1").build(); } public static void main(String[] args) { ClientConfig config =3D new DefaultClientConfig(); config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Bool= ean.TRUE); Client client =3D Client.create(config); client.addFilter(new HTTPBasicAuthFilter("admin", "admin")); WebResource resource =3D client.resource(getBaseURI()); ClientResponse response; response =3D resource.path("clusters").accept(MediaType.APPLICATION_J= SON).type(MediaType.APPLICATION_JSON).get(ClientResponse.class); System.out.println(response.getStatus()); System.out.println(response.getHeaders().get("Content-Type")); System.out.println(response.getEntity(ApiClusterList.class)); } } Result of running TestAmbariRestApi, 406 [text/plain;charset=3DISO-8859-1] Jun 12, 2014 11:58:43 AM com.sun.jersey.api.client.ClientResponse getEntity SEVERE: A message body reader for Java class com.vmware.bdd.api.model.ApiCl= usterList, and Java type class com.vmware.bdd.api.model.ApiClusterList, and= MIME media type text/plain; charset=3DISO-8859-1 was not found Jun 12, 2014 11:58:43 AM com.sun.jersey.api.client.ClientResponse getEntity SEVERE: The registered message body readers compatible with the MIME media = type are: text/plain; charset=3DISO-8859-1 -> com.sun.jersey.core.impl.provider.entity.StringProvider com.sun.jersey.core.impl.provider.entity.ReaderProvider */* -> com.sun.jersey.core.impl.provider.entity.FormProvider com.sun.jersey.core.impl.provider.entity.MimeMultipartProvider com.sun.jersey.core.impl.provider.entity.StringProvider com.sun.jersey.core.impl.provider.entity.ByteArrayProvider com.sun.jersey.core.impl.provider.entity.FileProvider com.sun.jersey.core.impl.provider.entity.InputStreamProvider com.sun.jersey.core.impl.provider.entity.DataSourceProvider com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$General com.sun.jersey.core.impl.provider.entity.ReaderProvider com.sun.jersey.core.impl.provider.entity.DocumentProvider com.sun.jersey.core.impl.provider.entity.SourceProvider$StreamSourceReade= r com.sun.jersey.core.impl.provider.entity.SourceProvider$SAXSourceReader com.sun.jersey.core.impl.provider.entity.SourceProvider$DOMSourceReader com.sun.jersey.json.impl.provider.entity.JSONJAXBElementProvider$General com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$General com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$General com.sun.jersey.core.impl.provider.entity.XMLRootObjectProvider$General com.sun.jersey.core.impl.provider.entity.EntityHolderReader com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$General com.sun.jersey.json.impl.provider.entity.JSONListElementProvider$General Exception in thread "main" com.sun.jersey.api.client.ClientHandlerException= : A message body reader for Java class com.vmware.bdd.api.model.ApiClusterL= ist, and Java type class com.vmware.bdd.api.model.ApiClusterList, and MIME = media type text/plain; charset=3DISO-8859-1 was not found at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:6= 30) at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:5= 86) at com.vmware.bdd.api.TestAmbariRestAPI.main(TestAmbariRestAPI.java:37) And I used the following command, and the Content-Type is text/plain on res= ponse. curl -H "Content-Type: application/json" -H "X-Requested-By: ambari" -X GE= T --user "admin:admin" -i http://10.141.73.63:8080/api/v1/clusters/ HTTP/1.1 200 OK Set-Cookie: AMBARISESSIONID=3D1i36z3duc4cjr561r6deiub8;Path=3D/ Expires: Thu, 01 Jan 1970 00:00:00 GMT Content-Type: text/plain Content-Length: 422 Server: Jetty(7.6.7.v20120910) { "href" : "http://10.141.73.63:8080/api/v1/clusters/", "items" : [ { "href" : "http://10.141.73.63:8080/api/v1/clusters/test", "Clusters" : { "cluster_name" : "test", "version" : "HDP-2.1" } } ] } Anybody give me some help? Thanks, -qing --_000_CFBF48416703chiqvmwarecom_ Content-Type: text/html; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable
Hi guys,

Following is content of TestAmbariRes= tApi class. Why the Content-Type always is text/plain on the resp= onse using ambari REST API?

import com.sun.jersey.api.client.Client;

import com.sun.jersey.api.client.ClientResponse= ;

import com.sun.jersey.api.client.WebResource;

import com.sun.jersey.api.client.config.ClientC= onfig;

import com.sun.jersey.api.client.config.Default= ClientConfig;

import com.sun.jersey.api.client.filter.HTTPBas= icAuthFilter;

import com.sun.jersey.api.json.JSONConfiguratio= n;

import com.vmware.bdd.api.model.ApiClusterList;=


import java.net.URI;


import javax.ws.rs.core.MediaType;

import javax.ws.rs.core.UriBuilder;


public class TestAmbariRestApi {


 &nbs= p; private static URI getBaseURI(= ) {

  &nb= sp;   return UriBuilder.fromUri("http:= //10.141.73.63:8080/api/v1").build();

 &nbs= p; }


 &nbs= p; public static void main(String[] args) {

  &nb= sp;   ClientConfig config =3D new DefaultClientConfig();

  &nb= sp;   config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);


  &nb= sp;   Client client =3D Client.create(config);

  &nb= sp;   client.addFilter(new HTTPB= asicAuthFilter("admin", "admin"));


  &nb= sp;   WebResource resource =3D client.resource(getBaseURI());


  &nb= sp;   ClientResponse response;

  &nb= sp;   response =3D resource.path("= clusters").accept(MediaType.APPL= ICATION_JSON).type(MediaType.APPLICAT= ION_JSON).get(ClientResponse.class);


  &nb= sp;   System.out.println(respons= e.getStatus());

  &nb= sp;   System.out.println(respons= e.getHeaders().get("Content-Type"<= /span>));

  &nb= sp;   System.out.println(respons= e.getEntity(ApiClusterList.class));

 &nbs= p; }

}


Result of = running TestAmbariRestApi,


406

[text/plain;charset=3DISO-8859-1]

Jun 12, 2014 11:58:43 AM= com.sun.jersey.api.client.ClientResponse getEntity

SEVERE: A message body r= eader for Java class com.vmware.bdd.api.model.ApiClusterList, and Java type= class com.vmware.bdd.api.model.ApiClusterList, and MIME media type text/pl= ain; charset=3DISO-8859-1 was not found

Jun 12, 2014 11:58:43 AM= com.sun.jersey.api.client.ClientResponse getEntity

SEVERE: The registered m= essage body readers compatible with the MIME media type are:

text/plain; charset=3DIS= O-8859-1 ->

  com.sun.jersey.co= re.impl.provider.entity.StringProvider

  com.sun.jersey.co= re.impl.provider.entity.ReaderProvider

*/* ->

  com.sun.jersey.co= re.impl.provider.entity.FormProvider

  com.sun.jersey.co= re.impl.provider.entity.MimeMultipartProvider

  com.sun.jersey.co= re.impl.provider.entity.StringProvider

  com.sun.jersey.co= re.impl.provider.entity.ByteArrayProvider

  com.sun.jersey.co= re.impl.provider.entity.FileProvider

  com.sun.jersey.co= re.impl.provider.entity.InputStreamProvider

  com.sun.jersey.co= re.impl.provider.entity.DataSourceProvider

  com.sun.jersey.co= re.impl.provider.entity.XMLJAXBElementProvider$General

  com.sun.jersey.co= re.impl.provider.entity.ReaderProvider

  com.sun.jersey.co= re.impl.provider.entity.DocumentProvider

  com.sun.jersey.co= re.impl.provider.entity.SourceProvider$StreamSourceReader

  com.sun.jersey.co= re.impl.provider.entity.SourceProvider$SAXSourceReader

  com.sun.jersey.co= re.impl.provider.entity.SourceProvider$DOMSourceReader

  com.sun.jersey.js= on.impl.provider.entity.JSONJAXBElementProvider$General

  com.sun.jersey.co= re.impl.provider.entity.XMLRootElementProvider$General

  com.sun.jersey.co= re.impl.provider.entity.XMLListElementProvider$General

  com.sun.jersey.co= re.impl.provider.entity.XMLRootObjectProvider$General

  com.sun.jersey.co= re.impl.provider.entity.EntityHolderReader

  com.sun.jersey.js= on.impl.provider.entity.JSONRootElementProvider$General

  com.sun.jersey.js= on.impl.provider.entity.JSONListElementProvider$General


Exception in thread &quo= t;main" com.sun.jersey.api.client.ClientHandlerException: A message body rea= der for Java class com.vmware.bdd.api.model.ApiClusterList, and Java type c= lass com.vmware.bdd.api.model.ApiClusterList, and MIME media type text/plai= n; charset=3DISO-8859-1 was not found

at com.sun.jersey.api.client.Client= Response.getEntity(ClientResponse.java:630)

at com.sun.jersey.api.client.Client= Response.getEntity(ClientResponse.java:586)

at com.vmware.bdd.api.TestAmbariRes= tAPI.main(TestA= mbariRestAPI.java:37)



And I used= the following command, and the Content-Type is text/plain on res= ponse.


curl -H &q= uot;Content-Type: application/json" -H  "X-Requested-By: amb= ari" -X GET --user "admin:admin" -i http://10.141.73.63:80= 80/api/v1/clusters/


HTTP/1.1 200 OK

Set-Cookie: AMBARISESSIONID=3D1i36z3duc4cjr561r6= deiub8;Path=3D/

Expires: Thu, 01 Jan 1970 00:00:00 GMT

Content-Type: text/plain

Content-Length: 422

Server: Jetty(7.6.7.v20120910)


{

  "href" : "http://10.141.73= .63:8080/api/v1/clusters/",

  "items" : [

    {

      "href" : "ht= tp://10.141.73.63:8080/api/v1/clusters/test",

      "Clusters" : {

        "cluster_name&q= uot; : "test",

        "version" = : "HDP-2.1"

      }

    }

  ]

}


Anybody give me some help?

Thanks,

-qing
--_000_CFBF48416703chiqvmwarecom_--