/** * Handle the general case with responses. */ private FcrepoResponse fcrepoGenericResponse(final URI url, final CloseableHttpResponse response, final Boolean throwExceptionOnFailure) throws FcrepoOperationFailedException { final int status = response.getStatusLine().getStatusCode(); final Map<String, List<String>> headers = getHeaders(response); if ((status >= HttpStatus.SC_OK && status < HttpStatus.SC_BAD_REQUEST) || !throwExceptionOnFailure) { return new FcrepoResponse(url, status, headers, getEntityContent(response)); } else { free(response); throw new FcrepoOperationFailedException(url, status, response.getStatusLine().getReasonPhrase()); } }