use of com.cedarsoftware.util.io.JsonObject in project components by Talend.
the class TSplunkEventCollectorWriter method handleResponse.
private void handleResponse(String jsonResponseString) throws IOException {
if (jsonResponseString == null || jsonResponseString.trim().isEmpty()) {
throw new IOException(getMessage("error.emptyResponse"));
}
try {
// JSONParser jsonParser = new JSONParser();
JsonObject<Object, Object> json = (JsonObject<Object, Object>) JsonReader.jsonToJava(jsonResponseString);
LOGGER.debug("Response String:/r/n" + String.valueOf(json));
lastErrorCode = ((Long) json.get("code")).intValue();
lastErrorMessage = (String) json.get("text");
if (lastErrorCode != 0) {
throw new IOException(getMessage("error.codeMessage", lastErrorCode, lastErrorMessage));
}
successCount += splunkObjectsForBulk.size();
} catch (JsonIoException e) {
throw new IOException(getMessage("error.responseParseException", e.getMessage()));
}
}
Aggregations