/*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License, version 2.1 as published by the Free Software
* Foundation.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, you can obtain a copy at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
* or from the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* Copyright 2006 - 2009 Pentaho Corporation. All rights reserved.
*
*/
package org.pentaho.platform.plugin.action.jfreereport.outputs;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import org.pentaho.platform.plugin.action.messages.Messages;
import org.pentaho.reporting.engine.classic.core.MasterReport;
import org.pentaho.reporting.engine.classic.core.ReportProcessingException;
import org.pentaho.reporting.engine.classic.core.modules.output.xml.XMLProcessor;
/**
* Creation-Date: 07.07.2006, 20:42:17
*
* @author Thomas Morgner
*/
public class JFreeReportXmlComponent extends AbstractGenerateStreamContentComponent {
private static final long serialVersionUID = 8323789322309175815L;
public JFreeReportXmlComponent() {
}
@Override
protected String getMimeType() {
return "text/xml"; //$NON-NLS-1$
}
@Override
protected String getExtension() {
return ".xml"; //$NON-NLS-1$
}
@SuppressWarnings("deprecation")
@Override
protected boolean performExport(final MasterReport report, final OutputStream outputStream) {
try {
final XMLProcessor processor = new XMLProcessor(report);
final OutputStreamWriter writer = new OutputStreamWriter(outputStream);
processor.setWriter(writer);
processor.processReport();
writer.close();
close();
return true;
} catch (ReportProcessingException e) {
error(Messages.getInstance().getString("JFreeReportXmlComponent.ERROR_0046_FAILED_TO_PROCESS_REPORT"), e); //$NON-NLS-1$
return false;
} catch (IOException e) {
error(Messages.getInstance().getString("JFreeReportXmlComponent.ERROR_0046_FAILED_TO_PROCESS_REPORT"), e); //$NON-NLS-1$
return false;
}
}
}