Search in sources :

Example 1 with ProjectExporter

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));
    }
}
Also used : User(org.eclipse.sw360.datahandler.thrift.users.User) IOException(java.io.IOException) ProjectExporter(org.eclipse.sw360.exporter.ProjectExporter)

Aggregations

IOException (java.io.IOException)1 User (org.eclipse.sw360.datahandler.thrift.users.User)1 ProjectExporter (org.eclipse.sw360.exporter.ProjectExporter)1