use of org.eclipse.sw360.exporter.ProjectExporter in project sw360portal by sw360.
the class ProjectPortlet method exportExcel.
private void exportExcel(ResourceRequest request, ResourceResponse response) {
final User user = UserCacheHolder.getUserFromRequest(request);
try {
boolean extendedByReleases = Boolean.valueOf(request.getParameter(PortalConstants.EXTENDED_EXCEL_EXPORT));
List<Project> projects = getFilteredProjectList(request);
ProjectExporter exporter = new ProjectExporter(thriftClients.makeComponentClient(), thriftClients.makeProjectClient(), user, projects, extendedByReleases);
PortletResponseUtil.sendFile(request, response, "Projects.xlsx", exporter.makeExcelExport(projects), CONTENT_TYPE_OPENXML_SPREADSHEET);
} catch (IOException | SW360Exception e) {
log.error("An error occurred while generating the Excel export", e);
response.setProperty(ResourceResponse.HTTP_STATUS_CODE, Integer.toString(HttpServletResponse.SC_INTERNAL_SERVER_ERROR));
}
}
Aggregations