[jbpm-commits] JBoss JBPM SVN: r4899 - in projects/report-server/trunk: core and 2 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue May 26 09:45:43 EDT 2009


Author: heiko.braun at jboss.com
Date: 2009-05-26 09:45:43 -0400 (Tue, 26 May 2009)
New Revision: 4899

Added:
   projects/report-server/trunk/core/src/main/java/org/jboss/bpm/report/FileWriter.java
   projects/report-server/trunk/core/src/main/java/org/jboss/bpm/report/JMXServerConfig.java
   projects/report-server/trunk/core/src/main/java/org/jboss/bpm/report/ReportFacade.java
Removed:
   projects/report-server/trunk/server/src/main/java/org/jboss/bpm/report/FileWriter.java
   projects/report-server/trunk/server/src/main/java/org/jboss/bpm/report/JMXServerConfig.java
   projects/report-server/trunk/server/src/main/java/org/jboss/bpm/report/ReportFacade.java
Modified:
   projects/report-server/trunk/core/pom.xml
   projects/report-server/trunk/report-server.iws
Log:
Move REST facade to core module for easier consumption

Modified: projects/report-server/trunk/core/pom.xml
===================================================================
--- projects/report-server/trunk/core/pom.xml	2009-05-26 13:35:58 UTC (rev 4898)
+++ projects/report-server/trunk/core/pom.xml	2009-05-26 13:45:43 UTC (rev 4899)
@@ -1,176 +1,187 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-   <modelVersion>4.0.0</modelVersion>
-   <name>JBoss BPM - Report Core</name>
-   <groupId>org.jboss.bpm</groupId>
-   <artifactId>report-core</artifactId>
-   <packaging>jar</packaging>
+  <modelVersion>4.0.0</modelVersion>
+  <name>JBoss BPM - Report Core</name>
+  <groupId>org.jboss.bpm</groupId>
+  <artifactId>report-core</artifactId>
+  <packaging>jar</packaging>
 
-   <!-- Parent -->
-   <parent>
-      <groupId>org.jboss.bpm</groupId>
-      <artifactId>report-parent</artifactId>
-      <version>1.0.0-SNAPSHOT</version>
-      <relativePath>../pom.xml</relativePath>
-   </parent>
+  <!-- Parent -->
+  <parent>
+    <groupId>org.jboss.bpm</groupId>
+    <artifactId>report-parent</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+    <relativePath>../pom.xml</relativePath>
+  </parent>
 
-   <properties>
-      <birt.version>2.3.2</birt.version>
-   </properties>
+  <properties>
+    <birt.version>2.3.2</birt.version>
+  </properties>
 
-   <dependencies>
-      <!-- Other -->
-      <dependency>
-         <groupId>commons-logging</groupId>
-         <artifactId>commons-logging</artifactId>
-      </dependency>
+  <dependencies>
+    <!-- Other -->
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+    </dependency>
 
-      <dependency>
-         <groupId>junit</groupId>
-         <artifactId>junit</artifactId>
-         <scope>test</scope>
-      </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
 
-      <dependency>
-         <groupId>org.eclipse.birt</groupId>
-         <artifactId>engineapi</artifactId>
-         <version>${birt.version}</version>
-         <exclusions>
-            <exclusion>
-               <groupId>dom4j</groupId>
-               <artifactId>dom4j</artifactId>
-            </exclusion>
-         </exclusions>
-      </dependency>
+    <dependency>
+      <groupId>org.eclipse.birt</groupId>
+      <artifactId>engineapi</artifactId>
+      <version>${birt.version}</version>
+      <exclusions>
+        <exclusion>
+          <groupId>dom4j</groupId>
+          <artifactId>dom4j</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
 
-      <dependency>
-         <groupId>org.eclipse.birt</groupId>
-         <artifactId>chartengineapi</artifactId>
-         <version>${birt.version}</version>
-      </dependency>
+    <dependency>
+      <groupId>org.eclipse.birt</groupId>
+      <artifactId>chartengineapi</artifactId>
+      <version>${birt.version}</version>
+    </dependency>
 
-      <dependency>
-         <groupId>org.eclipse.birt</groupId>
-         <artifactId>coreapi</artifactId>
-         <version>${birt.version}</version>
-      </dependency>
+    <dependency>
+      <groupId>org.eclipse.birt</groupId>
+      <artifactId>coreapi</artifactId>
+      <version>${birt.version}</version>
+    </dependency>
 
-      <dependency>
-         <groupId>org.eclipse.birt</groupId>
-         <artifactId>dataadapterapi</artifactId>
-         <version>${birt.version}</version>
-      </dependency>
+    <dependency>
+      <groupId>org.eclipse.birt</groupId>
+      <artifactId>dataadapterapi</artifactId>
+      <version>${birt.version}</version>
+    </dependency>
 
