List<DataSource> parts = parseParts(response.getEntityInputStream(),
response.getHeaders().getFirst("Content-Type"));
if (parts.size() == 0 || parts.size() > entityBatchOperations.size()) {
throw new UniformInterfaceException(String.format(
"Batch response from server does not contain the correct amount "
+ "of parts (expecting %d, received %d instead)",
parts.size(), entityBatchOperations.size()), response);
}
for (int i = 0; i < parts.size(); i++) {
DataSource ds = parts.get(i);
EntityBatchOperation entityBatchOperation = entityBatchOperations
.get(i);
StatusLine status = StatusLine.create(ds);
InternetHeaders headers = parseHeaders(ds);
InputStream content = parseEntity(ds);
if (status.getStatus() >= HTTP_ERROR) {
InBoundHeaders inBoundHeaders = new InBoundHeaders();
@SuppressWarnings("unchecked")
Enumeration<Header> e = headers.getAllHeaders();
while (e.hasMoreElements()) {
Header header = e.nextElement();
inBoundHeaders.putSingle(header.getName(),
header.getValue());
}
ClientResponse clientResponse = new ClientResponse(
status.getStatus(), inBoundHeaders, content, null);
UniformInterfaceException uniformInterfaceException = new UniformInterfaceException(
clientResponse);
throw uniformInterfaceException;
} else if (entityBatchOperation instanceof Job.CreateBatchOperation) {
try {