Java 类net.sf.jasperreports.engine.util.JRXmlUtils 实例源码

项目:jasperreports    文件:SimpleFontExtensionHelper.java   
/**
 *
 */
private SimpleFontExtensionHelper()
{
    try
    {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setFeature(JRXmlUtils.FEATURE_DISALLOW_DOCTYPE, true);

        documentBuilder = factory.newDocumentBuilder();
        documentBuilder.setErrorHandler(this);
    }
    catch (ParserConfigurationException e)
    {
        throw new JRRuntimeException(e);
    }
}
项目:jasperreports    文件:JRXmlDocumentProducer.java   
protected DocumentBuilder getDocumentBuilder() throws JRException {
    try{
        if (documentBuilderFactory != null) {
            return documentBuilderFactory.newDocumentBuilder();
        } else {
            return JRXmlUtils.createDocumentBuilder();
        }
    } catch (ParserConfigurationException e)
    {
        throw 
            new JRException(
                EXCEPTION_MESSAGE_KEY_DOCUMENT_BUILDER_CREATION_FAILURE, 
                null,
                e);
    }
}
项目:PDFReporter-Studio    文件:RemoteXMLDataAdapterDescriptor.java   
@Override
public List<JRDesignField> getFields(DataAdapterService con, JasperReportsConfiguration jConfig, JRDataset jDataset) throws JRException, UnsupportedOperationException {
    Throwable t = null;
    ArrayList<JRDesignField> fields = new ArrayList<JRDesignField>();
    try {
        String fileName = getDataAdapter().getFileName();
        Document doc = JRXmlUtils.parse(new URL(fileName), XMLUtils.isNamespaceAware(getDataAdapter(), jConfig.getJasperDesign()));
        fields.addAll(getFieldsFromDocument(doc, jConfig, jDataset));
    } catch (IOException e) {
        t = e;
    }

    if (t != null) {
        UIUtils.showError(t);
    }
    return fields;
}
项目:PDFReporter-Studio    文件:ShowAdaptersPage.java   
protected void createCheckboxes(Properties prop){
    Integer connectionIndex = 0;
    String connectionXML = prop.getProperty("connection." + connectionIndex); //$NON-NLS-1$
    while(connectionXML != null){
        try {
            Document document = JRXmlUtils.parse(new InputSource(new StringReader(connectionXML)));
            NamedNodeMap rootAttributes = document.getChildNodes().item(0).getAttributes();
            String connectionName = rootAttributes.getNamedItem("name").getTextContent(); //$NON-NLS-1$
            String connectionClass = rootAttributes.getNamedItem("connectionClass").getTextContent(); //$NON-NLS-1$
            if (ImportUtility.hasAdapter(connectionClass)){
                Button checkButton = new Button(content, SWT.CHECK);
                String type = connectionClass.substring(connectionClass.lastIndexOf(".")+1); //$NON-NLS-1$
                checkButton.setText(connectionName+" ("+ type + ")"); //$NON-NLS-1$ //$NON-NLS-2$
                checkButton.setData(document);
                selectedElements.add(checkButton);
            }
        } catch (JRException e) {}
        connectionIndex++;
        connectionXML = prop.getProperty("connection." + connectionIndex); //$NON-NLS-1$
    }
}
项目:PDFReporter-Studio    文件:ShowJSSAdaptersPage.java   
protected void createCheckboxes(Properties prop){
    String connectionXML = prop.getProperty("dataAdapters"); //$NON-NLS-1$
    Document document;
    try {
        document = JRXmlUtils.parse(new InputSource(new StringReader(connectionXML)));
        Node actualNode = document.getFirstChild();
        if (actualNode.hasChildNodes()) actualNode = actualNode.getFirstChild();
        else actualNode = null;
        while(actualNode != null){
            if (actualNode.getAttributes() != null){
                String name = actualNode.getChildNodes().item(0).getTextContent();
                String type = actualNode.getAttributes().getNamedItem("class").getTextContent();
                type = type.substring(type.lastIndexOf(".")+1);
                Button checkButton = new Button(content, SWT.CHECK);
                checkButton.setText(name+" ("+ type + ")"); //$NON-NLS-1$ //$NON-NLS-2$
                checkButton.setData(actualNode);
                selectedElements.add(checkButton);
            }
            actualNode = actualNode.getNextSibling();
        }
    } catch (JRException e) {
        e.printStackTrace();
    }
}
项目:PDFReporter-Studio    文件:DefaultManager.java   
/**
 * Load the list of the template set from the preferences file. If one of them has the default 
 * attribute set to true then it will be the selected default. If more of them has the attribute
 * to true only the last one will be the default. A template set is added to the available ones
 * only if it's file exist
 */