-      <dependency>
-         <groupId>org.eclipse.birt</groupId>
-         <artifactId>modelapi</artifactId>
-         <version>${birt.version}</version>
-      </dependency>
+    <dependency>
+      <groupId>org.eclipse.birt</groupId>
+      <artifactId>modelapi</artifactId>
+      <version>${birt.version}</version>
+    </dependency>
 
-      <dependency>
-         <groupId>org.eclipse.birt</groupId>
-         <artifactId>scriptapi</artifactId>
-         <version>${birt.version}</version>
-      </dependency>
+    <dependency>
+      <groupId>org.eclipse.birt</groupId>
+      <artifactId>scriptapi</artifactId>
+      <version>${birt.version}</version>
+    </dependency>
 
-      <dependency>
-         <groupId>org.eclipse.birt</groupId>
-         <artifactId>dteapi</artifactId>
-         <version>${birt.version}</version>
-      </dependency>
+    <dependency>
+      <groupId>org.eclipse.birt</groupId>
+      <artifactId>dteapi</artifactId>
+      <version>${birt.version}</version>
+    </dependency>
 
-      <!-- EMF (Eclipse Modeling Framework )  -->
+    <!-- EMF (Eclipse Modeling Framework )  -->
 
-      <dependency>
-         <groupId>org.eclipse.emf</groupId>
-         <artifactId>ecore</artifactId>
-         <version>2.4.2</version>
-      </dependency>
+    <dependency>
+      <groupId>org.eclipse.emf</groupId>
+      <artifactId>ecore</artifactId>
+      <version>2.4.2</version>
+    </dependency>
 
-      <dependency>
-         <groupId>org.eclipse.emf</groupId>
-         <artifactId>ecore-xmi</artifactId>
-         <version>2.4.1</version>
-      </dependency>
+    <dependency>
+      <groupId>org.eclipse.emf</groupId>
+      <artifactId>ecore-xmi</artifactId>
+      <version>2.4.1</version>
+    </dependency>
 
-      <dependency>
-         <groupId>org.eclipse.emf</groupId>
-         <artifactId>common</artifactId>
-         <version>2.4.0</version>
-      </dependency>
+    <dependency>
+      <groupId>org.eclipse.emf</groupId>
+      <artifactId>common</artifactId>
+      <version>2.4.0</version>
+    </dependency>
 
-      <!-- W3C -->
+    <!-- W3C -->
 
-      <dependency>
-         <groupId>org.w3c</groupId>
-         <artifactId>flute</artifactId>
-         <version>1.2</version>
-      </dependency>
+    <dependency>
+      <groupId>org.w3c</groupId>
+      <artifactId>flute</artifactId>
+      <version>1.2</version>
+    </dependency>
 
-      <dependency>
-         <groupId>org.w3c</groupId>
-         <artifactId>sac</artifactId>
-         <version>1.3</version>
-      </dependency>
+    <dependency>
+      <groupId>org.w3c</groupId>
+      <artifactId>sac</artifactId>
+      <version>1.3</version>
+    </dependency>
 
-      <!-- Commons -->
-      <dependency>
-         <groupId>commons-codec</groupId>
-         <artifactId>commons-codec</artifactId>
-         <version>1.3</version>
-         <!-- removing unwanted transitive dependencies -->
-         <exclusions>
-            <exclusion>
-               <artifactId>junit</artifactId>
-               <groupId>junit</groupId>
-            </exclusion>
-         </exclusions>
-      </dependency>
+    <!-- Commons -->
+    <dependency>
+      <groupId>commons-codec</groupId>
+      <artifactId>commons-codec</artifactId>
+      <version>1.3</version>
+      <!-- removing unwanted transitive dependencies -->
+      <exclusions>
+        <exclusion>
+          <artifactId>junit</artifactId>
+          <groupId>junit</groupId>
+        </exclusion>
+      </exclusions>
+    </dependency>
 
-      <dependency>
-         <groupId>commons-cli</groupId>
-         <artifactId>commons-cli</artifactId>
-         <version>1.0</version>
-         <!-- removing unwanted transitive dependencies -->
-         <exclusions>
-            <exclusion>
-               <artifactId>commons-lang</artifactId>
-               <groupId>commons-lang</groupId>
-            </exclusion>
-            <exclusion>
-               <artifactId>commons-logging</artifactId>
-               <groupId>commons-logging</groupId>
-            </exclusion>
-         </exclusions>
-      </dependency>
+    <dependency>
+      <groupId>commons-cli</groupId>
+      <artifactId>commons-cli</artifactId>
+      <version>1.0</version>
+      <!-- removing unwanted transitive dependencies -->
+      <exclusions>
+        <exclusion>
+          <artifactId>commons-lang</artifactId>
+          <groupId>commons-lang</groupId>
+        </exclusion>
+        <exclusion>
+          <artifactId>commons-logging</artifactId>
+          <groupId>commons-logging</groupId>
+        </exclusion>
+      </exclusions>
+    </dependency>
 
