org.outerj.xreporter.report
Class ReportManagerImpl

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.outerj.xreporter.report.ReportManagerImpl
All Implemented Interfaces:
org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.logger.LogEnabled, ReportManager, org.apache.avalon.framework.activity.Startable, org.apache.avalon.framework.thread.ThreadSafe

public class ReportManagerImpl
extends org.apache.avalon.framework.logger.AbstractLogEnabled
implements ReportManager, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.thread.ThreadSafe, org.apache.avalon.framework.activity.Startable

Implementation of ReportManager.


Field Summary
protected  AuthorisationManager authorisationManager
           
protected  org.apache.avalon.framework.component.ComponentManager componentManager
           
protected static java.lang.String DATASOURCE_NAME_EL
           
protected  DataSourceManager dataSourceManager
           
protected  java.lang.ClassLoader extensionsClassLoader
          ClassLoader used for user extensions, currenlty custom "execute steps".
protected  IdGenerator idGenerator
           
protected static java.lang.String INFO_EL
           
protected  org.outerj.xreporter.report.ReportManagerImpl.ManagementThread managementThread
           
protected  int managementThreadIntervalMs
          Time in between runs of the management thread that cleans up expired report instances
protected static java.lang.String REPORT
           
protected  java.lang.String REPORTCATALOG_EL
           
protected  java.util.Map reportDefinitionFiles
          Map containing an absolute filename as the key and a ReportDefinitionFile file object as the value.
protected  java.util.Map reportDefinitionsById
           
protected  java.io.File reportDirectory
           
protected  int reportExpirationTimeMs
           
protected  org.apache.commons.collections.FastHashMap reportInstancesById
           
protected static java.lang.String REPORTS
           
protected  java.lang.String resultSetNavigationStrategy
           
protected  Catalog rootCatalog
           
protected  org.outerj.xreporter.report.ReportManagerImpl.ScanReportDirectoryThread scanReportDirectoryThread
           
protected  int scanReportDirectoryThreadIntervalMs
           
protected static java.lang.String TIME_EL
           
 
Fields inherited from interface org.outerj.xreporter.report.ReportManager
ROLE
 
Constructor Summary
ReportManagerImpl()
           
 
Method Summary
 void compose(org.apache.avalon.framework.component.ComponentManager componentManager)
           
 void configure(org.apache.avalon.framework.configuration.Configuration configuration)
           
 Report createInstance(java.lang.String reportDefinitionId, java.lang.String dataSourceId, User user, ResourceHandle resourceHandle)
          Create a new report instance.
protected  boolean destroyReport(User user, ReportImpl report)
           
 boolean destroyReport(User user, java.lang.String reportInstanceId)
          Deletes all trace of the given report by calling its dispose method and removing its handle from the list of current instances.
 void generateCatalog(org.xml.sax.ContentHandler contentHandler, User user, java.lang.String dataSourceId, ResourceHandle resourceHandle)
          Generates a catalog of available report definitions.
 void generateReportInstanceList(org.xml.sax.ContentHandler contentHandler)
          Generates a list of all report instances.
 Report getReport(java.lang.String reportInstanceId, User user)
          Gets an existing report instance.
 ReportDefinition getReportDefinition(java.lang.String reportDefinitionId, User user)
           
 void initialize()
           
protected  void logReportCreatedEvent(java.lang.String user, java.lang.String customer, long time, java.lang.String reportId, java.lang.String reportDefinitionId, java.lang.String dataSourceId)
           
 void setListener(java.lang.String name, java.net.InetSocketAddress listener, boolean discloseHostName, boolean disclosePortNumber)
          Specify information about the environment this instance is listening on.
 void start()
           
 void stop()
           
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

reportDirectory

protected java.io.File reportDirectory

reportDefinitionsById

protected java.util.Map reportDefinitionsById

reportDefinitionFiles

protected java.util.Map reportDefinitionFiles
Map containing an absolute filename as the key and a ReportDefinitionFile file object as the value. This map will contain an entry for every ".xml" file in the report definition directory, regardless of whether a report definition could actually be built from it.