private void loadPreferences(){
    String defaults = prefs.get(DEFAULT_KEY, "");
    availableDefaults = new ArrayList<String>();
    if (!defaults.isEmpty()){
        try {
            Document document = JRXmlUtils.parse(new InputSource(new StringReader(defaults)));
            NodeList adapterNodes = document.getDocumentElement().getChildNodes();
            for (int i = 0; i < adapterNodes.getLength(); ++i) {
                Node adapterNode = adapterNodes.item(i);
                if (adapterNode.getNodeType() == Node.ELEMENT_NODE) {
                    String path = adapterNode.getAttributes().getNamedItem("path").getNodeValue(); //$NON-NLS-1$
                    String defaultReport = adapterNode.getAttributes().getNamedItem("default").getNodeValue(); //$NON-NLS-1$
                    //Check file existence
                    if (new File(path).exists()){
                        availableDefaults.add(path);
                        if (Boolean.parseBoolean(defaultReport)) actualDefault = path;
                    }
                }
            }
        } catch (JRException e) {
            e.printStackTrace();
        }
    }
}
项目:dynamicreports-jasper    文件:XmlReportTest.java   
@Override
protected void configureReport(JasperReportBuilder rb) {
    try {
        rb.setLocale(Locale.ENGLISH)
            .columns(
                column1 =   col.column("Column1", field("field1", type.stringType()).setDescription("@field1")),
                column2 =   col.column("Column2", field("field2", type.integerType())),
                column3 =   col.column("Column3", field("field3", type.bigDecimalType())))
            .setQuery("/data/row1", QueryLanguage.XPATH)
            .setParameter(JRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT, JRXmlUtils.parse(XmlReportTest.class.getResourceAsStream("data.xml")))
            .summary(cmp.subreport(createSubreport()));
    } catch (JRException e) {
        e.printStackTrace();
        Assert.fail(e.getMessage());
    }
}
项目:jasperreports    文件:XmlDataSourceApp.java   
/**
 *
 */