-      <dependency>
-         <groupId>commons-discovery</groupId>
-         <artifactId>commons-discovery</artifactId>
-         <version>0.2</version>
-      </dependency>
+    <dependency>
+      <groupId>commons-discovery</groupId>
+      <artifactId>commons-discovery</artifactId>
+      <version>0.2</version>
+    </dependency>
 
-      <!-- misc -->
-      <dependency>
-         <groupId>com.lowagie</groupId>
-         <artifactId>itext</artifactId>
-         <version>1.3</version>
-      </dependency>
+    <!-- misc -->
+    <dependency>
+      <groupId>com.lowagie</groupId>
+      <artifactId>itext</artifactId>
+      <version>1.3</version>
+    </dependency>
 
-      <dependency>
-         <groupId>com.ibm.icu</groupId>
-         <artifactId>icu4j</artifactId>
-         <version>3.8.1</version>
-      </dependency>
+    <dependency>
+      <groupId>com.ibm.icu</groupId>
+      <artifactId>icu4j</artifactId>
+      <version>3.8.1</version>
+    </dependency>
 
-      <dependency>
-         <groupId>rhino</groupId>
-         <artifactId>js</artifactId>
-         <version>1.6R2</version>
-      </dependency>
+    <dependency>
+      <groupId>rhino</groupId>
+      <artifactId>js</artifactId>
+      <version>1.6R2</version>
+    </dependency>
 
-   </dependencies>
+    <dependency>
+      <groupId>org.jboss.resteasy</groupId>
+      <artifactId>resteasy-jaxrs</artifactId>
+    </dependency>
 
+    <dependency>
+      <groupId>javax.servlet</groupId>
+      <artifactId>servlet-api</artifactId>
+      <scope>provided</scope>
+    </dependency>
 
+  </dependencies>
 
+
+
 </project>

Copied: projects/report-server/trunk/core/src/main/java/org/jboss/bpm/report/FileWriter.java (from rev 4817, projects/report-server/trunk/server/src/main/java/org/jboss/bpm/report/FileWriter.java)
===================================================================
--- projects/report-server/trunk/core/src/main/java/org/jboss/bpm/report/FileWriter.java	                        (rev 0)
+++ projects/report-server/trunk/core/src/main/java/org/jboss/bpm/report/FileWriter.java	2009-05-26 13:45:43 UTC (rev 4899)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.report;
+
+import javax.ws.rs.ext.Provider;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import java.lang.reflect.Type;
+import java.lang.annotation.Annotation;
+import java.io.OutputStream;
+import java.io.IOException;
+import java.io.FileInputStream;
+import java.io.File;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+ at Provider
+ at Produces({"text/html", "image/*"})
+public class FileWriter implements MessageBodyWriter
+{
+
+   public boolean isWriteable(Class aClass, Type type, Annotation[] annotations, MediaType mediaType)
+   {
+      return aClass.equals(java.io.File.class);
+   }
+
+   public long getSize(Object o, Class aClass, Type type, Annotation[] annotations, MediaType mediaType)
+   {
+      return ((File)o).length();
+   }
+
+   public void writeTo(Object o, Class aClass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap multivaluedMap, OutputStream outputStream) throws IOException, WebApplicationException
+   {
+      FileInputStream fin = new FileInputStream((File)o);
+      int c;
+      while ((c = fin.read()) != -1)
+      {
+         outputStream.write(c);
+      }
+
+      fin.close();
+
+   }
+}

