org.apache.struts2.views.xdocreport
Class AbstractXDocReportResult

java.lang.Object
  extended by org.apache.struts2.dispatcher.StrutsResultSupport
      extended by org.apache.struts2.views.xdocreport.AbstractXDocReportResult
All Implemented Interfaces:
com.opensymphony.xwork2.Result, Serializable, org.apache.struts2.StrutsStatics
Direct Known Subclasses:
LazyCommonsBeanUtilsXDocReportResult, LazyXDocReportResult, XDocReportResult

public abstract class AbstractXDocReportResult
extends org.apache.struts2.dispatcher.StrutsResultSupport

Abstract class for manage Struts2 Result with XDocReport to generate odt, docx report by using odt, docx document and convert it to another format like PDF/XHTML.

See Also:
Serialized Form

Field Summary
protected static String ACTION_KEY
           
static String LAST_MODIFIED
           
 
Fields inherited from class org.apache.struts2.dispatcher.StrutsResultSupport
DEFAULT_PARAM
 
Fields inherited from interface org.apache.struts2.StrutsStatics
HTTP_REQUEST, HTTP_RESPONSE, PAGE_CONTEXT, SERVLET_CONTEXT, SERVLET_DISPATCHER, STRUTS_ACTION_TAG_INVOCATION, STRUTS_PORTLET_CONTEXT
 
Constructor Summary
AbstractXDocReportResult()
           
 
Method Summary
protected  IURIResolver createWEBURIResolver(IXDocReport report, String converterId, String finalLocation, com.opensymphony.xwork2.ActionInvocation invocation)
           
protected  void disableHTTPResponseCache(javax.servlet.http.HttpServletResponse response)
          Disable cache HTTP hearder.
protected  void doExecute(String finalLocation, com.opensymphony.xwork2.ActionInvocation invocation)
           
protected  void doProcessReport(IXDocReport report, IContext context, String finalLocation, com.opensymphony.xwork2.ActionInvocation invocation)
           
protected  void doProcessReportWithConverter(IXDocReport report, IContext context, Options options, String finalLocation, com.opensymphony.xwork2.ActionInvocation invocation)
           
protected  String getContentDisposition(String fileName)
           
protected  String getContentDisposition(String sourceFileName, MimeMapping mimeMapping, javax.servlet.http.HttpServletRequest request)
           
 String getConverter()
          Returns the converter to use (according the JAR which is added in the classpath, values are PDF_ITEXT|XHTML_XWPF).
