Package org.ametys.odf.export.pdf
Class GeneratePDFEngine
- java.lang.Object
-
- org.ametys.odf.export.pdf.GeneratePDFEngine
-
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
GeneratePDFEngine
public class GeneratePDFEngine extends Object implements Runnable
Content consistency engine: generate consistency information for all contents. Sends a report e-mail if there are inconsistencies.
-
-
Field Summary
Fields Modifier and Type Field Description private String
_catalog
protected File
_catalogRootDirectory
The catalog directory.protected Context
_context
The avalon context.protected Map<String,Object>
_contextualParameters
The contextual parametersprotected Context
_environmentContext
The cocoon environment context.protected I18nUtils
_i18nUtils
The i18n utils.protected boolean
_initialized
Is the engine initialized ?private User
_issuer
protected static org.slf4j.Logger
_LOGGER
The logger.protected String
_mailFrom
The sender of the emailprotected ServiceManager
_manager
The service manager.private static boolean
_RUNNING
Is the thread running ?protected SourceResolver
_sourceResolver
The avalon source resolver.
-
Constructor Summary
Constructors Constructor Description GeneratePDFEngine()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_checkInitialization()
Check the initialization and throw an exception if not initialized.protected void
_dispose()
Dispose of the resources and looked-up components.protected void
_doGeneratePDF(Request request)
Generate the PDF fileprotected void
_generatePDF(Request request)
Generates the PDF file.protected void
_sendMail(boolean error)
Sends an email to the user who has launched the generation of PDFvoid
configure(Configuration configuration)
Configure the engine (called by the scheduler).protected String
getFailureMailBody()
Get the body of mail in case of failureprotected String
getLanguage()
Get the language for exportprotected String
getMailSubject()
Get the subject of mailprotected String
getSuccessMailBody()
Get the body of mail in case of successvoid
initialize(ServiceManager manager, Context context)
Initialize the alert engine.static boolean
isRunning()
Test if the engine is running at the time.void
run()
void
setCatalog(String code)
Set the code of catalogue to generatevoid
setContextualParameters(Map<String,Object> contextualParameters)
Set the contextual parametersvoid
setIssuer(User issuer)
Set the user who launched the PDF exportprivate static void
setRunning(boolean running)
-
-
-
Field Detail
-
_LOGGER
protected static final org.slf4j.Logger _LOGGER
The logger.
-
_RUNNING
private static boolean _RUNNING
Is the thread running ?
-
_environmentContext
protected Context _environmentContext
The cocoon environment context.
-
_manager
protected ServiceManager _manager
The service manager.
-
_sourceResolver
protected SourceResolver _sourceResolver
The avalon source resolver.
-
_i18nUtils
protected I18nUtils _i18nUtils
The i18n utils.
-
_catalogRootDirectory
protected File _catalogRootDirectory
The catalog directory.
-
_initialized
protected boolean _initialized
Is the engine initialized ?
-
_contextualParameters
protected Map<String,Object> _contextualParameters
The contextual parameters
-
-
Constructor Detail
-
GeneratePDFEngine
public GeneratePDFEngine()
-
-
Method Detail
-
initialize
public void initialize(ServiceManager manager, Context context) throws ContextException, ServiceException
Initialize the alert engine.- Parameters:
manager
- the avalon service manager.context
- the avalon context.- Throws:
ContextException
- if an error occurs retrieving the environment context.ServiceException
- if an error occurs retrieving a component.
-
configure
public void configure(Configuration configuration) throws ConfigurationException
Configure the engine (called by the scheduler).- Parameters:
configuration
- the component configuration.- Throws:
ConfigurationException
- if an error occurs
-
setContextualParameters
public void setContextualParameters(Map<String,Object> contextualParameters)
Set the contextual parameters- Parameters:
contextualParameters
- the contextual parameters
-
setCatalog
public void setCatalog(String code)
Set the code of catalogue to generate- Parameters:
code
- the code
-
setIssuer
public void setIssuer(User issuer)
Set the user who launched the PDF export- Parameters:
issuer
- the issuer
-
_checkInitialization
protected void _checkInitialization()
Check the initialization and throw an exception if not initialized.
-
isRunning
public static boolean isRunning()
Test if the engine is running at the time.- Returns:
- true if the engine is running, false otherwise.
-
setRunning
private static void setRunning(boolean running)
-
_dispose
protected void _dispose()
Dispose of the resources and looked-up components.
-
_generatePDF
protected void _generatePDF(Request request) throws AmetysRepositoryException, IOException
Generates the PDF file. Checks that there is no current generation process.- Parameters:
request
- The request- Throws:
AmetysRepositoryException
- if an error occurs.IOException
- if an I/O error occurs.
-
_doGeneratePDF
protected void _doGeneratePDF(Request request) throws IOException
Generate the PDF file- Parameters:
request
- the request- Throws:
IOException
- if an I/O error occurs.
-
getLanguage
protected String getLanguage()
Get the language for export- Returns:
- The language
-
_sendMail
protected void _sendMail(boolean error)
Sends an email to the user who has launched the generation of PDF- Parameters:
error
- true if the catalog wasn't generated successfully, false otherwise.
-
getMailSubject
protected String getMailSubject()
Get the subject of mail- Returns:
- the subject
-
getSuccessMailBody
protected String getSuccessMailBody()
Get the body of mail in case of success- Returns:
- the body
-
getFailureMailBody
protected String getFailureMailBody()
Get the body of mail in case of failure- Returns:
- the body
-
-