Copied: projects/report-server/trunk/core/src/main/java/org/jboss/bpm/report/JMXServerConfig.java (from rev 4817, projects/report-server/trunk/server/src/main/java/org/jboss/bpm/report/JMXServerConfig.java)
===================================================================
--- projects/report-server/trunk/core/src/main/java/org/jboss/bpm/report/JMXServerConfig.java	                        (rev 0)
+++ projects/report-server/trunk/core/src/main/java/org/jboss/bpm/report/JMXServerConfig.java	2009-05-26 13:45:43 UTC (rev 4899)
@@ -0,0 +1,152 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.report;
+
+import javax.management.*;
+import java.io.File;
+import java.util.Hashtable;
+import java.util.List;
+
+/**
+ * Hooks into JMX to get the JBoss AS configuration.
+ * (temp directories, etc)
+ *
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class JMXServerConfig
+{
+   // The MBeanServer
+   private MBeanServer mbeanServer;
+
+   public JMXServerConfig()
+   {
+      this.mbeanServer = getDefaultMBeanServer();
+   }
+
+   public MBeanServer getMbeanServer()
+   {
+      return mbeanServer;
+   }
+
+   public void setMbeanServer(MBeanServer mbeanServer)
+   {
+      this.mbeanServer = mbeanServer;
+   }
+
+   public File getServerTempDir()
+   {
+      try
+      {
+         ObjectName oname = ObjectNameFactory.create("jboss.system:type=ServerConfig");
+         File dir = (File)getMbeanServer().getAttribute(oname, "ServerTempDir");
+         return dir;
+      }
+      catch (JMException e)
+      {
+         return null;
+      }
+   }
+
+   public File getHomeDir()
+   {
+      try
+      {
+         ObjectName oname = ObjectNameFactory.create("jboss.system:type=ServerConfig");
+         File dir = (File)getMbeanServer().getAttribute(oname, "HomeDir");
+         return dir;
+      }
+      catch (JMException e)
+      {
+         return null;
+      }
+   }
+
+   public File getServerDataDir()
+   {
+      try
+      {
+         ObjectName oname = ObjectNameFactory.create("jboss.system:type=ServerConfig");
+         File dir = (File)getMbeanServer().getAttribute(oname, "ServerDataDir");
+         return dir;
+      }
+      catch (JMException e)
+      {
+         return null;
+      }
+   }
+
+   public static MBeanServer getDefaultMBeanServer() {
+      return findMBeanServer("jboss");
+   }
+
+   private static MBeanServer findMBeanServer(String agentId) {
+      List servers = MBeanServerFactory.findMBeanServer(null);
+      if (servers != null && servers.size() > 0) {
+         for (Object object : servers) {
+            MBeanServer server = (MBeanServer) object;
+            if (server.getDefaultDomain().equals(agentId)) {
+               return server;
+            }
+         }
+      }
+      return null;
+   }
+
+   public static class ObjectNameFactory
+   {
+      public static ObjectName create(String name)
+      {
+         try
+         {
+            return new ObjectName(name);
+         }
+         catch (MalformedObjectNameException e)
+         {
+            throw new Error("Invalid ObjectName: " + name + "; " + e);
+         }
+      }
+
+      public static ObjectName create(String domain, String key, String value)
+      {
+         try
+         {
+            return new ObjectName(domain, key, value);
+         }
+         catch (MalformedObjectNameException e)
+         {
+            throw new Error("Invalid ObjectName: " + domain + "," + key + "," + value + "; " + e);
+         }
+      }
+
+      public static ObjectName create(String domain, Hashtable table)
+      {
+         try
+         {
+            return new ObjectName(domain, table);
+         }
+         catch (MalformedObjectNameException e)
+         {
+            throw new Error("Invalid ObjectName: " + domain + "," + table + "; " + e);
+         }
+      }
+   }
+}

Copied: projects/report-server/trunk/core/src/main/java/org/jboss/bpm/report/ReportFacade.java (from rev 4817, projects/report-server/trunk/server/src/main/java/org/jboss/bpm/report/ReportFacade.java)
===================================================================
--- projects/report-server/trunk/core/src/main/java/org/jboss/bpm/report/ReportFacade.java	                        (rev 0)
+++ projects/report-server/trunk/core/src/main/java/org/jboss/bpm/report/ReportFacade.java	2009-05-26 13:45:43 UTC (rev 4899)
@@ -0,0 +1,167 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.report;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import java.io.*;
+import java.util.HashMap;
+import java.util.Enumeration;
+import java.util.Map;
+
+/**
+ * BIRT integration facade.<p>
+ *
+ * Uses the server data directory (i.e. <code>$JBOSS_HOME/server/default/data/birt</code>)
+ * as it's work directory (referred to as $WORK_DIR in the subsequent sections):
+ *
+ * <ul>
+ *    <li>report template location: $WORK_DIR/
+ *    <li>output directory: $WORK_DIR/output
+ * </ul>
+ *
+ * NOTE: It requires a BIRT report engine to be installed in the work directory:
+ * (<code>$WORK_DIR/ReportEngine</code>.
+ *
+ * @see org.jboss.bpm.report.JMXServerConfig
+ *
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+ at Path("report")
+public class ReportFacade
+{
+   private static final Log log = LogFactory.getLog(ReportFacade.class);
+   private BirtService birtService;
+   private boolean isInitialized;
+
+   public void lazyInitialize(HttpServletRequest request)
+   {
+      if(!isInitialized)
+      {
+         JMXServerConfig jmxConfig = new JMXServerConfig();
+         IntegrationConfig iConfig = new IntegrationConfig();
+
+         File severDataDir = jmxConfig.getServerDataDir();
+         String absServerDataDir = severDataDir.getAbsolutePath();
+
+         String birtDataDir = absServerDataDir + "/birt";
+         String defaultBirtHome = birtDataDir + "/ReportEngine";
+         String birtOutputDir = birtDataDir + "/output";
+
+         File birtOutput = new File(birtOutputDir);
+         birtOutput.mkdirs(); // will create parent directoy as well
+
+         // check dependency on ReportEngine
+         if(! new File(defaultBirtHome).exists())
+            throw new IllegalStateException("The BIRT report engine doesn't seem to be installed:" +defaultBirtHome);
+
+         // --
+
+         iConfig.setBirtHome(defaultBirtHome);
+         iConfig.setOutputDir( birtOutputDir );
+         iConfig.setReportDir( birtDataDir );
+
+         StringBuffer sb = new StringBuffer();
+         sb.append("http://");
+         sb.append(request.getServerName()).append(":");
+         sb.append(request.getServerPort());
+         sb.append(request.getContextPath());
+         sb.append(request.getServletPath());
+         sb.append("/report/view/image");
+
+         iConfig.setImageBaseUrl(sb.toString());
+
+         log.info("BIRT home: " +iConfig.getBirtHome());
+         log.info("Output dir: " +iConfig.getOutputDir());
+         log.info("Report dir: " +iConfig.getReportDir());
+
+         this.birtService = new BirtService(iConfig);
+         this.birtService.create();
+
+         isInitialized = true;
+      }
+   }
+
+   @GET
+   @Path("view/{fileName}")
+   @Produces("text/html")
+   public Response viewReportHtml(
+         @PathParam("fileName")
+         String fileName,
+         @Context HttpServletRequest
+               request
+   )
+   {
+      lazyInitialize(request);
+
+      Map queryParams = convertRequestParametersToMap(request);
+
+      RenderMetaData renderMeta = new RenderMetaData();
+      renderMeta.setReportName(fileName);
+      renderMeta.setFormat(RenderMetaData.Format.HTML);
+      renderMeta.setClassloader(Thread.currentThread().getContextClassLoader());
+      renderMeta.getParameters().putAll(queryParams);
+      
+      String outputFileName = birtService.render(renderMeta);
+      String absoluteFile = birtService.getIntegrationConfig().getOutputDir() + outputFileName;
+      log.info("Render " + absoluteFile);
+
+      File reportFile = new File(absoluteFile);
+      return Response.ok(reportFile).type("text/html").build();
+   }
+
+   @GET
+   @Path("view/image/{fileName}")
+   public Response getImage(
+         @PathParam("fileName")
+         String fileName,
+         @Context HttpServletRequest
+               request
+   )
+   {
+      lazyInitialize(request);
+      
+      String imageDir = birtService.getIntegrationConfig().getImageDirectory();
+      String absName = imageDir + fileName;
+      File imageFile = new File(absName);
+      if(!imageFile.exists())
+         throw new IllegalArgumentException("Image " +absName+" doesn't exist");
+      return Response.ok(imageFile).build();
+   }
+
+   static public Map<String, String> convertRequestParametersToMap(HttpServletRequest request){
+      Enumeration<?> initParameters=request.getParameterNames();
+      HashMap<String, String> parameterMap = new HashMap<String, String>();
+      while (initParameters.hasMoreElements()) {
+         String param = (String) initParameters.nextElement();
+         String value = request.getParameter(param);
+         if (param != null & value != null)
+            parameterMap.put(param, value);
+      }
+      return parameterMap;
+   }
+}

Modified: projects/report-server/trunk/report-server.iws
===================================================================
--- projects/report-server/trunk/report-server.iws	2009-05-26 13:35:58 UTC (rev 4898)
+++ projects/report-server/trunk/report-server.iws	2009-05-26 13:45:43 UTC (rev 4899)
@@ -17,12 +17,7 @@
   </component>
   <component name="ChangeListManager">
     <list default="true" name="Default" comment="">
-      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/report-server.iws" />
-      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/report-server.iml" afterPath="$PROJECT_DIR$/report-server.iml" />
-      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/report-server.ipr" />
-      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/server/pom.xml" afterPath="$PROJECT_DIR$/server/pom.xml" />
-      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/server/src/main/webapp/WEB-INF/web.xml" afterPath="$PROJECT_DIR$/server/src/main/webapp/WEB-INF/web.xml" />
-      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/core/pom.xml" afterPath="$PROJECT_DIR$/core/pom.xml" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/report-server.iws" afterPath="$PROJECT_DIR$/report-server.iws" />
     </list>
   </component>
   <component name="ChangeListSynchronizer" />
@@ -346,7 +341,7 @@
       <showLibraryContents />
       <hideEmptyPackages />
       <abbreviatePackageNames />
-      <showStructure PackagesPane="false" ProjectPane="false" />
+      <showStructure PackagesPane="false" Scope="false" ProjectPane="false" />
       <autoscrollToSource />
       <autoscrollFromSource />
       <sortByType />
@@ -366,13 +361,6 @@
   <component name="RecentsManager" />
   <component name="RestoreUpdateTree" />
   <component name="RunManager">
-    <configuration default="true" type="Remote" factoryName="Remote">
-      <option name="USE_SOCKET_TRANSPORT" value="true" />
-      <option name="SERVER_MODE" value="false" />
-      <option name="SHMEM_ADDRESS" value="javadebug" />
-      <option name="HOST" value="localhost" />
-      <option name="PORT" value="5005" />
-    </configuration>
     <configuration default="true" type="Applet" factoryName="Applet">
       <module name="" />
       <option name="MAIN_CLASS_NAME" />
@@ -385,6 +373,23 @@
       <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
       <option name="ALTERNATIVE_JRE_PATH" />
     </configuration>
+    <configuration default="true" type="Remote" factoryName="Remote">
+      <option name="USE_SOCKET_TRANSPORT" value="true" />
+      <option name="SERVER_MODE" value="false" />
+      <option name="SHMEM_ADDRESS" value="javadebug" />
+      <option name="HOST" value="localhost" />
+      <option name="PORT" value="5005" />
+    </configuration>
+    <configuration default="true" type="Application" factoryName="Application" enabled="false" merge="false">
+      <option name="MAIN_CLASS_NAME" />
+      <option name="VM_PARAMETERS" />
+      <option name="PROGRAM_PARAMETERS" />
+      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
+      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
+      <option name="ALTERNATIVE_JRE_PATH" />
+      <option name="ENABLE_SWING_INSPECTOR" value="false" />
+      <module name="" />
+    </configuration>
     <configuration default="true" type="JUnit" factoryName="JUnit" enabled="false" merge="false">
       <module name="" />
       <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
@@ -401,22 +406,21 @@
         <value defaultName="wholeProject" />
       </option>
     </configuration>
-    <configuration default="true" type="Application" factoryName="Application" enabled="false" merge="false">
-      <option name="MAIN_CLASS_NAME" />
-      <option name="VM_PARAMETERS" />
-      <option name="PROGRAM_PARAMETERS" />
-      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
-      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
-      <option name="ALTERNATIVE_JRE_PATH" />
-      <option name="ENABLE_SWING_INSPECTOR" value="false" />
-      <module name="" />
-    </configuration>
     <configuration name="&lt;template&gt;" type="WebApp" default="true" selected="false">
       <Host>localhost</Host>
       <Port>5050</Port>
     </configuration>
   </component>
-  <component name="ScopeViewComponent" />
+  <component name="ScopeViewComponent">
+    <subPane subId="Project">
+      <PATH>
+        <PATH_ELEMENT USER_OBJECT="Root">
+          <option name="myItemId" value="" />
+          <option name="myItemType" value="" />
+        </PATH_ELEMENT>
+      </PATH>
+    </subPane>
+  </component>
   <component name="SelectInManager" />
   <component name="StarteamConfiguration">
     <option name="SERVER" value="" />
@@ -482,33 +486,33 @@
     </todo-panel>
   </component>
   <component name="ToolWindowManager">
-    <frame x="501" y="63" width="1144" height="882" extended-state="0" />
-    <editor active="true" />
+    <frame x="0" y="22" width="1280" height="774" extended-state="6" />
+    <editor active="false" />
     <layout>
-      <window_info id="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="-1" />
-      <window_info id="CVS" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="-1" />
-      <window_info id="IDEtalk" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="-1" />
+      <window_info id="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="3" />
+      <window_info id="CVS" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="8" />
+      <window_info id="IDEtalk" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="3" />
       <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="7" />
-      <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.32968035" order="0" />
+      <window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.3290008" order="0" />
       <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3299363" order="1" />
       <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" order="1" />
-      <window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="-1" />
+      <window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="8" />
       <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" order="6" />
-      <window_info id="Module Dependencies" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="-1" />
-      <window_info id="Dependency Viewer" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="-1" />
-      <window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="-1" />
+      <window_info id="Module Dependencies" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="3" />
+      <window_info id="Dependency Viewer" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="8" />
+      <window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="3" />
       <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" order="1" />
-      <window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="-1" />
+      <window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="8" />
       <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="2" />
-      <window_info id="Maven" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="-1" />
+      <window_info id="Maven" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="8" />
       <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" order="2" />
-      <window_info id="File View" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="-1" />
+      <window_info id="File View" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="3" />
       <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" order="4" />
       <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" order="0" />
-      <window_info id="IDEtalk Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="-1" />
-      <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="-1" />
+      <window_info id="IDEtalk Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="8" />
+      <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="8" />
+      <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="0" />
       <window_info id="Web" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" order="2" />
-      <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="0" />
       <window_info id="EJB" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" order="3" />
       <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" order="5" />
     </layout>

Deleted: projects/report-server/trunk/server/src/main/java/org/jboss/bpm/report/FileWriter.java
===================================================================
--- projects/report-server/trunk/server/src/main/java/org/jboss/bpm/report/FileWriter.java	2009-05-26 13:35:58 UTC (rev 4898)
+++ projects/report-server/trunk/server/src/main/java/org/jboss/bpm/report/FileWriter.java	2009-05-26 13:45:43 UTC (rev 4899)
@@ -1,67 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software 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.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.bpm.report;
-
-import javax.ws.rs.ext.Provider;
-import javax.ws.rs.ext.MessageBodyWriter;
-import javax.ws.rs.Produces;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import java.lang.reflect.Type;
-import java.lang.annotation.Annotation;
-import java.io.OutputStream;
-import java.io.IOException;
-import java.io.FileInputStream;
-import java.io.File;
-
-/**
- * @author Heiko.Braun <heiko.braun at jboss.com>
- */
- at Provider
- at Produces({"text/html", "image/*"})
-public class FileWriter implements MessageBodyWriter
-{
-
-   public boolean isWriteable(Class aClass, Type type, Annotation[] annotations, MediaType mediaType)
-   {
-      return aClass.equals(java.io.File.class);
-   }
-
-   public long getSize(Object o, Class aClass, Type type, Annotation[] annotations, MediaType mediaType)
-   {
-      return ((File)o).length();
-   }
-
-   public void writeTo(Object o, Class aClass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap multivaluedMap, OutputStream outputStream) throws IOException, WebApplicationException
-   {
-      FileInputStream fin = new FileInputStream((File)o);
-      int c;
-      while ((c = fin.read()) != -1)
-      {
-         outputStream.write(c);
-      }
-
-      fin.close();
-
-   }
-}

