Class Generator<In,Out>

java.lang.Object
fr.opensagres.xdocreport.document.Generator<In,Out>

public abstract class Generator<In,Out> extends Object
  • Field Details

  • Constructor Details

    • Generator

      public Generator()
  • Method Details

    • 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, fr.opensagres.xdocreport.core.XDocReportException
      Parameters:
      request -
      Returns:
      Throws:
      IOException
      fr.opensagres.xdocreport.core.XDocReportException
    • loadReport

      protected IXDocReport loadReport(String reportId, XDocReportRegistry registry, In request) throws IOException, fr.opensagres.xdocreport.core.XDocReportException
      Load report.
      Parameters:
      reportId -
      registry -
      request -
      Returns:
      Throws:
      IOException
      fr.opensagres.xdocreport.core.XDocReportException
    • isCacheOriginalDocument

      protected boolean isCacheOriginalDocument(String reportId, In request)
    • getFieldsMetadata

      protected fr.opensagres.xdocreport.template.formatter.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 fr.opensagres.xdocreport.converter.Options getOptionsConverter(IXDocReport report, In request)
    • prepareOptions

      protected void prepareOptions(fr.opensagres.xdocreport.converter.Options options, IXDocReport report, String converterId, In request)
    • isGenerateContentDisposition

      protected boolean isGenerateContentDisposition(String reportId, fr.opensagres.xdocreport.converter.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 fr.opensagres.xdocreport.template.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 fr.opensagres.xdocreport.template.ITemplateEngine getTemplateEngine(IXDocReport report, In request)
    • getTemplateEngine

      protected fr.opensagres.xdocreport.template.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, fr.opensagres.xdocreport.core.XDocReportException
      Returns input stream of the report to load identified with reportId.
      Parameters:
      reportId - report id.
      request - Http servlet request context.
      Returns:
      Throws:
      IOException
      fr.opensagres.xdocreport.core.XDocReportException
    • populateContext

      protected abstract void populateContext(fr.opensagres.xdocreport.template.IContext context, String reportId, In request) throws IOException, fr.opensagres.xdocreport.core.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
      fr.opensagres.xdocreport.core.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, fr.opensagres.xdocreport.converter.MimeMapping mimeMapping, In request, Out response)
    • prepareHTTPResponse

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