fr.opensagres.xdocreport.document
Class Generator<In,Out>

java.lang.Object
  extended by fr.opensagres.xdocreport.document.Generator<In,Out>
Direct Known Subclasses:
Tools

public abstract class Generator<In,Out>
extends Object


Field Summary
static String CONVERTER_ID_HTTP_PARAM
           
static String DISPATCH_HTTP_PARAM
           
static String DOWNLOAD_DISPATCH
           
static String ENTRY_NAME_HTTP_PARAM
           
static String PROCESS_STATE_HTTP_PARAM
           
static String REMOVE_DISPATCH
           
static String REPORT_ID_HTTP_PARAM
           
static String TEMPLATE_ENGINE_ID_HTTP_PARAM
           
static String TEMPLATE_ENGINE_KIND_HTTP_PARAM
           
static String VIEW_DISPATCH
           
 
Constructor Summary
Generator()
           
 
Method Summary
protected  void doDocumentArchive(ProcessState state, String entryName, In request, Out response)
           
protected  boolean doGenerateReport(String entryName, In request, Out response)
           
protected  void doRedirectAfterRemoveReport(In request, Out response)
           
protected  void doRemoveReport(In request, Out response)
          Remove report from the registry.
protected  void doSaveEntry(ProcessState processState, String entryName, In request, Out response)
          Extract entry from a report.
protected  void doSaveReport(ProcessState processState, In request, Out response)
          Save document archive of the report.
protected abstract  void error(In request, Out response, Exception cause)
          Invoked when there is an error thrown in any part of doRequest() processing.
protected  String getConverterId(IXDocReport report, In request)
          Returns the converter id.
protected  String getDispatchParameter(In request)
          Returns dispatch parameter value.
protected  String getEntryName(In request)
          Returns the entry name of the report.
protected  FieldsMetadata getFieldsMetadata(String reportId, In request)
           
protected  Options getOptionsConverter(IXDocReport report, In request)
           
protected abstract  OutputStream getOutputStream(Out response)
           
protected abstract  String getParameter(In request, String name)
           
protected  ProcessState getProcessState(In request)
          Returns process state (original|preprocessed|generated).
protected  XDocReportRegistry getRegistry(In request)
          Returns the XDocReport registry which load and cache document.
protected  IXDocReport getReport(In request)
           
protected  String getReportId(In request)
          Returns the id of the report.
protected abstract  InputStream getSourceStream(String reportId, In request)
          Returns input stream of the report to load identified with reportId.
protected  ITemplateEngine getTemplateEngine(In request)
          Returns the template engine from request and otherwise returns the default template engine.
protected  ITemplateEngine getTemplateEngine(IXDocReport report, In request)
           
protected  ITemplateEngine getTemplateEngine(String reportId, In request)
          Returns the template engine to use for the report.
protected  String getTemplateEngineId(In request)
          Returns the template engine id from request.
protected  String getTemplateEngineKind(In request)
           
protected  String getTemplateEngineKind(String reportId, In request)
           
protected  boolean isCacheOriginalDocument(String reportId, In request)
           
protected  boolean isGenerateContentDisposition(String reportId, MimeMapping mimeMapping, In request)
           
protected  IXDocReport loadReport(String reportId, XDocReportRegistry registry, In request)
          Load report.
protected abstract  void populateContext(IContext context, String reportId, In request)
          Put the Java model in the context for the report reportId.
protected abstract  void prepareHTTPResponse(String id, MimeMapping mimeMapping, In request, Out response)
           
protected abstract  void prepareHTTPResponse(String reportId, String entryName, In request, Out response)
           
protected  void prepareOptions(Options options, IXDocReport report, String converterId, In request)
           
 void processRequest(In request, Out response)
          Handles all requests (by default).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REMOVE_DISPATCH

public static final String REMOVE_DISPATCH
See Also:
Constant Field Values

DOWNLOAD_DISPATCH

public static final String DOWNLOAD_DISPATCH
See Also:
Constant Field Values

VIEW_DISPATCH

public static final String VIEW_DISPATCH
See Also:
Constant Field Values

REPORT_ID_HTTP_PARAM

public static final String REPORT_ID_HTTP_PARAM
See Also:
Constant Field Values

TEMPLATE_ENGINE_KIND_HTTP_PARAM

public static final String TEMPLATE_ENGINE_KIND_HTTP_PARAM
See Also:
Constant Field Values

TEMPLATE_ENGINE_ID_HTTP_PARAM

public static final String TEMPLATE_ENGINE_ID_HTTP_PARAM
See Also:
Constant Field Values

ENTRY_NAME_HTTP_PARAM

public static final String ENTRY_NAME_HTTP_PARAM
See Also:
Constant Field Values

PROCESS_STATE_HTTP_PARAM

public static final String PROCESS_STATE_HTTP_PARAM
See Also:
Constant Field Values

DISPATCH_HTTP_PARAM

public static final String DISPATCH_HTTP_PARAM
See Also:
Constant Field Values

CONVERTER_ID_HTTP_PARAM

public static final String CONVERTER_ID_HTTP_PARAM
See Also:
Constant Field Values
Constructor Detail

Generator

public Generator()
Method Detail

processRequest

public void processRequest(In request,
                           Out response)
                    throws Exception
Handles all requests (by default).

Parameters:
request - In object containing client request
response - Out object for the response
Throws:
Exception

doRemoveReport

