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;
}
Aggregations