StringBuilder requestIds = new StringBuilder();
List<InstanceSummary> instances = new ArrayList<InstanceSummary>();
int statusCount = 0;
for (Map.Entry<String, InstancesSummaryResult> entry : results.entrySet()) {
String colo = entry.getKey();
InstancesSummaryResult result = results.get(colo);
message.append(colo).append('/').append(result.getMessage()).append('\n');
requestIds.append(colo).append('/').append(result.getRequestId()).append('\n');
statusCount += result.getStatus().ordinal();
if (result.getInstancesSummary() == null) {
continue;
}
for (InstanceSummary instance : result.getInstancesSummary()) {
instance.summaryMap = instance.getSummaryMap();
instances.add(instance);
}
}
InstanceSummary[] arrInstances = new InstanceSummary[instances.size()];
APIResult.Status status = (statusCount == 0) ? APIResult.Status.SUCCEEDED
: ((statusCount == results.size() * 2) ? APIResult.Status.FAILED : APIResult.Status.PARTIAL);
InstancesSummaryResult result = new InstancesSummaryResult(status, message.toString(),
instances.toArray(arrInstances));
result.setRequestId(requestIds.toString());
return result;
}