final List<ResourceInstallCount> results = getSummaryCounts();
if (StringUtil.isEmpty(resourceTypeId)) {
// output only resource types
return new StreamingOutput() {
@Override
public void write(OutputStream stream) throws IOException, WebApplicationException {
if (log.isDebugEnabled()) {
log.debug("Generating inventory summary CSV report for resource types.");
}
CsvWriter<ResourceInstallCount> csvWriter = new CsvWriter<ResourceInstallCount>();
List<String> columns = getColumns();
csvWriter.setColumns(columns.toArray(new String[columns.size()]));
stream.write((getHeader() + "\n").getBytes());
for (ResourceInstallCount installCount : results) {
csvWriter.write(installCount, stream);
}
}
};
} else {
// output resource details for specified type and version
return new StreamingOutput() {
@Override
public void write(OutputStream stream) throws IOException, WebApplicationException {
if (log.isDebugEnabled()) {
log.debug("Generating detailed inventory summary CSV report for [resourceTypeId: " +
resourceTypeId + ", version: " + version + "]");