
com.box.restclientv2.responseparsers.DefaultFileResponseParser Maven / Gradle / Ivy
package com.box.restclientv2.responseparsers;
import org.apache.http.HttpResponse;
import com.box.restclientv2.exceptions.BoxRestException;
import com.box.restclientv2.interfaces.IBoxResponse;
import com.box.restclientv2.interfaces.IBoxResponseParser;
import com.box.restclientv2.responses.DefaultBoxResponse;
/**
* Default implementation for response parser to parse a response with a file InputStream.
*/
public class DefaultFileResponseParser implements IBoxResponseParser {
@Override
public Object parse(IBoxResponse response) throws BoxRestException {
if (!(response instanceof DefaultBoxResponse)) {
throw new BoxRestException("class mismatch, expected:" + DefaultBoxResponse.class.getName() + ";current:" + response.getClass().getCanonicalName());
}
HttpResponse httpResponse = ((DefaultBoxResponse) response).getHttpResponse();
try {
return httpResponse.getEntity().getContent();
}
catch (Exception e) {
throw new BoxRestException(e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy