StringBuilder buffer = new StringBuilder();
StringBuilder requestIds = new StringBuilder();
int statusCount = 0;
for (Entry<String, APIResult> entry : results.entrySet()) {
String colo = entry.getKey();
APIResult result = entry.getValue();
buffer.append(colo).append('/').append(result.getMessage()).append('\n');
requestIds.append(colo).append('/').append(result.getRequestId()).append('\n');
statusCount += result.getStatus().ordinal();
}
APIResult.Status status = (statusCount == 0) ? APIResult.Status.SUCCEEDED
: ((statusCount == results.size() * 2) ? APIResult.Status.FAILED : APIResult.Status.PARTIAL);
APIResult result = new APIResult(status, buffer.toString());
result.setRequestId(requestIds.toString());
return result;
}