Search in sources :

Example 1 with ComponentExporter

use of org.eclipse.sw360.exporter.ComponentExporter in project sw360portal by sw360.

the class ComponentPortlet 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<Component> components = getFilteredComponentList(request);
        ComponentExporter exporter = new ComponentExporter(thriftClients.makeComponentClient(), components, user, extendedByReleases);
        PortletResponseUtil.sendFile(request, response, "Components.xlsx", exporter.makeExcelExport(components), 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) ComponentExporter(org.eclipse.sw360.exporter.ComponentExporter) IOException(java.io.IOException)

Aggregations

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