Deleted: projects/report-server/trunk/server/src/main/java/org/jboss/bpm/report/JMXServerConfig.java
===================================================================
--- projects/report-server/trunk/server/src/main/java/org/jboss/bpm/report/JMXServerConfig.java	2009-05-26 13:35:58 UTC (rev 4898)
+++ projects/report-server/trunk/server/src/main/java/org/jboss/bpm/report/JMXServerConfig.java	2009-05-26 13:45:43 UTC (rev 4899)
@@ -1,152 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software 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.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.bpm.report;
-
-import javax.management.*;
-import java.io.File;
-import java.util.Hashtable;
-import java.util.List;
-
-/**
- * Hooks into JMX to get the JBoss AS configuration.
- * (temp directories, etc)
- *
- * @author Heiko.Braun <heiko.braun at jboss.com>
- */
-public class JMXServerConfig
-{
-   // The MBeanServer
-   private MBeanServer mbeanServer;
-
-   public JMXServerConfig()
-   {
-      this.mbeanServer = getDefaultMBeanServer();
-   }
-
-   public MBeanServer getMbeanServer()
-   {
-      return mbeanServer;
-   }
-
-   public void setMbeanServer(MBeanServer mbeanServer)
-   {
-      this.mbeanServer = mbeanServer;
-   }
-
-   public File getServerTempDir()
-   {
-      try
-      {
-         ObjectName oname = ObjectNameFactory.create("jboss.system:type=ServerConfig");
-         File dir = (File)getMbeanServer().getAttribute(oname, "ServerTempDir");
-         return dir;
-      }
-      catch (JMException e)
-      {
-         return null;
-      }
-   }
-
-   public File getHomeDir()
-   {
-      try
-      {
-         ObjectName oname = ObjectNameFactory.create("jboss.system:type=ServerConfig");
-         File dir = (File)getMbeanServer().getAttribute(oname, "HomeDir");
-         return dir;
-      }
-      catch (JMException e)
-      {
-         return null;
-      }
-   }
-
-   public File getServerDataDir()
-   {
-      try
-      {
-         ObjectName oname = ObjectNameFactory.create("jboss.system:type=ServerConfig");
-         File dir = (File)getMbeanServer().getAttribute(oname, "ServerDataDir");
-         return dir;
-      }
-      catch (JMException e)
-      {
-         return null;
-      }
-   }
-
-   public static MBeanServer getDefaultMBeanServer() {
-      return findMBeanServer("jboss");
-   }
-
-   private static MBeanServer findMBeanServer(String agentId) {
-      List servers = MBeanServerFactory.findMBeanServer(null);
-      if (servers != null && servers.size() > 0) {
-         for (Object object : servers) {
-            MBeanServer server = (MBeanServer) object;
-            if (server.getDefaultDomain().equals(agentId)) {
-               return server;
-            }
-         }
-      }
-      return null;
-   }
-
-   public static class ObjectNameFactory
-   {
-      public static ObjectName create(String name)
-      {
-         try
-         {
-            return new ObjectName(name);
-         }
-         catch (MalformedObjectNameException e)
-         {
-            throw new Error("Invalid ObjectName: " + name + "; " + e);
-         }
-      }
-
-      public static ObjectName create(String domain, String key, String value)
-      {
-         try
-         {
-            return new ObjectName(domain, key, value);
-         }
-         catch (MalformedObjectNameException e)
-         {
-            throw new Error("Invalid ObjectName: " + domain + "," + key + "," + value + "; " + e);
-         }
-      }
-
-      public static ObjectName create(String domain, Hashtable table)
-      {
-         try
-         {
-            return new ObjectName(domain, table);
-         }
-         catch (MalformedObjectNameException e)
-         {
-            throw new Error("Invalid ObjectName: " + domain + "," + table + "; " + e);
-         }
-      }
-   }
-}