reportInstancesById

protected org.apache.commons.collections.FastHashMap reportInstancesById

idGenerator

protected IdGenerator idGenerator

dataSourceManager

protected DataSourceManager dataSourceManager

authorisationManager

protected AuthorisationManager authorisationManager

componentManager

protected org.apache.avalon.framework.component.ComponentManager componentManager

rootCatalog

protected Catalog rootCatalog

extensionsClassLoader

protected java.lang.ClassLoader extensionsClassLoader
ClassLoader used for user extensions, currenlty custom "execute steps".


managementThreadIntervalMs

protected int managementThreadIntervalMs
Time in between runs of the management thread that cleans up expired report instances


managementThread

protected org.outerj.xreporter.report.ReportManagerImpl.ManagementThread managementThread

reportExpirationTimeMs

protected int reportExpirationTimeMs

scanReportDirectoryThread

protected org.outerj.xreporter.report.ReportManagerImpl.ScanReportDirectoryThread scanReportDirectoryThread

scanReportDirectoryThreadIntervalMs

protected int scanReportDirectoryThreadIntervalMs

resultSetNavigationStrategy

protected java.lang.String resultSetNavigationStrategy

REPORTCATALOG_EL

protected final java.lang.String REPORTCATALOG_EL
See Also:
Constant Field Values

TIME_EL

protected static final java.lang.String TIME_EL
See Also:
Constant Field Values

DATASOURCE_NAME_EL

protected static final java.lang.String DATASOURCE_NAME_EL
See Also:
Constant Field Values

INFO_EL

protected static final java.lang.String INFO_EL
See Also:
Constant Field Values

REPORTS

protected static final java.lang.String REPORTS
See Also:
Constant Field Values

REPORT

protected static final java.lang.String REPORT
See Also:
Constant Field Values
Constructor Detail

ReportManagerImpl

public ReportManagerImpl()
Method Detail

setListener

public void setListener(java.lang.String name,
                        java.net.InetSocketAddress listener,
                        boolean discloseHostName,
                        boolean disclosePortNumber)
Description copied from interface: ReportManager
Specify information about the environment this instance is listening on. Will be propogated to execution contexts for each instance for use in displaying header information as well as providing a way to determine where to submit requests for subreport output.

Specified by:
setListener in interface ReportManager

configure

public void configure(org.apache.avalon.framework.configuration.Configuration configuration)
               throws org.apache.avalon.framework.configuration.ConfigurationException
Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable
Throws:
org.apache.avalon.framework.configuration.ConfigurationException

compose

public void compose(org.apache.avalon.framework.component.ComponentManager componentManager)
             throws org.apache.avalon.framework.component.ComponentException
Specified by:
compose in interface org.apache.avalon.framework.component.Composable
Throws:
org.apache.avalon.framework.component.ComponentException

initialize

public void initialize()
                throws java.lang.Exception
Specified by:
initialize in interface org.apache.avalon.framework.activity.Initializable
Throws:
java.lang.Exception

createInstance

public Report createInstance(java.lang.String reportDefinitionId,
                             java.lang.String dataSourceId,
                             User user,
                             ResourceHandle resourceHandle)
                      throws UnknownReportDefintionIdException,
                             UnknownDataSourceIdException,
                             java.lang.Exception
Description copied from interface: ReportManager
Create a new report instance. The returned instance will be locked so that others cannot use it concurrently. You must release the instance (usually in a finally-block) by calling its release method when you're done with it.

This method will also check that the user has the rights to use the report and datasource.

Specified by:
createInstance in interface ReportManager
Throws:
UnknownReportDefintionIdException
UnknownDataSourceIdException
java.lang.Exception
See Also:
ReportManager.createInstance(java.lang.String, java.lang.String, org.outerj.xreporter.user.User, org.outerj.xreporter.resource.ResourceHandle)

logReportCreatedEvent

