use of org.pentaho.reporting.libraries.resourceloader.ResourceException in project pentaho-platform by pentaho.
the class PRPTImportHandler method extractMetaData.
// keep it protected for test goal, we should not add any logic for this method such we just
// incapsulate getting information from external class
/**
* extract metadata from input bundle
*
* @param bytes
* @return
* @throws PlatformImportException if we are failed to create metadata from input data
*/
protected DocumentMetaData extractMetaData(byte[] bytes) throws PlatformImportException {
try {
ResourceManager mgr = new ResourceManager();
MasterReport report = (MasterReport) mgr.createDirectly(bytes, MasterReport.class).getResource();
return report.getBundle().getMetaData();
} catch (ResourceException e) {
throw new PlatformImportException("An unexpected error occurred while parsing a report definition", e);
}
}
use of org.pentaho.reporting.libraries.resourceloader.ResourceException in project pentaho-platform by pentaho.
the class JFreeReportComponent method createReport.
protected MasterReport createReport(final String reportDefinition) throws ResourceException, IOException {
ReportGenerator generator = ReportGenerator.createInstance();
// add the runtime context so that PentahoResourceData class can get access to the solution repo
// generator.setObject(PentahoResourceData.PENTAHO_RUNTIME_CONTEXT_KEY, getRuntimeContext());
URL url = null;
IPentahoRequestContext requestContext = PentahoRequestContextHolder.getRequestContext();
try {
// $NON-NLS-1$ //$NON-NLS-2$
url = new URL(requestContext.getContextPath());
} catch (Exception e) {
// a null URL is ok
// $NON-NLS-1$
warn(Messages.getInstance().getString("JFreeReportLoadComponent.WARN_COULD_NOT_CREATE_URL"));
}
// Read the encoding from the XML file - see BISERVER-895
final String encoding = XmlHelper.getEncoding(reportDefinition, null);
ByteArrayInputStream inStream = new ByteArrayInputStream(reportDefinition.getBytes(encoding));
InputSource reportDefinitionInputSource = new InputSource(inStream);
reportDefinitionInputSource.setEncoding(encoding);
return generator.parseReport(reportDefinitionInputSource, getDefinedResourceURL(url));
}
use of org.pentaho.reporting.libraries.resourceloader.ResourceException in project pentaho-platform by pentaho.
the class JFreeReportLoadComponent method getReportFromInputParam.
private MasterReport getReportFromInputParam() throws ResourceException, UnsupportedEncodingException, IOException {
MasterReport report = null;
if (isDefinedInput(AbstractJFreeReportComponent.REPORTGENERATEDEFN_REPORTDEFN)) {
IActionParameter o = getInputParameter(AbstractJFreeReportComponent.REPORTGENERATEDEFN_REPORTDEFN);
if (o != null) {
String repDef = o.getStringValue();
ReportGenerator generator = ReportGenerator.getInstance();
IPentahoRequestContext requestContext = PentahoRequestContextHolder.getRequestContext();
URL url = null;
try {
url = new URL(requestContext.getContextPath());
} catch (Exception e) {
// a null URL is ok
// $NON-NLS-1$
warn(Messages.getInstance().getString("JFreeReportLoadComponent.WARN_COULD_NOT_CREATE_URL"));
}
report = generator.parseReport(new InputSource(new ByteArrayInputStream(repDef.getBytes("UTF-8"))), // $NON-NLS-1$
getDefinedResourceURL(url));
}
}
return report;
}
Aggregations