protected void doRemoveReport(In request,
                              Out response)
                       throws IOException
Remove report from the registry.

Parameters:
request -
response -
Throws:
IOException

doRedirectAfterRemoveReport

protected void doRedirectAfterRemoveReport(In request,
                                           Out response)
                                    throws IOException
Throws:
IOException

doDocumentArchive

protected void doDocumentArchive(ProcessState state,
                                 String entryName,
                                 In request,
                                 Out response)
                          throws Exception
Throws:
Exception

doSaveReport

protected void doSaveReport(ProcessState processState,
                            In request,
                            Out response)
                     throws Exception
Save document archive of the report.

Parameters:
processState -
request -
response -
Throws:
IOException
Exception

doSaveEntry

protected void doSaveEntry(ProcessState processState,
                           String entryName,
                           In request,
                           Out response)
                    throws IOException,
                           Exception
Extract entry from a report.

Parameters:
processState -
request -
response -
Throws:
IOException
Exception

doGenerateReport

protected boolean doGenerateReport(String entryName,
                                   In request,
                                   Out response)
                            throws Exception,
                                   IOException
Throws:
Exception
IOException

getReport

protected IXDocReport getReport(In request)
                         throws IOException,
                                XDocReportException
Parameters:
request -
Returns:
Throws:
IOException
XDocReportException

loadReport

protected IXDocReport loadReport(String reportId,
                                 XDocReportRegistry registry,
                                 In request)
                          throws IOException,
                                 XDocReportException
Load report.

Parameters:
reportId -
registry -
request -
Returns:
Throws:
IOException
XDocReportException

isCacheOriginalDocument

protected boolean isCacheOriginalDocument(String reportId,
                                          In request)

getFieldsMetadata

protected FieldsMetadata getFieldsMetadata(String reportId,
                                           In request)

error

protected abstract void error(In request,
                              Out response,
                              Exception cause)
Invoked when there is an error thrown in any part of doRequest() processing.

Default will send a simple HTML response indicating there was a problem.

Parameters:
request - original In from servlet container.
response - Out object from servlet container.
cause - Exception that was thrown by some other part of process.

getConverterId

protected String getConverterId(IXDocReport report,
                                In request)
Returns the converter id.

Parameters:
request -
Returns:

getOptionsConverter

protected Options getOptionsConverter(IXDocReport report,
                                      In request)

prepareOptions

protected void prepareOptions(Options options,
                              IXDocReport report,
                              String converterId,
                              In request)

isGenerateContentDisposition

protected boolean isGenerateContentDisposition(String reportId,
                                               MimeMapping mimeMapping,
                                               In request)

getDispatchParameter

protected String getDispatchParameter(In request)
Returns dispatch parameter value.

Parameters:
request -
Returns:

getReportId

protected String getReportId(In request)
Returns the id of the report.

Parameters:
request -
Returns:

getProcessState

protected ProcessState getProcessState(In request)
Returns process state (original|preprocessed|generated).

Parameters:
request -
Returns:

getEntryName

protected String getEntryName(In request)
Returns the entry name of the report.

Parameters:
request -
Returns:

getTemplateEngineKind

protected String getTemplateEngineKind(String reportId,
                                       In request)

getTemplateEngineKind

protected String getTemplateEngineKind(In request)

getTemplateEngineId

protected String getTemplateEngineId(In request)
Returns the template engine id from request.

Parameters:
request -
Returns:

getTemplateEngine

protected ITemplateEngine getTemplateEngine(String reportId,
                                            In request)
Returns the template engine to use for the report. By default, it search if there is template id from request and otherwise returns the default template engine.

Parameters:
reportId -
request -
Returns:

getTemplateEngine

protected ITemplateEngine getTemplateEngine(IXDocReport report,
                                            In request)

getTemplateEngine

protected ITemplateEngine getTemplateEngine(In request)
Returns the template engine from request and otherwise returns the default template engine.

Parameters:
request -
Returns:

getRegistry

protected XDocReportRegistry getRegistry(In request)
Returns the XDocReport registry which load and cache document. By default the registry is a singleton. If you wish manage registry per HTTP session, override this method, create an instance per session and returns the registry instance linked to the HTTP session.

Parameters:
request -
Returns:

getSourceStream

protected abstract InputStream getSourceStream(String reportId,
                                               In request)
                                        throws IOException,
                                               XDocReportException
Returns input stream of the report to load identified with reportId.

Parameters:
reportId - report id.
request - Http servlet request context.
Returns:
Throws:
IOException
XDocReportException

populateContext

protected abstract void populateContext(IContext context,
                                        String reportId,
                                        In request)
                                 throws IOException,
                                        XDocReportException
Put the Java model in the context for the report reportId.

Parameters:
context - XDocReport context to register Java data model.
reportId - report id.
request - Http servlet request context.
Throws:
IOException
XDocReportException

getOutputStream

protected abstract OutputStream getOutputStream(Out response)
                                         throws IOException
Throws:
IOException

getParameter

protected abstract String getParameter(In request,
                                       String name)

prepareHTTPResponse

protected abstract void prepareHTTPResponse(String id,
                                            MimeMapping mimeMapping,
                                            In request,
                                            Out response)

prepareHTTPResponse

protected abstract void prepareHTTPResponse(String reportId,
                                            String entryName,
                                            In request,
                                            Out response)


Copyright © 2013. All rights reserved.