### Eclipse Workspace Patch 1.0
#P org.eclipse.birt.report.engine
Index: src/org/eclipse/birt/report/engine/api/ReportEngine.java
===================================================================
RCS file: /cvsroot/birt/source/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/api/ReportEngine.java,v
retrieving revision 1.32
diff -u -r1.32 ReportEngine.java
--- src/org/eclipse/birt/report/engine/api/ReportEngine.java 5 Feb 2007 09:50:15 -0000 1.32
+++ src/org/eclipse/birt/report/engine/api/ReportEngine.java 6 Feb 2007 21:44:30 -0000
@@ -347,4 +347,16 @@
{
return engine.openReportDocument( systemId, reader, options );
}
+
+ public IDeliveryTask createDeliveryTask(String deliveryType) {
+ return engine.createDeliveryTask(deliveryType);
+ }
+
+ public DeliveryInfo[] getDeliveryInfo() {
+ return engine.getDeliveryInfo();
+ }
+
+ public String[] getSupportedDeliveryType() {
+ return engine.getSupportedDeliveryType();
+ }
}
\ No newline at end of file
Index: src/org/eclipse/birt/report/engine/api/HTMLRenderContext.java
===================================================================
RCS file: /cvsroot/birt/source/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/api/HTMLRenderContext.java,v
retrieving revision 1.8
diff -u -r1.8 HTMLRenderContext.java
--- src/org/eclipse/birt/report/engine/api/HTMLRenderContext.java 1 Feb 2007 10:22:26 -0000 1.8
+++ src/org/eclipse/birt/report/engine/api/HTMLRenderContext.java 6 Feb 2007 21:44:29 -0000
@@ -11,6 +11,8 @@
package org.eclipse.birt.report.engine.api;
+import java.util.ArrayList;
+
/**
* Defines the context for rendering report in HTML emitter. Objects stored in the
* context object is mainly used for image and action handling, but can be used for
@@ -45,10 +47,16 @@
protected IRenderOption renderOption;
/**
+ * Associated rendered files of a *rendered* report
+ */
+ protected ArrayList renderedFiles;
+
+ /**
* dummy constrictor
*/
public HTMLRenderContext()
{
+ renderedFiles = new ArrayList();
}
/**
@@ -135,4 +143,45 @@
return renderOption;
}
+
+ /**
+ * reset the rendered files in render context
+ * called by HTMLEmitter during initialization
+ */
+ public void clearRenderedFiles()
+ {
+ renderedFiles.clear();
+ }
+
+ /**
+ * add the rendered file to the render context
+ */
+ public void addRenderedFile(String renderedFile)
+ {
+ renderedFiles.add(renderedFile);
+ }
+
+ /**
+ * remove the rendered file from the render context
+ */
+ public void removeRenderedFile(String renderedFile)
+ {
+ renderedFiles.remove(renderedFile);
+ }
+
+ /**
+ * get all the rendered files for this render context
+ *
+ * @return an array of absolute path of the rendered files
+ */
+ public String[] getRenderedFiles()
+ {
+ int siz = renderedFiles.size();
+ String[] arr = null;
+
+ if (siz > 0)
+ arr = (String[]) renderedFiles.toArray(new String[siz]);
+
+ return arr;
+ }
}
Index: src/org/eclipse/birt/report/engine/api/IRunAndRenderTask.java
===================================================================
RCS file: /cvsroot/birt/source/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/api/IRunAndRenderTask.java,v
retrieving revision 1.7
diff -u -r1.7 IRunAndRenderTask.java
--- src/org/eclipse/birt/report/engine/api/IRunAndRenderTask.java 30 Nov 2005 00:20:57 -0000 1.7
+++ src/org/eclipse/birt/report/engine/api/IRunAndRenderTask.java 6 Feb 2007 21:44:30 -0000
@@ -43,4 +43,18 @@
* @param id the identifier for the emitter
*/
public abstract void setEmitterID(String id);
+
+ /**
+ * Get all relevant rendered files that the emitter emits. First element of the
+ * array is the primary report file, (e.g.: .html, .pdf, etc.) followed by any
+ * file(s) that are associated with the rendered report. If the primary report
+ * file is rendered as stream, then it will contain null.
+ *
+ * @return an array of absolute path of the rendered files; null if the report
+ * has not been rendered yet.
+ *
+ * @exception EngineException
+ */
+ public abstract String[] getRenderedFiles() throws EngineException;
+
}
\ No newline at end of file
Index: src/org/eclipse/birt/report/engine/api/IRenderTask.java
===================================================================
RCS file: /cvsroot/birt/source/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/api/IRenderTask.java,v
retrieving revision 1.10
diff -u -r1.10 IRenderTask.java
--- src/org/eclipse/birt/report/engine/api/IRenderTask.java 10 Jun 2006 08:56:29 -0000 1.10
+++ src/org/eclipse/birt/report/engine/api/IRenderTask.java 6 Feb 2007 21:44:29 -0000
@@ -135,4 +135,17 @@
* render( );
*/
public abstract void render( InstanceID iid ) throws EngineException;
+
+ /**
+ * Get all relevant rendered files that the emitter emits. First element of the
+ * array is the primary report file, (e.g.: .html, .pdf, etc.) followed by any
+ * file(s) that are associated with the rendered report. If the primary report
+ * file is rendered as stream, then it will contain null.
+ *
+ * @return an array of absolute path of the rendered files; null if the report
+ * has not been rendered yet.
+ *
+ * @exception EngineException
+ */
+ public abstract String[] getRenderedFiles() throws EngineException;
}
Index: src/org/eclipse/birt/report/engine/api/IReportEngine.java
===================================================================
RCS file: /cvsroot/birt/source/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/api/IReportEngine.java,v
retrieving revision 1.12
diff -u -r1.12 IReportEngine.java
--- src/org/eclipse/birt/report/engine/api/IReportEngine.java 5 Feb 2007 09:50:15 -0000 1.12
+++ src/org/eclipse/birt/report/engine/api/IReportEngine.java 6 Feb 2007 21:44:30 -0000
@@ -274,4 +274,27 @@
* shut down the engine, release all the resources.
*/
public void shutdown( );
+
+ /**
+ * creates a report delivery task
+ *
+ * @param deliveryType the delivery type (MAIL, FTP, etc.)
+ *
+ * @return IDeliveryTask the delivery task object
+ */
+ public IDeliveryTask createDeliveryTask( String deliveryType );
+
+ /**
+ * return all supported delivery types
+ * @return all supported delivery types
+ */
+ public String[] getSupportedDeliveryType( );
+
+ /**
+ * return all delivery extension information
+ * @return all delivery extension information
+ */
+ public DeliveryInfo[] getDeliveryInfo( );
+
+
}
Index: src/org/eclipse/birt/report/engine/extension/internal/ExtensionManager.java
===================================================================
RCS file: /cvsroot/birt/source/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/extension/internal/ExtensionManager.java,v
retrieving revision 1.19
diff -u -r1.19 ExtensionManager.java
--- src/org/eclipse/birt/report/engine/extension/internal/ExtensionManager.java 1 Feb 2007 10:22:46 -0000 1.19
+++ src/org/eclipse/birt/report/engine/extension/internal/ExtensionManager.java 6 Feb 2007 21:44:31 -0000
@@ -22,20 +22,23 @@
import org.eclipse.birt.core.framework.IExtensionPoint;
import org.eclipse.birt.core.framework.IExtensionRegistry;
import org.eclipse.birt.core.framework.Platform;
+import org.eclipse.birt.report.engine.api.DeliveryInfo;
import org.eclipse.birt.report.engine.api.EmitterInfo;
+import org.eclipse.birt.report.engine.delivery.IDelivery;
import org.eclipse.birt.report.engine.emitter.IContentEmitter;
import org.eclipse.birt.report.engine.extension.IReportItemGeneration;
import org.eclipse.birt.report.engine.extension.IReportItemPresentation;
import org.eclipse.birt.report.engine.extension.IReportItemQuery;
/**
- * Manages engine extensions. Currently, engine supports 4 types of extensions: emitters,
- * extended items Query, Generation, Presentation time extensions
+ * Manages engine extensions. Currently, engine supports 5 types of extensions: emitters,
+ * extended items Query, Generation, Presentation time and delivery extensions.
*/
public class ExtensionManager
{
protected static Logger logger = Logger.getLogger( ExtensionManager.class.getName( ) );
+ public final static String EXTENSION_POINT_DELIVERY = "org.eclipse.birt.report.engine.delivery"; //$NON-NLS-1$
public final static String EXTENSION_POINT_EMITTERS = "org.eclipse.birt.report.engine.emitters"; //$NON-NLS-1$
public final static String EXTENSION_POINT_GENERATION = "org.eclipse.birt.report.engine.reportitemGeneration"; //$NON-NLS-1$
public final static String EXTENSION_POINT_PRESENTATION = "org.eclipse.birt.report.engine.reportitemPresentation"; //$NON-NLS-1$
@@ -66,6 +69,7 @@
*/
protected ArrayList emitterExtensions = new ArrayList();
+
/**
* stores all the mime types that are supported
*/
@@ -74,6 +78,18 @@
protected HashMap emitters = new HashMap();
/**
+ * stores all the delivery extensions
+ */
+ protected ArrayList deliveryExtensions = new ArrayList();
+
+ /**
+ * stores all the delivery type that are supported
+ */
+ protected HashMap deliveryTypes = new HashMap();
+
+ protected HashMap deliveryProviders = new HashMap();
+
+ /**
* HTML pagination.
*/
public static final String PAGE_BREAK_PAGINATION = "page-break-pagination";
@@ -98,6 +114,7 @@
loadPresentationExtensionDefns();
loadQueryExtensionDefns();
loadEmitterExtensionDefns();
+ loadDeliveryExtensionDefns();
}
/**
@@ -243,6 +260,55 @@
}
/**
+ * @param deliveryType that the extension point supports
+ * @param id the specified delivery extension id
+ *
+ * @return a delivery extension
+ */
+ public IDelivery createDeliveryExtension(String deliveryType, String id)
+ {
+ if (deliveryType == null)
+ {
+ return null;
+ }
+
+ IConfigurationElement config = null;
+ int numDeliveryExtensions = deliveryExtensions.size();
+ for (int i=0; i < numDeliveryExtensions; i++)
+ {
+ DeliveryInfo deliveryInfo = (DeliveryInfo)deliveryExtensions.get(i);
+ if (deliveryType.equalsIgnoreCase(deliveryInfo.getDeliveryType( )))
+ {
+ if (id != null && id.equalsIgnoreCase((deliveryInfo.getID())) || id == null)
+ {
+ config = deliveryInfo.getDeliveryExtensionElement( );
+ break;
+ }
+ }
+ }
+
+ if (config != null)
+ {
+ Object object = createObject(config, "class"); //$NON-NLS-1$
+ if (object instanceof IDelivery)
+ {
+ return (IDelivery)object;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * @param deliveryType that the extension point supports
+ * @return a delivery extension
+ */
+ public IDelivery createDeliveryExtension(String deliveryType)
+ {
+ return createDeliveryExtension(deliveryType, null);
+ }
+
+ /**
* @return all the emitter extensions
*/
public Collection getSupportedFormat()
@@ -251,6 +317,15 @@
}
/**
+ * return all supported delivery types
+ * @return all supported delivery types
+ */
+ public Collection getSupportedDeliveryType()
+ {
+ return deliveryTypes.keySet();
+ }
+
+ /**
* return all emitter informations
* @return all emitter informations
*/
@@ -266,6 +341,21 @@
}
/**
+ * return all delivery extension information
+ * @return all delivery extension information
+ */
+ public DeliveryInfo[] getDeliveryInfo( )
+ {
+ DeliveryInfo[] infos = new DeliveryInfo[deliveryProviders.size( )];
+ Object[] keys = deliveryProviders.keySet( ).toArray( );
+ for ( int index = 0, length = keys.length; index < length; index++ )
+ {
+ infos[index] = (DeliveryInfo) deliveryProviders.get( keys[index].toString( ) );
+ }
+ return infos;
+ }
+
+ /**
* @param config
* @param property
* @return
@@ -397,6 +487,38 @@
}
/**
+ * load delivery extension definitions
+ */
+ protected void loadDeliveryExtensionDefns()
+ {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint extPoint = registry.getExtensionPoint(EXTENSION_POINT_DELIVERY);
+ if (extPoint == null)
+ return;
+
+ IExtension[] exts = extPoint.getExtensions();
+ logger.log(Level.FINE, "Start load extension point: {0}", EXTENSION_POINT_DELIVERY); //$NON-NLS-1$
+ for (int i = 0; i < exts.length; i++)
+ {
+ String namespace = exts[i].getNamespace( );
+ IConfigurationElement[] configs = exts[i].getConfigurationElements();
+ for (int j = 0; j < configs.length; j++)
+ {
+ String typ = configs[j].getAttribute("type"); //$NON-NLS-1$
+ String name = configs[j].getAttribute("name"); //$NON-NLS-1$
+ String id = configs[j].getAttribute("id"); //$NON-NLS-1$
+ DeliveryInfo deliveryInfo = new DeliveryInfo( typ, id, name,
+ namespace, configs[j] );
+ deliveryExtensions.add(deliveryInfo);
+ assert( typ != null );
+ deliveryTypes.put( typ.toLowerCase( ), deliveryInfo);
+ deliveryProviders.put( id, deliveryInfo );
+ logger.log(Level.FINE, "Load {0} delivery {1}", new String[]{typ, id}); //$NON-NLS-1$
+ }
+ }
+ }
+
+ /**
* @param format the output format
* @return the mime type for the specific format
*/
Index: src/org/eclipse/birt/report/engine/i18n/Messages.properties
===================================================================
RCS file: /cvsroot/birt/source/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/i18n/Messages.properties,v
retrieving revision 1.19
diff -u -r1.19 Messages.properties
--- src/org/eclipse/birt/report/engine/i18n/Messages.properties 9 Nov 2006 03:39:31 -0000 1.19
+++ src/org/eclipse/birt/report/engine/i18n/Messages.properties 6 Feb 2007 21:44:31 -0000
@@ -7,11 +7,13 @@
Error.Msg001=En: There is a {0} in the {1}.
###########################################################
+Error.DeliveryTypeNotSupported=The delivery type {0} is not supported.
Error.OutputFormatNotSupported=The output format {0} is not supported.
Error.InvalidParameter=Some required parameter values are not set or set to incompatible data type.
Error.InvalidDesignFile=The design file {0} has error and can not be run.
Error.DesignFileNotFound=The design file {0} can not be found.
Error.CannotCreateExtensionInstance=Report engine fails to initialize {0} emitter, please make sure required libraries for this emitter are installed.
+Error.CannotCreateDeliveryExtensionInstance=Report engine fails to initialize {0} delivery extension, please make sure required libraries for this delivery extension are installed.
Error.MissingComputedColumnExpression=The expression for computed column {0} is missing.
###########################################################
Index: src/org/eclipse/birt/report/engine/i18n/MessageConstants.java
===================================================================
RCS file: /cvsroot/birt/source/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/i18n/MessageConstants.java,v
retrieving revision 1.18
diff -u -r1.18 MessageConstants.java
--- src/org/eclipse/birt/report/engine/i18n/MessageConstants.java 23 May 2006 21:46:38 -0000 1.18
+++ src/org/eclipse/birt/report/engine/i18n/MessageConstants.java 6 Feb 2007 21:44:31 -0000
@@ -21,11 +21,13 @@
public static final String TEST_ERROR_MESSAGE_00 = "Error.Msg001"; //$NON-NLS-1$
// Exceptions
+ public static final String DELIVERY_TYPE_NOT_SUPPORTED_EXCEPTION = "Error.DeliveryTypeNotSupported"; //$NON-NLS-1$
public static final String FORMAT_NOT_SUPPORTED_EXCEPTION = "Error.OutputFormatNotSupported"; //$NON-NLS-1$
public static final String INVALID_PARAMETER_EXCEPTION = "Error.InvalidParameter"; //$NON-NLS-1$
public static final String DESIGN_FILE_NOT_FOUND_EXCEPTION = "Error.DesignFileNotFound"; //$NON-NLS-1$
public static final String INVALID_DESIGN_FILE_EXCEPTION = "Error.InvalidDesignFile"; //$NON-NLS-1$
public static final String CANNOT_CREATE_EMITTER_EXCEPTION = "Error.CannotCreateExtensionInstance"; //$NON-NLS-1$
+ public static final String CANNOT_CREATE_DELIVERY_EXCEPTION = "Error.CannotCreateDeliveryExtensionInstance"; //$NON-NLS-1$
public static final String MISSING_COMPUTED_COLUMN_EXPRESSION_EXCEPTION = "Error.MissingComputedColumnExpression"; //$NON-NLS-1$
// Page Errors
Index: META-INF/MANIFEST.MF
===================================================================
RCS file: /cvsroot/birt/source/org.eclipse.birt.report.engine/META-INF/MANIFEST.MF,v
retrieving revision 1.16
diff -u -r1.16 MANIFEST.MF
--- META-INF/MANIFEST.MF 8 Dec 2006 03:33:32 -0000 1.16
+++ META-INF/MANIFEST.MF 6 Feb 2007 21:44:29 -0000
@@ -27,6 +27,7 @@
org.eclipse.birt.report.engine.css.engine.value.css,
org.eclipse.birt.report.engine.data,
org.eclipse.birt.report.engine.data.dte,
+ org.eclipse.birt.report.engine.delivery,
org.eclipse.birt.report.engine.emitter,
org.eclipse.birt.report.engine.executor,
org.eclipse.birt.report.engine.executor.buffermgr,
@@ -35,10 +36,10 @@
org.eclipse.birt.report.engine.extension,
org.eclipse.birt.report.engine.extension.internal,
org.eclipse.birt.report.engine.i18n,
- org.eclipse.birt.report.engine.internal.document; x-friends:="org.eclipse.birt.report.engine.tests",
- org.eclipse.birt.report.engine.internal.document.v2; x-friends:="org.eclipse.birt.report.engine.tests",
- org.eclipse.birt.report.engine.internal.executor.doc; x-friends:="org.eclipse.birt.report.engine.tests",
- org.eclipse.birt.report.engine.internal.executor.dom; x-friends:="org.eclipse.birt.report.engine.tests",
+ org.eclipse.birt.report.engine.internal.document;x-friends:="org.eclipse.birt.report.engine.tests",
+ org.eclipse.birt.report.engine.internal.document.v2;x-friends:="org.eclipse.birt.report.engine.tests",
+ org.eclipse.birt.report.engine.internal.executor.doc;x-friends:="org.eclipse.birt.report.engine.tests",
+ org.eclipse.birt.report.engine.internal.executor.dom;x-friends:="org.eclipse.birt.report.engine.tests",
org.eclipse.birt.report.engine.internal.util,
org.eclipse.birt.report.engine.ir,
org.eclipse.birt.report.engine.layout,
Index: src/org/eclipse/birt/report/engine/api/impl/EngineTask.java
===================================================================
RCS file: /cvsroot/birt/source/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/api/impl/EngineTask.java,v
retrieving revision 1.52
diff -u -r1.52 EngineTask.java
--- src/org/eclipse/birt/report/engine/api/impl/EngineTask.java 2 Feb 2007 07:45:20 -0000 1.52
+++ src/org/eclipse/birt/report/engine/api/impl/EngineTask.java 6 Feb 2007 21:44:31 -0000
@@ -11,6 +11,7 @@
package org.eclipse.birt.report.engine.api.impl;
+import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
@@ -1211,4 +1212,54 @@
emitter.initialize( services );
}
+ /**
+ * get the absolute path of the primary rendered file
+ *
+ * @param format output format (html, pdf, etc.)
+ *
+ * @return absolute path of the primary rendered file, null if
+ * the reported was rendered as a stream or not found.
+ */
+ protected String getPrimaryRenderedFile(String format)
+ {
+ String file = null;
+ Object outputFile = renderOptions.getOutputFileName( );
+ Object outputStream = renderOptions.getOutputStream( );
+
+ // report output file takes precedence
+ if (outputFile != null)
+ {
+ File f = null;
+ try {
+ f = new File(outputFile.toString());
+ if (f.exists())
+ file = f.getAbsolutePath();
+ }
+ catch (Exception ex) { }
+ }
+ else if (outputStream != null)
+ {
+ file = null;
+ }
+ else
+ {
+ // neither specified.
+ File f = null;
+
+ // FIX: default file should be query from the emitter.
+ if (format != null) {
+ String defaultReportFile = "report."
+ + format.toLowerCase();
+ try {
+ f = new File( defaultReportFile );
+ if (f.exists())
+ file = f.getAbsolutePath();
+ }
+ catch (Exception ex) {
+ }
+ }
+ }
+
+ return file;
+ }
}
\ No newline at end of file
Index: src/org/eclipse/birt/report/engine/api/impl/RenderTask.java
===================================================================
RCS file: /cvsroot/birt/source/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/api/impl/RenderTask.java,v
retrieving revision 1.57
diff -u -r1.57 RenderTask.java
--- src/org/eclipse/birt/report/engine/api/impl/RenderTask.java 1 Feb 2007 10:22:21 -0000 1.57
+++ src/org/eclipse/birt/report/engine/api/impl/RenderTask.java 6 Feb 2007 21:44:31 -0000
@@ -28,6 +28,7 @@
import org.eclipse.birt.report.engine.api.UnsupportedFormatException;
import org.eclipse.birt.report.engine.emitter.CompositeContentEmitter;
import org.eclipse.birt.report.engine.emitter.IContentEmitter;
+import org.eclipse.birt.report.engine.emitter.IEmitterRenderInfo;
import org.eclipse.birt.report.engine.executor.IReportExecutor;
import org.eclipse.birt.report.engine.executor.OnPageBreakLayoutPageHandle;
import org.eclipse.birt.report.engine.executor.ReportExecutor;
@@ -363,10 +364,19 @@
innerRender = new ReportletRender( bookmark );
}
+ public String[] getRenderedFiles() throws EngineException
+ {
+ return innerRender.getRenderedFiles();
+ }
+
private abstract class InnerRender
{
+ protected String[] renderedFiles;
+
void render() throws EngineException
{
+ renderedFiles = null;
+
try
{
setupRenderOption( );
@@ -414,6 +424,7 @@
closeRender( );
executor.close( );
}
+ getRenderedFiles(emitter);
}
catch ( EngineException e )
{
@@ -450,6 +461,26 @@
protected abstract void load( ReportContentLoader loader,
IContentEmitter emitter );
+
+ protected void getRenderedFiles(IContentEmitter emitter) throws EngineException
+ {
+ if (emitter instanceof IEmitterRenderInfo)
+ {
+ IEmitterRenderInfo info = (IEmitterRenderInfo)emitter;
+ renderedFiles = info.getRenderedFiles();
+ }
+ else
+ {
+ String[] reportFile = new String[1];
+ reportFile[0] = getPrimaryRenderedFile(emitter.getOutputFormat());
+ renderedFiles = reportFile;
+ }
+ }
+
+ public String[] getRenderedFiles() throws EngineException {
+
+ return renderedFiles;
+ }
}
/**
Index: plugin.xml
===================================================================
RCS file: /cvsroot/birt/source/org.eclipse.birt.report.engine/plugin.xml,v
retrieving revision 1.16
diff -u -r1.16 plugin.xml
--- plugin.xml 21 Mar 2006 11:11:49 -0000 1.16
+++ plugin.xml 6 Feb 2007 21:44:29 -0000
@@ -5,6 +5,7 @@
+
0)
+ {
+ IConfigurationElement propertiesElement =
+ propertiesElements[propertiesElements.length-1];
+ deliveryProps = getPropertiesDefns(propertiesElement);
+ }
+ }
+
+ return deliveryProps;
+ }
+
+ private static Properties getPropertiesDefns(IConfigurationElement propertiesElement) {
+
+ IConfigurationElement[] propsElement = propertiesElement.getChildren( "property" );
+ Properties props = new Properties();
+
+ int numProps = propsElement.length;
+ for(int i = 0; i < numProps; i++)
+ {
+ IConfigurationElement propElement = propsElement[i];
+
+ String propName = propElement.getAttribute( "name" );
+ String propValue = propElement.getAttribute( "value" );
+ props.setProperty( propName, propValue );
+ }
+
+ return props;
+ }
+}
+
Index: src/org/eclipse/birt/report/engine/emitter/IEmitterRenderInfo.java
===================================================================
RCS file: src/org/eclipse/birt/report/engine/emitter/IEmitterRenderInfo.java
diff -N src/org/eclipse/birt/report/engine/emitter/IEmitterRenderInfo.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/birt/report/engine/emitter/IEmitterRenderInfo.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,20 @@
+package org.eclipse.birt.report.engine.emitter;
+
+/**
+ * Emitters implement this interface to return the rendered files
+ * associated with a rendered report.
+ */
+public interface IEmitterRenderInfo {
+ /**
+ * Get all relevant rendered files that the emitter emits. First element of the
+ * array is the primary report file, (e.g.: .html, .pdf, etc.) followed by any
+ * file(s) that are associated with the rendered report. If the primary report
+ * file is rendered as stream, then it will contain null.
+ *
+ * @return an array of absolute path of the rendered files; null if the report
+ * has not been rendered yet.
+ *
+ */
+ public String[] getRenderedFiles();
+
+}
Index: src/org/eclipse/birt/report/engine/delivery/IDeliveryServices.java
===================================================================
RCS file: src/org/eclipse/birt/report/engine/delivery/IDeliveryServices.java
diff -N src/org/eclipse/birt/report/engine/delivery/IDeliveryServices.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/birt/report/engine/delivery/IDeliveryServices.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,26 @@
+package org.eclipse.birt.report.engine.delivery;
+
+import java.util.Properties;
+
+import org.eclipse.birt.report.engine.api.IEngineTask;
+
+/**
+ * IDeliveryServices interface provide delivery configuration and
+ * options to the delivery extensions.
+ */
+public interface IDeliveryServices {
+
+ /**
+ * Get the delivery configuration
+ *
+ * @return the delivery configuration
+ */
+ public Properties getDeliveryConfig();
+
+ /**
+ *
+ * @return the engine task
+ */
+ public IEngineTask getTask();
+}
+
Index: src/org/eclipse/birt/report/engine/util/MimeFileNameMap.java
===================================================================
RCS file: src/org/eclipse/birt/report/engine/util/MimeFileNameMap.java
diff -N src/org/eclipse/birt/report/engine/util/MimeFileNameMap.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/birt/report/engine/util/MimeFileNameMap.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,117 @@
+package org.eclipse.birt.report.engine.util;
+
+import java.net.FileNameMap;
+import java.util.Hashtable;
+
+/**
+ * Common MIME types map
+ */
+public class MimeFileNameMap implements FileNameMap {
+
+ private static Hashtable map = new Hashtable(71);
+
+ private static final String DEFAULT_MIME_TYPE = "application/octet-stream";
+
+ public MimeFileNameMap() {
+ }
+
+ // common MIME mapping
+ static {
+
+ // text
+ map.put("css", "text/css");
+ map.put("csv", "text/csv");
+ map.put("htm", "text/html");
+ map.put("html", "text/html");
+ map.put("txt", "text/plain");
+ map.put("text", "text/plain");
+ map.put("xml", "text/xml");
+ map.put("xsl", "test/xml");
+
+ // image
+ map.put("bmp", "image/bmp");
+ map.put("gif", "image/gif");
+ map.put("ief", "image/ief");
+ map.put("jpg", "image/jpeg");
+ map.put("jpe", "image/jpeg");
+ map.put("jpeg", "image/jpeg");
+ map.put("png", "image/png");
+ map.put("svg", "image/svg+xml");
+ map.put("tif", "image/tiff");
+ map.put("tiff", "image/tiff");
+
+ // application
+ map.put("ai", "application/postscript");
+ map.put("bin", "application/octet-stream");
+ map.put("doc", "application/msword");
+ map.put("eps", "application/postscript");
+ map.put("exe", "application/octet-stream");
+ map.put("oda", "application/oda");
+ map.put("pdf", "application/pdf");
+ map.put("ppt", "application/vnd.ms-powerpoint");
+ map.put("ps", "application/postscript");
+ map.put("rtf", "application/rtf");
+ map.put("xls", "application/vnd.ms-excel");
+ map.put("zip", "application/zip");
+
+ // audio
+ map.put("aif", "audio/x-aiff");
+ map.put("aiff", "audio/x-aiff");
+ map.put("au", "audio/basic");
+ map.put("mid", "audio/midi");
+ map.put("midi", "audio/midi");
+ map.put("wav", "audio/x-wav");
+
+ // video
+ map.put("avi", "video/x-msvideo");
+ map.put("mpe", "video/mpeg");
+ map.put("mpeg", "video/mpeg");
+ map.put("mpg", "video/mpeg");
+ map.put("mov", "video/quicktime");
+ map.put("qt", "video/quicktime");
+ }
+
+ private static String getContentType(String extension) {
+ String key = extension.toLowerCase();
+ String mimetype = (String) map.get(key);
+ if (mimetype != null)
+ return mimetype;
+ else
+ return DEFAULT_MIME_TYPE;
+ }
+
+ private static String getFileExtension(String filename) {
+
+ if (filename == null)
+ return null;
+
+ int pos = filename.lastIndexOf('.');
+
+ if (pos != -1)
+ return filename.substring(pos + 1);
+ else
+ return null;
+ }
+
+ public void addContentType(String extension, String mimetype) {
+ map.put(extension, mimetype.toLowerCase());
+ }
+
+ public void removeContentType(String extension) {
+ map.remove(extension);
+ }
+
+ public String getContentTypeFor(String fileName) {
+
+ String extension = getFileExtension(fileName);
+
+ if (extension != null) {
+ return getContentType(extension);
+ }
+ else {
+ return DEFAULT_MIME_TYPE;
+ }
+ }
+
+}
+
Index: src/org/eclipse/birt/report/engine/delivery/DeliveryException.java
===================================================================
RCS file: src/org/eclipse/birt/report/engine/delivery/DeliveryException.java
diff -N src/org/eclipse/birt/report/engine/delivery/DeliveryException.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/birt/report/engine/delivery/DeliveryException.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,85 @@
+package org.eclipse.birt.report.engine.delivery;
+
+import org.eclipse.birt.core.exception.BirtException;
+import org.eclipse.birt.core.i18n.ResourceHandle;
+
+import com.ibm.icu.util.ULocale;
+import com.ibm.icu.util.UResourceBundle;
+
+public class DeliveryException extends BirtException {
+
+ private static final long serialVersionUID = 1L;
+
+ static protected UResourceBundle rb = new ResourceHandle(ULocale.getDefault()).getUResourceBundle();
+
+ private String deliveryType;
+
+ /**
+ * @param pluginId
+ * Returns the unique identifier of the plug-in associated with
+ * this exception
+ * @param deliveryType
+ * the delivery type
+ * @param errorCode
+ * used to retrieve a piece of externalized message displayed to
+ * end user.
+ * @param cause
+ * the nested exception
+ */
+ public DeliveryException(String pluginId, String deliveryType, String errorCode, Throwable cause)
+ {
+ super(pluginId, errorCode, rb, cause);
+ this.deliveryType = deliveryType;
+ }
+
+ /**
+ * @param pluginId
+ * Returns the unique identifier of the plug-in associated with
+ * this exception
+ * @param deliveryType
+ * the delivery type
+ * @param errorCode
+ * used to retrieve a piece of externalized message displayed to
+ * end user.
+ * @param arg0
+ * first argument used to format error messages
+ * @param cause
+ * the nested exception
+ */
+ public DeliveryException(String pluginId, String deliveryType, String errCode, Object arg0, Throwable cause)
+ {
+ super(pluginId, errCode, arg0, rb, cause);
+ this.deliveryType = deliveryType;
+ }
+
+ /**
+ * @param pluginId
+ * Returns the unique identifier of the plug-in associated with
+ * this exception
+ * @param deliveryType
+ * the delivery type
+ * @param errorCode
+ * used to retrieve a piece of externalized message displayed to
+ * end user.
+ * @param args
+ * string arguments used to format error messages
+ * @param cause
+ * the nested exception
+ */
+ public DeliveryException(String pluginId, String deliveryType, String errCode, Object[] args, Throwable cause)
+ {
+ super(pluginId, errCode, args, rb, cause);
+ this.deliveryType = deliveryType;
+ }
+
+ /**
+ * get the delivery type
+ *
+ * @return the delivery type
+ */
+ public String getDeliveryType()
+ {
+ return deliveryType;
+ }
+}
+
Index: src/org/eclipse/birt/report/engine/delivery/EngineDeliveryServices.java
===================================================================
RCS file: src/org/eclipse/birt/report/engine/delivery/EngineDeliveryServices.java
diff -N src/org/eclipse/birt/report/engine/delivery/EngineDeliveryServices.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/birt/report/engine/delivery/EngineDeliveryServices.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,105 @@
+package org.eclipse.birt.report.engine.delivery;
+
+import java.util.Enumeration;
+import java.util.Properties;
+
+import org.eclipse.birt.report.engine.api.IEngineTask;
+
+
+public class EngineDeliveryServices implements IDeliveryServices {
+
+ /**
+ * the delivery extension configuration
+ */
+ protected Properties deliveryConfig;
+
+ /**
+ * The task that results in this
+ */
+ protected IEngineTask task;
+
+ /**
+ * The delivery type
+ */
+ protected String deliveryType;
+
+ /**
+ * The delivery extension name
+ */
+ protected String deliveryName;
+
+ /**
+ * The delivery extension id
+ */
+ protected String deliveryId;
+
+ /**
+ * ctor
+ *
+ * @param task the engine task
+ */
+ public EngineDeliveryServices(IEngineTask task)
+ {
+ this.task = task;
+ }
+
+ public void setDeliveryConfig(Properties config) {
+
+ Properties dst = new Properties();
+
+ copyProperties(dst, config);
+
+ this.deliveryConfig = dst;
+ }
+
+ public Properties getDeliveryConfig() {
+ return this.deliveryConfig;
+ }
+
+ /**
+ * @return Returns the task.
+ */
+ public IEngineTask getTask( )
+ {
+ return this.task;
+ }
+
+ public String getDeliveryID() {
+ return this.deliveryId;
+ }
+
+ public void setDeliveryID(String id)
+ {
+ this.deliveryId = id;
+ }
+
+ public String getDeliveryName() {
+ return this.deliveryName;
+ }
+
+ public void setDeliveryName(String name)
+ {
+ this.deliveryName = name;
+ }
+
+ public String getDeliveryType()
+ {
+ return this.deliveryType;
+ }
+
+ public void setDeliveryType(String type)
+ {
+ this.deliveryType = type;
+ }
+
+ private static void copyProperties(Properties dst, Properties src) {
+ if (dst == null || src == null) return;
+
+ for (Enumeration names = src.propertyNames(); names.hasMoreElements();) {
+ Object key = names.nextElement();
+ dst.put(key, src.get(key));
+ }
+ }
+
+}
+
Index: schema/delivery.exsd
===================================================================
RCS file: schema/delivery.exsd
diff -N schema/delivery.exsd
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ schema/delivery.exsd 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,200 @@
+
+
+
+
+
+
+
+
+ This extension point allows custom report delivery.
+
+
+
+
+
+
+ Root element for delivery extension.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ A delivery extension that provides custom report delivery.
+
+
+
+
+
+
+
+
+
+ an optional identifier of the delivery extension
+
+
+
+
+
+
+ the name of the delivery extension
+
+
+
+
+
+
+ the type of delivery this delivery extension provides. (MAIL, FTP, etc.)
+
+
+
+
+
+
+ a fully qualified name of the java class that implements <code>org.eclipse.birt.report.engine.delivery.IDelivery</code> interface.
+
+
+
+
+
+
+
+
+
+
+
+
+ a list of delivery extension property
+
+
+
+
+
+
+
+
+
+
+
+
+ a delivery extension property
+
+
+
+
+
+
+ property name
+
+
+
+
+
+
+ property value
+
+
+
+
+
+
+
+
+
+
+
+ 2.2
+
+
+
+
+
+
+
+
+ The following is a sample usage of the delivery extension point:
+
+<p>
+<pre>
+<extension
+ point="org.eclipse.birt.report.engine.delivery"
+ name = "Delivery Engine">
+
+ <delivery
+ type="MAIL"
+ name="Mail Delivery"
+ id="org.eclipse.birt.report.engine.delivery.mail"
+ class="org.eclipse.birt.report.engine.delivery.mail.MailDelivery">
+ <properties>
+ <property name="mail.host" value="" />
+ </properties>
+ </delivery>
+
+</extension>
+
+</pre>
+
+
+
+
+
+
+
+
+ The value of the class attribute for the delivery element must be the fully qualified name of a class that implements <code>org.eclipse.birt.engine.delivery.IDelivery</code>.
+<p>
+
+
+
+
+
+
+
+
+ <code>org.eclipse.birt.report.engine.delivery.mail.MailDelivery</code> ---- An e-mail delivery extension that supports SMTP report delivery.
+
+
+
+
+
+
+
+
+ Copyright (c) 2007 All rights reserved.
+This program and the accompanying materials are made available under
+the terms of the Eclipse Public License v1.0 which accompanies this
+distribution, and is available at http://www.eclipse.org/legal/epl-v10.html<br><br>
+
+
+
+
Index: src/org/eclipse/birt/report/engine/delivery/IDelivery.java
===================================================================
RCS file: src/org/eclipse/birt/report/engine/delivery/IDelivery.java
diff -N src/org/eclipse/birt/report/engine/delivery/IDelivery.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/birt/report/engine/delivery/IDelivery.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,59 @@
+package org.eclipse.birt.report.engine.delivery;
+
+import java.util.Properties;
+
+/**
+ * All delivery extensions are required to implement
+ * the IDelivery interface.
+ */
+public interface IDelivery {
+
+ /**
+ * Initialize the delivery extension
+ *
+ * @param IDeliveryServices provides various information for the delivery extension
+ * such as delivery configuration, options, etc.
+ *
+ * @exception throws DeliveryException on error
+ */
+ public void initialize(IDeliveryServices service) throws DeliveryException;
+
+ /**
+ * Get the delivery type
+ *
+ * @return the delivery type (MAIL, FTP, etc.)
+ */
+ public String getDeliveryType();
+
+ /**
+ * Get the delivery extension name
+ *
+ * @return the delivery extension name
+ */
+ public String getDeliveryName();
+
+ /**
+ * Get the delivery extension id
+ *
+ * @return the delivery id
+ */
+ public String getDeliveryID();
+
+ /**
+ * Validate the delivery configuration
+ *
+ * @exception throws DeliveryException on error
+ */
+ public void validateConfiguration(Properties config) throws DeliveryException;
+
+
+ /**
+ * Deliver the rendered files
+ *
+ * @param fileInfos the files to be delivered by this extension
+ *
+ * @exception throws DeliveryException on error
+ */
+ public void deliver(IRenderedFileInfo[] fileInfos) throws DeliveryException;
+}
+