public void fill() throws JRException
{
    long start = System.currentTimeMillis();
    Map<String, Object> params = new HashMap<String, Object>();
    Document document = JRXmlUtils.parse(JRLoader.getLocationInputStream("data/northwind.xml"));
    params.put(JRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT, document);
    params.put(JRXPathQueryExecuterFactory.XML_DATE_PATTERN, "yyyy-MM-dd");
    params.put(JRXPathQueryExecuterFactory.XML_NUMBER_PATTERN, "#,##0.##");
    params.put(JRXPathQueryExecuterFactory.XML_LOCALE, Locale.ENGLISH);
    params.put(JRParameter.REPORT_LOCALE, Locale.US);

    JasperFillManager.fillReportToFile("build/reports/CustomersReport.jasper", params);
    System.err.println("Filling time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:XmlDataAdapterService.java   
protected Document loadDataDocument(XmlDataAdapter xmlDataAdapter, Map<String, Object> parameters) throws JRException
{
    DataFileUtils dataFileUtils = DataFileUtils.instance(getParameterContributorContext());
    DataFileStream dataStream = dataFileUtils.getDataStream(
            xmlDataAdapter.getDataFile(), parameters);
    try
    {
        Document dataDocument = JRXmlUtils.parse(dataStream, xmlDataAdapter.isNamespaceAware());
        return dataDocument;
    }
    finally
    {
        dataStream.dispose();
    }
}
项目:jasperreports    文件:JRXmlDataSource.java   
public JRXmlDataSource(
        JasperReportsContext jasperReportsContext,
        InputStream in, 
        String selectExpression,
        boolean isNamespaceAware
        ) throws JRException 
{
    this(jasperReportsContext, JRXmlUtils.parse(new InputSource(in), isNamespaceAware), selectExpression);

    this.inputStream = in;
    this.closeInputStream = false;
}
项目:jasperreports    文件:JRXmlDataSource.java   
/**
 * Creates a document using the current node as root.
 * 
 * @return a document having the current node as root
 * @throws JRException
 */
@Override
public Document subDocument() throws JRException
{
    if(currentNode == null)
    {
        throw 
            new JRException(
                EXCEPTION_MESSAGE_KEY_NODE_NOT_AVAILABLE,
                (Object[])null);
    }

    // create a new document from the current node
    return JRXmlUtils.createDocument(currentNode);
}
项目:PDFReporter-Studio    文件:ServerManager.java   
public static void loadServerProfiles(MServers root) {
    root.removeChildren();
    serverProfiles.clear();

    Preferences prefs = PropertiesHelper.INSTANCE_SCOPE.getNode(JaspersoftStudioPlugin.getUniqueIdentifier());

    String xml = prefs.get(PREF_TAG, null); //$NON-NLS-1$

    if (xml != null) {
        try {
            Document document = JRXmlUtils.parse(new InputSource(new StringReader(xml)));

            NodeList adapterNodes = document.getDocumentElement().getChildNodes();// .getElementsByTagName("dataAdapter");

            for (int i = 0; i < adapterNodes.getLength(); ++i) {
                Node adapterNode = adapterNodes.item(i);

                if (adapterNode.getNodeType() == Node.ELEMENT_NODE) {
                    try {
                        ServerProfile sprof = (ServerProfile) CastorUtil.read(adapterNode, MServerProfile.MAPPINGFILE);

                        MServerProfile sp = new MServerProfile(root, sprof);
                        new MDummy(sp);
                        serverProfiles.add(sp);
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
            }

        } catch (JRException e) {
            UIUtils.showError(e);
        }
    }
}
项目:PDFReporter-Studio    文件:XMLDataAdapterDescriptor.java   
@Override
public List<JRDesignField> getFields(DataAdapterService con, JasperReportsConfiguration jConfig, JRDataset jDataset) throws JRException, UnsupportedOperationException {
    setRecursiveRetrieval(jConfig);
    ArrayList<JRDesignField> fields = new ArrayList<JRDesignField>();
    String fileName = getDataAdapter().getFileName();
    File in = new File(fileName);
    Document doc = JRXmlUtils.parse(in, XMLUtils.isNamespaceAware(getDataAdapter(), jConfig.getJasperDesign()));
    fields.addAll(getFieldsFromDocument(doc, jConfig, jDataset));
    return fields;
}
项目:PDFReporter-Studio    文件:PreferencesTemplateStylesStorage.java   
/**
 * Read all the styles from the properties file
 */
private void findAll() {
    try {
        String xml = prefs.get(PREF_KEYS_STYLES, null);
        if (xml != null) {
            Document document = JRXmlUtils.parse(new InputSource(new StringReader(xml)));

            NodeList adapterNodes = document.getDocumentElement().getChildNodes();
            for (int i = 0; i < adapterNodes.getLength(); ++i) {
                Node adapterNode = adapterNodes.item(i);
                if (adapterNode.getNodeType() == Node.ELEMENT_NODE) {
                    // 1. Find out the class of this styles...
                    String className = adapterNode.getAttributes().getNamedItem("type").getNodeValue(); //$NON-NLS-1$
                    TemplateStyle factory = getBuilder(className); 
                    if (factory != null){
                        TemplateStyle readStyle = factory.buildFromXML(adapterNode);
                        Integer uniequeTemplateId = getId();
                        readStyle.storePropertiy(STYLE_ID, uniequeTemplateId);
                        styleDescriptors.put(uniequeTemplateId, readStyle);
                    }
                }
            }

        } else {
            prefs.put(PREF_KEYS_STYLES, "<templateStyles></templateStyles>");
            prefs.flush();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:PDFReporter-Studio    文件:PreferencesTemplateStylesStorage.java   
public List<TemplateStyle> readTemplateFromFile(String xml) {
    List<TemplateStyle> result = new ArrayList<TemplateStyle>();
    try {
        if (xml != null) {
            Document document = JRXmlUtils.parse(new InputSource(new StringReader(xml)));
            NodeList adapterNodes = document.getDocumentElement().getChildNodes();
            for (int i = 0; i < adapterNodes.getLength(); ++i) {
                Node adapterNode = adapterNodes.item(i);
                if (adapterNode.getNodeType() == Node.ELEMENT_NODE && adapterNode.getAttributes().getNamedItem("type")!=null) {
                    // 1. Find out the class of this styles...
                    String className = adapterNode.getAttributes().getNamedItem("type").getNodeValue(); //$NON-NLS-1$
                    TemplateStyle factory = getBuilder(className); 
                    if (factory != null){
                        TemplateStyle readStyle = factory.buildFromXML(adapterNode);
                        Integer uniequeTemplateId = getId();
                        readStyle.storePropertiy(STYLE_ID, uniequeTemplateId);
                        result.add(readStyle);
                    }
                }
            }

        } 
    } catch (Exception e) {
        e.printStackTrace();
    }
    return result;
}
项目:jasper-service    文件:JasperProcess.java   
protected Map<String, Object> readDataFile(String xmlDataFile) throws JRException {
    Document document = JRXmlUtils.parse(JRLoader.getLocationInputStream(xmlDataFile));
    Map<String, Object> params = new HashMap<String, Object>();
    params.put(JRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT, document);
    params.put(JRXPathQueryExecuterFactory.XML_DATE_PATTERN, "yyyy-MM-dd");
    params.put(JRXPathQueryExecuterFactory.XML_NUMBER_PATTERN, "#,##0.##");
    params.put(JRXPathQueryExecuterFactory.XML_LOCALE, Locale.ENGLISH);
    params.put(JRParameter.REPORT_LOCALE, Locale.US);
    return params;
}
项目:jasperreports    文件:RemoteXmlDataAdapterService.java   
@Override
public void contributeParameters(Map<String, Object> parameters) throws JRException 
{
    RemoteXmlDataAdapter remoteXmlDataAdapter = getRemoteXmlDataAdapter();
    if (remoteXmlDataAdapter != null)
    {
        if (remoteXmlDataAdapter.isUseConnection()) 
        {
            String fileName = remoteXmlDataAdapter.getFileName();
            if (fileName.toLowerCase().startsWith("https://") ||
                fileName.toLowerCase().startsWith("http://") ||
                fileName.toLowerCase().startsWith("file:")) {

                // JRXPathQueryExecuterFactory.XML_URL not available.
                // Once this is available, remove XML_URL from this class.
                parameters.put(XML_URL, fileName);
            }
            else 
            {
                InputStream dataStream = RepositoryUtil.getInstance(getJasperReportsContext()).getInputStreamFromLocation(remoteXmlDataAdapter.getFileName());
                try
                {
                    Document document = JRXmlUtils.parse(dataStream, remoteXmlDataAdapter.isNamespaceAware());
                    parameters.put(JRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT, document);
                }
                finally
                {
                    try
                    {
                        dataStream.close();
                    }
                    catch (IOException e)
                    {
                        log.warn("Failed to close input stream for " + remoteXmlDataAdapter.getFileName());
                    }
                }
            }

            Locale locale = remoteXmlDataAdapter.getLocale();
            if (locale != null) {
                parameters.put(JRXPathQueryExecuterFactory.XML_LOCALE, locale);
            }

            TimeZone timeZone = remoteXmlDataAdapter.getTimeZone();
            if (timeZone != null) {
                parameters.put(JRXPathQueryExecuterFactory.XML_TIME_ZONE, timeZone);
            }

            String datePattern = remoteXmlDataAdapter.getDatePattern();
            if (datePattern != null && datePattern.trim().length()>0) {
                parameters.put(JRXPathQueryExecuterFactory.XML_DATE_PATTERN, datePattern);
            }

            String numberPattern = remoteXmlDataAdapter.getNumberPattern();
            if (numberPattern != null && numberPattern.trim().length()>0) {
                parameters.put(JRXPathQueryExecuterFactory.XML_NUMBER_PATTERN, numberPattern);
            }
        }
    }
}
项目:jasperreports    文件:JRXmlDataSource.java   
public JRXmlDataSource(JasperReportsContext jasperReportsContext, File file, String selectExpression, boolean isNamespaceAware)
        throws JRException {
    this(jasperReportsContext, JRXmlUtils.parse(file, isNamespaceAware), selectExpression);
}
项目:openreports    文件:JasperReportEngine.java   
public JasperPrint fillReport(ReportEngineInput input) throws ProviderException
{
    Connection conn = null;

    Report report = input.getReport();
    Map<String,Object> parameters = input.getParameters();

    ReportDataSource dataSource = report.getDataSource();

    try
    {
        JasperReport jr = null;

        if (report.isQueryReport()) return fillQueryReport(report, parameters, input.getExportType());

        jr = (JasperReport) JRLoader
                .loadObject(directoryProvider.getReportDirectory() + report.getFile());

        List<ReportParameterMap> subReports = report.getSubReportParameters();
        if (subReports != null && subReports.size() > 0)
        {
            Iterator<ReportParameterMap> iterator = report.getSubReportParameters().iterator();
            while (iterator.hasNext())
            {
                ReportParameterMap rpMap = iterator.next();

                JasperReport subReport = (JasperReport) JRLoader.loadObject(directoryProvider
                        .getReportDirectory()
                        + rpMap.getReportParameter().getData());

                parameters.put(rpMap.getReportParameter().getName(), subReport);
            }
        }

        JasperPrint jp = null;

        // create new HashMap to send to JasperReports in order to
        // fix serialization problems
        Map<String,Object> jasperReportMap = new HashMap<String,Object>(parameters);

        if (input.getXmlInput() != null)
        {
            ByteArrayInputStream stream = new ByteArrayInputStream(input.getXmlInput().getBytes());
            Document document = JRXmlUtils.parse(stream);

            jasperReportMap.put(JRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT, document);

            jp = JasperFillManager.fillReport(jr, jasperReportMap);
        }
        else if (dataSource == null)
        {
            jp = JasperFillManager.fillReport(jr, jasperReportMap, new JREmptyDataSource());
        }
        else
        {
            conn = dataSourceProvider.getConnection(dataSource.getId());
            jp = JasperFillManager.fillReport(jr, jasperReportMap, conn);
        }

        if (jp == null || jp.getPages().size() < 1) throw new ProviderException(LocalStrings.ERROR_REPORT_EMPTY);

        return jp;
    }
    catch (Exception e)
    {
        if (!e.getMessage().equals(LocalStrings.ERROR_REPORT_EMPTY)) log.error("JasperReportEngine.fillReport", e);
        throw new ProviderException(e.getMessage());
    }
    finally
    {
        try
        {
            if (conn != null) conn.close();
        }
        catch (Exception ex)
        {
            log.error("Error closing connection: " + ex.getMessage());
        }
    }
}
项目:PDFReporter-Studio    文件:ImportJSSServersWizard.java   
protected List<ServerProfile> createCheckBoxData(Properties prop) {
    List<ServerProfile> result = new ArrayList<ServerProfile>();
    String xmlString = prop.getProperty("serverprofiles");
    if (xmlString == null)
        return result;

    Document document;
    try {
        document = JRXmlUtils.parse(new InputSource(new StringReader(xmlString)));
        Node actualNode = document.getFirstChild();
        if (actualNode.hasChildNodes())
            actualNode = actualNode.getFirstChild();
        else
            actualNode = null;
        while (actualNode != null) {
            if (actualNode.getNodeName().equals("serverProfile")) {
                Node child = actualNode.getFirstChild();
                ServerProfile srv = new ServerProfile();
                while (child != null) {
                    if (child.getNodeName().equals("name"))
                        srv.setName(child.getTextContent());
                    if (child.getNodeName().equals("jrVersion"))
                        srv.setJrVersion(child.getTextContent());
                    if (child.getNodeName().equals("url")) {
                        String connectionString = child.getTextContent();
                        if (connectionString.endsWith("/services/repository")) { //$NON-NLS-1$
                            connectionString = connectionString.substring(0, connectionString.lastIndexOf("services/repository")); //$NON-NLS-1$
                        }
                        srv.setUrl(connectionString);
                    }
                    if (child.getNodeName().equals("user"))
                        srv.setUser(child.getTextContent());
                    if (child.getNodeName().equals("pass"))
                        srv.setPass(child.getTextContent());
                    if (child.getNodeName().equals("supportsDateRanges"))
                        srv.setSupportsDateRanges(child.getTextContent().equals("true"));
                    if (child.getNodeName().equals("chunked"))
                        srv.setChunked(child.getTextContent().equals("true"));
                    if (child.getNodeName().equals("timeout"))
                        srv.setTimeout(Integer.parseInt(child.getTextContent()));
                    child = child.getNextSibling();
                }
                result.add(srv);
            }
            actualNode = actualNode.getNextSibling();
        }
    } catch (JRException e) {
        e.printStackTrace();
    }
    return result;
}
项目:ireport-fork    文件:JRXMLDataSourceConnection.java   
/**
 * This method is call before the datasource is used and permit to add special parameters to the map
 *
 */
@SuppressWarnings("unchecked")
@Override
public java.util.Map getSpecialParameters(java.util.Map map) throws net.sf.jasperreports.engine.JRException
{
    if (isUseConnection())
    {

        /*
        if (this.getFilename().toLowerCase().startsWith("https://") ||
            this.getFilename().toLowerCase().startsWith("http://") ||
            this.getFilename().toLowerCase().startsWith("file:"))
        {
            map.put(JRXPathQueryExecuterFactory.XML_URL, this.getFilename());
        }
        else
        {
        */
            Document document = JRXmlUtils.parse(new File( this.getFilename()));
            map.put(JRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT, document);
        //}


        if (getLocale()!=null)
       {
           map.put(JRXPathQueryExecuterFactory.XML_LOCALE, getLocale());
       }

       if (getTimeZone() != null)
       {
           map.put(JRXPathQueryExecuterFactory.XML_TIME_ZONE, getTimeZone());
       }

       if (getDatePattern() != null && getDatePattern().trim().length()>0)
       {
           map.put(JRXPathQueryExecuterFactory.XML_DATE_PATTERN, getDatePattern());
       }

       if (getNumberPattern() != null && getNumberPattern().trim().length()>0)
       {
           map.put(JRXPathQueryExecuterFactory.XML_NUMBER_PATTERN, getNumberPattern());
       }

    }
    return map;
}
项目:ireport-fork    文件:JRXMLDataSourceConnection.java   
/**
 * This method is call before the datasource is used and permit to add special parameters to the map
 *
 */
public java.util.Map getSpecialParameters(java.util.Map map) throws net.sf.jasperreports.engine.JRException
{
    if (isUseConnection())
    {

        System.out.println("Running against: " + this.getFilename());
        System.out.flush();
        if (this.getFilename().toLowerCase().startsWith("https://") ||
            this.getFilename().toLowerCase().startsWith("http://") ||
            this.getFilename().toLowerCase().startsWith("file:"))
        {

            map.put(JRXPathQueryExecuterFactory.XML_URL, this.getFilename());
        }
        else
        {

            Document document = JRXmlUtils.parse(new File( this.getFilename()));
            map.put(JRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT, document);
        }


        if (getLocale()!=null)
       {
           map.put(JRXPathQueryExecuterFactory.XML_LOCALE, getLocale());
       }

       if (getTimeZone() != null)
       {
           map.put(JRXPathQueryExecuterFactory.XML_TIME_ZONE, getTimeZone());
       }

       if (getDatePattern() != null && getDatePattern().trim().length()>0)
       {
           map.put(JRXPathQueryExecuterFactory.XML_DATE_PATTERN, getDatePattern());
       }

       if (getNumberPattern() != null && getNumberPattern().trim().length()>0)
       {
           map.put(JRXPathQueryExecuterFactory.XML_NUMBER_PATTERN, getNumberPattern());
       }

    }
    return map;
}
项目:openreportsv2    文件:JasperReportEngine.java   
public JasperPrint fillReport(ReportEngineInput input) throws ProviderException
{
    Connection conn = null;

    Report report = input.getReport();
    Map<String,Object> parameters = input.getParameters();

    ReportDataSource dataSource = report.getDataSource();

    try
    {
        JasperReport jr = null;

        if (report.isQueryReport()) return fillQueryReport(report, parameters, input.getExportType());

        jr = (JasperReport) JRLoader
                .loadObject(directoryProvider.getReportDirectory() + report.getFile());

        List<ReportParameterMap> subReports = report.getSubReportParameters();
        if (subReports != null && subReports.size() > 0)
        {
            Iterator<ReportParameterMap> iterator = report.getSubReportParameters().iterator();
            while (iterator.hasNext())
            {
                ReportParameterMap rpMap = iterator.next();

                JasperReport subReport = (JasperReport) JRLoader.loadObject(directoryProvider
                        .getReportDirectory()
                        + rpMap.getReportParameter().getData());

                parameters.put(rpMap.getReportParameter().getName(), subReport);
            }
        }

        JasperPrint jp = null;

        // create new HashMap to send to JasperReports in order to
        // fix serialization problems
        Map<String,Object> jasperReportMap = new HashMap<String,Object>(parameters);

           if (input.getXmlInput() != null)
           {
               ByteArrayInputStream stream = new ByteArrayInputStream(input.getXmlInput().getBytes());
               Document document = JRXmlUtils.parse(stream);

               jasperReportMap.put(JRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT, document);

               jp = JasperFillManager.fillReport(jr, jasperReportMap);               
           }
           else if (dataSource == null)
        {           
            jp = JasperFillManager.fillReport(jr, jasperReportMap, new JREmptyDataSource());
        }
        else
        {
            conn = dataSourceProvider.getConnection(dataSource.getId());
            jp = JasperFillManager.fillReport(jr, jasperReportMap, conn);
        }

        if (jp == null || jp.getPages().size() < 1) throw new ProviderException(LocalStrings.ERROR_REPORT_EMPTY);

        return jp;
    }
    catch (Exception e)
    {
           if (!e.getMessage().equals(LocalStrings.ERROR_REPORT_EMPTY)) log.error("JasperReportEngine.fillReport", e);
        throw new ProviderException(e.getMessage());
    }
    finally
    {
        try
        {
            if (conn != null) conn.close();
        }
        catch (Exception ex)
        {
            log.error("Error closing connection: " + ex.getMessage());
        }
    }
}