Skip to content

Commit

Permalink
TII-256 - Log responses from Turnitin in the TurnitinOC Provider
Browse files Browse the repository at this point in the history
  • Loading branch information
bbailla2 authored and Miguel Pellicer committed Apr 4, 2019
1 parent 97076de commit 917c1bb
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,18 @@ private HashMap<String, Object> makeHttpCall(String method, String urlStr, Map<S
// Send request:
int responseCode = connection.getResponseCode();
String responseMessage = connection.getResponseMessage();
String responseBody = IOUtils.toString(connection.getInputStream(), StandardCharsets.UTF_8);
String responseBody;
if (responseCode < 200 || responseCode >= 300)
{
// getInputStream() throws an exception in this case, but getErrorStream() has the information necessary for troubleshooting
responseBody = IOUtils.toString(connection.getErrorStream(), StandardCharsets.UTF_8);
log.warn("Turnitin response code: " + responseCode + "; message: " + responseMessage + "; body:\n" + responseBody);
}
else
{
responseBody = IOUtils.toString(connection.getInputStream(), StandardCharsets.UTF_8);
log.debug("Turnitin response code: " + responseCode + "; message: " + responseMessage + "; body:\n" + responseBody);
}

HashMap<String, Object> response = new HashMap<String, Object>();
response.put(RESPONSE_CODE, responseCode);
Expand Down

0 comments on commit 917c1bb

Please sign in to comment.