protected  String getConverter(com.opensymphony.xwork2.ActionInvocation invocation)
           
 String getDownload()
          Returns true if report must be downloaded (generate Content-Disposition:"attachment; filename... in the HTTP Header) and false otherwise.
 String[] getExpressions()
           
 String[] getFieldsAsList()
           
protected  FieldsMetadata getFieldsMetadata(IXDocReport report, String location, com.opensymphony.xwork2.ActionInvocation invocation)
           
protected  String getLocation(String finalLocation, com.opensymphony.xwork2.ActionInvocation invocation)
           
protected  Options getOptionsConverter(IXDocReport report, String finalLocation, com.opensymphony.xwork2.ActionInvocation invocation)
           
protected  IXDocReport getReport(XDocReportRegistry registry, String location, com.opensymphony.xwork2.ActionInvocation invocation)
           
protected  String getReportId(String finalLocation)
           
protected  File getSourceFile(String finalLocation, LocationType locationType, com.opensymphony.xwork2.ActionInvocation invocation)
           
protected  InputStream getSourceStream(String finalLocation, LocationType locationType, File sourceFile, com.opensymphony.xwork2.ActionInvocation invocation)
           
protected  InputStream getSourceStreamFromClasspath(String path)
           
 String getTemplateEngine()
          Get Template engine to use (according the JAR which is added in the classpath, values are Velocity|Freemarker).
protected  String getTemplateEngine(com.opensymphony.xwork2.ActionInvocation invocation)
           
 String getTrackLastModified()
          Returns true if docx, odt file which is used to load must be tracked to observe the document change and false otherwise.
protected  String getValue(String value, com.opensymphony.xwork2.ActionInvocation invocation)
           
protected  XDocReportInitializerAware getXDocReportInitializerAware(Object action)
           
protected  boolean isDisableHTTPResponseCache()
           
protected  boolean isDownload(com.opensymphony.xwork2.ActionInvocation invocation)
           
protected  boolean isGenerateContentDisposition(String reportId, MimeMapping mimeMapping, com.opensymphony.xwork2.ActionInvocation invocation)
           
protected  boolean isTrackLastModified(com.opensymphony.xwork2.ActionInvocation invocation)
           
protected abstract  void populateContext(IXDocReport report, IContext context, String finalLocation, com.opensymphony.xwork2.ActionInvocation invocation)
           
protected  void prepareHTTPResponse(String reportId, String entryName, com.opensymphony.xwork2.ActionInvocation invocation, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
protected  void prepareHTTPResponse(String reportId, String finalLocation, MimeMapping mimeMapping, com.opensymphony.xwork2.ActionInvocation invocation, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
protected  void prepareOptions(Options options, IXDocReport report, String converterId, String finalLocation, com.opensymphony.xwork2.ActionInvocation invocation)
           
 void setConverter(String converter)
          Set the converter to use (according the JAR which is added in the classpath, values are static value PDF_ITEXT|XHTML_XWPF ).
 void setDownload(String download)
          Set to true if report must be downloaded (generate Content-Disposition:"attachment; filename... in the HTTP Header) and false otherwise.
 void setExpression(String expression)
           
 void setFieldAsList(String fieldAsList)
           
 void setTemplateEngine(String templateEngine)
          Set Template engine to use (according the JAR which is added in the classpath, values are Velocity|Freemarker).
 void setTrackLastModified(String trackLastModified)
          Set to true if docx, odt file which is used to load must be tracked to observe the document change.
 
Methods inherited from class org.apache.struts2.dispatcher.StrutsResultSupport
conditionalParse, execute, getLastFinalLocation, getLocation, setEncode, setLocation, setParse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACTION_KEY

protected static final String ACTION_KEY
See Also:
Constant Field Values

LAST_MODIFIED

public static final String LAST_MODIFIED
Constructor Detail

AbstractXDocReportResult

public AbstractXDocReportResult()
Method Detail

setTemplateEngine

public void setTemplateEngine(String templateEngine)
Set Template engine to use (according the JAR which is added in the classpath, values are Velocity|Freemarker). The template engine can use OGNL expression too (ex : #action.templateEngine will use the Action#getTemplateEngine() method).

Parameters:
templateEngine -

getTemplateEngine

public String getTemplateEngine()
Get Template engine to use (according the JAR which is added in the classpath, values are Velocity|Freemarker).

Returns:

setConverter

public void setConverter(String converter)
Set the converter to use (according the JAR which is added in the classpath, values are static value PDF_ITEXT|XHTML_XWPF ). The converter can use OGNL expression too (ex : #action.converter will use the Action#getConverter() method). If converter is null, no conversion is done.

Parameters:
converter -

getConverter

public String getConverter()
Returns the converter to use (according the JAR which is added in the classpath, values are PDF_ITEXT|XHTML_XWPF). If converter is null, no conversion is done.

Returns:

setExpression

public void setExpression(String expression)
Parameters:
expression -

getExpressions

public String[] getExpressions()
Returns:

setTrackLastModified

public void setTrackLastModified(String trackLastModified)
Set to true if docx, odt file which is used to load must be tracked to observe the document change. If document change, report will be reloaded with the new file.

Parameters:
trackLastModified -

getTrackLastModified

public String getTrackLastModified()
Returns true if docx, odt file which is used to load must be tracked to observe the document change and false otherwise. If document change, report will be reloaded with the new file.

Returns:

setDownload

public void setDownload(String download)
Set to true if report must be downloaded (generate Content-Disposition:"attachment; filename... in the HTTP Header) and false otherwise. By default download is true.

Parameters:
download -

getDownload

public String getDownload()
Returns true if report must be downloaded (generate Content-Disposition:"attachment; filename... in the HTTP Header) and false otherwise.

Returns:

setFieldAsList

public void setFieldAsList(String fieldAsList)

getFieldsAsList

public String[] getFieldsAsList()

doExecute

protected void doExecute(String finalLocation,
                         com.opensymphony.xwork2.ActionInvocation invocation)
                  throws Exception
Specified by:
doExecute in class org.apache.struts2.dispatcher.StrutsResultSupport
Throws:
Exception

getReport

protected IXDocReport getReport(XDocReportRegistry registry,
                                String location,
                                com.opensymphony.xwork2.ActionInvocation invocation)
                         throws javax.servlet.ServletException,
                                IOException
Parameters:
registry -
finalLocation -
invocation -
Returns:
Throws:
javax.servlet.ServletException
IOException

isTrackLastModified

protected boolean isTrackLastModified(com.opensymphony.xwork2.ActionInvocation invocation)

isDownload

protected boolean isDownload(com.opensymphony.xwork2.ActionInvocation invocation)

getLocation

protected String getLocation(String finalLocation,
                             com.opensymphony.xwork2.ActionInvocation invocation)

getTemplateEngine

protected String getTemplateEngine(com.opensymphony.xwork2.ActionInvocation invocation)

getValue

protected String getValue(String value,
                          com.opensymphony.xwork2.ActionInvocation invocation)

getReportId

protected String getReportId(String finalLocation)

getSourceStream

protected InputStream getSourceStream(String finalLocation,
                                      LocationType locationType,
                                      File sourceFile,
                                      com.opensymphony.xwork2.ActionInvocation invocation)
                               throws IOException
Throws:
IOException

getSourceFile

protected File getSourceFile(String finalLocation,
                             LocationType locationType,
                             com.opensymphony.xwork2.ActionInvocation invocation)

getSourceStreamFromClasspath

protected InputStream getSourceStreamFromClasspath(String path)

getFieldsMetadata

protected FieldsMetadata getFieldsMetadata(IXDocReport report,
                                           String location,
                                           com.opensymphony.xwork2.ActionInvocation invocation)

doProcessReport

protected void doProcessReport(IXDocReport report,
                               IContext context,
                               String finalLocation,
                               com.opensymphony.xwork2.ActionInvocation invocation)
                        throws XDocReportException,
                               IOException
Parameters:
report -
context -
options -
finalLocation -
invocation -
Throws:
IOException
XDocReportException

doProcessReportWithConverter

protected void doProcessReportWithConverter(IXDocReport report,
                                            IContext context,
                                            Options options,
                                            String finalLocation,
                                            com.opensymphony.xwork2.ActionInvocation invocation)
                                     throws XDocConverterException,
                                            XDocReportException,
                                            IOException
Parameters:
report -
context -
finalLocation -
invocation -
Throws:
IOException
XDocReportException
XDocConverterException

getOptionsConverter

protected Options getOptionsConverter(IXDocReport report,
                                      String finalLocation,
                                      com.opensymphony.xwork2.ActionInvocation invocation)
Parameters:
report -
request -
Returns:

getConverter

protected String getConverter(com.opensymphony.xwork2.ActionInvocation invocation)

prepareOptions

protected void prepareOptions(Options options,
                              IXDocReport report,
                              String converterId,
                              String finalLocation,
                              com.opensymphony.xwork2.ActionInvocation invocation)

createWEBURIResolver

protected IURIResolver createWEBURIResolver(IXDocReport report,
                                            String converterId,
                                            String finalLocation,
                                            com.opensymphony.xwork2.ActionInvocation invocation)

prepareHTTPResponse

protected void prepareHTTPResponse(String reportId,
                                   String finalLocation,
                                   MimeMapping mimeMapping,
                                   com.opensymphony.xwork2.ActionInvocation invocation,
                                   javax.servlet.http.HttpServletRequest request,
                                   javax.servlet.http.HttpServletResponse response)

isGenerateContentDisposition

protected boolean isGenerateContentDisposition(String reportId,
                                               MimeMapping mimeMapping,
                                               com.opensymphony.xwork2.ActionInvocation invocation)

prepareHTTPResponse

protected void prepareHTTPResponse(String reportId,
                                   String entryName,
                                   com.opensymphony.xwork2.ActionInvocation invocation,
                                   javax.servlet.http.HttpServletRequest request,
                                   javax.servlet.http.HttpServletResponse response)

isDisableHTTPResponseCache

protected boolean isDisableHTTPResponseCache()

getContentDisposition

protected String getContentDisposition(String sourceFileName,
                                       MimeMapping mimeMapping,
                                       javax.servlet.http.HttpServletRequest request)

getContentDisposition

protected String getContentDisposition(String fileName)

disableHTTPResponseCache

protected void disableHTTPResponseCache(javax.servlet.http.HttpServletResponse response)
Disable cache HTTP hearder.

Parameters:
response -

getXDocReportInitializerAware

protected XDocReportInitializerAware getXDocReportInitializerAware(Object action)

populateContext

protected abstract void populateContext(IXDocReport report,
                                        IContext context,
                                        String finalLocation,
                                        com.opensymphony.xwork2.ActionInvocation invocation)
                                 throws Exception
Parameters:
report -
finalLocation -
invocation -
Throws:
XDocReportException
Exception


Copyright © 2013. All rights reserved.