* @throws BoxRestException
*/
@Override
public Object parse(IBoxResponse response) throws BoxRestException {
if (!(response instanceof DefaultBoxResponse)) {
throw new BoxRestException("class mismatch, expected:" + DefaultBoxResponse.class.getName() + ";current:" + response.getClass().getName());
}
HttpResponse httpResponse = ((DefaultBoxResponse) response).getHttpResponse();
InputStream in = null;
try {
in = httpResponse.getEntity().getContent();
if (in == null) {
return null;
}
else {
return parseInputStream(in);
}
}
catch (Exception e) {
throw new BoxRestException(e, "Failed to parse response.");
}
finally {
IOUtils.closeQuietly(in);
}
}