protected void logReportCreatedEvent(java.lang.String user,
                                     java.lang.String customer,
                                     long time,
                                     java.lang.String reportId,
                                     java.lang.String reportDefinitionId,
                                     java.lang.String dataSourceId)

getReport

public Report getReport(java.lang.String reportInstanceId,
                        User user)
                 throws UnknownReportId,
                        ReportInUseException,
                        DataSourceAccessDeniedException,
                        ReportAccessDeniedException,
                        UnknownDataSourceIdException,
                        AuthorisationException
Description copied from interface: ReportManager
Gets an existing report instance. The returned instance will be locked so that others cannot use it concurrently. You must release the instance (usually in a finally-block) by calling its release method when you're done with it.

This method will also check that the user has the rights to use the report and associated datasource.

Specified by:
getReport in interface ReportManager
Throws:
UnknownReportId
ReportInUseException
DataSourceAccessDeniedException
ReportAccessDeniedException
UnknownDataSourceIdException
AuthorisationException
See Also:
ReportManager.getReport(java.lang.String, org.outerj.xreporter.user.User)

getReportDefinition

public ReportDefinition getReportDefinition(java.lang.String reportDefinitionId,
                                            User user)
                                     throws UnknownReportDefintionIdException,
                                            ReportAccessDeniedException,
                                            ReportDefinitionViewingNotAllowedException,
                                            AuthorisationException
Specified by:
getReportDefinition in interface ReportManager
Throws:
UnknownReportDefintionIdException
ReportAccessDeniedException
ReportDefinitionViewingNotAllowedException
AuthorisationException

generateCatalog

public void generateCatalog(org.xml.sax.ContentHandler contentHandler,
                            User user,
                            java.lang.String dataSourceId,
                            ResourceHandle resourceHandle)
                     throws org.xml.sax.SAXException,
                            UnknownDataSourceIdException,
                            DataSourceAccessDeniedException,
                            AuthorisationException
Description copied from interface: ReportManager
Generates a catalog of available report definitions. This catalog will only contain reports to which the user has access (controlled by the AuthorisationManager), and with which the datasource is compatible. Additionaly, an exception will be thrown when the user has no access to the data source (also controlled by the AuthorisationManager).

Specified by:
generateCatalog in interface ReportManager
Throws:
org.xml.sax.SAXException
UnknownDataSourceIdException
DataSourceAccessDeniedException
AuthorisationException
See Also:
ReportManager.generateCatalog(org.xml.sax.ContentHandler, org.outerj.xreporter.user.User, java.lang.String, org.outerj.xreporter.resource.ResourceHandle)

start

public void start()
           throws java.lang.Exception
Specified by:
start in interface org.apache.avalon.framework.activity.Startable
Throws:
java.lang.Exception

stop

public void stop()
          throws java.lang.Exception
Specified by:
stop in interface org.apache.avalon.framework.activity.Startable
Throws:
java.lang.Exception

generateReportInstanceList

public void generateReportInstanceList(org.xml.sax.ContentHandler contentHandler)
                                throws org.xml.sax.SAXException
Description copied from interface: ReportManager
Generates a list of all report instances. Used for administration (auditing) purposes.

Specified by:
generateReportInstanceList in interface ReportManager
Throws:
org.xml.sax.SAXException
See Also:
ReportManager.generateReportInstanceList(org.xml.sax.ContentHandler)

destroyReport

public boolean destroyReport(User user,
                             java.lang.String reportInstanceId)
                      throws UnknownReportId
Description copied from interface: ReportManager
Deletes all trace of the given report by calling its dispose method and removing its handle from the list of current instances.

Specified by:
destroyReport in interface ReportManager
Throws:
UnknownReportId
See Also:
ReportManager.destroyReport(org.outerj.xreporter.user.User, java.lang.String)

destroyReport

protected boolean destroyReport(User user,
                                ReportImpl report)
See Also:
ReportManager.destroyReport(org.outerj.xreporter.user.User, java.lang.String)