use of com.box.androidsdk.content.models.BoxObject in project box-android-sdk by box.
the class BoxRequestBatch method onSend.
@Override
public BoxResponseBatch onSend() throws BoxException {
BoxResponseBatch responses = new BoxResponseBatch();
if (mExecutor != null) {
ArrayList<BoxFutureTask<BoxObject>> tasks = new ArrayList<BoxFutureTask<BoxObject>>();
for (BoxRequest req : mRequests) {
BoxFutureTask task = req.toTask();
mExecutor.submit(task);
tasks.add(task);
}
for (BoxFutureTask<BoxObject> task : tasks) {
try {
BoxResponse<BoxObject> response = task.get();
responses.addResponse(response);
} catch (InterruptedException e) {
throw new BoxException(e.getMessage(), e);
} catch (ExecutionException e) {
throw new BoxException(e.getMessage(), e);
}
}
} else {
for (BoxRequest req : mRequests) {
BoxObject value = null;
Exception ex = null;
try {
value = req.send();
} catch (Exception e) {
ex = e;
}
BoxResponse<BoxObject> response = new BoxResponse<BoxObject>(value, ex, req);
responses.addResponse(response);
}
}
return responses;
}
Aggregations