Package org.wso2.carbon.reporting.api

Examples of org.wso2.carbon.reporting.api.ReportingException


            while (iterator.hasNext()) {
                names.add(element.getLocalName());
            }

        } catch (ReportingException e) {
            throw new ReportingException("OMElement creation fail from " + file);

        }
        return names.toArray(new String[names.size()]);
    }
View Full Code Here


                reportFilesResource.setContent(fileContent);

                registry.put("/reports/" + fileName + ".jrxml", reportFilesResource);
                status = "success";
            } catch (RegistryException e) {
                throw new ReportingException("Failed to upload " + "\"" + fileName + "\"", e);
            }
        } else {
            throw new ReportingException("File content empty or in-complete template");
        }
        return status;
    }
View Full Code Here

    public String getReportResources(String componentName, String reportTemplate)
            throws ReportingException {
        try {
            return CommonUtil.getReportResources(componentName, reportTemplate, getConfigSystemRegistry());
        } catch (XMLStreamException e) {
            throw new ReportingException(" Failed to get report template" ,e);
        }
    }
View Full Code Here

            }
            registry.commitTransaction();
        } catch (Exception e) {
            String msg = "Error occurred adding .jrxml file from " +
                    bundle.getSymbolicName() + " to registry";
            throw new ReportingException(msg, e);
        }

    }
View Full Code Here

            response.setContentType("application/vnd.ms-excel");
            downloadFileName = reportName + ".xls";
        } else if (reportType.equals("html")) {
            response.setContentType("text/html");
        } else {
            throw new ReportingException("requested report type can not be support");
        }

        if (downloadFileName != null) {
            response.setHeader("Content-Disposition", "attachment; filename=\"" + downloadFileName + "\"");
        }
View Full Code Here

            generateType = "html";
            response.setContentType("text/html");


        } else {
            throw new ReportingException("requested report type can not be support");
        }
        if (downloadFileName != null) {
            response.setHeader("Content-Disposition", "attachment; filename=\"" + downloadFileName + "\"");
        }
        Object reportDataObject = request.getSession().getAttribute(dataSessionVar);
        if (reportDataObject == null) {
            throw new ReportingException("can't generate report , data unavailable in session ");
        }
        try {
            String serverURL = CarbonUIUtil.getServerURL(request.getSession().getServletContext(), request.getSession());
            ConfigurationContext configurationContext = (ConfigurationContext) request.getSession().getServletContext().
                    getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
View Full Code Here

    public ByteArrayOutputStream generateHtmlReport(JasperPrint jasperPrint)
            throws ReportingException, JRException {

        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        if (jasperPrint == null) {
            throw new ReportingException("jasperPrint null, can't convert to HTML report");
        }
        try {
            JRHtmlExporter jrHtmlExporter = new JRHtmlExporter();
            jrHtmlExporter.setParameter(JRHtmlExporterParameter.JASPER_PRINT, jasperPrint);
            jrHtmlExporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, true);
View Full Code Here

public class XMLReport {
    public ByteArrayOutputStream generateXmlReport(JasperPrint jasperPrint)
            throws JRException, ReportingException {
        ByteArrayOutputStream xmlOutputStream = new ByteArrayOutputStream();
        if(jasperPrint==null){
            throw new ReportingException("jasperPrint null, can't convert to  XML report");
        }
        JRXmlExporter jrXmlExporter = new JRXmlExporter();
        jrXmlExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
        jrXmlExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, xmlOutputStream);
        try {
View Full Code Here

        String type = request.getParameter("type");
        String reportData = request.getParameter("reportDataSession");
        String downloadFileName = null;

        if (component == null || template == null || type == null || reportData == null) {
            throw new ReportingException("required one or more parameters missing (component ,template , reportType, reportData)");
        }

        if (type.equals("pdf")) {
            response.setContentType("application/pdf");
            downloadFileName = template + ".pdf";
        } else if (type.equals("excel")) {
            response.setContentType("application/vnd.ms-excel");
            downloadFileName = template + ".xls";
        } else if (type.equals("html")) {
            response.setContentType("text/html");

        } else {
            throw new ReportingException("requested report type can not be support");
        }
        if (downloadFileName != null) {
            response.setHeader("Content-Disposition", "attachment; filename=\"" + downloadFileName + "\"");
        }
        Object reportDataObject = request.getSession().getAttribute(reportData);
        if (reportDataObject == null) {
            throw new ReportingException("can't generate report , data unavailable in session ");
        }

        try {
            String serverURL = CarbonUIUtil.getServerURL(request.getSession().getServletContext(), request.getSession());
            ConfigurationContext configurationContext = (ConfigurationContext) request.getSession().getServletContext().
                    getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
            String cookie = (String) request.getSession().getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);

            ReportResourceSupplierClient resourceSupplierClient = new ReportResourceSupplierClient(cookie,
                    serverURL, configurationContext);

            List<ReportDataManager> reportDataList = (List<ReportDataManager>) reportDataObject;
            String reportResource = resourceSupplierClient.getReportResources(component, template);
            JRDataSource jrDataSource = new JRBeanCollectionDataSource(reportDataList);
            JasperPrintProvider jasperPrintProvider = new JasperPrintProvider();
            JasperPrint jasperPrint = jasperPrintProvider.createJasperPrint(jrDataSource ,reportResource, new ReportParamMap[0]);
            request.getSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE,jasperPrint);
            ReportStream reportStream = new ReportStream();
            ByteArrayOutputStream outputStream =  reportStream.getReportStream(jasperPrint,type);
            ServletOutputStream servletOutputStream = response.getOutputStream();
            try{
            outputStream.writeTo(servletOutputStream);
            outputStream.flush();
            }finally {
                outputStream.close();
                servletOutputStream.close();
            }

        } catch (Exception e) {
            String msg = "Error occurred handling " + template + "report request from " + component;
            log(msg);
            throw new ReportingException(msg, e);
        }
    }
View Full Code Here

     */
    public ByteArrayOutputStream generatePdfReport(JasperPrint jasperPrint) throws JRException, ReportingException {

        ByteArrayOutputStream pdfOutputStream = new ByteArrayOutputStream();
        if (jasperPrint == null) {
            throw new ReportingException("jasperPrint null, can't convert to  PDF report");
        }
        try {

            JRPdfExporter jrPdfExporter = new JRPdfExporter();
            jrPdfExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
View Full Code Here

TOP

Related Classes of org.wso2.carbon.reporting.api.ReportingException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.