Search in sources :

Example 1 with JsonIoException

use of com.cedarsoftware.util.io.JsonIoException 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()));
    }
}
Also used : JsonIoException(com.cedarsoftware.util.io.JsonIoException) JsonObject(com.cedarsoftware.util.io.JsonObject) JsonObject(com.cedarsoftware.util.io.JsonObject) IOException(java.io.IOException)

Aggregations

JsonIoException (com.cedarsoftware.util.io.JsonIoException)1 JsonObject (com.cedarsoftware.util.io.JsonObject)1 IOException (java.io.IOException)1