Deleted: projects/report-server/trunk/server/src/main/java/org/jboss/bpm/report/ReportFacade.java
===================================================================
--- projects/report-server/trunk/server/src/main/java/org/jboss/bpm/report/ReportFacade.java	2009-05-26 13:35:58 UTC (rev 4898)
+++ projects/report-server/trunk/server/src/main/java/org/jboss/bpm/report/ReportFacade.java	2009-05-26 13:45:43 UTC (rev 4899)
@@ -1,167 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software 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.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.bpm.report;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.*;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-import java.io.*;
-import java.util.HashMap;
-import java.util.Enumeration;
-import java.util.Map;
-
-/**
- * BIRT integration facade.<p>
- *
- * Uses the server data directory (i.e. <code>$JBOSS_HOME/server/default/data/birt</code>)
- * as it's work directory (referred to as $WORK_DIR in the subsequent sections):
- *
- * <ul>
- *    <li>report template location: $WORK_DIR/
- *    <li>output directory: $WORK_DIR/output
- * </ul>
- *
- * NOTE: It requires a BIRT report engine to be installed in the work directory:
- * (<code>$WORK_DIR/ReportEngine</code>.
- *
- * @see org.jboss.bpm.report.JMXServerConfig
- *
- * @author Heiko.Braun <heiko.braun at jboss.com>
- */
- at Path("report")
-public class ReportFacade
-{
-   private static final Log log = LogFactory.getLog(ReportFacade.class);
-   private BirtService birtService;
-   private boolean isInitialized;
-
-   public void lazyInitialize(HttpServletRequest request)
-   {
-      if(!isInitialized)
-      {
-         JMXServerConfig jmxConfig = new JMXServerConfig();
-         IntegrationConfig iConfig = new IntegrationConfig();
-
-         File severDataDir = jmxConfig.getServerDataDir();
-         String absServerDataDir = severDataDir.getAbsolutePath();
-
-         String birtDataDir = absServerDataDir + "/birt";
-         String defaultBirtHome = birtDataDir + "/ReportEngine";
-         String birtOutputDir = birtDataDir + "/output";
-
-         File birtOutput = new File(birtOutputDir);
-         birtOutput.mkdirs(); // will create parent directoy as well
-
-         // check dependency on ReportEngine
-         if(! new File(defaultBirtHome).exists())
-            throw new IllegalStateException("The BIRT report engine doesn't seem to be installed:" +defaultBirtHome);
-
-         // --
-
-         iConfig.setBirtHome(defaultBirtHome);
-         iConfig.setOutputDir( birtOutputDir );
-         iConfig.setReportDir( birtDataDir );
-
-         StringBuffer sb = new StringBuffer();
-         sb.append("http://");
-         sb.append(request.getServerName()).append(":");
-         sb.append(request.getServerPort());
-         sb.append(request.getContextPath());
-         sb.append(request.getServletPath());
-         sb.append("/report/view/image");
-
-         iConfig.setImageBaseUrl(sb.toString());
-
-         log.info("BIRT home: " +iConfig.getBirtHome());
-         log.info("Output dir: " +iConfig.getOutputDir());
-         log.info("Report dir: " +iConfig.getReportDir());
-
-         this.birtService = new BirtService(iConfig);
-         this.birtService.create();
-
-         isInitialized = true;
-      }
-   }
-
-   @GET
-   @Path("view/{fileName}")
-   @Produces("text/html")
-   public Response viewReportHtml(
-         @PathParam("fileName")
-         String fileName,
-         @Context HttpServletRequest
-               request
-   )
-   {
-      lazyInitialize(request);
-
-      Map queryParams = convertRequestParametersToMap(request);
-
-      RenderMetaData renderMeta = new RenderMetaData();
-      renderMeta.setReportName(fileName);
-      renderMeta.setFormat(RenderMetaData.Format.HTML);
-      renderMeta.setClassloader(Thread.currentThread().getContextClassLoader());
-      renderMeta.getParameters().putAll(queryParams);
-      
-      String outputFileName = birtService.render(renderMeta);
-      String absoluteFile = birtService.getIntegrationConfig().getOutputDir() + outputFileName;
-      log.info("Render " + absoluteFile);
-
-      File reportFile = new File(absoluteFile);
-      return Response.ok(reportFile).type("text/html").build();
-   }
-
-   @GET
-   @Path("view/image/{fileName}")
-   public Response getImage(
-         @PathParam("fileName")
-         String fileName,
-         @Context HttpServletRequest
-               request
-   )
-   {
-      lazyInitialize(request);
-      
-      String imageDir = birtService.getIntegrationConfig().getImageDirectory();
-      String absName = imageDir + fileName;
-      File imageFile = new File(absName);
-      if(!imageFile.exists())
-         throw new IllegalArgumentException("Image " +absName+" doesn't exist");
-      return Response.ok(imageFile).build();
-   }
-
-   static public Map<String, String> convertRequestParametersToMap(HttpServletRequest request){
-      Enumeration<?> initParameters=request.getParameterNames();
-      HashMap<String, String> parameterMap = new HashMap<String, String>();
-      while (initParameters.hasMoreElements()) {
-         String param = (String) initParameters.nextElement();
-         String value = request.getParameter(param);
-         if (param != null & value != null)
-            parameterMap.put(param, value);
-      }
-      return parameterMap;
-   }
-}




More information about the jbpm-commits mailing list