Search in sources :

Example 1 with KylinProjectResponse

use of org.apache.ranger.services.kylin.client.json.model.KylinProjectResponse in project ranger by apache.

the class KylinClient method getKylinProjectResponse.

private List<KylinProjectResponse> getKylinProjectResponse(ClientResponse response) {
    List<KylinProjectResponse> projectResponses = null;
    try {
        if (response != null && response.getStatus() == HttpStatus.SC_OK) {
            String jsonString = response.getEntity(String.class);
            Gson gson = new GsonBuilder().setPrettyPrinting().create();
            projectResponses = gson.fromJson(jsonString, new TypeToken<List<KylinProjectResponse>>() {
            }.getType());
        } else {
            String msgDesc = "Unable to get a valid response for " + "expected mime type : [" + EXPECTED_MIME_TYPE + "], kylinUrl: " + kylinUrl + " - got null response.";
            LOG.error(msgDesc);
            HadoopException hdpException = new HadoopException(msgDesc);
            hdpException.generateResponseDataMap(false, msgDesc, msgDesc + ERROR_MESSAGE, null, null);
            throw hdpException;
        }
    } catch (HadoopException he) {
        throw he;
    } catch (Throwable t) {
        String msgDesc = "Exception while getting kylin project response, kylinUrl: " + kylinUrl;
        HadoopException hdpException = new HadoopException(msgDesc, t);
        LOG.error(msgDesc, t);
        hdpException.generateResponseDataMap(false, BaseClient.getMessage(t), msgDesc + ERROR_MESSAGE, null, null);
        throw hdpException;
    } finally {
        if (response != null) {
            response.close();
        }
    }
    return projectResponses;
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) KylinProjectResponse(org.apache.ranger.services.kylin.client.json.model.KylinProjectResponse) Gson(com.google.gson.Gson) ArrayList(java.util.ArrayList) List(java.util.List) HadoopException(org.apache.ranger.plugin.client.HadoopException)

Aggregations

Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 HadoopException (org.apache.ranger.plugin.client.HadoopException)1 KylinProjectResponse (org.apache.ranger.services.kylin.client.json.model.KylinProjectResponse)1